/* NAVBAR NEW STYLE */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    /* Fallback */
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

/* Helper to center the inner content of navbar */
.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Left & Right areas */
.header-left,
.header-right {
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Center Navigation */
.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.nav-links {
    display: flex;
    gap: 2rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-text-main);
    position: relative;
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.nav-links a:hover,
.nav-links a.active {
    opacity: 1;
    color: var(--color-primary);
}

/* Underline for active/hover */
.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--color-primary);
    transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* Theme Toggle Button */
#theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-main);
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#theme-toggle:hover {
    background: rgba(128, 128, 128, 0.1);
}

/* Theme Icon Logic & Animation */
.sun-icon,
.moon-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Perfectly centered */
    transition: all 0.4s ease;
    /* Simpler, smoother transition */
}

/* Default State (Light Mode) */
/* Sun is VISIBLE */
[data-theme="light"] .sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
}

[data-theme="light"] .moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

/* Dark Mode State */
/* Moon is VISIBLE */
[data-theme="dark"] .sun-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

[data-theme="dark"] .moon-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}

/* Back Arrow Button */
.back-arrow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--color-text-main);
    transition: all 0.3s ease;
    backdrop-filter: var(--glass-blur);
    text-decoration: none;
}

.back-arrow-btn:hover {
    transform: translateX(-5px);
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    padding: 0;
}

.bar {
    width: 100%;
    height: 2px;
    background-color: var(--color-text-main);
    border-radius: 2px;
    transition: 0.3s;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
        z-index: 1002;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background: var(--color-bg);
        padding: 5rem 2rem;
        transition: right 0.3s ease-in-out;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 1001;
        backdrop-filter: none;
        /* Solid background for mobile menu legibility */
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-links {
        flex-direction: column;
        gap: 2rem;
        align-items: flex-start;
    }

    .nav-links a {
        font-size: 1.5rem;
    }

    /* Mobile Header Layout */
    .header-center {
        justify-content: flex-end;
        flex: unset;
        margin-right: 1rem;
    }
}

/* Logo / Avatar Area */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    /* Prevent clicks when hidden */
}

.nav-logo.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--glass-border);
}

.nav-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-main);
    display: none;
}

@media (min-width: 768px) {
    .nav-name {
        display: block;
    }

    /* Absolute centering for desktop to ignore left/right width differences */
    .header-container {
        position: relative;
    }

    .header-center {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
    }
}