@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@300;400;500;600;700&display=swap');

/* Root variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 8px 24px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --border-radius-small: 8px;
    
    /* Reading specific colors */
    --reading-bg: #fefefe;
    --highlight-word: #ffeaa7;
    --highlight-sentence: #ddd6fe;
    --annotation-color: #fb7185;
}

/* Dark mode variables */
[data-theme="dark"] {
    --primary-color: #1e293b;
    --secondary-color: #3b82f6;
    --accent-color: #ef4444;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --reading-bg: #1e293b;
    --highlight-word: #fbbf24;
    --highlight-sentence: #8b5cf6;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comfortaa', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    transition: all 0.3s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.1rem; }

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.container-fluid {
    width: 100%;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-light);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-accent {
    color: var(--accent-color);
}

.nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-small);
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-small);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--secondary-color);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-accent {
    background: var(--accent-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline:hover {
    background: var(--secondary-color);
    color: white;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Grid System */
.grid {
    display: grid;
    gap: 2rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    background: var(--surface-color);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.upload-icon {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

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

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.book-item {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.book-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.book-cover {
    width: 100%;
    height: 250px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    position: relative;
}

.book-info {
    padding: 1rem;
}

.book-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.book-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Reader Interface */
.reader-container {
    display: flex;
    height: calc(100vh - 80px);
}

.reader-sidebar {
    width: 300px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    overflow-y: auto;
}

.reader-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.reader-toolbar {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.reader-text {
    flex: 1;
    overflow-y: auto;
    width: 90%;
    box-shadow: var(--shadow-light);
    font-family: var(--reader-font, 'Comfortaa'), serif;
    line-height: var(--reader-line-height, 1.8);
    font-size: var(--reader-font-size, 18px);
    color: var(--text-primary);
    background: var(--reading-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    margin: 1rem auto;
    margin-bottom: 120px; /* Space for floating toolbox */
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.tts-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius-small);
    transition: all 0.3s ease;
}

.tts-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.tts-btn.active {
    background: var(--secondary-color);
    color: white;
}

/* Popup Controls */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

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

.popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.popup-close:hover {
    color: var(--text-primary);
}

/* TTS Controls Popup */
.tts-popup {
    min-width: 400px;
}

.tts-position {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

/* Settings Popup */
.settings-popup {
    min-width: 450px;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group h4 {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.font-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.font-option {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: var(--surface-color);
}

.font-option:hover {
    border-color: var(--secondary-color);
}

.font-option.active {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
}

/* Annotation Controls */
.annotation-popup {
    min-width: 350px;
}

.annotation-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.annotation-style-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.style-option {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.style-option:hover {
    border-color: var(--secondary-color);
}

.style-option.active {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
}

.color-options {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

/* Custom Color Management */
.color-option.add-color {
    min-width: 34px;
    min-height: 34px;
    transform: translate(-2px, 2px);
    padding: 4px 0px 0px 8px;
    background-color: #eee;
}

.color-option.add-color:hover {
    color: var(--accent-color);
}

.custom-color-input {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.custom-color-input input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.custom-color {
    position: relative;
}

.remove-color {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #dc2626;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.custom-color:hover .remove-color {
    opacity: 1;
}

/* Enhanced annotation interaction */
.annotation {
    cursor: pointer;
    position: relative;
}

.annotation:hover::after {
    content: attr(data-note);
    position: absolute;
    top: -2rem;
    left: 0;
    background: var(--surface-color);
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    max-width: 200px;
    word-wrap: break-word;
    white-space: normal;
}

/* Button variants */
.btn.btn-danger {
    background: #dc2626;
    color: white;
    border: 1px solid #dc2626;
}

.btn.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-primary);
    transform: scale(1.2);
}

/* Text Selection Styles */
.text-selected {
    background: rgba(52, 152, 219, 0.3);
    border-radius: 2px;
}

/* Enhanced Annotation Styles */
.annotation {
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.annotation:hover {
    transform: scale(1.02);
}

.annotation.highlight {
    background-color: var(--annotation-bg, #ffeaa7);
    padding: 0 2px;
    border-radius: 2px;
}

.annotation.underline {
    border-bottom: 2px solid var(--annotation-color, #fb7185);
}

.annotation.strikethrough {
    text-decoration: line-through;
    text-decoration-color: var(--annotation-color, #fb7185);
    text-decoration-thickness: 2px;
}

/* Floating Toolbox Bar */
.floating-toolbox {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 100rem;
    box-shadow: var(--shadow-heavy);
    z-index: 100;
    transition: all 0.3s ease;
    max-width: 100vw;
    min-width: 300px;
    display: flex;
    padding: 0.75rem 1rem;
}

.floating-toolbox.collapsed .toolbox-content {
    display: none;
}

.floating-toolbox.collapsed {
    width: 60px;
    height: 60px;
    background: var(--secondary-color);
    min-width: unset;
    left: auto;
    right: 1rem;
    transform: none;
    padding: 2px;
}

.toolbox-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.toolbox-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.toolbox-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.1);
}

.toolbox-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.toolbox-collapse {
    min-width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.toolbox-collapse:hover {
    background: var(--accent-color);
    transform: scale(1.1);
}

.floating-toolbox.collapsed .toolbox-collapse {
    min-width: 54px;
    height: 54px;
    font-size: x-large;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.page-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}

.progress-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 120px;
}

.progress-section .progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-section .progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 30px;
}

/* Floating TTS Control Bar */
.floating-tts-bar {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-heavy);
    z-index: 110;
    padding: 1rem;
    min-width: 400px;
    max-width: 90vw;
}

.tts-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tts-control-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.tts-control-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.1);
}

.tts-control-btn.tts-play-pause {
    width: 55px;
    height: 55px;
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    font-size: 1.3rem;
}

.tts-control-btn.tts-play-pause:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

.tts-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tts-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.tts-progress-fill {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.3s ease;
}

.tts-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

/* Selection Popup */
.selection-popup {
    position: absolute;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-medium);
    padding: 0.5rem;
    z-index: 120;
    display: flex;
    gap: 0.25rem;
}

.selection-btn {
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.selection-btn:hover {
    background: var(--secondary-color);
    color: white;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Improved animations */
.floating-toolbox {
    animation: slideInFromBottom 0.5s ease-out;
}

.floating-tts-bar {
    animation: slideInFromBottom 0.3s ease-out;
}

@keyframes slideInFromBottom {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.toolbox-btn.playing {
    background: var(--accent-color);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Selection Popup */
.selection-popup {
    position: absolute;
    background: var(--surface-color);
    border-radius: var(--border-radius-small);
    padding: 0.5rem;
    box-shadow: var(--shadow-heavy);
    z-index: 1001;
    display: flex;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
    animation: popupSlideIn 0.2s ease-out;
}

.selection-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.selection-btn.primary {
    background: var(--secondary-color);
    color: white;
}

.selection-btn.secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.selection-btn:hover {
    transform: translateY(-1px);
}

/* Collapsible Sidebar */
.reader-sidebar {
    position: fixed;
    right: 0;
    top: 80px;
    height: calc(100vh - 80px);
    width: 350px;
    background: var(--surface-color);
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 98;
    display: flex;
    flex-direction: column;
}

.reader-sidebar.open {
    transform: translateX(0);
}

.sidebar-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 100px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--border-radius-small) 0 0 var(--border-radius-small);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
    transition: all 0.3s;
}

.sidebar-toggle:hover {
    background: var(--border-color);
}

.sidebar-toggle i {
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.sidebar-toggle.open i {
    transform: rotate(180deg);
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.sidebar-tab {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.sidebar-tab.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
    background: var(--surface-color);
}

.sidebar-tab:hover {
    background: var(--border-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Reader Content Adjustments */
.reader-content {
    margin-right: 0;
    transition: margin-right 0.3s ease;
}

.reader-sidebar.open ~ .reader-content {
    margin-right: 350px;
}

.book-info h2 {

.reading-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--secondary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Remove old TTS controls from toolbar */
.tts-controls {
    display: none;
}

/* Range Slider Improvements */
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    transition: background 0.3s;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    transition: all 0.3s;
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    border: none;
    transition: all 0.3s;
}

.form-range::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .reader-container {
        flex-direction: column;
    }
    
    .reader-sidebar {
        width: 100%;
        height: 200px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        gap: 1rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    
    .reader-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tts-controls {
        flex-wrap: wrap;
    }
    
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .popup-content {
        padding: 1.5rem;
        margin: 1rem;
        width: calc(100% - 2rem);
    }
    
    .tts-popup,
    .settings-popup,
    .annotation-popup {
        min-width: auto;
    }
        bottom: 1rem;
        left: 1rem;
        width: 45px;
        height: 45px;
    }
    
    .reader-sidebar {
        width: 100%;
        top: 60px;
        height: calc(100vh - 60px);
    }
    
    .reader-sidebar.open ~ .reader-content {
        margin-right: 0;
    }
    
    .sidebar-toggle {
        right: 0.5rem;
        width: 35px;
        height: 80px;
    }
    
    .reader-text {
        padding: 1.5rem;
        margin: 1rem;
        font-size: 16px;
        margin-bottom: 120px; /* Space for floating toolbox */
    }
    
    .floating-toolbox {
        bottom: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        transform: none;
        min-width: auto;
        max-width: none;
    }
    
    .toolbox-content {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .toolbox-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .page-display {
        font-size: 0.7rem;
        min-width: 60px;
    }
    
    .progress-section {
        min-width: 80px;
    }
    
    .floating-tts-bar {
        bottom: 4rem;
        left: 0.5rem;
        right: 0.5rem;
        transform: none;
        min-width: auto;
        padding: 0.75rem;
    }
    
    .tts-controls {
        gap: 0.25rem;
    }
    
    .tts-control-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .tts-control-btn.tts-play-pause {
        width: 45px;
        height: 45px;
    }
    
    .selection-popup {
        flex-direction: column;
        min-width: 120px;
    }
    
    .selection-btn {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    #ttsPanel .popup-content {
        position: fixed !important;
        bottom: 120px !important;
        right: 1rem !important;
        left: 1rem !important;
        width: auto !important;
    }
}

@media (max-width: 480px) {
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .card {
        padding: 1.5rem;
    }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-light { font-weight: 300; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.p-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.hidden { display: none; }
.flex { display: flex; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* Footer Styles */
.footer {
    background: var(--primary-color);
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h4 {
    color: white;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.footer-section p a {
    color: rgba(255, 255, 255, 0.8);
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: white;
}

.footer-logo {
    margin-bottom: 1rem;
}

.footer-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
}

.footer-logo .logo-text {
    color: white;
}

.footer-logo .logo-accent {
    color: var(--accent-color);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-link:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1.5rem;
    text-align: center;
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin: 0;
}

.footer-bottom a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-bottom a:hover {
    color: white;
}

/* Dark theme footer adjustments */
[data-theme="dark"] .footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .footer-section h4 {
    color: var(--text-primary);
}

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

[data-theme="dark"] .footer-section p a {
    color: var(--text-secondary);
}

[data-theme="dark"] .footer-section ul li a {
    color: var(--text-secondary);
}

[data-theme="dark"] .footer-section ul li a:hover {
    color: var(--text-primary);
}

[data-theme="dark"] .footer-logo .logo-text {
    color: var(--text-primary);
}

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

[data-theme="dark"] .social-link:hover {
    background: var(--secondary-color);
    color: white;
}

[data-theme="dark"] .footer-bottom {
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .footer-bottom p {
    color: var(--text-muted);
}

[data-theme="dark"] .footer-bottom a {
    color: var(--text-secondary);
}

[data-theme="dark"] .footer-bottom a:hover {
    color: var(--text-primary);
}

/* Responsive footer */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .footer-bottom {
        text-align: center;
    }
}

/* Loading and Error States */
.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.error-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--accent-color);
}
