/* ========================================
   Unified Sub-page Navigation — site-nav
   ======================================== */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    font-family: 'Tajawal', sans-serif;
}

.site-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 16px;
}

/* Brand */
.site-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    transition: color 0.3s;
}

.site-nav-brand i {
    color: #6366f1;
    font-size: 1.1rem;
}

.site-nav-brand:hover {
    color: #6366f1;
}

/* Hamburger Toggle */
.site-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    margin-right: auto;
    border-radius: 8px;
    transition: background 0.3s;
}

.site-nav-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
}

.site-nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #e2e8f0;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.site-nav-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.site-nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.site-nav-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Menu Container — Desktop: horizontal */
.site-nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.site-nav-menu::-webkit-scrollbar {
    display: none;
}

/* Nav Groups */
.site-nav-group {
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
    padding-left: 12px;
    margin-left: 8px;
}

.site-nav-group:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 24px;
    background: rgba(99, 102, 241, 0.2);
}

.site-nav-group:first-child {
    padding-left: 0;
    margin-left: 0;
}

.site-nav-group:first-child::before {
    display: none;
}

.site-nav-group-label {
    display: none; /* Hidden on desktop, shown in mobile drawer */
}

/* Navigation Links */
.site-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.site-nav-link:hover {
    color: #e2e8f0;
    background: rgba(99, 102, 241, 0.1);
}

.site-nav-link.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.12);
    font-weight: 700;
}

.site-nav-link i {
    font-size: 0.78rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== Responsive — Tablet ===== */
@media (max-width: 1100px) {
    .site-nav-link span {
        display: none;
    }

    .site-nav-link {
        padding: 8px 10px;
        font-size: 0;
    }

    .site-nav-link i {
        font-size: 1rem;
    }

    .site-nav-link:hover::after,
    .site-nav-link.active::after {
        content: attr(data-tooltip);
    }
}

/* ===== Responsive — Mobile ===== */
@media (max-width: 768px) {
    .site-nav-inner {
        height: 56px;
    }

    .site-nav-toggle {
        display: flex;
    }

    .site-nav-menu {
        position: fixed;
        top: 56px;
        right: -300px;
        width: 280px;
        height: calc(100vh - 56px);
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: stretch;
        padding: 16px 12px;
        gap: 8px;
        overflow-y: auto;
        transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        border-left: 1px solid rgba(99, 102, 241, 0.15);
    }

    .site-nav-menu.open {
        right: 0;
    }

    /* Show group labels in mobile */
    .site-nav-group-label {
        display: flex;
        align-items: center;
        gap: 8px;
        color: #6366f1;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 8px 12px 4px;
    }

    .site-nav-group {
        flex-direction: column;
        align-items: stretch;
        padding-left: 0;
        margin-left: 0;
        gap: 2px;
    }

    .site-nav-group:not(:last-child)::before {
        display: none;
    }

    .site-nav-group:not(:last-child) {
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(99, 102, 241, 0.08);
    }

    .site-nav-link {
        padding: 10px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .site-nav-link span {
        display: inline;
    }

    .site-nav-link i {
        font-size: 0.9rem;
        width: 20px;
    }
}

/* ===== Light Theme ===== */
body.light-theme .site-nav {
    background: rgba(248, 250, 252, 0.92);
    border-bottom-color: rgba(99, 102, 241, 0.12);
}

body.light-theme .site-nav-brand {
    color: #1e293b;
}

body.light-theme .site-nav-toggle span {
    background: #1e293b;
}

body.light-theme .site-nav-link {
    color: #64748b;
}

body.light-theme .site-nav-link:hover {
    color: #1e293b;
    background: rgba(99, 102, 241, 0.08);
}

body.light-theme .site-nav-link.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

@media (max-width: 768px) {
    body.light-theme .site-nav-menu {
        background: rgba(248, 250, 252, 0.98);
        border-left-color: rgba(99, 102, 241, 0.12);
    }
}

/* ===== Ensure body padding for fixed nav ===== */
body:has(.site-nav) .tool-page,
body:has(.site-nav) .unit-page {
    padding-top: 80px;
}

/* Fallback for browsers that don't support :has() */
.has-site-nav .tool-page,
.has-site-nav .unit-page {
    padding-top: 80px;
}
