/* ============================================================
   Student Navigation — Professional Dark Theme
   ============================================================ */

/* --- Design tokens --- */
:root {
    --nav-height: 64px;
    --nav-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --nav-surface: rgba(255, 255, 255, 0.07);
    --nav-surface-hover: rgba(255, 255, 255, 0.12);
    --nav-surface-active: rgba(255, 255, 255, 0.18);
    --nav-text: #e2e8f0;
    --nav-text-muted: #94a3b8;
    --nav-accent: #818cf8;
    --nav-accent-glow: rgba(129, 140, 248, 0.25);
    --nav-border: rgba(255, 255, 255, 0.08);
    --nav-radius: 10px;
    --nav-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --nav-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Top navbar ---- */
.top-navbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--nav-height);
    padding: 0 1rem;
    background: var(--nav-bg);
    color: var(--nav-text);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 14px -4px rgba(0, 0, 0, 0.3);
    font-family: var(--nav-font);
}

.top-navbar a {
    text-decoration: none;
    color: inherit;
}

/* ---- Brand ---- */
.brand-wrapper {
    display: flex;
    align-items: center;
    height: var(--nav-height);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-icon {
    line-height: 1;
}

.logo-icon img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand-name {
    letter-spacing: 0.4px;
    color: #fff;
}

.brand-tagline {
    font-size: 0.6rem;
    font-weight: 500;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 3px;
}

/* ---- Desktop nav links ---- */
.nav-links-desktop {
    display: none;
}

.menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--nav-radius);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    color: var(--nav-text-muted);
    background: transparent;
    transition: background var(--nav-transition), color var(--nav-transition);
    position: relative;
}

.nav-item:hover {
    background: var(--nav-surface-hover);
    color: #fff;
}

.nav-item.active,
.nav-item:global(.active) {
    background: var(--nav-surface-active);
    color: #fff;
}

.nav-item:global(.active)::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--nav-accent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
    opacity: 0.85;
    filter: invert(1) brightness(2);
}

/* Icon-font counterpart to .nav-icon, for nav items drawn with a Bootstrap glyph
   instead of a PNG. It inherits the item's colour, so it must NOT take .nav-icon's
   invert filter — that would flip a white glyph to black. */
.nav-glyph {
    font-size: 1.05rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item .nav-badge {
    background: var(--nav-surface);
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 0.65rem;
    margin-left: 4px;
}

.nav-item .nav-badge.new {
    background: #f59e0b;
    color: #111;
}

/* ---- Desktop right actions ---- */
.actions-desktop {
    margin-left: auto;
    display: none;
    align-items: center;
    gap: 0.75rem;
}

/* Mobile header subscription badge — right of brand, hidden on desktop */
.mobile-header-sub-badge {
    display: none;
    margin-left: auto;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.18);
    transition: background 0.18s, box-shadow 0.18s;
    font-size: 0.78rem;
    font-weight: 600;
    color: #4338ca;
    white-space: nowrap;
    line-height: 1.2;
}

.mobile-header-sub-badge:hover,
.mobile-header-sub-badge:active {
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* Trial: red pill */
.mobile-header-sub-badge .text-danger {
    color: #dc2626 !important;
    font-size: 0.75rem;
}

/* Premium: green pill */
.mobile-header-sub-badge .text-success {
    color: #059669 !important;
    font-size: 0.75rem;
}

.mobile-header-sub-badge .bi {
    font-size: 0.9rem;
}

@media (max-width: 859.98px) {
    .mobile-header-sub-badge {
        display: flex;
    }
}

@media (min-width: 860px) {
    .mobile-header-sub-badge {
        display: none !important;
    }
}

.auth-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-inline .nav-item {
    background: var(--nav-surface);
}

.auth-inline .nav-item:hover {
    background: var(--nav-surface-hover);
}

/* ---- User profile dropdown (desktop) ---- */
.user-profile {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--nav-surface);
    border: 1px solid var(--nav-border);
    color: var(--nav-text);
    border-radius: 40px;
    padding: 0.35rem 0.85rem 0.35rem 0.4rem;
    cursor: pointer;
    font: inherit;
    transition: background var(--nav-transition);
}

.user-btn:hover {
    background: var(--nav-surface-hover);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.avatar.large {
    width: 48px;
    height: 48px;
    font-size: 1rem;
    margin-right: 0.75rem;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.user-meta .name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
}

.user-meta .status {
    font-size: 0.55rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-top: 3px;
}

.caret {
    font-size: 0.55rem;
    margin-left: 0.15rem;
    opacity: 0.5;
}

/* Dropdown panel */
.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.65rem);
    width: 250px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 0.85rem 0.75rem 0.9rem;
    box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-dropdown.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ud-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.65rem;
}

.ud-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
}

.ud-status {
    font-size: 0.6rem;
    opacity: 0.55;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 3px;
}

.ud-section {
    margin-top: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ud-section:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.ud-section.danger {
    border-top: 1px solid rgba(239, 68, 68, 0.2);
}

.ud-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #cbd5e1;
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background var(--nav-transition), color var(--nav-transition);
}

.ud-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.ud-item.logout-btn {
    color: #fca5a5;
}

.ud-item.logout-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
}

.ud-item.lang {
    padding: 0;
}

.logout-form {
    margin: 0;
}

/* ============================================================
   Responsive — Desktop / Mobile
   ============================================================ */

@media (min-width: 860px) {
    .hamburger,
    .mobile-panel,
    .overlay {
        display: none;
    }

    .nav-links-desktop {
        display: flex;
        margin-left: 1.5rem;
    }

    .actions-desktop {
        display: flex;
    }

    .top-navbar {
        padding: 0 1.5rem;
    }

    .menu-list {
        gap: 0.2rem;
    }
}

@media (max-width: 859.98px) {
    .top-navbar {
        height: var(--nav-height);
    }

    .brand-wrapper {
        flex: 1;
    }

    .nav-links-desktop,
    .actions-desktop {
        display: none !important;
    }
}

/* ============================================================
   Mobile Bottom Navigation
   ============================================================ */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px -2px rgba(0, 0, 0, 0.08);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
    gap: 2px;
}

@media (max-width: 859.98px) {
    .mobile-bottom-nav {
        display: flex;
    }

    .hamburger {
        display: none !important;
    }

    .mobile-panel,
    .overlay {
        display: none !important;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #9ca3af;
    transition: color var(--nav-transition), background var(--nav-transition);
    position: relative;
    min-width: 60px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.mobile-nav-item:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.mobile-nav-item.active,
.mobile-nav-item:global(.active) {
    color: #6366f1;
}

.mobile-nav-item.active::before,
.mobile-nav-item:global(.active)::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: #6366f1;
    border-radius: 0 0 3px 3px;
}

.mobile-nav-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    line-height: 1;
    transition: transform var(--nav-transition);
}

.mobile-nav-item.active .mobile-nav-icon,
.mobile-nav-item:global(.active) .mobile-nav-icon {
    transform: scale(1.08);
}

.mobile-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: inherit;
}

/* Six items (Dashboard, Lessons, Grammar, Library, Vocabulary, Profile) no longer fit
   at the default 60px minimum on the narrowest phones — let them shrink there rather
   than overflow the bar. */
@media (max-width: 400px) {
    .mobile-nav-item {
        min-width: 0;
        flex: 1 1 0;
        padding: 6px 4px;
    }

    .mobile-nav-label {
        font-size: 0.6rem;
    }
}

/* Subscription badge in mobile bottom nav */
.mobile-sub-item {
    min-width: 52px;
}

.mobile-sub-badge-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

/* Hide the bi icons from SubscriptionStatusBadge in mobile nav — show only text */
.mobile-sub-badge-icon .bi {
    font-size: 1.1rem;
    display: block;
}

/* Trial state */
.mobile-sub-badge-icon .text-danger {
    font-size: 0.58rem;
    font-weight: 700;
    white-space: nowrap;
    color: #ef4444 !important;
}

/* Premium state */
.mobile-sub-badge-icon .text-success {
    font-size: 0.62rem;
    font-weight: 700;
    color: #10b981 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Avatar in mobile bottom nav */
.avatar-icon {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 50%;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow var(--nav-transition);
}

.mobile-nav-item.active .avatar-icon {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #6366f1;
}

/* ============================================================
   Mobile Profile Panel (Bottom Sheet)
   ============================================================ */

.mobile-profile-panel {
    display: none;
}

@media (max-width: 859.98px) {
    .mobile-profile-panel {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        pointer-events: none;
    }

    .mobile-profile-panel.open {
        pointer-events: auto;
    }
}

.mobile-profile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: all 0.3s ease;
}

.mobile-profile-panel.open .mobile-profile-backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.mobile-profile-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 30px -5px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 80vh;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.mobile-profile-panel.open .mobile-profile-content {
    transform: translateY(0);
}

.profile-handle {
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 10px auto 6px;
}

.mobile-profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
}

.mobile-profile-header .avatar {
    width: 52px;
    height: 52px;
    font-size: 1.15rem;
    box-shadow: 0 2px 8px -2px rgba(99, 102, 241, 0.35);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-status {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.3;
}

.profile-sub-status {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.profile-sub-status .text-danger {
    color: #ef4444 !important;
    font-size: 0.78rem;
    font-weight: 600;
}

.profile-sub-status .text-success {
    color: #10b981 !important;
    font-size: 0.78rem;
    font-weight: 600;
}

.profile-sub-status .bi {
    font-size: 0.85rem;
}

.close-profile-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    color: #6b7280;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--nav-transition);
}

.close-profile-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.mobile-profile-body {
    padding: 6px 0;
    overflow-y: auto;
    max-height: calc(80vh - 110px);
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: #374151;
    text-decoration: none;
    transition: background var(--nav-transition);
    font-weight: 500;
    font-size: 0.95rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.profile-menu-item:hover {
    background: #f9fafb;
    color: #111827;
}

.profile-menu-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-menu-item.logout-btn {
    color: #ef4444;
    margin-top: 4px;
    border-top: 1px solid #f3f4f6;
}

.profile-menu-item.logout-btn:hover {
    background: #fef2f2;
}

.lang-item {
    cursor: default;
}

.lang-item:hover {
    background: transparent;
}

/* ============================================================
   Guest pages (GuestNavMenu / GuestFooter)

   Guests have no fixed bottom bar any more — the header carries the
   language links, Sign in and the call to action — so the space the
   signed-in bottom nav needs is given back on guest pages. Only guest
   pages render .lp-nav.
   ============================================================ */

@media (max-width: 860px) {
    .page:has(.lp-nav) .page-content {
        padding-bottom: 0;
    }
}

/* Keep keyboard focus clear of the sticky header (WCAG 2.4.11) and give
   in-page anchors room under it. Phones: the 56px brand row stays. */
html:has(.lp-nav) {
    scroll-padding-top: 68px;
}

@media (min-width: 768px) {
    html:has(.lp-nav) {
        scroll-padding-top: 84px;
    }
}

/* The landing page's phone header reveals its call to action once the hero
   button has scrolled away. The button (#lp-hero-cta) defines the view
   timeline; naming it on a common ancestor lets the header, a sibling
   subtree, animate on it. See GuestNavMenu.razor.css. */
@supports (animation-timeline: view()) and (timeline-scope: --lp-hero-cta) {
    .page:has(#lp-hero-cta) {
        timeline-scope: --lp-hero-cta;
    }
}

/* ============================================================
   Hamburger (fallback, hidden when bottom nav active)
   ============================================================ */

.hamburger {
    margin-left: auto;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
    z-index: 2001;
}

.hamburger .bar {
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 4px;
    transition: 0.25s;
}

.hamburger[aria-expanded="true"] .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger[aria-expanded="true"] .bar:nth-child(2) {
    opacity: 0;
}

.hamburger[aria-expanded="true"] .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   Overlay
   ============================================================ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 1900;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   Focus States (Accessibility)
   ============================================================ */

.nav-item:focus-visible,
.user-btn:focus-visible,
.mobile-nav-item:focus-visible,
.profile-menu-item:focus-visible {
    outline: 2px solid var(--nav-accent);
    outline-offset: 2px;
}

/* ============================================================
   Safe Area Support (Notched Devices)
   ============================================================ */

@supports (padding: max(0px)) {
    .mobile-bottom-nav {
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    .mobile-profile-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ============================================================
   Tablet — hide bottom nav, show desktop layout
   ============================================================ */

@media (min-width: 860px) {
    .mobile-bottom-nav,
    .mobile-profile-panel {
        display: none !important;
    }
}

/* Six primary links (Dashboard, Lessons, Grammar, Library, Vocabulary, Subscription)
   plus the Admin menu no longer fit a narrow desktop at full size. Tighten the row
   there — and below ~1050px drop the per-item icons, which buys ~27px each and keeps
   the labels readable rather than letting the navbar overflow. Kept at the end of the
   file so it wins over the base .nav-item / .nav-links-desktop rules. */
@media (min-width: 860px) and (max-width: 1150px) {
    .nav-links-desktop {
        margin-left: 0.75rem;
    }

    .nav-item {
        padding: 0.5rem 0.6rem;
        gap: 0.35rem;
    }
}

@media (min-width: 860px) and (max-width: 1050px) {
    .nav-links-desktop .nav-icon,
    .nav-links-desktop .nav-glyph {
        display: none;
    }

    .nav-item {
        padding: 0.5rem 0.5rem;
        font-size: 0.82rem;
    }
}
