@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ==========================================================================
   Aesthetic Refinement: Ethereal Glass
   Overrides base styling to introduce premium UI/UX conventions
   ========================================================================== */

/* Overriding and extending CSS Variables for Light Theme */
:root, [data-theme="light"] {
    --primary-color: #C5A031; /* Refined Gold */
    --secondary-color: #0F4C81; /* Royal Oceanic Blue */
    --accent-color: #F8F5E6; 
    --surface-color: rgba(255, 255, 255, 0.65); /* Glassmorphism Base */
    --surface-border: rgba(255, 255, 255, 0.8);
    --text-color: #1A202C;
    
    --primary-hover: #D4AF37;
    --primary-light: #FDF9E7;
    --bg-color: #f5f7fa;
    --bg-gradient: linear-gradient(135deg, #f3f4f6 0%, #e2e8f0 100%);
    --text-muted: #64748B;
    --text-secondary: #334155;
    
    --border-radius: 16px;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow: 0 8px 32px rgba(15, 76, 129, 0.05);
    --shadow-hover: 0 16px 48px rgba(15, 76, 129, 0.12);
    --glass-blur: blur(16px);
    
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Outfit', sans-serif;
}

/* Overriding CSS Variables for Dark Theme */
[data-theme="dark"] {
    --primary-color: #D4AF37;
    --secondary-color: #E2E8F0;
    --accent-color: #1E293B;
    --surface-color: rgba(15, 23, 42, 0.55);
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-color: #F8FAFC;
    
    --primary-hover: #F1C40F;
    --bg-color: #0B0F19;
    --bg-gradient: radial-gradient(circle at top right, #1E293B 0%, #0B0F19 60%, #040609 100%);
    --text-muted: #94A3B8;
    --text-secondary: #CBD5E1;
    
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 16px 48px rgba(212, 175, 55, 0.15); /* Ethereal Gold glow */
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --primary-color: #D4AF37;
        --secondary-color: #E2E8F0;
        --accent-color: #1E293B;
        --surface-color: rgba(15, 23, 42, 0.55);
        --surface-border: rgba(255, 255, 255, 0.08);
        --text-color: #F8FAFC;
        
        --primary-hover: #F1C40F;
        --bg-color: #0B0F19;
        --bg-gradient: radial-gradient(circle at top right, #1E293B 0%, #0B0F19 60%, #040609 100%);
        --text-muted: #94A3B8;
        --text-secondary: #CBD5E1;
        
        --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        --shadow-hover: 0 16px 48px rgba(212, 175, 55, 0.15);
    }
}

/* Base Body Application */
body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    min-height: 100vh;
    background-attachment: fixed; /* Ensures gradient doesn't stretch weirdly on scroll */
    letter-spacing: -0.01em;
}

/* Elegant Typography for Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
    font-weight: 700;
}

.hero-content h2 {
    font-size: 3.5rem;
    line-height: 1.1;
    background: linear-gradient(to right, var(--text-color), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-wrap: balance;
}

/* Glassmorphism Header */
.app-header {
    background: var(--surface-color);
    box-shadow: 0 1px 0 var(--surface-border), var(--shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 0 12px; /* Reduced from 24px to save space */
    display: flex; 
    align-items: center;
    justify-content: space-between;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 2px; /* Extremely compact to save space */
}

.header-actions .btn-icon {
    width: 40px !important;
    height: 40px !important;
    font-size: 0.95rem; /* Smaller icons */
}

.header-logo h1 {
    font-size: 1.15rem; /* Reduced to avoid line breaking */
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap; /* Prevent title from breaking onto 2 lines */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Premium Buttons */
.btn {
    border-radius: 999px; /* Pill shape for primary actions */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-body);
    position: relative;
    overflow: hidden;
}

/* ========================================================= */
/* PREMIUM HERO OVERHAUL */
/* ========================================================= */
.hero-section {
    background: var(--surface-color) !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.05) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid var(--surface-border) !important;
    position: relative;
    overflow: hidden;
    padding: 60px 20px !important;
    border-radius: 24px !important;
    margin-top: 15px; /* Slight breathing room down from the fixed header */
}

/* Mystic Orb hidden inside the glass hero panel */
.hero-section::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -20px;
    width: 250px;
    height: 250px;
    background: var(--primary-color);
    filter: blur(90px);
    opacity: 0.25;
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1; /* Elevate content above the internal glow */
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 15px !important;
    margin-top: 35px;
}

/* Transform the 3 stats into floating premium widgets */
.stat-item {
    background: var(--bg-color); /* Indented / raised contrast */
    padding: 15px 20px;
    border-radius: 18px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* Lift them out of the surface */
    min-width: 90px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.stat-item:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.stat-number {
    background: linear-gradient(45deg, var(--text-color), var(--primary-color));
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    font-size: 2.2rem !important;
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    letter-spacing: 1.5px !important;
    font-size: 0.75rem !important;
    font-weight: 700;
}

/* ========================================================= */
/* POST-QUIZ RESULTS OVERHAUL */
/* ========================================================= */
.results-card {
    background: var(--surface-color) !important;
    border-radius: 24px !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.05) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    padding: 40px 20px !important;
    border: 1px solid var(--surface-border) !important;
    text-align: center;
    position: relative;
    overflow: hidden;
    margin-top: 20px;
}

.results-icon {
    width: 90px !important;
    height: 90px !important;
    border-radius: 50% !important;
    background: var(--bg-color) !important;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.05) !important;
    margin: 0 auto 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 3px solid var(--primary-color) !important;
}

.results-icon i {
    font-size: 3.5rem !important;
    text-shadow: 0 4px 10px rgba(0,0,0,0.2) !important;
}

.results-card h2 {
    font-size: 2.2rem !important;
    background: linear-gradient(to right, var(--text-color), var(--primary-color));
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    margin-bottom: 30px !important;
}

.results-stats {
    display: flex !important;
    justify-content: space-around !important;
    gap: 10px !important;
    margin-bottom: 40px !important;
}

.result-stat {
    background: var(--bg-color) !important;
    padding: 15px 10px !important;
    border-radius: 16px !important;
    border: 1px solid var(--surface-border) !important;
    flex: 1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
    transition: transform 0.3s ease;
}

.result-stat:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color) !important;
}

.result-stat .stat-value {
    display: block !important;
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    color: var(--primary-color) !important;
    margin-bottom: 5px !important;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ========================================================= */
/* TOAST NOTIFICATION FIX & STYLING */
/* ========================================================= */
.toast {
    /* CRITICAL FIX: The toast bounding box was translating down when hidden, covering the navigation buttons */
    pointer-events: none !important; 
    
    background: var(--surface-color) !important;
    color: var(--text-color) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid var(--primary-color) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important;
    border-radius: 999px !important; /* Pill style */
    font-weight: 600 !important;
    padding: 12px 25px !important;
    bottom: 90px !important; /* Clear the bottom-nav height completely even when visible */
}

/* ========================================================= */
/* RECENT ACTIVITY COMPONENT OVERHAUL */
/* ========================================================= */
.recent-activity {
    margin-top: 40px;
}

.recent-activity h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--text-color);
    position: relative;
    padding-left: 15px;
}

.recent-activity h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 4px;
    background: var(--primary-color);
    border-radius: 4px;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center; /* Center them perfectly on wider desktop screens */
}

.activity-item {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    padding: 18px 25px;
    border-radius: 18px;
    display: flex;
    justify-content: flex-start; /* Stop brutal left/right splitting */
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 650px; /* Constrain stretching on desktop/tablets */
    margin: 0 auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.activity-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
}

.activity-item i {
    font-size: 1.6rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.activity-item .activity-content {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 2px;
}

.activity-item .activity-content p {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-color);
}

.activity-item .activity-content small {
    color: var(--text-muted);
    font-weight: 500;
}

.empty-state {
    background: rgba(var(--text-color-rgb), 0.02);
    border: 2px dashed var(--surface-border);
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.3s;
}

.empty-state:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.02);
}

.empty-state i {
    font-size: 3rem;
    color: var(--surface-border);
    margin-bottom: 15px;
    display: block;
}

.empty-state p {
    margin: 5px 0;
    font-size: 0.95rem;
}

/* ========================================================= */
/* PREMIUM APP FOOTER OVERHAUL */
/* ========================================================= */
.app-footer {
    text-align: center;
    padding: 30px 20px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--surface-border);
    margin-top: 50px;
    padding-bottom: 90px; /* Leave space for bottom nav on mobile */
}

.app-footer .footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.app-footer .footer-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

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

.app-footer .footer-dot {
    color: var(--surface-border);
    font-size: 1.2rem;
}

.app-footer p {
    margin: 5px 0;
}

.app-footer .b20-link {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    transition: filter 0.2s ease;
}

.app-footer .b20-link:hover {
    filter: brightness(1.2);
}

/* ========================================================= */
/* PROGRESS & ACHIEVEMENTS PAGE OVERHAUL */
/* ========================================================= */
.progress-header {
    background: linear-gradient(135deg, var(--surface-color), var(--bg-color));
    padding: 30px;
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.progress-header h2 {
    margin: 0;
    font-size: 2rem;
}

.level-badge {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-hover));
    color: #fff;
    padding: 10px 25px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}

.level-badge i {
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.stat-card {
    background: var(--surface-color) !important;
    border-radius: 20px !important;
    padding: 25px 20px !important;
    border: 1px solid var(--surface-border) !important;
    box-shadow: 0 5px 20px rgba(0,0,0,0.03) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    text-align: center;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08) !important;
}

.stat-card i {
    font-size: 2.5rem !important;
    color: var(--primary-color) !important;
    margin-bottom: 15px !important;
    filter: drop-shadow(0 2px 4px rgba(212, 175, 55, 0.4));
}

.stat-card .stat-number {
    font-size: 2.2rem !important;
    font-weight: 800 !important;
    background: linear-gradient(to right, var(--text-color), var(--primary-color));
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.stat-card .stat-label {
    letter-spacing: 1.5px;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.achievement-card {
    background: var(--surface-color) !important;
    border-radius: 18px !important;
    padding: 20px !important;
    border: 1px solid var(--surface-border) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03) !important;
    transition: all 0.3s ease;
    text-align: center;
}

.achievement-card.unlocked {
    border-color: var(--primary-color) !important;
    background: linear-gradient(145deg, var(--surface-color), rgba(var(--primary-color-rgb), 0.03)) !important;
}

.achievement-card.unlocked .achievement-icon {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-hover)) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4) !important;
    border: none !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.achievement-card.locked {
    opacity: 0.65;
    filter: grayscale(100%);
}

.achievement-card.locked .achievement-icon {
    background: transparent !important;
    color: var(--text-muted) !important;
    border: 2px dashed var(--surface-border) !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.achievement-title {
    font-weight: 800 !important;
    font-size: 1.1rem !important;
    margin-top: 15px !important;
    margin-bottom: 5px !important;
}

/* ========================================================= */
/* BRANDING & LOGO (IMAGE INJECTION)                         */
/* ========================================================= */
.header-logo h1 {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px; /* App icon curvature */
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.brand-logo:hover {
    transform: scale(1.1) rotate(-8deg); /* Playful magnetic tilt */
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5); /* Primary color glow */
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-hover));
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3) !important;
    border: none !important;
}

.btn-secondary {
    background: var(--surface-color) !important;
    color: var(--text-color) !important;
    border: 2px solid var(--primary-color) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
    font-weight: 700 !important;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--primary-color) !important;
    color: #fff !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
}
.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}
[data-theme="dark"] .btn-primary {
    color: #000;
}

/* Cards & Interactables - The "Floating" Glass aesthetic */
.action-card, .book-card, .mode-card, .stat-card, .quiz-game, .quiz-results {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    transition: var(--transition);
}

.action-card:hover, .book-card:hover, .mode-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-hover);
}

/* Search input elegance */
.search-input {
    border-radius: 999px;
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    padding: 16px 24px;
    font-family: var(--font-body);
}
.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
}

/* Floating Bottom Nav (Mobile) */
.bottom-nav {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--surface-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}
.nav-item-fab {
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
}

/* Customizing the Hero section to act as a banner instead of solid block */
.hero-section {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow);
}
[data-theme="dark"] .hero-section {
    background: var(--surface-color); 
}

/* Enhanced mode cards icons */
.mode-card i, .action-card i {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Modal Glass Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.glass-modal {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.hidden .glass-modal {
    transform: translateY(30px);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--error-color);
}

/* Update Book Grid for Comprehensive In-Flow Cards */
.books-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)) !important;
    gap: 24px !important;
    align-items: start !important; /* Extremely important for cards with varying text heights */
}

.book-card {
    cursor: text !important; /* Content cards, not clickable buttons */
    user-select: text !important;
}

.book-card:hover {
    transform: translateY(-2px) !important; /* Milder hover effect since it is now a native content card */
}

/* Header Collision Prevention on very narrow devices */
@media (max-width: 380px) {
    .header-logo h1 {
        font-size: 1rem !important; /* Shrink title */
        white-space: nowrap;
    }
    
    .app-header {
        padding: 0 12px;
    }

    .header-actions {
        gap: 2px !important;
    }

    .header-actions .btn-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.85rem !important;
    }
}

/* Global Container Clamp for Legal/About Pages */
.app-main {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Page Section Titles (e.g., Sobre page) */
.section-title {
    text-align: center;
    padding-top: 100px; /* Clear the 60px fixed glass header + margin */
    padding-bottom: 30px;
    padding-left: 20px;
    padding-right: 20px;
    width: 100%;
}

.section-title h2 {
    font-size: 2.2rem;
    margin-bottom: 12px;
    background: linear-gradient(45deg, var(--text-color), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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