/* ============================================================
   TRAKANALYTICA DATA LAB — HEADER STYLES
   Scope: topbar + navbar (loaded globally via header.php)
   ============================================================ */

/* ===== TOPBAR ===== */
.topbar {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    border-bottom: none;
    padding: 9px 0;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.85);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar-inner span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.topbar a {
    color: #e9d5ff;
    font-weight: 600;
}
.topbar a:hover { color: #ffffff; }

/* ===== NAVBAR ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    transition: var(--transition);
}
.navbar.scrolled {
    background: rgba(255, 255, 255, 0.98);
    border-bottom-color: var(--border-medium);
    box-shadow: 0 4px 24px rgba(109,40,217,0.08);
}
.nav-container {
    display: flex;
    align-items: center;
    gap: 32px;
    padding-top: 20px;
    padding-bottom: 20px;
}
.nav-logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
    margin-left: 0;
}
.nav-item > a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 9px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}
.nav-item > a:hover,
.nav-item.active > a {
    color: var(--text-primary);
    background: var(--accent-glow-soft);
}
.nav-item.active > a { color: var(--accent-secondary); }

/* Dropdown */
.nav-item.has-dropdown { position: relative; }
/* Invisible bridge fills the gap so mouse doesn't leave the hover zone */
.nav-item.has-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 16px;
    background: transparent;
}
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    width: 340px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 8px;
    padding-top: 12px;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    z-index: 100;
}
.nav-item.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.dropdown-item:hover { background: var(--accent-glow-soft); }
.dropdown-item strong { display: block; font-size: 0.88rem; color: var(--text-primary); margin-bottom: 2px; }
.dropdown-item span { font-size: 0.78rem; color: var(--text-muted); }
.dropdown-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dropdown-icon.health { background: var(--health-glow); color: var(--health); }
.dropdown-icon.economic { background: var(--economic-glow); color: var(--economic); }
.dropdown-icon.survey { background: var(--survey-glow); color: var(--survey); }
.dropdown-icon.training { background: var(--training-glow); color: var(--training); }
.dropdown-icon.all { background: linear-gradient(135deg,#ede9fe,#ddd6fe); color: #6d28d9; }
.dropdown-item-all strong { color: #6d28d9 !important; }
.dropdown-item-all:hover { background: rgba(109,40,217,.06); }
.dropdown-divider { height: 1px; background: var(--border-subtle, #f0f0f0); margin: 4px 2px; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 12px;
}
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 22px; height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== RESPONSIVE — HEADER ===== */
@media (max-width: 768px) {
    .topbar-inner span:first-child { display: none; }

    .nav-menu {
        position: fixed;
        top: 0; right: -100%;
        width: 80%; max-width: 360px;
        height: 100vh;
        background: white;
        border-left: 1px solid var(--border-medium);
        flex-direction: column;
        align-items: flex-start;
        padding: 80px 24px 40px;
        gap: 4px;
        transition: var(--transition-slow);
        z-index: 999;
        overflow-y: auto;
        box-shadow: -8px 0 40px rgba(0,0,0,0.1);
    }
    .nav-menu.open { right: 0; }
    .nav-item { width: 100%; }
    .nav-item > a { width: 100%; justify-content: space-between; }
    .dropdown-menu {
        position: static;
        transform: none;
        width: 100%;
        opacity: 1;
        pointer-events: auto;
        box-shadow: none;
        border: none;
        background: var(--accent-glow-soft);
        border-radius: var(--radius-sm);
        margin-top: 4px;
        display: none;
    }
    .nav-item.has-dropdown.dropdown-open .dropdown-menu { display: block; }

    .hamburger { display: flex !important; }
    .nav-container { padding-top: 14px; padding-bottom: 14px; gap: 16px; }
    .nav-logo img { height: 32px; }

    /* Keep auth buttons visible on mobile — only shrink them */
    .nav-actions {
        display: flex;
        gap: 8px;
        margin-left: 0;
    }
    /* Hide the logged-in user dropdown pill on very small screens; user can open hamburger */
    .nav-user-menu { display: none; }
    /* But always show Sign In / Register for logged-out users */
    .nav-actions .btn-sm {
        padding: 6px 12px;
        font-size: 12.5px;
    }
}

@media (max-width: 480px) {
    .topbar { display: none; }
}