/* AudioBook Organizer - Component Styles */

/* Column Content */
.column-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    position: relative;
}

.column-title-container {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.back-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-arrow:hover {
    background-color: var(--background-light);
    color: var(--text-primary);
}

/* Book Content Specific Styles */
.book-content {
    font-size: 1.1rem;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-md);
    background: white;
    white-space: pre-wrap;
    
    /* Make it focusable and show blinking cursor */
    cursor: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    
    /* Blinking cursor styling */
    caret-color: #333;
    outline: none;
    
    /* Ensure contenteditable works smoothly */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.book-content:focus {
    outline: none;
    caret-color: #4CAF50;
    
    /* Add subtle focus indication */
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.3);
}

/* Edit Mode Styling */
.book-content.edit-mode {
    background: rgba(255, 248, 225, 0.8) !important;
    border: 2px solid #FF9800 !important;
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px rgba(255, 152, 0, 0.2), 0 2px 8px rgba(255, 152, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.book-content.edit-mode:focus {
    caret-color: #FF5722;
    border-color: #FF5722 !important;
    box-shadow: inset 0 0 0 2px rgba(255, 87, 34, 0.3), 0 4px 12px rgba(255, 87, 34, 0.2);
}

/* Edit Mode Indicator - REMOVED to prevent overlap with formatting toolbar */

/* Ensure text selection and cursor work properly */
.book-content * {
    cursor: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.book-content p {
    margin-bottom: 1.5em;
    text-align: justify;
}

/* Sections Panel Specific Styles */
.sections-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    min-height: 100px;
}

.section-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--spacing-md);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    cursor: pointer;
    margin-left: var(--spacing-md);
    border-left: 2px solid var(--border-color);
}

.section-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.02);
}

.section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    padding-right: var(--spacing-md);
}

.section-name {
    font-weight: 500;
    color: var(--text-primary);
    flex-grow: 1;
}

.section-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: background 0.3s ease, color 0.3s ease;
}

.copy-section-btn {
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 24px;
}

.copy-section-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.copy-section-btn:active {
    transform: translateY(0);
}

.section-text {
    background-color: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin: var(--spacing-sm) 0;
    font-style: italic;
    max-height: 100px;
    overflow-y: auto;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

/* Missing Audio Warning Styles */
.missing-audio-warning {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    width: 100%;
}

.missing-audio-warning .warning-icon {
    font-size: 1.2rem;
    margin-right: var(--spacing-xs);
}

.missing-audio-warning .warning-text {
    color: #856404;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.missing-audio-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.missing-audio-actions input[type="file"] {
    flex: 1;
    font-size: 0.8rem;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: var(--radius-sm);
    background: white;
}

.missing-audio-actions button {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.missing-audio-actions button:hover {
    background: #c82333;
}

/* Dark theme styles for missing audio warning */
[data-theme="dark"] .missing-audio-warning {
    background: rgba(255, 193, 7, 0.15);
    border-color: #ffc107;
}

[data-theme="dark"] .missing-audio-warning .warning-text {
    color: #ffc107;
}

[data-theme="dark"] .missing-audio-actions input[type="file"] {
    background: var(--background-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Upload Progress Feedback Styles */
.upload-progress-container {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm);
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid #2196F3;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
    width: 100%;
}

.upload-progress-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
}

.upload-progress-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e3f2fd;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    animation: uploadSpin 1s linear infinite;
    flex-shrink: 0;
}

.upload-progress-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0; /* Allow text to wrap */
}

.upload-file-name {
    font-weight: 500;
    color: #1976D2;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-status {
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

@keyframes uploadSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark theme styles for upload progress */
[data-theme="dark"] .upload-progress-container {
    background: rgba(33, 150, 243, 0.15);
    border-color: #2196F3;
}

[data-theme="dark"] .upload-progress-spinner {
    border-color: rgba(33, 150, 243, 0.3);
    border-top-color: #2196F3;
}

[data-theme="dark"] .upload-file-name {
    color: #64B5F6;
}

[data-theme="dark"] .upload-status {
    color: #bbb;
}

/* File Upload Styles */
.file-upload {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.file-upload input[type="file"] {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Button Styles */
button {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button[disabled] {
    background-color: #ccc;
    cursor: not-allowed;
}

.save-btn, .load-btn {
    background-color: var(--primary-color);
}

.save-btn:hover, .load-btn:hover {
    background-color: var(--primary-hover);
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    flex-wrap: wrap;
}

/* Smart Select Controls */
.smart-select-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: auto;
}

.smart-select-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#smartSelectChars {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Loading and Error Messages */
.loading,
.error-message {
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    transition: background 0.3s ease, color 0.3s ease;
}

.error-message {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
}

.loading {
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

/* Selection Tools */
#selection-tools {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000 !important;
    min-width: 400px;
    max-width: 80vw;
    display: none;
    animation: fadeIn 0.2s ease-out;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Dark Theme Support for Components */
[data-theme="dark"] #selection-tools {
    background: var(--bg-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .selection-preview {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .modal {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] input[type="file"] {
    color: var(--text-primary);
}

[data-theme="dark"] input[type="number"] {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .section-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .section-item:hover {
    background: var(--bg-primary);
}

[data-theme="dark"] .chapter-item {
    border-color: var(--border-color);
}

[data-theme="dark"] .chapter-sections {
    background: var(--bg-primary);
}

.selection-tools-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.selection-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.selection-preview {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    max-height: 300px;
    min-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    
    /* Better scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-secondary);
}

.selection-preview::-webkit-scrollbar {
    width: 8px;
}

.selection-preview::-webkit-scrollbar-track {
    background: var(--background-light);
    border-radius: 4px;
}

.selection-preview::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.selection-preview::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Character Counter */
.char-counter {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1000;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

/* Selection Guide */
.selection-guide {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 12px;
    z-index: 2000;
    display: none;
    backdrop-filter: blur(10px);
    max-width: 90vw;
    text-align: center;
}

.guide-step {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
}

.guide-step:last-child {
    margin-bottom: 0;
}

.guide-step i {
    font-size: 18px;
    min-width: 24px;
}

/* Make the last two steps horizontal */
.selection-guide .guide-step:nth-child(2),
.selection-guide .guide-step:nth-child(3) {
    display: inline-flex;
    margin-bottom: 0;
    margin-right: 20px;
    font-size: 13px;
}

.selection-guide .guide-step:nth-child(3) {
    margin-right: 0;
}

/* Container for horizontal steps */
.selection-guide .guide-step:nth-child(2) {
    margin-bottom: 0;
}

/* Add a wrapper div styling in case we need it */
.horizontal-steps {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 8px;
}

/* Export Panel */
.export-panel {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-md);
    background: white;
}

.export-panel h2 {
    margin-bottom: var(--spacing-md);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.dropdown {
    margin: var(--spacing-sm) 0;
}

.dropdown select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    width: 100px;
}

/* Status Messages */
.status {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status.success {
    background-color: #d4edda;
    color: #155724;
}

.status.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 400px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
}

/* Position close button on the modal container, not header */
.modal-overlay .modal {
    position: relative;
}

.modal-close {
    position: absolute;
    top: 30px;
    right: 30px;
    background: white;
    border: 2px solid #e74c3c;
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    color: #e74c3c;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

.modal-close:hover {
    color: white;
    background: #e74c3c;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* Dark mode support for modal close button */
html[data-theme="dark"] .modal-close {
    background: var(--bg-secondary);
    border-color: #e74c3c;
    color: #e74c3c;
}

html[data-theme="dark"] .modal-close:hover {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.modal-body {
    margin-bottom: var(--spacing-md);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    margin-top: 0;
    border-top: 1px solid var(--border-color);
}

/* Chapter Styles - Base styles only (layout handled in main.css) */
.chapter-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.chapter-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.chapter-header:hover {
    background: var(--bg-primary);
}

.chapter-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chapter-controls {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.chapter-sections {
    padding: var(--spacing-md);
    transition: height 0.3s ease-in-out;
}

.chapter-sections.collapsed {
    height: 0;
    padding: 0;
    overflow: hidden;
}

.chapter-duration {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 2px 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    transition: background 0.3s ease, color 0.3s ease;
}

.chapter-collapse-icon {
    transition: transform 0.3s ease;
}

.chapter-collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.chapter-play-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chapter-play-btn i {
    font-size: 1.2rem;
}

/* Chapter Audio Player */
.chapter-audio-player {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.chapter-audio-player.active {
    display: block;
}

.chapter-audio-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.chapter-audio-progress {
    flex: 1;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease;
}

.chapter-audio-progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    width: 0;
    transition: width 0.1s linear;
}

.chapter-audio-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.chapter-audio-sections {
    display: flex;
    height: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: var(--spacing-sm);
    transition: background 0.3s ease;
}

.chapter-audio-section {
    height: 100%;
    border-right: 1px solid white;
    transition: background-color 0.2s;
}

.chapter-audio-section:last-child {
    border-right: none;
}

.chapter-audio-section.active {
    background-color: rgba(var(--primary-color-rgb), 0.2);
}

.edit-toggle-btn i,
.reset-btn i {
    margin-right: 6px;
}

.reset-btn {
    background-color: #ff9800; /* Orange */
    color: white;
    margin-left: 8px; /* This will move the button to the right */
}

.reset-btn:hover {
    background-color: #e68a00; /* Darker orange on hover */
}

/* =================================================================
  Component-Specific Overrides & Global Component Styles
================================================================= */

/* reCAPTCHA Badge Visibility Control */
/* Hide the badge by default on all pages */
.grecaptcha-badge {
    visibility: hidden;
}

/* Show the badge ONLY on the authentication page */
.auth-body .grecaptcha-badge {
    visibility: visible;
}

/* Dark Theme Support for All Inputs */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

[data-theme="dark"] .file-upload input[type="file"] {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .loading {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .error-message {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.3);
    color: #ff8a8a;
}

/* Dark Theme Support for Additional Components */
[data-theme="dark"] .section-text {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .section-status {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

[data-theme="dark"] .chapter-header {
    background: var(--bg-secondary);
}

[data-theme="dark"] .chapter-header:hover {
    background: var(--bg-primary);
}

[data-theme="dark"] .chapter-audio-player {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .chapter-audio-progress {
    background: var(--bg-primary);
}

[data-theme="dark"] .chapter-audio-sections {
    background: var(--bg-primary);
}

[data-theme="dark"] .chapter-duration {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

/* Reorder Modal Styles */
#reorderModal .modal {
    min-width: 480px;
    max-width: 520px;
    max-height: 85vh;
    padding: 24px;
}

/* Responsive design for smaller screens */
@media (max-width: 600px) {
    #reorderModal .modal,
    #exportModal .modal {
        min-width: 95%;
        max-width: 95%;
        padding: 16px;
    }
}

.reorder-modal .modal-header {
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.reorder-modal .modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Center the buttons in reorder modal footer */
#reorderModal .modal-footer {
    justify-content: center;
}

/* Ensure reorder modal buttons are visible */
#reorderModal .btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

#reorderModal .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

#reorderModal .btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

#reorderModal .btn-secondary:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.reorder-instructions {
    background: var(--bg-secondary);
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.reorder-instructions p {
    margin: 3px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.reorder-chapters-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.reorder-chapters-list::-webkit-scrollbar {
    width: 6px;
}

.reorder-chapters-list::-webkit-scrollbar-track {
    background: transparent;
}

.reorder-chapters-list::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 3px;
    opacity: 0.6;
}

.reorder-chapters-list::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.reorder-chapter-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 14px;
    cursor: move;
    transition: all 0.2s ease;
    position: relative;
}

.reorder-chapter-item:hover:not(.dragging) {
    background: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.reorder-chapter-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border: 2px solid var(--primary-color);
    background: var(--bg-primary);
}

.reorder-chapter-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.reorder-drag-handle {
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
}

.reorder-drag-handle:active {
    cursor: grabbing;
}

.reorder-chapter-title {
    flex: 1;
    font-weight: bold;
    color: var(--text-primary);
}

.reorder-sections-toggle {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.reorder-sections-toggle:hover {
    background: var(--primary-hover);
}

.reorder-sections-dropdown {
    display: none;
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.reorder-sections-dropdown.open {
    display: block;
}

.reorder-section-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin: 4px 0;
    cursor: move;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.reorder-section-item:hover:not(.dragging) {
    border-color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.reorder-section-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border: 2px solid var(--primary-color);
    background: var(--bg-primary);
}

.reorder-section-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 0.9rem;
}

.reorder-section-drag-handle:active {
    cursor: grabbing;
}

.reorder-section-name {
    flex: 1;
    color: var(--text-primary);
}

.reorder-placeholder {
    background: transparent;
    border: 2px dashed var(--primary-color);
    border-radius: var(--radius-sm);
    height: 60px;
    margin: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 0.9rem;
    opacity: 0.8;
}

.reorder-placeholder.section-placeholder {
    height: 40px;
    font-size: 0.8rem;
    background: rgba(var(--primary-color-rgb), 0.05);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-primary);
}

/* Dark theme support for reorder modal */
[data-theme="dark"] .reorder-instructions {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .reorder-chapter-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .reorder-chapter-item:hover {
    background: var(--bg-primary);
}

[data-theme="dark"] .reorder-sections-dropdown {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .reorder-section-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .reorder-section-item:hover:not(.dragging) {
    background: var(--bg-primary);
    transform: translateY(-1px);
}

[data-theme="dark"] .reorder-chapter-item.dragging,
[data-theme="dark"] .reorder-section-item.dragging {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--bg-primary);
}

/* Inline editing styles */
.editable-title {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background-color 0.2s ease;
}

.editable-title:hover {
    background-color: rgba(var(--primary-color-rgb), 0.1);
}

.inline-edit-input {
    background: var(--bg-primary);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: inherit;
    font-weight: inherit;
    color: var(--text-primary);
    outline: none;
    min-width: 150px;
}

.inline-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.3);
}

/* Dark theme support for inline editing */
[data-theme="dark"] .inline-edit-input {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

/* Modern insertion line feedback */
.drag-over-above {
    position: relative;
}

.drag-over-above::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(var(--primary-color-rgb), 0.6);
    z-index: 100;
    animation: insertionLinePulse 1s ease-in-out infinite alternate;
}

.drag-over-below {
    position: relative;
}

.drag-over-below::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(var(--primary-color-rgb), 0.6);
    z-index: 100;
    animation: insertionLinePulse 1s ease-in-out infinite alternate;
}

@keyframes insertionLinePulse {
    0% { opacity: 0.6; transform: scaleY(1); }
    100% { opacity: 1; transform: scaleY(1.2); }
}

/* Smooth transitions for reorder items */
.reorder-chapter-item,
.reorder-section-item {
    transition: all 0.2s ease;
}

.reorder-chapter-item:not(.dragging),
.reorder-section-item:not(.dragging) {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Formatting styles */
.fmt-bold {
    font-weight: bold !important;
}

.fmt-italic {
    font-style: italic !important;
}

.fmt-underline {
    text-decoration: underline !important;
}

/* Ensure nested formatting elements inherit and combine styles */
.fmt-bold .fmt-italic,
.fmt-italic .fmt-bold {
    font-weight: bold !important;
    font-style: italic !important;
}

.fmt-bold .fmt-underline,
.fmt-underline .fmt-bold {
    font-weight: bold !important;
    text-decoration: underline !important;
}

.fmt-italic .fmt-underline,
.fmt-underline .fmt-italic {
    font-style: italic !important;
    text-decoration: underline !important;
}

/* Handle all three formats combined */
.fmt-bold .fmt-italic .fmt-underline,
.fmt-bold .fmt-underline .fmt-italic,
.fmt-italic .fmt-bold .fmt-underline,
.fmt-italic .fmt-underline .fmt-bold,
.fmt-underline .fmt-bold .fmt-italic,
.fmt-underline .fmt-italic .fmt-bold {
    font-weight: bold !important;
    font-style: italic !important;
    text-decoration: underline !important;
}

