/* =========================================================
   Header / Navigation - Clean, Proportional & No-Overlap
   ========================================================= */
.scroll-progress {
    position: fixed; left: 0; top: 0; z-index: 200; height: 3px; width: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6, var(--coral));
    transform: scaleX(0); transform-origin: left; pointer-events: none;
}

.site-header {
    position: sticky; top: 0; z-index: 100; width: 100%;
    border-bottom: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: box-shadow .25s, height .25s;
}
.top-bar {
    background: #0f172a;
    color: #94a3b8;
    font-size: 12.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.top-bar-inner {
    width: 100%; max-width: 1400px; margin: 0 auto; padding: 7px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.tb-left, .tb-right {
    display: flex; align-items: center; gap: 18px;
}
.tb-left span, .tb-right a {
    color: #cbd5e1; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 500;
}
.tb-right a:hover { color: #fff; }
.tb-left i, .tb-right i { color: #818cf8; font-size: 14px; }
.site-header.scrolled .top-bar {
    display: none;
}
@media (max-width: 768px) {
    .tb-left { display: none; }
    .top-bar-inner { justify-content: center; }
}
.site-header.scrolled {
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}
.header-inner {
    width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 20px; height: 70px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    transition: height .25s ease;
}
.scrolled .header-inner { height: 60px; }

/* ---------- Logo ---------- */
.logo { flex-shrink: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo img { height: 44px; width: auto; transition: height .25s ease, transform .25s; display: block; }
.scrolled .logo img { height: 38px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text strong { font: 700 15px/1.2 var(--font-head); color: var(--navy); letter-spacing: -.01em; white-space: nowrap; }
.logo-text small { margin-top: 2px; font: 600 10px/1.2 var(--font-ui); letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.logo:hover img { transform: scale(1.03); }

/* ---------- Desktop nav ---------- */
.main-nav { display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; padding: 0 10px; }
.mnav-head, .mnav-foot { display: none; }
.nav-list { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; flex-wrap: nowrap; }
.nav-list > li { position: relative; }
.nav-link {
    position: relative; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
    padding: 7px 10px; border-radius: 6px; text-decoration: none;
    font: 600 13px/1 var(--font-ui); letter-spacing: .2px; color: var(--navy);
    transition: color .2s, background .2s;
}
.nav-link::after {
    content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px;
    background: var(--primary); transform: scaleX(0); transform-origin: right;
    transition: transform .2s ease;
}
.nav-link:hover, .nav-link.active, .has-drop:hover > .nav-link { color: var(--primary); background: #f8fafc; }
.nav-link:hover::after, .nav-link.active::after, .has-drop:hover > .nav-link::after { transform: scaleX(1); transform-origin: left; }
.nav-link i { font-size: 13px; transition: transform .2s; }
.has-drop:hover > .nav-link i { transform: rotate(180deg); }

/* Dropdown */
.dropdown {
    position: absolute; top: calc(100% + 8px); left: 0; min-width: 220px; padding: 6px;
    background: #fff; border-radius: 8px; border: 1px solid #e2e8f0;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: none; transform-origin: top left; list-style: none; margin: 0; z-index: 150;
}
.dropdown::before { content: ''; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.dropdown::after {
    content: ''; position: absolute; top: -5px; left: 20px; width: 8px; height: 8px; background: #fff;
    border-left: 1px solid #e2e8f0; border-top: 1px solid #e2e8f0; transform: rotate(45deg);
}
.has-drop:hover .dropdown, .has-drop:focus-within .dropdown { display: block; animation: ddIn .2s ease both; }
@keyframes ddIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.dropdown a {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px;
    font: 500 13px/1.3 var(--font-ui); color: var(--navy); text-decoration: none;
    transition: background .15s, color .15s, padding .15s;
}
.dd-ic {
    width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px; display: grid; place-items: center;
    background: #eef2ff; color: var(--primary); font-size: 14px; transition: background .15s, color .15s;
}
.dropdown a:hover { background: #f1f5f9; color: var(--primary); padding-left: 12px; }
.dropdown a:hover .dd-ic { background: var(--primary); color: #fff; }
.dropdown a.current { background: #eef2ff; color: var(--primary); font-weight: 600; }

/* ---------- Actions ---------- */
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-link {
    white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
    font: 600 13px/1 var(--font-ui); letter-spacing: .2px; text-transform: uppercase;
    color: var(--navy); text-decoration: none; padding: 8px 10px; border-radius: 6px;
    transition: color .2s, background .2s;
}
.admin-link:hover { color: var(--primary); background: #f8fafc; }
.btn-study {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; padding: 0 16px; font-size: 13px; font-weight: 600; border-radius: 6px;
    white-space: nowrap; background: var(--primary); color: #fff; text-decoration: none;
    border: 0; cursor: pointer; transition: background .2s, transform .15s;
}
.btn-study:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }

/* ---------- Mobile Toggle ---------- */
.nav-toggle {
    display: none; position: relative; width: 38px; height: 38px; border: 0; border-radius: 6px;
    background: #eef2ff; cursor: pointer; padding: 0;
}
.nav-toggle span {
    position: absolute; left: 9px; width: 20px; height: 2px; border-radius: 2px; background: var(--navy);
    transition: transform .25s, opacity .2s, top .25s;
}
.nav-toggle span:nth-child(1) { top: 12px; }
.nav-toggle span:nth-child(2) { top: 18px; width: 14px; }
.nav-toggle span:nth-child(3) { top: 24px; }
.nav-toggle:hover span:nth-child(2) { width: 20px; }

.nav-overlay {
    position: fixed; inset: 0; z-index: 110; background: rgba(15, 23, 42, 0.45);
    opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}

/* ---------- Breakpoints ---------- */
@media (max-width: 1280px) {
    .nav-link { padding: 6px 7px; font-size: 12.5px; }
    .logo-text strong { font-size: 14px; }
    .logo-text small { font-size: 9.5px; }
}

@media (max-width: 1160px) {
    .logo-text { display: none; }
    .nav-link { padding: 6px 6px; font-size: 12px; }
}

/* Off-canvas mobile menu for tablets & phones */
@media (max-width: 1040px) {
    .header-inner { height: 64px; }
    .logo img, .scrolled .logo img { height: 40px; }
    .scrolled .header-inner { height: 56px; }
    .header-actions { margin-left: auto; }
    .nav-toggle { display: block; }
    .logo-text { display: flex; }

    .main-nav {
        position: fixed; top: 0; right: 0; z-index: 120; margin: 0;
        width: min(320px, 85vw); height: 100vh; height: 100dvh; overflow-y: auto;
        display: flex; flex-direction: column; background: #fff; padding: 0 18px 24px;
        box-shadow: -15px 0 40px rgba(15, 23, 42, 0.15);
        transform: translateX(105%); transition: transform .35s ease;
    }
    .mnav-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 14px 0; border-bottom: 1px solid #f1f5f9; margin-bottom: 6px;
    }
    .mnav-head img { height: 38px; width: auto; }
    .mnav-close {
        width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1f5f9; color: var(--navy);
        font-size: 18px; cursor: pointer; display: grid; place-items: center;
    }
    .mnav-close:hover { background: var(--primary); color: #fff; }

    .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
    .nav-list > li { border-bottom: 1px solid #f1f5f9; }
    .nav-link { display: flex; justify-content: space-between; width: 100%; padding: 12px 4px; font-size: 14px; }
    .nav-link::after { display: none; }
    .has-drop:hover > .nav-link i { transform: none; }
    .has-drop.open > .nav-link { color: var(--primary); }
    .has-drop.open > .nav-link i { transform: rotate(180deg); }

    .dropdown, .has-drop:hover .dropdown, .has-drop:focus-within .dropdown {
        display: block; animation: none;
        position: static; min-width: 0; padding: 0 0 0 4px; border: 0; border-radius: 0; box-shadow: none;
        opacity: 1; visibility: visible; transform: none;
        max-height: 0; overflow: hidden; transition: max-height .3s ease;
    }
    .dropdown::before, .dropdown::after { display: none; }
    .has-drop.open .dropdown { max-height: 280px; padding-bottom: 8px; }

    .mnav-foot { display: grid; gap: 10px; margin-top: auto; padding-top: 20px; }
    .mnav-foot .btn { height: 42px; width: 100%; font-size: 14px; border-radius: 6px; }

    body.nav-open { overflow: hidden; }
    body.nav-open .site-header { z-index: 130; }
    body.nav-open .main-nav { transform: none; }
    body.nav-open .nav-overlay { opacity: 1; visibility: visible; }
    body.nav-open .nav-toggle span:nth-child(1) { top: 18px; transform: rotate(45deg); }
    body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
    body.nav-open .nav-toggle span:nth-child(3) { top: 18px; transform: rotate(-45deg); }
}

@media (max-width: 640px) {
    .header-inner { height: 58px; }
    .logo img, .scrolled .logo img { height: 36px; }
    .scrolled .header-inner { height: 52px; }
    .logo-text strong { font-size: 13.5px; }
    .logo-text small { font-size: 9px; }
    .admin-link { display: none; }
    .btn-study { height: 34px; padding: 0 12px; font-size: 12.5px; }
}
