/* ============================================
   Library / Bookshelf Styles
   ============================================ */

/* Library Toolbar */
.library-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.library-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.library-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.library-search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.library-search-input:focus {
    border-color: var(--accent);
}

.library-search-input::placeholder {
    color: var(--text-muted);
}

.library-filters {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.library-filter-select {
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

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

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

/* Format badge on card */
.book-card-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.book-card:hover .book-card-badge {
    opacity: 1;
}

/* Book Card */
.book-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--border);
}

.book-card:hover .book-card-overlay {
    opacity: 1;
}

.book-card-cover {
    aspect-ratio: 3/4;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-card-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-cover-text {
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.book-card-cover-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-cover-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Hover overlay */
.book-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.book-card-play-btn {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(8px);
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.4);
}

.book-card:hover .book-card-play-btn {
    transform: translateY(0);
}

.book-card-play-btn:hover {
    transform: scale(1.08) !important;
    background: var(--accent-hover);
}

/* Card info */
.book-card-info {
    padding: 12px;
}

.book-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.book-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.book-card-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card-status {
    flex-shrink: 0;
}

/* Status indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.status-dot.pending { background: var(--text-muted); }
.status-dot.converting { background: var(--accent-warm); animation: pulse 1.5s infinite; }
.status-dot.completed { background: var(--accent); }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Conversion progress on card */
.book-card-progress {
    height: 3px;
    background: var(--border);
    margin-top: 8px;
    border-radius: 2px;
    overflow: hidden;
}

.book-card-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width var(--transition);
    border-radius: 2px;
}

/* Card actions (on hover) */
.book-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.book-card:hover .book-card-actions {
    opacity: 1;
}

.book-card-action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
}

.book-card-action-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.book-card-action-btn.delete:hover {
    background: var(--danger);
}

/* Upload Area */
.upload-area {
    max-width: 700px;
    margin: 0 auto;
}

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
    transition: color var(--transition);
}

.upload-dropzone:hover .upload-dropzone-icon,
.upload-dropzone.dragover .upload-dropzone-icon {
    color: var(--accent);
}

.upload-dropzone h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-dropzone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-dropzone .formats {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Upload progress */
.upload-progress {
    margin-top: 24px;
    display: none;
}

.upload-progress.active {
    display: block;
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Post-upload chapter review */
.chapter-review {
    margin-top: 32px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    display: none;
}

.chapter-review.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.chapter-review-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chapter-review-list {
    max-height: 400px;
    overflow-y: auto;
}

.chapter-review-item {
    padding: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 0;
    font-size: 0.9rem;
}

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

.chapter-review-item .chapter-checkbox-label {
    padding: 12px 0 12px 16px;
}

.chapter-review-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.chapter-review-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 12px 8px;
    transition: background var(--transition-fast);
}

.chapter-review-row:hover {
    background: var(--bg-elevated);
}

.chapter-review-num {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 30px;
}

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

.chapter-review-chars {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.chapter-expand-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
}

.chapter-review-item.expanded .chapter-expand-icon {
    transform: rotate(180deg);
}

.chapter-review-text {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 16px 0 50px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border-top: 0 solid var(--border);
}

.chapter-review-item.expanded .chapter-review-text {
    max-height: 200px;
    padding: 12px 16px 12px 50px;
    border-top-width: 1px;
    overflow-y: auto;
}

.chapter-review-text p {
    margin: 0;
}

/* Conversion settings */
.conversion-settings {
    margin-top: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 0;
    display: none;
    overflow: hidden;
}

.conversion-settings.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.conversion-settings h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0;
}

/* Conversion sections */
.conv-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.conv-section:last-child {
    border-bottom: none;
}

.conv-section-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.conv-section-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.conv-section-action {
    text-align: center;
    background: var(--bg-elevated);
    padding: 24px 20px;
}

.btn-convert-large {
    font-size: 1rem;
    padding: 14px 32px;
    width: 100%;
    max-width: 400px;
    justify-content: center;
}

.conv-summary {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.conversion-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Conversion progress overlay */
.conversion-overlay {
    margin-top: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 32px;
    text-align: center;
    display: none;
}

.conversion-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.conversion-overlay .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
}

.conversion-overlay h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.conversion-overlay p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.conversion-progress-bar {
    max-width: 400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .library-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .library-search {
        width: 100%;
    }

    .library-filters {
        width: 100%;
    }

    .library-filter-select {
        flex: 1;
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }

    .upload-dropzone {
        padding: 40px 24px;
    }
}

/* ============================================
   Voice List with Preview
   ============================================ */
.voice-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}

.voice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border);
}

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

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

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

.voice-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.voice-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.voice-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-preview-btn {
    width: 32px;
    height: 32px;
    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);
}

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

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

/* Export mode radio buttons */
.export-mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 6px 0;
}

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

.radio-label {
    cursor: pointer;
}

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

/* ============================================
   Voice Category Headers
   ============================================ */
.voice-category-header {
    padding: 8px 14px;
    font-size: 0.7rem;
    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;
}

/* ============================================
   Chapter Selection Checkboxes (Uploader)
   ============================================ */
.chapter-review-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chapter-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

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

.chapter-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.chapter-checkbox {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.chapter-selection-info {
    padding: 8px 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: right;
}
