/* Reading History page styles */

.history-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem 0;
}

.history-header {
    margin-bottom: 2rem;
    text-align: center;
}

.history-header-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.history-header-icon svg {
    width: 40px;
    height: 40px;
    fill: var(--accent-brown, #8b7355);
}

.history-header h1 {
    font-family: var(--serif-font, Georgia, serif);
    font-size: 2rem;
    margin: 0;
    color: #333;
}

/* Filter Bar */
.history-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.filter-label {
    font-size: 0.85rem;
    color: #666;
    flex-shrink: 0;
}

.filter-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    background: #fff;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: 16px;
    border: 1px solid #d4a537;
}

.filter-chip-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e9ecef;
    color: #888;
    text-decoration: none;
    transition: all 0.15s ease;
}

.filter-chip-clear:hover {
    background: #dc3545;
    color: #fff;
}

.filter-chip-clear svg {
    width: 10px;
    height: 10px;
}

.filter-separator {
    color: #999;
    font-size: 1.1rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Date Groups */
.history-date-group {
    margin-bottom: 1.5rem;
}

.history-date {
    font-family: var(--serif-font, Georgia, serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

/* History Items */
.history-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    margin-bottom: 0.5rem;
}

/* Card container */
.history-item-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    transition: border-color 0.2s ease;
}

.history-item-card:hover {
    border-color: #d4a537;
}

/* Top row: title and meta */
.history-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Title row with favorite toggle */
.history-item-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* Icons container (practices + favorites + bookmark) */
.history-item-icons {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
}

/* Article title link */
.history-item-title {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
    line-height: 1.3;
    text-decoration: none;
}

.history-item-title:hover {
    color: #d4a537;
}

/* Practice icons */
.history-article-practices {
    display: inline-flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.history-practice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #8b7355;
}

.history-practice-icon svg {
    width: 16px;
    height: 16px;
}

.history-practice-icon {
    position: relative;
    cursor: pointer;
}

/* Practice icon tooltip */
.history-practice-tooltip {
    display: none;
    position: fixed;
    padding: 0.4rem 0.7rem;
    background-color: #f5f2ee;
    color: #5a6a7a;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #e8e4df;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    pointer-events: none;
}

/* Context line with filter links - inside the card */
.history-item-context {
    font-size: 0.85rem;
    color: #777;
    line-height: 1.3;
    margin-top: 0.5rem;
}

.history-item-context .context-in,
.history-item-context .context-separator {
    color: #999;
}

.history-item-context .filter-link {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.history-item-context .filter-link:hover {
    color: #d4a537;
    text-decoration: underline;
}

/* Meta area (badge + time) - side by side on desktop */
.history-item-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Status Badges */
.history-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.history-badge.finished {
    background: #d4edda;
    color: #155724;
}

.history-badge.reading {
    background: #fff3cd;
    color: #856404;
}

.history-time {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
}

/* Load More Button */
#load-more-container {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.load-more-button {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-button:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.load-more-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* HTMX Loading State */
.load-more-button.htmx-request {
    opacity: 0.7;
    pointer-events: none;
}

.load-more-button.htmx-request::after {
    content: "...";
}

/* Article Summary Card (timeline view) */
.article-summary-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.article-summary-title {
    font-family: var(--serif-font, Georgia, serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.5rem 0;
}

.article-summary-context {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.article-summary-context .context-in,
.article-summary-context .context-separator {
    color: #999;
}

.article-summary-context .filter-link {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-summary-context .filter-link:hover {
    color: #d4a537;
    text-decoration: underline;
}

.article-summary-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0;
    padding: 1rem 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #333;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: #777;
    margin-top: 0.25rem;
}

.article-read-link {
    display: inline-block;
    margin-top: 0.5rem;
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.article-read-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Back link */
.history-back-link {
    margin-bottom: 1.5rem;
}

.history-back-link a {
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.history-back-link a:hover {
    color: #333;
}

/* Event Timeline */
.event-timeline {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 1.5rem;
}

.timeline-heading {
    font-family: var(--serif-font, Georgia, serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.timeline-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.timeline-icon svg {
    width: 16px;
    height: 16px;
}

.timeline-item.event-start .timeline-icon {
    background: #e3f2fd;
    color: #1976d2;
}

.timeline-item.event-finish .timeline-icon {
    background: #e8f5e9;
    color: #388e3c;
}

.timeline-item.event-chunk .timeline-icon {
    background: #f5f5f5;
    color: #757575;
}

.timeline-item.event-favorite .timeline-icon {
    background: #fff8e1;
    color: #d4a537;
}

.timeline-item.event-unfavorite .timeline-icon {
    background: #fce4ec;
    color: #c2185b;
}

.timeline-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.timeline-event-type {
    font-weight: 500;
    color: #333;
    font-size: 0.95rem;
}

.timeline-time {
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.125rem;
}

/* Empty State */
.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.history-empty p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.history-cta {
    display: inline-block;
    background: #3498db;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
}

.history-cta:hover {
    background: #2980b9;
}

/* Article Summary Actions (favorite + read link) */
.article-summary-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Compact Favorite Toggle (for history list items) */
.favorite-toggle-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

/* Book toggle in history matches favorite toggle size */
.history-item-icons .book-toggle-compact {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.favorite-toggle-compact:hover {
    color: #d4a537;
    background: rgba(212, 165, 55, 0.1);
}

.favorite-toggle-compact.favorited {
    color: #d4a537;
}

.favorite-toggle-compact.favorited:hover {
    color: #b8922f;
}

.favorite-toggle-compact .star-icon {
    transition: transform 0.15s ease;
}

.favorite-toggle-compact:active .star-icon {
    transform: scale(0.9);
}

/* Pulse animation for compact toggle */
@keyframes favorite-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.favorite-toggle-compact.animating .star-icon {
    animation: favorite-pulse 0.3s ease;
}

/* Footer toggle styles for history page (reuse from article.css pattern) */
.favorite-toggle-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorite-toggle-footer:hover {
    border-color: #d4a537;
    background: rgba(212, 165, 55, 0.05);
    color: #d4a537;
}

.favorite-toggle-footer.favorited {
    border-color: #d4a537;
    background: rgba(212, 165, 55, 0.1);
    color: #d4a537;
}

.favorite-toggle-footer .favorite-toggle-label {
    color: #555;
}

.favorite-toggle-footer.favorited .favorite-toggle-label {
    color: #8b7355;
}

.favorite-toggle-footer .star-icon {
    transition: transform 0.15s ease;
}

.favorite-toggle-footer.animating .star-icon {
    animation: favorite-pulse 0.3s ease;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .history-filter-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .filter-breadcrumb {
        order: 3;
        width: 100%;
        padding-top: 0.25rem;
    }

    /* Stack title and meta vertically on mobile */
    .history-item-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Meta row: badge and time side by side */
    .history-item-meta {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }

    .history-item-context {
        margin-top: 0.375rem;
    }
}

/* --- Unfavorite Confirmation Modal --- */
.unfavorite-confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.unfavorite-confirm-overlay.active {
    display: flex;
}

.unfavorite-confirm-dialog {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.unfavorite-confirm-title {
    font-family: var(--serif-font, Georgia, serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.75rem 0;
}

.unfavorite-confirm-message {
    font-size: 0.95rem;
    color: #666;
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
}

.unfavorite-confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.unfavorite-confirm-cancel,
.unfavorite-confirm-remove {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unfavorite-confirm-cancel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
}

.unfavorite-confirm-cancel:hover {
    background: #e9ecef;
}

.unfavorite-confirm-remove {
    background: #dc3545;
    border: 1px solid #dc3545;
    color: #fff;
}

.unfavorite-confirm-remove:hover {
    background: #c82333;
}

@media (max-width: 600px) {
    .unfavorite-confirm-dialog {
        padding: 1.25rem;
    }

    .unfavorite-confirm-actions {
        flex-direction: column-reverse;
    }

    .unfavorite-confirm-cancel,
    .unfavorite-confirm-remove {
        width: 100%;
    }
}

/* =============================================================================
   PUBLISH STATE STYLING (Early/Preview content)
   ============================================================================= */

/* Combined: Background Tint + Left Border Accent */
.history-item-card.state-early {
    background: linear-gradient(135deg, #f6faf5 0%, #eef4ec 100%);
    border-left: 4px solid #9ab392;
}

.history-item-card.state-preview {
    background: linear-gradient(135deg, #f4faf9 0%, #e8f4f2 100%);
    border-left: 4px solid #7dbdb4;
}

/* Timeline items - state styling */
.timeline-item.state-early {
    background: linear-gradient(135deg, #f6faf5 0%, #eef4ec 100%);
    border-left: 4px solid #9ab392;
    border-radius: 6px;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}

.timeline-item.state-preview {
    background: linear-gradient(135deg, #f4faf9 0%, #e8f4f2 100%);
    border-left: 4px solid #7dbdb4;
    border-radius: 6px;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}
