:root {
    --nav-height: 72px;
}

body {
    padding-top: var(--nav-height);
}

nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    width: 100%;
    border-bottom: 1px solid var(--border);
    background-color: rgba(248, 251, 253, 0.9);
    backdrop-filter: blur(10px);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

html.dark nav {
    background-color: rgba(15, 20, 25, 0.8);
}

.nav-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    gap: 16px;
    position: relative;
}

.nav-logo {
    order: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
    text-decoration: none;
    transition: opacity 0.3s;
    line-height: 1;
    margin-left: 0;
    padding-left: 0;
}

.nav-logo span {
    display: block;
    line-height: 1;
}

.nav-logo:hover {
    opacity: 0.8;
}

html.dark .nav-logo,
html.dark .logo-brand {
    color: #7dd3fc;
    text-shadow: 0 0 12px rgba(125, 211, 252, 0.45);
}

.logo-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.nav-right {
    order: 2;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    padding-right: 0;
    flex: 1;
    justify-content: flex-end;
}

.nav-links {
    display: flex;
    gap: 16px;
    font-size: 13px;
    font-weight: 500;
    align-items: center;
}

@media (min-width: 768px) {
    .nav-links {
        gap: 24px;
        font-size: 14px;
    }
}

.nav-links a {
    color: var(--muted-foreground);
    text-decoration: none;
    transition: color 0.3s;
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-toggle {
    display: inline-flex;
    visibility: visible;
    opacity: 1;
    order: 3;
    margin-left: 16px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, #ffffff 0%, #e8f1ff 100%);
    color: var(--primary);
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    z-index: 120;
}

.nav-toggle:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.nav-toggle:active {
    transform: translateY(0);
}

.nav-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

html.dark .nav-toggle {
    background: linear-gradient(135deg, #111729 0%, #1a2847 100%);
    border-color: rgba(96, 165, 250, 0.35);
}

.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    font: inherit;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: color 0.3s, background-color 0.3s;
}

.dropdown-toggle:hover,
.nav-dropdown.open .dropdown-toggle,
.nav-dropdown:focus-within .dropdown-toggle {
    color: var(--primary);
    background: var(--primary-light);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 210px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
    padding: 8px;
    display: grid;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 10;
}

.dropdown-menu a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--foreground);
    font-size: 13px;
}

.dropdown-menu a:hover {
    background: var(--secondary);
    color: var(--foreground);
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-mobile {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    z-index: 90;
}

.nav-mobile-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 20px 28px;
    display: grid;
    gap: 18px;
    background: #ffffff;
}

.nav-group {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 91, 219, 0.06) 0%, rgba(248, 251, 253, 0.95) 100%);
    border: 1px solid rgba(59, 91, 219, 0.12);
}

.nav-group-title {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    font-weight: 700;
    margin-bottom: 4px;
}

.nav-mobile a {
    color: var(--foreground);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.3);
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.nav-mobile a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 91, 219, 0.08);
}

nav.nav-open .nav-mobile {
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

nav.nav-open::after {
    content: "";
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 80;
}

html.dark nav.nav-open::after {
    background: #0f1419;
}

html.dark .nav-group {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.12) 0%, rgba(26, 31, 58, 0.9) 100%);
    border-color: rgba(96, 165, 250, 0.25);
}

html.dark .nav-mobile,
html.dark .nav-mobile-inner {
    background: #0f1419;
}

html.dark .nav-mobile a {
    background: rgba(17, 23, 41, 0.85);
    border-color: rgba(96, 165, 250, 0.2);
}

@media (max-width: 960px) {
    .nav-right {
        display: flex;
    }

    .nav-links {
        display: none !important;
    }

    .nav-toggle {
        display: inline-flex !important;
    }

    .dropdown-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        border: none;
        padding: 0;
        background: transparent;
    }
}

@media (min-width: 961px) {
    .nav-toggle {
        display: none;
    }
}

@media (max-width: 767px) {
    :root {
        --nav-height: 64px;
    }

    .nav-content {
        padding: 0 1rem;
    }

    .logo-img {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    :root {
        --nav-height: 60px;
    }

    .nav-content {
        padding: 0 0.75rem;
    }

    .logo-img {
        width: 26px;
        height: 26px;
    }
}
