/* Book Reader Redesign - Glassmorphic Design with Tamil Support */

/* Python Code Runner Component */
.python-runner {
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    background-color: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

[data-theme="dark"] .python-runner {
    border-color: #4b5563;
    background-color: #0f172a;
}

.python-runner-header {
    background: linear-gradient(to right, #eff6ff, #e0e7ff);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d1d5db;
}

[data-theme="dark"] .python-runner-header {
    background: linear-gradient(to right, #1e293b, #1e293b);
    border-bottom-color: #4b5563;
}

.python-runner-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
}

[data-theme="dark"] .python-runner-label {
    color: #f1f5f9;
}

.python-runner-buttons {
    display: flex;
    gap: 0.5rem;
}

.python-runner-code {
    background-color: #f9fafb;
    padding: 1rem;
}

[data-theme="dark"] .python-runner-code {
    background-color: #020617;
}

.python-runner-code textarea {
    width: 100%;
    min-height: 150px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background-color: #f9fafb;
    border: none;
    resize: vertical;
    color: #1f2937;
}

[data-theme="dark"] .python-runner-code textarea {
    background-color: #020617;
    color: #f1f5f9;
}

.python-runner-footer {
    background-color: #f9fafb;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #d1d5db;
}

[data-theme="dark"] .python-runner-footer {
    background-color: #1e293b;
    border-top-color: #4b5563;
}

.python-run-button {
    background-color: #14b8a6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
}

.python-run-button:hover {
    background-color: #0d9488;
}

.python-run-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.python-runner-info {
    font-size: 0.75rem;
    color: #6b7280;
}

.python-runner-output {
    background-color: #f9fafb;
    border-top: 1px solid #d1d5db;
    padding: 1rem;
}

[data-theme="dark"] .python-runner-output {
    background-color: #1e293b;
    border-top-color: #4b5563;
}

.python-output-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0d9488;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

[data-theme="dark"] .python-output-label {
    color: #2dd4bf;
}

.python-output-content {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #1f2937;
}

[data-theme="dark"] .python-output-content {
    color: #f1f5f9;
}

/* Glassmorphic Cards - Exact Specification */
.glass-card {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1.5rem !important;
    padding: 1.5rem !important;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1) !important;
}

[data-theme="dark"] .glass-card {
    background-color: rgba(50, 70, 92, 0.8) !important;
    border-color: #3f556d !important;
}

.glass-card-lg {
    border-radius: 1.5rem;
}

.glass-card-xl {
    border-radius: 1.75rem;
}

/* Two-Column Layout */
.book-reader-layout {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0.75rem !important;
    display: flex !important;
    gap: 1rem !important;
    width: 100%;
}

@media (max-width: 768px) {
    .book-reader-layout {
        max-width: none !important;
        width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }
}

.book-sidebar {
    width: 320px !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    top: 1.5rem !important;
    align-self: flex-start !important;
    max-height: calc(100vh - 3rem) !important;
    overflow-y: auto !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1.5rem !important;
    padding: 1.5rem !important;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1) !important;
}

[data-theme="dark"] .book-sidebar {
    background-color: rgba(50, 70, 92, 0.8) !important;
    border-color: #3f556d !important;
}

.book-sidebar::-webkit-scrollbar {
    width: 6px;
}

.book-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.book-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.3);
    border-radius: 3px;
}

.book-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.5);
}

@media (max-width: 1024px) {
    .book-reader-layout {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        gap: 0.5rem !important;
        flex-direction: row !important;
    }
    
    .book-sidebar {
        position: fixed !important;
        left: 0 !important;
        top: var(--mobile-navbar-height, 70px) !important;
        height: calc(100dvh - var(--mobile-navbar-height, 70px)) !important;
        width: 85% !important;
        max-width: 320px !important;
        z-index: 1080 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        align-self: auto !important;
        max-height: none !important;
        border-radius: 0 1rem 1rem 0 !important;
        margin: 0 !important;
        background-color: var(--card) !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.15) !important;
    }
    
    .book-sidebar.show {
        transform: translateX(0) !important;
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: var(--mobile-navbar-height, 70px);
        left: 0;
        width: 100%;
        height: calc(100dvh - var(--mobile-navbar-height, 70px));
        background: rgba(0, 0, 0, 0.25);
        z-index: 1070;
    }
    
    .book-main-content {
        width: 100% !important;
    }
    
    .reading-area {
        max-height: none !important;
        padding: 1rem !important;
        border-radius: 1rem !important;
    }
}

@media (max-width: 768px) {
    .book-reader-layout {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .reading-area {
        padding: 0.75rem !important;
        font-size: 15px !important;
    }
    
    .reading-area p,
    .reading-area li,
    #markdownContent p,
    #markdownContent li,
    .reader-prose p,
    .reader-prose li {
        font-size: 15px !important;
        line-height: 1.7 !important;
    }
    
    .reading-area h1,
    #markdownContent h1,
    .reader-prose h1 {
        font-size: 1.5rem !important;
    }
    
    .reading-area h2,
    #markdownContent h2,
    .reader-prose h2 {
        font-size: 1.3rem !important;
    }
    
    .reading-area h3,
    #markdownContent h3,
    .reader-prose h3 {
        font-size: 1.15rem !important;
    }
}

.book-main-content {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Override old sidebar styles */
.book-sidebar.glass-card {
    background-color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(229, 231, 235, 0.8) !important;
}

[data-theme="dark"] .book-sidebar.glass-card {
    background-color: rgba(50, 70, 92, 0.95) !important;
    border-color: rgba(63, 85, 109, 0.8) !important;
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 1.5rem !important;
}

.sidebar-section-title {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #6b7280 !important;
    margin-bottom: 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

[data-theme="dark"] .sidebar-section-title {
    color: #c6d2db !important;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.toc-badge {
    background-color: #f8f3d4 !important;
    color: #6b7280 !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 0.375rem !important;
    min-width: 2rem !important;
    text-align: center !important;
}

[data-theme="dark"] .toc-badge {
    background-color: #526d82 !important;
    color: #c6d2db !important;
}

.sidebar-separator {
    height: 1px;
    background-color: var(--border);
    margin: 1rem 0;
    opacity: 0.6;
}

/* TOC Styling */
.toc-list {
    max-height: 350px !important;
    overflow-y: auto !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0.75rem !important;
    background-color: rgba(249, 250, 251, 0.5) !important;
    border: 1px solid rgba(229, 231, 235, 0.6) !important;
}

[data-theme="dark"] .toc-list {
    background-color: rgba(30, 41, 59, 0.3);
    border-color: rgba(63, 85, 109, 0.6);
}

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

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

.toc-list::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.toc-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.7);
}

.toc-item {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    border-radius: 0;
    transition: all 0.2s;
    font-size: 0.875rem;
    line-height: 1.4;
    border-left: 3px solid transparent;
}

.toc-item:hover {
    background-color: rgba(246, 65, 108, 0.08);
    border-left-color: rgba(246, 65, 108, 0.3);
}

[data-theme="dark"] .toc-item:hover {
    background-color: rgba(255, 179, 63, 0.12);
    border-left-color: rgba(255, 179, 63, 0.4);
}

.toc-item.active {
    background-color: rgba(246, 65, 108, 0.1) !important;
    color: #f6416c !important;
    font-weight: 600 !important;
    border-left-color: #f6416c !important;
}

[data-theme="dark"] .toc-item.active {
    background-color: rgba(255, 179, 63, 0.1) !important;
    color: #ffb33f !important;
    border-left-color: #ffb33f !important;
}

.toc-item.level-1 {
    padding-left: 0.875rem;
    font-weight: 500;
}

.toc-item.level-2 {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
}

.toc-item.level-3 {
    padding-left: 2.25rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* Reading Stats Card */
.stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
    padding: 0 !important;
    background: linear-gradient(135deg, rgba(246, 65, 108, 0.08) 0%, rgba(246, 65, 108, 0.03) 100%) !important;
    border-radius: 1rem !important;
    border: 1px solid rgba(229, 231, 235, 0.6) !important;
    overflow: hidden !important;
}

[data-theme="dark"] .stats-grid {
    background: linear-gradient(135deg, rgba(255, 179, 63, 0.12) 0%, rgba(255, 179, 63, 0.05) 100%);
    border-color: rgba(63, 85, 109, 0.6);
}

.stat-box {
    text-align: center;
    padding: 1rem;
    position: relative;
}

.stat-box:first-child::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background-color: rgba(229, 231, 235, 0.6);
}

[data-theme="dark"] .stat-box:first-child::after {
    background-color: rgba(63, 85, 109, 0.6);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Download Links */
.download-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.download-link-pdf {
    color: #dc2626 !important;
    background-color: rgba(220, 38, 38, 0.05) !important;
    border-color: rgba(220, 38, 38, 0.2) !important;
}

.download-link-pdf:hover {
    background-color: rgba(220, 38, 38, 0.1) !important;
    border-color: #f6416c !important;
    transform: translateY(-1px) !important;
}

.download-link-epub {
    color: #9333ea !important;
    background-color: rgba(147, 51, 234, 0.05) !important;
    border-color: rgba(147, 51, 234, 0.2) !important;
}

.download-link-epub:hover {
    background-color: rgba(147, 51, 234, 0.1) !important;
    border-color: #f6416c !important;
    transform: translateY(-1px) !important;
}

[data-theme="dark"] .download-link-pdf:hover,
[data-theme="dark"] .download-link-epub:hover {
    border-color: #ffb33f !important;
}

.download-link i {
    font-size: 1rem;
}

/* Toolbar */
.reader-toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem 1.5rem !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1rem !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1) !important;
}

[data-theme="dark"] .reader-toolbar {
    background-color: rgba(50, 70, 92, 0.8) !important;
    border-color: #3f556d !important;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-book-info {
    display: flex;
    flex-direction: column;
}

.toolbar-now-reading {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toolbar-book-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
}

/* Reading Area */
.reading-area {
    max-height: 75vh !important;
    overflow-y: auto !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: none !important;
    border-radius: 1.5rem !important;
    padding: 1.25rem !important;
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.06) !important;
}

[data-theme="dark"] .reading-area {
    background-color: rgba(50, 70, 92, 0.8) !important;
    border: none !important;
}

/* Match books.html body text: Poppins, 16px, line-height 1.8 */
.reading-area,
#markdownContent,
.reader-prose {
    font-family: 'Poppins', sans-serif !important;
    font-size: 16px !important;
    line-height: 1.8 !important;
}

.reading-area p,
.reading-area li,
.reading-area td,
.reading-area th,
.reading-area blockquote,
#markdownContent p,
#markdownContent li,
#markdownContent td,
#markdownContent th,
.reader-prose p,
.reader-prose li {
    font-family: 'Poppins', sans-serif !important;
    font-size: 16px !important;
    line-height: 1.8 !important;
}

/* Override reading-enhancements.css 18px */
.reading-mode-active .markdown-content {
    font-size: 16px !important;
    line-height: 1.8 !important;
    font-family: 'Poppins', sans-serif !important;
}

/* Search Highlighting */
mark.search-highlight {
    background-color: #fef08a;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

mark.search-highlight.active {
    background-color: #fbbf24;
    animation: ring-pulse 1s ease-in-out;
}

@keyframes ring-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    color: #78350f;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    z-index: 100;
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(var(--primary), 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.text-muted {
    color: var(--muted-foreground);
}

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

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-2xl {
    border-radius: 1rem;
}

.rounded-3xl {
    border-radius: 1.5rem;
}
