/* Hide theme toggle button on mobile devices */
@media (max-width: 768px) {
    #appThemeToggleBtn {
        display: none !important;
    }
}

/* Premium Reading Styles */
.reading-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    border-radius: 16px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    position: relative;
}

/* Reading Themes */
.theme-reading-paper {
    background-color: #f4ecd8 !important;
    color: #2c2512 !important;
    border: 1px solid #e5d8b8 !important;
}
.theme-reading-paper .text-main,
.theme-reading-paper h1,
.theme-reading-paper h2,
.theme-reading-paper h3,
.theme-reading-paper h4,
.theme-reading-paper h5,
.theme-reading-paper h6 {
    color: #2c2512 !important;
}
.theme-reading-paper .text-muted {
    color: #786645 !important;
}
.theme-reading-paper hr {
    border-color: rgba(44, 37, 18, 0.2) !important;
    opacity: 1 !important;
}
.theme-reading-paper .btn-outline-secondary {
    color: #2c2512 !important;
    border-color: #bfae8a !important;
    background-color: rgba(44, 37, 18, 0.04) !important;
}
.theme-reading-paper .btn-outline-secondary:hover {
    background-color: rgba(44, 37, 18, 0.12) !important;
    color: #1a150a !important;
}
.theme-reading-paper .theme-toggle-btn {
    color: #2c2512 !important;
    border-color: #bfae8a !important;
}

.theme-reading-green {
    background-color: #e2f0d9 !important;
    color: #2b3a25 !important;
    border: 1px solid #cfebd0 !important;
}
.theme-reading-green .text-main,
.theme-reading-green h1,
.theme-reading-green h2,
.theme-reading-green h3,
.theme-reading-green h4,
.theme-reading-green h5,
.theme-reading-green h6 {
    color: #2b3a25 !important;
}
.theme-reading-green .text-muted {
    color: #4f6848 !important;
}
.theme-reading-green hr {
    border-color: rgba(43, 58, 37, 0.2) !important;
    opacity: 1 !important;
}
.theme-reading-green .btn-outline-secondary {
    color: #2b3a25 !important;
    border-color: #a3c99b !important;
    background-color: rgba(43, 58, 37, 0.04) !important;
}
.theme-reading-green .btn-outline-secondary:hover {
    background-color: rgba(43, 58, 37, 0.12) !important;
    color: #182414 !important;
}
.theme-reading-green .theme-toggle-btn {
    color: #2b3a25 !important;
    border-color: #a3c99b !important;
}

.theme-reading-white {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
    border: 1px solid #eaeaea !important;
}
.theme-reading-white .text-main,
.theme-reading-white h1,
.theme-reading-white h2,
.theme-reading-white h3,
.theme-reading-white h4,
.theme-reading-white h5,
.theme-reading-white h6 {
    color: #1a1a1a !important;
}
.theme-reading-white .text-muted {
    color: #666666 !important;
}
.theme-reading-white hr {
    border-color: rgba(0, 0, 0, 0.12) !important;
    opacity: 1 !important;
}
.theme-reading-white .btn-outline-secondary {
    color: #1a1a1a !important;
    border-color: #cccccc !important;
    background-color: rgba(0, 0, 0, 0.03) !important;
}
.theme-reading-white .btn-outline-secondary:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
    color: #000000 !important;
}
.theme-reading-white .theme-toggle-btn {
    color: #1a1a1a !important;
    border-color: #cccccc !important;
}

.theme-reading-dark {
    background-color: hsl(240, 35%, 6%) !important;
    color: #c4c4d4 !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
}
.theme-reading-dark .text-main,
.theme-reading-dark h1,
.theme-reading-dark h2,
.theme-reading-dark h3,
.theme-reading-dark h4,
.theme-reading-dark h5,
.theme-reading-dark h6 {
    color: #f7fafc !important;
}
.theme-reading-dark .text-muted {
    color: #a0aec0 !important;
}
.theme-reading-dark hr {
    border-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 1 !important;
}
.theme-reading-dark .btn-outline-secondary {
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    background-color: rgba(255, 255, 255, 0.04) !important;
}
.theme-reading-dark .btn-outline-secondary:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}
.theme-reading-dark .theme-toggle-btn {
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* VIP Lock Box Theme Protection Override */
#vipLockBox {
    background-color: #14141e !important;
    color: #f7fafc !important;
    border-color: #ffc107 !important;
}
#vipLockBox h4,
#vipLockBox h5,
#vipLockBox .text-main {
    color: #ffffff !important;
}
#vipLockBox .text-warning {
    color: #ffc107 !important;
}
#vipLockBox .text-muted {
    color: #cbd5e1 !important;
}

/* Reading Content Text Settings */
.reading-content {
    white-space: pre-line;
    font-size: 1.25rem;
    line-height: 1.8;
}

/* Fonts definition */
.font-nunito { font-family: 'Nunito', 'Outfit', sans-serif !important; }
.font-outfit { font-family: 'Outfit', sans-serif !important; }
.font-playfair { font-family: 'Playfair Display', serif !important; }
.font-notoserif { font-family: 'Noto Serif', serif !important; }
.font-lora { font-family: 'Lora', serif !important; }
.font-merriweather { font-family: 'Merriweather', serif !important; }
.font-literata { font-family: 'Literata', serif !important; }
.font-roboto { font-family: 'Roboto', sans-serif !important; }
.font-inter { font-family: 'Inter', sans-serif !important; }
.font-bevietnam { font-family: 'Be Vietnam Pro', sans-serif !important; }
.font-lexend { font-family: 'Lexend', sans-serif !important; }
.font-palatino { font-family: 'Palatino', 'Palatino Linotype', serif !important; }
.font-arial { font-family: 'Arial', sans-serif !important; }
.font-times { font-family: 'Times New Roman', Times, serif !important; }

/* Spacings */
.lh-normal { line-height: 1.6 !important; }
.lh-medium { line-height: 1.9 !important; }
.lh-high { line-height: 2.2 !important; }

/* Float Settings Menu Bar */
.reading-settings-bar {
    background: var(--navbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 6px 16px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Premium Toast Notification */
.premium-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    pointer-events: none;
}
.premium-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.premium-toast-success { border-color: rgba(40, 167, 69, 0.6) !important; box-shadow: 0 10px 30px rgba(40, 167, 69, 0.2) !important; }
.premium-toast-error { border-color: rgba(220, 53, 69, 0.6) !important; box-shadow: 0 10px 30px rgba(220, 53, 69, 0.2) !important; }
.premium-toast-info { border-color: rgba(0, 123, 255, 0.6) !important; box-shadow: 0 10px 30px rgba(0, 123, 255, 0.2) !important; }
.premium-toast .toast-icon-success { color: #28a745; }
.premium-toast .toast-icon-error { color: #dc3545; }
.premium-toast .toast-icon-info { color: #007bff; }

/* Premium Confirm Dialog */
.premium-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.premium-confirm-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.premium-confirm-box {
    background: #14141e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.premium-confirm-overlay.show .premium-confirm-box {
    transform: scale(1);
}

/* Mobile Edge-to-Edge Full Screen Reading */
@media (max-width: 767.98px) {
    #readingBox.reading-container {
        margin-left: -12px !important;
        margin-right: -12px !important;
        width: calc(100% + 24px) !important;
        max-width: calc(100% + 24px) !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        padding: 30px 16px 40px 16px !important;
    }
}

/* Crisp rendering optimization for reading canvas */
#canvasWrapper canvas {
    image-rendering: -webkit-optimize-contrast; /* Tối ưu tương phản, giữ nét cực tốt cho Safari (macOS/iOS) */
    image-rendering: auto;                      /* Nội suy chất lượng cao tránh mất nét cho Android, Chrome, Firefox */
    -webkit-font-smoothing: antialiased;        /* Làm mượt nét chữ trên các thiết bị chạy WebKit/Blink */
    -moz-osx-font-smoothing: grayscale;         /* Làm mượt nét chữ trên Firefox macOS */
}

/* Premium Select dropdown styling in reading settings modal */
.glass-dropdown select.form-select {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--glass-border) !important;
}

/* Tùy chỉnh màu các dòng option trong menu phông chữ */
.glass-dropdown select.form-select option {
    background-color: #0d0e18 !important; /* Trùng với màu nền của menu dropdown */
    color: #e0e0f0 !important;             /* Chữ xám sáng dễ đọc */
}

/* Hộp điều khiển cỡ chữ & giãn dòng trong menu cài đặt */
.glass-dropdown .settings-control-box {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--glass-border) !important;
}

/* Tùy biến các nút tăng giảm + - */
.glass-dropdown .settings-control-box .btn-outline-secondary {
    border-color: var(--glass-border) !important;
    color: var(--text-main) !important;
    transition: all 0.2s ease;
    background: transparent !important;
}

.glass-dropdown .settings-control-box .btn-outline-secondary:hover {
    background-color: var(--nav-active-bg) !important;
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
}


/* Extracted Sidebar Styles */
/* Styling Sidebars */
    .reading-sidebar {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1050;
    }

    .left-sidebar {
        left: 24px;
        width: 80px;
    }

    .right-sidebar {
        right: 24px;
        width: 280px;
        height: 80vh;
        background: var(--card-bg, rgba(20, 20, 28, 0.7));
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
        border-radius: 16px;
        padding: 16px;
        display: flex;
        flex-direction: column;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }

    /* Buttons in Left Sidebar */
    .sidebar-btn {
        background: var(--card-bg, rgba(20, 20, 28, 0.7));
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
        color: var(--text-main, #f7fafc);
        border-radius: 12px;
        width: 72px;
        height: 72px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 0.72rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        text-decoration: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .sidebar-btn:hover,
    .sidebar-btn.active-scroll {
        background: rgba(255, 193, 7, 0.15);
        border-color: #ffc107;
        color: #ffc107;
    }

    .sidebar-btn i {
        font-size: 1.25rem;
    }

    /* Right Sidebar styling */
    .sidebar-title {
        font-size: 0.95rem;
        font-weight: 700;
        color: var(--text-main, #f7fafc);
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
        text-align: center;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .chapter-list-scrollbar {
        flex: 1;
        overflow-y: auto;
        padding-right: 4px;
    }

    /* Scrollbar Styling for Right Sidebar */
    .chapter-list-scrollbar::-webkit-scrollbar {
        width: 6px;
    }

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

    .chapter-list-scrollbar::-webkit-scrollbar-thumb {
        background: var(--glass-border, rgba(255, 255, 255, 0.15));
        border-radius: 10px;
    }

    .chapter-list-scrollbar::-webkit-scrollbar-thumb:hover {
        background: rgba(139, 92, 246, 0.4);
    }

    /* Chapter items */
    .sidebar-chapter-item {
        display: block;
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.85rem;
        color: var(--text-muted, #a0aec0);
        text-decoration: none;
        border-radius: 6px;
        transition: all 0.2s ease;
        border-left: 2px solid transparent;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.5;
        margin-bottom: 2px;
    }

    .sidebar-chapter-item:hover {
        background: var(--nav-active-bg, rgba(255, 255, 255, 0.05));
        color: var(--accent-primary, #8b5cf6);
        padding-left: 15px;
    }

    .sidebar-chapter-item.active {
        background: rgba(255, 193, 7, 0.15);
        color: #d97706 !important;
        border-left-color: #d97706;
        font-weight: 600;
    }

    /* Light theme overrides for sidebars */
    [data-bs-theme="light"] .right-sidebar,
    [data-bs-theme="light"] .sidebar-btn {
        background: rgba(255, 255, 255, 0.92) !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        color: #2d3748 !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
    }

    [data-bs-theme="light"] .sidebar-title {
        color: #1a202c !important;
        border-bottom-color: rgba(0, 0, 0, 0.08) !important;
    }

    [data-bs-theme="light"] .sidebar-chapter-item {
        color: #4a5568 !important;
    }

    [data-bs-theme="light"] .sidebar-chapter-item:hover {
        background: rgba(124, 58, 237, 0.1) !important;
        color: #7c3aed !important;
    }

    /* Adjust main container margin on wide screens to make room for sidebars */
    @media (min-width: 1400px) {
        .container.py-4 {
            max-width: 1320px;
            padding-left: 100px !important;
            padding-right: 300px !important;
        }
    }

    @media (min-width: 1200px) and (max-width: 1399.98px) {
        .container.py-4 {
            max-width: 1140px;
            padding-left: 90px !important;
            padding-right: 290px !important;
        }
    }

/* Hover Scale Utility */
.hover-scale {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-scale:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
}

/* Toast Notification Floating Container & Animation */
#custom-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10999 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.custom-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(20, 20, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: toast-fade-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    font-size: 0.9rem;
}

.custom-toast.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
}

.custom-toast.toast-success {
    border-color: rgba(34, 197, 94, 0.5);
}

.custom-toast.toast-info {
    border-color: rgba(59, 130, 246, 0.5);
}

@keyframes toast-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-fade-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* Support Buttons Equal Width Styling */
.support-btn-equal {
    min-width: 250px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 575.98px) {
    .support-btn-equal {
        min-width: 100%;
        width: 100%;
    }
}
