/* =========================================
   header.css - Finalized with Refined Dot
   ========================================= */

:root {
    --mobile-nav-height: 65px;
    --mobile-nav-safe-padding: 80px;
    --student-search-bar-height: 45px;
    --text-dark: #1f2937;
    --text-muted: #6c757d;
    --card-bg-default: #ffffff;
    --card-border: #e0e0e0;
    --page-bg: #f8f9fa;
    --primary-color: #007bff;
    --theme-bg: #f8f9fa;
}

/* --- 1. GENERAL HEADER LAYOUT --- */
.main-header {
    background-color: var(--card-bg-default, #ffffff);
    border-bottom: 1px solid var(--card-border, #e0e0e0);
    width: 100%;
    height: 70px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: block;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 15px;
}

/* --- 2. LOGO & NAV --- */
.logo-icon {
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 5px 10px 5px 0;
    text-decoration: none;
}
.logo-icon img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.main-nav { display: flex; align-items: center; gap: 15px; }
.main-nav a, .main-nav .dropdown-toggle {
    color: var(--text-dark, #1f2937);
    text-decoration: none;
    font-weight: 500;
}
.main-nav a:hover, .main-nav .dropdown-toggle:hover {
    color: var(--primary-color, #007bff);
}

/* --- 3. AVATAR FIX --- */
.nav-avatar, .initials-placeholder { 
    width: 46px !important; 
    height: 46px !important; 
    min-width: 46px;
    border-radius: 50%; 
    object-fit: cover; 
    vertical-align: middle; 
    border: 2px solid gold; 
    transition: border-color 0.2s; 
    box-sizing: border-box;
}

.initials-placeholder {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: #ffffff !important;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
}

.nav-avatar:hover, .initials-placeholder:hover { border-color: #ddd; }

/* --- 4. DROPDOWNS --- */
.nav-item-dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
    background: none; border: none;
    color: var(--text-dark, #1f2937);
    font: inherit; cursor: pointer;
    padding: 10px; font-weight: 500;
}
.dropdown-menu { 
    display: none; 
    position: absolute; 
    top: 100%; right: 0;
    background-color: var(--card-bg-default, white); 
    box-shadow: 0 8px 16px rgba(0,0,0,0.15); 
    z-index: 1001; 
    border-radius: 8px; 
    min-width: 160px; 
    border: 1px solid var(--card-border, #eee); 
}
.nav-item-dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { 
    color: var(--text-dark, #333); 
    padding: 12px 16px; 
    text-decoration: none; 
    display: block; 
    text-align: left; 
}
.dropdown-menu a:hover { background-color: var(--page-bg, #f1f1f1); }

/* --- 5. THEME MODAL STYLING --- */
#theme-options-modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center; 
    justify-content: center; 
    padding: 1rem;
}
#theme-options-modal.is-open { display: flex; }

#theme-options-modal .modal-content {
    background-color: var(--card-bg-default); 
    color: var(--text-dark);
    max-width: 350px;
    width: 90%; 
    border-radius: 12px;
    display: flex; 
    flex-direction: column; 
    max-height: 80vh;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

#theme-options-modal .modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 15px;
    border-bottom: 1px solid var(--card-border);
    background-color: var(--card-bg-default);
}
#theme-options-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
}

#theme-options-modal .close-modal { display: none !important; }

#theme-options-modal .modal-body {
    padding: 0; 
    overflow-y: auto;
}

#theme-options-modal .theme-option-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

#theme-options-modal .theme-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    padding: 14px 15px; 
    cursor: pointer;
    border-bottom: 1px solid var(--card-border);
    font-weight: 500; 
    color: var(--text-dark); 
    border-left: 4px solid transparent;
    transition: background-color 0.2s;
}
#theme-options-modal .theme-item:hover { background-color: var(--theme-bg, #f1f1f1); }
#theme-options-modal .theme-item.active {
    font-weight: 700;
    background-color: var(--theme-bg, #eef);
    border-left-color: var(--theme-color, blue);
}

.theme-label-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.theme-color-indicator {
    display: block !important;
    width: 16px; 
    height: 16px; 
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid var(--card-border); 
    margin-right: 12px; 
    flex-shrink: 0;
    background-color: var(--theme-color, #ccc);
}

#theme-options-modal .modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    background-color: var(--card-bg-default);
}

#theme-options-modal .modal-footer .btn {
    font-size: 0.85rem;
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    background-color: #6c757d; 
    color: white;
    border: none;
    transition: background-color 0.2s;
    margin: 0;
}

/* --- 6. AI CHAT MODAL --- */
#ai-chat-modal {
    display: none; position: fixed; z-index: 2001; inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
#ai-chat-modal.active, #ai-chat-modal.show { display: flex !important; }

/* --- 7. COST BADGES --- */
.menu-cost-badge {
    display: flex; align-items: center; gap: 8px;
    background-color: var(--page-bg, #fafafa); color: var(--text-dark);
    padding: 12px 16px; border-bottom: 1px solid var(--card-border);
    font-size: 0.8rem; font-weight: 600;
    white-space: nowrap; width: auto; min-width: 100%;
    cursor: pointer; user-select: none; transition: background-color 0.2s;
}
.menu-cost-badge i { color: #f59e0b; }

.teacher-stats-row {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--card-border);
    background-color: var(--card-bg-default, #ffffff);
}
.teacher-stat-compact {
    padding: 10px 16px; flex: 1; text-align: center; position: relative; cursor: pointer;
}
.teacher-stat-compact:first-child { border-right: 1px solid var(--card-border); }
.stat-value-compact { font-weight: 700; color: var(--primary-color); display: block; font-size: 1.1rem; }
.stat-label-compact { font-size: 0.75rem; color: var(--text-muted); display: block; }

.desktop-cost-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; margin-right: 15px;
    background-color: var(--page-bg, #f8f9fa);
    border: 1px solid var(--card-border, #e0e0e0);
    border-radius: 20px; font-size: 0.9rem; font-weight: 600; color: var(--text-dark);
    cursor: pointer; transition: all 0.2s ease; user-select: none;
    white-space: nowrap !important; flex-shrink: 1 !important;
    overflow: hidden !important; text-overflow: ellipsis !important;
}
.desktop-cost-badge:hover {
    background-color: #e9ecef; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.desktop-cost-badge i { color: #f59e0b; flex-shrink: 0; }

/* --- 8. NOTIFICATION DOT & ANIMATION (Refined) --- */
.notification-dot {
    /* 1. Positioning: Inline but "Super" (Upper Index) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: top; /* Moves it up like an exponent */
    margin-left: 4px;    /* Space from "AI" text */
    margin-top: -2px;    /* Slight tweak upwards */
    
    /* 2. Sizing: Smaller and fixed */
    min-width: 16px;     /* Smaller width */
    height: 26px;        /* Smaller height */
    width: 26px;
    padding: 0 4px;      /* Padding for double digits (10+) */
    
    /* 3. Appearance */
    background-color: #28a745; 
    color: white;
    font-size: 9px;      /* Smaller, crisp text */
    font-weight: 700;
    border-radius: 5rem; /* Pill shape */
    border: 1px solid #fff; /* Clean white border separator */
    
    /* 4. State */
    opacity: 0;          /* Hidden by default */
    transform: scale(0); /* Start shrunk */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy pop-in */
    z-index: 100;
}

/* Visibility State */
.notification-dot.active {
    opacity: 1;
    transform: scale(1); /* Pop in to normal size */
    display: inline-flex; /* Ensure it's visible */
}

/* Gentle Pulsating Animation (Shadow Ripple) */
.notification-dot.pulsating {
    background-color: #22c55e; /* Slightly brighter green */
    animation: gentle-pulse 2s infinite;
}

@keyframes gentle-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        /* Ripples out to 5px but fades to transparent */
        box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); 
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* Mobile specific positioning - KEEP ABSOLUTE for Mobile Icons */
.mobile-nav-item .notification-dot {
    position: absolute;
    top: 5px;
    right: 25%;
    margin: 0; /* Reset desktop margins */
    min-width: 14px;
    height: 14px;
    font-size: 8px;
    border: 1px solid white;
}

/* Adjust Desktop Chat Button alignment */
#global-chat-btn-desktop {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0px; /* Reduced gap since dot has margin-left */
}

/* --- 9. MOBILE BOTTOM NAV & QUERIES --- */
.mobile-bottom-nav { display: none; }

@media (min-width: 769px) and (max-width: 1000px) {
    .header-container.container { padding-left: 10px; padding-right: 10px; max-width: 100%; }
    .main-nav a, .main-nav .dropdown-toggle { font-size: 0.85rem; padding: 10px 8px; }
    .desktop-cost-badge i { display: none !important; }
    .desktop-cost-badge span { display: inline-block !important; font-size: 0.8rem; }
    .desktop-cost-badge { margin-right: 5px; padding: 6px 10px; gap: 0; }
    .logo-icon img { height: 50px; width: 150px; }
}

@media (max-width: 768px) {
    .desktop-cost-badge { display: none; }
    .main-header { display: none; }
    
    body.teacher-mobile-view, body.student-mobile-view { padding-bottom: var(--mobile-nav-safe-padding) !important; }
    body.student-dashboard-page.student-mobile-view, body.teacher-dashboard-page.teacher-mobile-view {
        padding-bottom: calc(var(--mobile-nav-safe-padding) + var(--student-search-bar-height)) !important;
    }
    
    .sticky-search-bar {
        position: sticky; bottom: var(--mobile-nav-height); 
        z-index: 999; background-color: var(--card-bg-default, #ffffff); 
        box-shadow: 0 -2px 8px rgba(0,0,0,0.07);
    }
    
    .mobile-bottom-nav { 
        display: block;
        position: fixed !important; 
        bottom: 0 !important; 
        left: 0 !important; 
        right: 0 !important; 
        width: 100% !important; 
        height: var(--mobile-nav-height); 
        background-color: var(--card-bg-default, #ffffff); 
        border-top: 1px solid var(--card-border, #e0e0e0); 
        z-index: 1000; 
    }
    
    .mobile-nav-content { display: flex; justify-content: space-around; align-items: center; height: 100%; }
    
    .mobile-nav-item { 
        display: flex; flex-direction: column; align-items: center; justify-content: center; 
        color: var(--text-muted); text-decoration: none; font-size: 10px; flex: 1;
    }
    .mobile-nav-item svg { width: 24px; height: 24px; margin-bottom: 2px; }

    /* --- MOBILE AVATAR SIZE FIX (Strict Enforcement) --- */
    .mobile-nav-item .nav-avatar, 
    .mobile-nav-item .initials-placeholder { 
        width: 38px !important; 
        height: 38px !important; 
        min-width: 38px !important;
        max-width: 38px !important;
        font-size: 0.85em !important; 
        border: 2px solid gold;
    }

    .mobile-nav-item-placeholder {
        width: 70px; 
        flex-shrink: 0;
        display: block;
    }
    
    body.teacher-mobile-view .mobile-bottom-nav.teacher-nav { display: block; }
    body.student-mobile-view .mobile-bottom-nav.student-mobile-nav { display: block; }
    body.teacher-mobile-view .teacher-header-apk-icon { display: none; }

    .mobile-create-menu { 
        position: absolute; left: 50%; bottom: 15px; transform: translateX(-50%); 
        width: 60px; height: 60px; z-index: 1001; 
    }
    .mobile-nav-item-create { 
        width: 60px; height: 60px; border-radius: 50%; 
        background-color: #28a745; color: white; 
        display: flex; align-items: center; justify-content: center; 
        box-shadow: 0 4px 12px rgba(0,0,0,0.2); border: 3px solid white; 
    }
    .mobile-nav-item-create svg { width: 32px; height: 32px; }

    .fan-menu-item {
        position: absolute; bottom: 5px; left: 5px;
        width: 50px; height: 50px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        color: white; z-index: 90;
        opacity: 0; transform: scale(0.5);
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease-out;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        text-decoration: none;
    }
    .fan-menu-item svg { width: 24px; height: 24px; }
    .fan-item-1 { background-color: #007bff; }
    .fan-item-2 { background-color: #fd7e14; }
    .fan-item-3 { background-color: #28a745; }

    .mobile-create-menu.active .mobile-nav-item-create { background-color: #dc3545; transform: rotate(135deg); }
    .mobile-create-menu.active .fan-menu-item { opacity: 1; }
    .mobile-create-menu.active .fan-item-1 { transform: translate(-55px, -55px) scale(1); }
    .mobile-create-menu.active .fan-item-2 { transform: translate(0px, -80px) scale(1); }
    .mobile-create-menu.active .fan-item-3 { transform: translate(55px, -55px) scale(1); }

    .mobile-dropdown { position: relative; }
    .mobile-dropdown .dropdown-menu { 
        display: none; position: absolute; bottom: calc(100% + 10px); right: 0;
        top: auto; transform: none; left: auto; min-width: 280px;
        background-color: var(--card-bg-default, white); 
        box-shadow: 0 -4px 16px rgba(0,0,0,0.15); 
        z-index: 1001; border-radius: 8px; border: 1px solid var(--card-border, #eee);
        padding-bottom: 5px;
    }
    .dropdown-menu a { font-size: 1.15rem; padding: 12px 16px; }
    .mobile-dropdown.active .dropdown-menu { display: block; }
}

/* --- 10. MISC --- */
#mobile-tooltip {
    position: fixed; background: rgba(0,0,0,0.9); color: white;
    padding: 8px 12px; border-radius: 6px; font-size: 0.85rem;
    z-index: 10000; pointer-events: none; max-width: 200px;
    text-align: center; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.close-modal { color: var(--text-muted, #aaa); position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; cursor: pointer; display: none; }

#apk-modal .modal-content h2 { margin-top: 0; }
.modal-download-btn { 
    display: block; width: 100%; background-color: #28a745; color: white; 
    padding: 12px 20px; border: none; border-radius: 8px; cursor: pointer; 
    font-size: 16px; font-weight: 500; text-align: center; text-decoration: none; margin-top: 20px; 
}