/* ============================================
   Reader / Text Highlighting Styles
   ============================================ */

.reader-view {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: calc(100vh - var(--header-height) - var(--player-height) - 40px);
    max-width: 1200px;
    margin: 0 auto;
}

/* Sidebar - Chapter list */
.reader-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.reader-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reader-sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

.reader-sidebar-back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.reader-sidebar-back:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
}

.chapter-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.chapter-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.chapter-item.has-audio::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-left: auto;
}

.chapter-item-num {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 24px;
    font-weight: 600;
}

.chapter-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-item-duration {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Conversion section in sidebar */
.reader-sidebar-conversion {
    border-top: 1px solid var(--border);
    padding: 12px;
}

.reader-conversion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.reader-conversion-header h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.conversion-status-complete {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--accent);
}

.conversion-status-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.conversion-mini-settings {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.conv-select {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.78rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    outline: none;
}

.conv-select:focus {
    border-color: var(--accent);
}

.conversion-actions-reader {
    margin-bottom: 8px;
}

.conversion-progress-reader {
    margin-top: 8px;
}

.conv-progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Music section in sidebar */
.reader-sidebar-music {
    border-top: 1px solid var(--border);
    padding: 12px;
}

/* Bookmarks section in sidebar */
.reader-bookmarks {
    border-top: 1px solid var(--border);
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.reader-bookmarks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.reader-bookmarks-header h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.bookmark-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.8rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
    color: var(--text-secondary);
}

.bookmark-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.bookmark-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bookmark-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.bookmark-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    transition: all var(--transition-fast);
}

.bookmark-item:hover .bookmark-delete {
    opacity: 1;
}

.bookmark-delete:hover {
    color: var(--danger);
}

/* Main text area */
.reader-content {
    background: var(--bg-card);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 40px;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height) - var(--player-height) - 40px);
    position: relative;
}

.reader-content-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.reader-content-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.reader-content-header .chapter-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Text content with word spans */
.reader-text {
    font-family: var(--font-reading);
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 680px;
}

.reader-text p {
    margin-bottom: 1.2em;
    text-align: justify;
}

/* Word highlighting */
.word {
    transition: background-color 0.1s ease, color 0.1s ease;
    border-radius: 2px;
    padding: 0 1px;
}

.word.active {
    background-color: var(--accent);
    color: #000;
    border-radius: 3px;
    padding: 1px 2px;
}

.word.active-sentence {
    background-color: var(--accent-dim);
}

/* No audio message */
.reader-no-audio {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    margin-top: 20px;
}

.reader-no-audio p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Reading progress indicator */
.reader-progress-indicator {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    z-index: 10;
    margin: -40px -40px 40px -40px;
}

.reader-progress-indicator-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.1s linear;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .reader-view {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .reader-sidebar {
        border-radius: var(--radius-lg);
        border-right: none;
        margin-bottom: 16px;
        max-height: 300px;
    }

    .reader-content {
        border-radius: var(--radius-lg);
        padding: 24px 20px;
        max-height: none;
    }

    .reader-text {
        font-size: 1rem;
    }

    .reader-progress-indicator {
        margin: -24px -20px 24px -20px;
    }
}

/* Sidebar toggle for mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: calc(var(--player-height) + 16px);
    right: 16px;
    z-index: 150;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: #000;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }
}

/* ============================================
   Mini Voice List (Reader sidebar)
   ============================================ */
.voice-list-mini {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    margin-bottom: 6px;
}

.voice-item-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
}

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

.voice-item-mini:hover {
    background: var(--bg-elevated);
}

.voice-item-mini.selected {
    background: var(--accent-dim);
    border-left: 2px solid var(--accent);
}

.voice-item-mini-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-item-mini-gender {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.voice-preview-btn-mini {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    padding: 0;
}

.voice-preview-btn-mini:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.voice-preview-btn-mini.playing {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Export mode mini (reader sidebar) */
.export-mode-options-mini {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.radio-option-mini {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.radio-option-mini input[type="radio"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.radio-option-mini span {
    cursor: pointer;
}

.radio-option-mini:hover span {
    color: var(--text-primary);
}

/* ============================================
   Chapter Export Button (Sidebar)
   ============================================ */
.chapter-item-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.chapter-item-row .chapter-item {
    flex: 1;
    min-width: 0;
}

.chapter-export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    margin-right: 4px;
}

.chapter-export-btn:hover {
    color: var(--accent);
    background: var(--bg-elevated);
}

/* ============================================
   Reader Chapter Selection (Conversion Panel)
   ============================================ */
.reader-chapter-select {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.reader-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.reader-select-all-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.reader-chapter-checkboxes {
    max-height: 140px;
    overflow-y: auto;
    background: var(--bg-input);
}

.reader-chapter-cb-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.reader-chapter-cb-item:last-child {
    border-bottom: none;
}

.reader-chapter-cb-item:hover {
    background: var(--bg-elevated);
}

.reader-chapter-cb-item.converted {
    opacity: 0.6;
}

.reader-chapter-cb-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 13px;
    height: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

.reader-chapter-cb-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-ch-done-mark {
    font-size: 0.6rem;
    color: var(--accent);
    flex-shrink: 0;
    font-weight: 600;
    text-transform: uppercase;
}

/* ============================================
   Voice Category Headers (Mini - Reader)
   ============================================ */
.voice-category-header-mini {
    padding: 4px 8px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ============================================
   Music Track List (Reader sidebar)
   ============================================ */
.music-track-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.music-track-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
}

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

.music-track-item:hover {
    background: var(--bg-elevated);
}

.music-track-item.selected {
    background: var(--accent-dim);
    border-left: 2px solid var(--accent);
}

.music-track-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-track-duration {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.music-preview-btn {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    padding: 0;
}

.music-preview-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.music-preview-btn.playing {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}
