/* =============================================
   VR Library — Design System
   Dark mode with purple/blue gradient accents
   Glassmorphism + Modern Animations
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&display=swap');

/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(255, 255, 255, 0.07);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --text-muted: #6b6b8a;
    --accent-primary: #7c3aed;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #7c3aed, #3b82f6);
    --accent-gradient-hover: linear-gradient(135deg, #6d28d9, #2563eb);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --gold: #fbbf24;
    --silver: #94a3b8;
    --bronze: #d97706;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: 'Noto Sans Thai', 'Inter', sans-serif;
    color-scheme: dark;
    /* Global default for dark theme */
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #e4e6eb;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.75);
    --border-glass: rgba(0, 0, 0, 0.1);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8a8aaa;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.15);
    color-scheme: light;
}

[data-theme="light"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border-glass);
}

[data-theme="light"] .navbar.scrolled {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .card,
[data-theme="light"] .stat-card,
[data-theme="light"] .book-card,
[data-theme="light"] .reading-card,
[data-theme="light"] .badge-card,
[data-theme="light"] .goal-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .dropdown-menu a {
    color: var(--text-primary);
}

[data-theme="light"] .dropdown-menu a:hover {
    background: rgba(124, 58, 237, 0.08);
}

[data-theme="light"] .table-wrapper,
[data-theme="light"] .data-table thead {
    background: rgba(124, 58, 237, 0.04);
}

[data-theme="light"] .data-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.04);
}

[data-theme="light"] .data-table td,
[data-theme="light"] .data-table th {
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .form-control,
[data-theme="light"] .chat-input {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
}

[data-theme="light"] .admin-sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chat-window {
    background: rgba(255, 255, 255, 0.97);
}

[data-theme="light"] .chat-msg-content {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chat-msg.user .chat-msg-content {
    background: rgba(124, 58, 237, 0.1);
    border-color: rgba(124, 58, 237, 0.2);
}

[data-theme="light"] .hero {
    background: linear-gradient(180deg, #e8e0f7 0%, var(--bg-primary) 100%);
}

[data-theme="light"] .search-overlay {
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .search-overlay .search-box-large {
    border-color: rgba(0, 0, 0, 0.15);
    background: #fff;
}

[data-theme="light"] .footer {
    background: #1a1a2e;
    color: #fff;
}

[data-theme="light"] .footer a {
    color: rgba(255, 255, 255, 0.7);
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    margin-right: 8px;
}

.theme-toggle:hover {
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

img {
    max-width: 100%;
    display: block;
}

ul,
ol {
    list-style: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

/* ===== Utility ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-center {
    text-align: center;
}

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

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

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

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

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 0 20px;
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(10, 10, 26, 0.95);
    box-shadow: var(--shadow-md);
}

.navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.4rem;
}

.navbar-brand i {
    font-size: 1.6rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-nav a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-xp {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-glass);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
}

.navbar-xp i {
    font-size: 0.9rem;
}

.navbar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    cursor: pointer;
    object-fit: cover;
}

.navbar-toggle {
    display: none;
    background: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    min-width: 200px;
    padding: 8px;
    display: none;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

.dropdown.active .dropdown-menu {
    display: block;
    animation: fadeDown 0.2s ease;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dropdown-menu a:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.dropdown-divider {
    border-top: 1px solid var(--border-glass);
    margin: 6px 0;
}

/* ===== Hero Section ===== */
.hero {
    position: relative;
    min-height: 90vh;
    display: flex;
    align-items: center;
    padding: 100px 0 60px;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 0;
}

.hero-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 70% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    animation: heroGlow 8s ease-in-out infinite alternate;
}

@keyframes heroGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-5%, 3%) scale(1.1);
    }
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    animation: fadeUp 0.6s ease;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 20px;
    animation: fadeUp 0.6s ease 0.1s both;
}

.hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 36px;
    animation: fadeUp 0.6s ease 0.2s both;
}

.hero-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    animation: fadeUp 0.6s ease 0.3s both;
}

.hero-stats {
    display: flex;
    gap: 48px;
    justify-content: center;
    margin-top: 60px;
    animation: fadeUp 0.6s ease 0.4s both;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Floating books animation */
.floating-books {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.floating-book {
    position: absolute;
    font-size: 2rem;
    opacity: 0.1;
    animation: float 20s linear infinite;
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.1;
    }

    90% {
        opacity: 0.1;
    }

    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

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

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

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 36px;
    font-size: 1.05rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

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

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(124, 58, 237, 0.4);
}

.book-card-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg-secondary);
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.book-card:hover .book-card-cover img {
    transform: scale(1.08);
}

.book-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.book-card-body {
    padding: 16px;
}

.book-card-category {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.book-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-author {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.book-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-glass);
}

.book-card-xp {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gold);
}

.book-card-pages {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Section Headers ===== */
.section {
    padding: 80px 0;
}

.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-header h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Grid ===== */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

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

.category-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

.category-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    color: white;
}

.category-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.category-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Progress Bar ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-glass);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar-lg {
    height: 12px;
}

/* ===== XP Level Badge ===== */
.level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    box-shadow: var(--shadow-glow);
}

.level-badge-lg {
    width: 60px;
    height: 60px;
    font-size: 1.3rem;
}

/* ===== Leaderboard ===== */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
}

.leaderboard-item:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.leaderboard-rank {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.9rem;
    background: var(--bg-glass);
    color: var(--text-muted);
    flex-shrink: 0;
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a2e;
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: white;
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.leaderboard-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.leaderboard-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-glass);
}

.leaderboard-name {
    font-weight: 600;
}

.leaderboard-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.leaderboard-stats {
    text-align: right;
}

.leaderboard-xp {
    font-weight: 700;
    color: var(--gold);
}

.leaderboard-books {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0c0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    color-scheme: dark;
    /* Helps browser native UI match theme */
}

/* Style options specifically for dark theme */
select.form-control option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ===== Alert / Flash ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeDown 0.3s ease;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--info);
}

/* ===== Auth Pages ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    display: block;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--accent-primary);
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ===== Admin Layout ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 24px;
    font-weight: 800;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 16px;
}

.admin-sidebar-brand i {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.4rem;
}

.admin-nav {
    padding: 0 12px;
}

.admin-nav-label {
    padding: 8px 12px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 16px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.admin-nav a:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.admin-nav a.active {
    background: var(--accent-gradient);
    color: white;
}

.admin-nav a i {
    width: 20px;
    text-align: center;
}

.admin-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
}

/* Admin Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Table ===== */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.data-table .user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.data-table .user-cell img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    animation: zoomIn 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-glass);
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

/* ===== PDF Reader ===== */
.reader-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1a1a2e;
}

.reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.reader-title {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reader-page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0 12px;
}

.reader-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.reader-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.reader-viewport {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background: #2a2a3e;
}

.reader-viewport canvas {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 100%;
}

/* ===== Profile Page ===== */
.profile-header {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--accent-primary);
    object-fit: cover;
    flex-shrink: 0;
}

/* Avatar Fallback (FA icon) */
.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
    color: white;
    flex-shrink: 0;
}

.avatar-fallback i {
    font-size: 1em;
}

.profile-avatar.avatar-fallback {
    font-size: 2.5rem;
}

.navbar-avatar.avatar-fallback {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
}

.leaderboard-avatar.avatar-fallback {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.dash-avatar.avatar-fallback {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

.review-avatar.avatar-fallback {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.user-cell .avatar-fallback {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

/* Avatar Upload Wrapper */
.avatar-upload-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
    flex-shrink: 0;
}

.avatar-upload-wrapper input[type="file"] {
    display: none;
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
    font-size: 0.75rem;
    flex-direction: column;
    gap: 4px;
}

.avatar-upload-wrapper:hover .avatar-upload-overlay {
    opacity: 1;
}

.avatar-upload-overlay i {
    font-size: 1.2rem;
}

.avatar-remove-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: 2px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.2s ease;
}

.avatar-remove-btn:hover {
    transform: scale(1.15);
}

.profile-info h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.profile-info .profile-level {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.profile-xp-bar {
    width: 300px;
    max-width: 100%;
}

.profile-xp-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.profile-stats {
    display: flex;
    gap: 32px;
    margin-left: auto;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.profile-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Badges Grid ===== */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
}

.badge-card.earned {
    border-color: rgba(124, 58, 237, 0.4);
    box-shadow: var(--shadow-glow);
}

.badge-card.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.badge-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.badge-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Search ===== */
.search-bar {
    position: relative;
    max-width: 480px;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 44px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.search-bar input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.filter-tag {
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-tag:hover,
.filter-tag.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
}

.pagination a,
.pagination span {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

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

.pagination a:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

/* ===== Star Rating ===== */
.stars {
    display: flex;
    gap: 4px;
    color: var(--gold);
}

.stars .empty {
    color: var(--text-muted);
    font-weight: 400 !important;
}

.stars i {
    font-weight: 900;
}

.star-input {
    display: flex;
    gap: 4px;
    direction: rtl;
}

.star-input input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.star-input label {
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 400;
    /* Regular / Outline */
}

.star-input label i {
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
}

.star-input input:checked~label,
.star-input label:hover,
.star-input label:hover~label {
    color: var(--gold) !important;
}

.star-input input:checked~label i,
.star-input label:hover i,
.star-input label:hover~label i {
    font-weight: 900 !important;
    /* Solid / Filled */
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-glass);
    padding: 48px 0 24px;
    margin-top: 80px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.footer-brand i {
    margin-right: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.footer-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

.footer h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.footer a {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px 0;
}

.footer a:hover {
    color: var(--accent-primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-glass);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== XP Award Animation ===== */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 3000;
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    padding: 48px;
    text-align: center;
    box-shadow: 0 0 60px rgba(251, 191, 36, 0.3);
}

.xp-popup.show {
    animation: xpPopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes xpPopIn {
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

.xp-popup .xp-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.xp-popup .xp-amount {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--gold);
    margin-bottom: 8px;
}

.xp-popup .xp-label {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== Confetti Overlay ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2999;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: var(--transition);
    }

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

    .admin-content {
        margin-left: 0;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        margin: 20px auto 0;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.2rem;
    }

    .hero-stats {
        gap: 24px;
        flex-wrap: wrap;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .navbar-nav {
        display: none;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-nav.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-glass);
        padding: 16px;
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .section {
        padding: 60px 0;
    }

    .section-header h2 {
        font-size: 1.6rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .auth-card {
        padding: 24px;
    }

    .container {
        padding: 0 12px;
    }
}

/* ===== Book Detail ===== */
.book-detail {
    padding-top: 100px;
}

.book-detail-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 48px;
    align-items: start;
}

.book-cover-large {
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 100px;
}

.book-cover-large img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
}

.book-meta {
    display: flex;
    gap: 24px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.book-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.book-meta-item i {
    color: var(--accent-primary);
}

/* Review Card */
.review-card {
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.review-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.review-author {
    font-weight: 600;
    font-size: 0.9rem;
}

.review-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.review-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ===== Completion Overlay ===== */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.5s ease;
}

.completion-card {
    text-align: center;
    padding: 60px;
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    box-shadow: 0 0 80px rgba(251, 191, 36, 0.2);
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 480px;
}

.completion-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.completion-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.completion-xp {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--gold);
    margin: 16px 0;
}

.completion-message {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-glass);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== Reading Progress Cards ===== */
.reading-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: var(--transition);
}

.reading-card:hover {
    background: var(--bg-card-hover);
}

.reading-card-cover {
    width: 60px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

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

.reading-card-info {
    flex: 1;
}

.reading-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.reading-card-progress {
    margin-top: 8px;
}

.reading-card-status {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.reading-card-status.completed {
    color: var(--success);
}

.reading-card-status.reading {
    color: var(--info);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    background: none;
}

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

.tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeUp 0.3s ease;
}

@media (max-width: 768px) {
    .book-detail-grid {
        grid-template-columns: 1fr;
    }

    .book-cover-large {
        max-width: 240px;
        margin: 0 auto;
        position: static;
    }
}

/* ===== Admin Layout ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: rgba(10, 10, 26, 0.95);
    border-right: 1px solid var(--border-glass);
    backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px;
    font-weight: 800;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-glass);
}

.admin-sidebar-brand i {
    font-size: 1.4rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-nav {
    padding: 12px;
}

.admin-nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.admin-nav a:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.admin-nav a.active {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.admin-nav a i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.admin-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.admin-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Data Table ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: rgba(255, 255, 255, 0.03);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-cell img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-glass);
}

/* ===== Filter Tags ===== */
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-tag:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.filter-tag.active {
    background: rgba(124, 58, 237, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: 600;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.9rem;
}

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

.text-center {
    text-align: center;
}

.mb-3 {
    margin-bottom: 24px;
}

.mt-3 {
    margin-top: 24px;
}

.gap-1 {
    gap: 6px;
}

.gap-2 {
    gap: 12px;
}

.items-center {
    align-items: center;
}

/* ===== Admin Responsive ===== */
@media (max-width: 1024px) {
    .admin-sidebar {
        width: 220px;
    }

    .admin-content {
        margin-left: 220px;
    }

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

@media (max-width: 768px) {
    .admin-sidebar {
        display: none;
    }

    .admin-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Search Overlay ===== */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(5, 5, 20, 0.92);
    backdrop-filter: blur(30px);
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.search-overlay.active {
    display: block;
    opacity: 1;
}

.search-overlay-inner {
    max-width: 700px;
    margin: 80px auto;
    padding: 0 24px;
}

.search-close {
    position: fixed;
    top: 24px;
    right: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 10001;
    transition: var(--transition);
}

.search-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.search-box-large {
    position: relative;
    margin-bottom: 24px;
}

.search-box-large i:first-child {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    color: var(--text-muted);
}

.search-box-large input {
    width: 100%;
    padding: 20px 55px;
    background: var(--bg-glass);
    border: 2px solid var(--border-glass);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
    outline: none;
    transition: var(--transition);
}

.search-box-large input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.15);
}

.search-spinner {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-primary);
    display: none;
}

.search-spinner.active {
    display: block;
}

.search-hint {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.95rem;
}

.search-results {
    display: grid;
    gap: 12px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.search-result-item:hover {
    transform: translateX(8px);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.1);
}

.search-result-cover {
    width: 50px;
    height: 65px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.search-result-cover-placeholder {
    width: 50px;
    height: 65px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
}

.search-result-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.search-result-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

/* ===== Mega Category Icons ===== */
.mega-categories {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
}

.mega-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: var(--bg-glass);
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 100px;
    text-align: center;
}

.mega-cat:hover {
    transform: translateY(-6px) scale(1.05);
    border-color: var(--border-glass);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.mega-cat.active {
    border-color: var(--accent-primary);
    background: rgba(108, 92, 231, 0.12);
    box-shadow: 0 0 25px rgba(108, 92, 231, 0.15);
}

.mega-cat-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    transition: var(--transition);
}

.mega-cat-icon span {
    font-size: 2rem;
}

.mega-cat-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.mega-cat-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Filtered Area ===== */
.filtered-books {
    margin-top: 16px;
    min-height: 200px;
}

.filtered-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.filtered-loading.hidden {
    display: none;
}

/* ===== 3D Bookshelf ===== */
.bookshelf-3d {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 24px;
    perspective: 1500px;
}

.shelf-book {
    position: relative;
    cursor: pointer;
}

.shelf-book-inner {
    position: relative;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
}

.shelf-book:hover .shelf-book-inner {
    transform: rotateY(-8deg) translateY(-12px) scale(1.05);
}

.shelf-book-cover {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    aspect-ratio: 3/4;
}

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

.shelf-book-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
}

.shelf-book-placeholder span {
    font-size: 3rem;
}

.placeholder-title {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-weight: 600;
}

/* ===== Book Hover Popup ===== */
.book-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(15px);
    width: 260px;
    background: rgba(20, 20, 40, 0.97);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 18px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}

.shelf-book:hover .book-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
    pointer-events: auto;
}

.book-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(20, 20, 40, 0.97);
}

.book-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.book-popup-cat {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.book-popup-xp {
    font-size: 0.78rem;
    color: var(--accent-secondary);
    font-weight: 700;
}

.book-popup-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 6px;
    line-height: 1.3;
}

.book-popup-author {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.book-popup-meta {
    display: flex;
    gap: 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.book-popup .btn-sm {
    width: 100%;
    text-align: center;
    font-size: 0.82rem;
    padding: 8px 16px;
}

/* ===== Pulse Glow ===== */
.pulse-glow {
    animation: pulseGlow 2.5s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(108, 92, 231, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(108, 92, 231, 0.6);
    }
}


/* ===== Certificate ===== */
.certificate-frame {
    max-width: 800px;
    margin: 0 auto;
    background: #fffef7;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.certificate-inner {
    border: 3px double #b8860b;
    margin: 12px;
    padding: 40px;
}

.certificate-border {
    border: 1px solid #daa520;
    padding: 40px;
    position: relative;
    text-align: center;
}

.certificate-ornament {
    position: absolute;
    font-size: 1.5rem;
    color: #b8860b;
}

.certificate-ornament.top-left {
    top: 10px;
    left: 10px;
}

.certificate-ornament.top-right {
    top: 10px;
    right: 10px;
}

.certificate-ornament.bottom-left {
    bottom: 10px;
    left: 10px;
}

.certificate-ornament.bottom-right {
    bottom: 10px;
    right: 10px;
}

.certificate-header h4 {
    font-size: 1rem;
    color: #666;
    font-weight: 400;
    margin: 8px 0;
}

.certificate-header h2 {
    font-size: 2rem;
    color: #333;
    font-family: serif;
    letter-spacing: 4px;
}

.certificate-logo {
    font-size: 3rem;
}

.certificate-name {
    font-size: 2.5rem;
    color: #b8860b;
    font-family: serif;
    margin: 20px 0;
    font-style: italic;
}

.certificate-title {
    font-size: 1.2rem;
    color: #444;
    margin: 12px 0;
    font-weight: 600;
}

.certificate-desc {
    font-size: 0.95rem;
    color: #666;
}

.certificate-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 40px;
}

.cert-line {
    width: 150px;
    border-bottom: 1px solid #333;
    margin: 0 auto 6px;
}

.certificate-footer span {
    font-size: 0.85rem;
    color: #666;
}

.seal-circle {
    width: 60px;
    height: 60px;
    border: 2px solid #b8860b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto;
}

.certs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.cert-card {
    text-align: center;
    padding: 32px 24px;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.cert-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(108, 92, 231, 0.15);
}

.cert-card-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.cert-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.cert-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.cert-card-date {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Responsive for Phase 1 ===== */
@media (max-width: 768px) {
    .mega-categories {
        gap: 10px;
    }

    .mega-cat {
        min-width: 80px;
        padding: 14px 10px;
    }

    .mega-cat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .bookshelf-3d {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 16px;
    }

    .book-popup {
        display: none !important;
    }

    .search-overlay-inner {
        margin: 40px auto;
    }



    .certificate-inner {
        padding: 20px;
    }

    .certificate-border {
        padding: 20px;
    }

    .certificate-name {
        font-size: 1.5rem;
    }
}

/* ===== Phase 2: AI Chat Widget ===== */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    font-family: inherit;
}

.chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    color: #fff;
    font-size: 1.4rem;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.5);
}

.chat-bubble::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--accent-gradient);
    opacity: 0.3;
    animation: chatPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes chatPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.chat-bubble-icon {
    display: block;
}

.chat-bubble-close {
    display: none;
    font-size: 1.2rem;
}

.chat-widget.open .chat-bubble-icon {
    display: none;
}

.chat-widget.open .chat-bubble-close {
    display: block;
}

.chat-widget.open .chat-bubble::before {
    display: none;
}

.chat-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--accent-error);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: rgba(15, 15, 35, 0.97);
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.chat-widget.open .chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(59, 130, 246, 0.1));
    border-bottom: 1px solid var(--border-glass);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.chat-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.chat-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: statusPulse 2s ease infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.chat-minimize {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    min-height: 200px;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 90%;
    animation: msgAppear 0.3s ease;
}

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.chat-msg.user .chat-msg-avatar {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.chat-msg-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.chat-msg.user .chat-msg-content {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
    border-radius: 16px 16px 4px 16px;
}

.chat-msg-content p {
    margin: 0;
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.chat-suggestions {
    padding: 8px 16px 4px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-glass);
}

.chat-chip {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.chat-chip:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.4);
    color: var(--text-primary);
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-glass);
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
}

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

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Teacher Dashboard Charts */
.chart-container {
    position: relative;
    height: 300px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid var(--border-glass);
    padding: 20px;
}

.dashboard-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dashboard-filter select {
    padding: 8px 16px;
    border-radius: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.goal-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    transition: var(--transition);
}

.goal-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
}

.goal-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
}

.goal-progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 1s ease;
}

/* Responsive Chat */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: 70vh;
    }

    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-bubble {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }
}

/* ===== Student Dashboard ===== */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    margin-bottom: 24px;
}

.dash-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dash-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

.dash-xp-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.dash-stat-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.dash-stat-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
}

.dash-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin: 0 auto 12px;
}

.dash-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
}

.dash-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.dash-continue-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.dash-continue-card:hover {
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.2);
}

.dash-continue-cover {
    width: 50px;
    height: 65px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.dash-continue-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dash-continue-info {
    flex: 1;
}

.dash-completed-card {
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.dash-completed-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
}

.dash-completed-cover {
    width: 100%;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
}

.dash-completed-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Heatmap */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    transition: var(--transition);
}

.heatmap-level-0 {
    background: rgba(255, 255, 255, 0.05);
}

.heatmap-level-1 {
    background: rgba(124, 58, 237, 0.25);
}

.heatmap-level-2 {
    background: rgba(124, 58, 237, 0.5);
}

.heatmap-level-3 {
    background: rgba(124, 58, 237, 0.8);
}

.heatmap-cell:hover {
    transform: scale(1.3);
}

[data-theme="light"] .heatmap-level-0 {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .dash-continue-card:hover,
[data-theme="light"] .dash-completed-card:hover {
    background: rgba(124, 58, 237, 0.04);
}

/* ===== Netflix-style Recommendation Rows ===== */
.netflix-section {
    margin-bottom: 32px;
}

.netflix-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.netflix-section-title {
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.netflix-row-wrap {
    position: relative;
}

.netflix-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.netflix-row::-webkit-scrollbar {
    display: none;
}

.netflix-card {
    flex: 0 0 200px;
    scroll-snap-align: start;
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
    color: inherit;
    position: relative;
}

.netflix-card:hover {
    transform: scale(1.08);
    z-index: 10;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-primary);
}

.netflix-card-cover {
    width: 100%;
    height: 260px;
    overflow: hidden;
    position: relative;
}

.netflix-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}

.netflix-card:hover .netflix-card-cover img {
    transform: scale(1.08);
}

.netflix-card-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.netflix-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 12px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

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

.netflix-card-overlay .nf-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.netflix-card-overlay .nf-meta {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

.netflix-card-body {
    padding: 10px 12px 14px;
}

.netflix-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.netflix-card-author {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.netflix-card-xp {
    font-size: 0.7rem;
    color: var(--gold);
    margin-top: 4px;
    font-weight: 600;
}

.netflix-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    opacity: 0;
}

.netflix-row-wrap:hover .netflix-arrow {
    opacity: 1;
}

.netflix-arrow:hover {
    background: var(--accent-primary);
}

.netflix-arrow.left {
    left: -12px;
}

.netflix-arrow.right {
    right: -12px;
}

[data-theme="light"] .netflix-arrow {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .netflix-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ===== Premium Reader UI ===== */
.reader-mode-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 3px;
}

.reader-mode-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.reader-mode-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 600;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.flip-book {
    box-shadow: 0 0 20px rgba(0, 0, 0, 1);
    margin: 0 auto;
    display: none;
}

.page {
    background-color: #fff;
}

.page-content {
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
}

@media (max-width: 992px) {
    /* Navbar Mobile Menu */
    .navbar-toggle {
        display: block !important;
    }

    .navbar-nav {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-glass);
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 8px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }

    .navbar-nav.mobile-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .navbar-nav a {
        width: 100%;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    /* Admin Sidebar Layout */
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        padding: 16px 0;
    }

    .admin-sidebar-brand {
        padding: 0 20px 12px;
        margin-bottom: 12px;
    }

    .admin-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0 16px;
    }

    .admin-nav-label {
        display: none;
    }

    .admin-nav a {
        margin-bottom: 0;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .admin-content {
        margin-left: 0;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    /* Hero Section */
    .hero {
        padding: 80px 0 40px;
        min-height: auto;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero p {
        font-size: 1rem;
        margin-bottom: 24px;
    }

    .hero-actions {
        flex-direction: column;
        gap: 12px;
        padding: 0 20px;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .hero-stats {
        gap: 24px;
        margin-top: 40px;
    }

    /* Dashboard */
    .dash-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

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

    .dash-user {
        flex-direction: column;
    }

    /* Netflix recommendation cards */
    .netflix-card {
        flex: 0 0 160px;
    }

    .netflix-card-cover {
        height: 210px;
    }

    /* Profile Header */
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 24px;
        gap: 20px;
    }

    .profile-stats {
        margin: 16px auto 0;
        width: 100%;
        justify-content: center;
        gap: 24px;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
        text-align: center;
    }

    /* PDF Reader Toolbar */
    .reader-toolbar {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
        text-align: center;
    }

    .reader-controls {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .dash-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .navbar-brand span {
        display: none; /* Hide site name on very small screens to fit XP/Avatar */
    }
}