/**
 * Header and Navigation Styles
 * Used by: partials/header.html (included in most pages)
 * Uses design system variables from shared_styles.html
 */

/* ================================
   HEADER MAIN CONTAINER
   ================================ */

.header {
    position: relative;
    z-index: 10;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 24px;
    animation: slideDown 0.6s ease-out;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ================================
   BRAND / LOGO SECTION
   ================================ */

.brand {
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand a {
    display: block;
    line-height: 0;
}

.logo {
    height: 48px;
    width: auto;
    filter: brightness(1.1);
    transition: transform 0.3s;
}

.logo:hover {
    transform: scale(1.05);
}

.brand-text h1 {
    color: var(--white);
    font-size: 1.8em;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--white) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-text p {
    color: var(--gray);
    font-size: 0.9em;
    font-weight: 400;
    margin-top: 4px;
}

/* ================================
   NAVIGATION LINKS
   ================================ */

.header-nav {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-link {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    transition: color 0.3s;
    position: relative;
    padding: 8px 0;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s;
}

.nav-link:hover {
    color: var(--white);
}

.nav-link:hover::after {
    width: 100%;
}

.nav-link.active {
    color: var(--white);
}

.nav-link.active::after {
    width: 100%;
}

/* ================================
   CREDIT BALANCE WIDGET
   ================================ */

.credit-balance-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 50px;
    margin-left: 16px;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.credit-balance-widget:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.credit-balance-widget svg {
    color: var(--primary-light);
    flex-shrink: 0;
}

.credit-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.credit-count {
    color: var(--white);
    font-size: 1.1em;
    font-weight: 700;
}

.credit-label {
    color: var(--gray);
    font-size: 0.85em;
    font-weight: 500;
}

.low-credits-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ================================
   USER MENU (Authenticated Users)
   ================================ */

.user-menu {
    position: relative;
    margin-left: 16px;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 8px 16px 8px 8px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--white);
    font-weight: 500;
}

.user-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95em;
    color: white;
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9em;
}

/* ================================
   USER DROPDOWN MENU
   ================================ */

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--dark-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.95em;
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--glass);
    color: var(--primary-light);
}

.dropdown-item svg {
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

/* Admin Link Styling */
.admin-link {
    position: relative;
}

.admin-link:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.admin-badge-small {
    display: inline-block;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}

/* ================================
   AUTH BUTTONS (Anonymous Users)
   ================================ */

.auth-btn {
    padding: 10px 24px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.3s;
    margin-left: 12px;
}

.auth-btn-login {
    color: var(--white);
    background: var(--glass);
    border: 1px solid var(--glass-border);
}

.auth-btn-login:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.auth-btn-register {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.auth-btn-register:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* ================================
   MOBILE MENU TOGGLE (Hamburger)
   ================================ */

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.mobile-menu-toggle:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.mobile-menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Hamburger animation when open */
.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

@media (max-width: 768px) {
    .header {
        padding: 16px;
    }

    .header-content {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .brand {
        flex: 1;
    }

    .brand-text h1 {
        font-size: 1.4em;
    }

    .brand-text p {
        font-size: 0.8em;
    }

    .logo {
        height: 36px;
    }

    /* Show hamburger on mobile */
    .mobile-menu-toggle {
        display: flex;
        order: 1;
    }

    /* Hide nav by default on mobile */
    .header-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 8px;
        padding-top: 16px;
        margin-top: 16px;
        border-top: 1px solid var(--glass-border);
        order: 2;
    }

    /* Show nav when menu is open */
    .header-nav.mobile-open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 12px 16px;
        background: var(--glass);
        border-radius: 8px;
        text-align: center;
    }

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

    .nav-link::after {
        display: none;
    }

    .nav-link.active {
        background: rgba(99, 102, 241, 0.15);
        border: 1px solid var(--primary);
    }

    .credit-balance-widget {
        width: 100%;
        justify-content: center;
        margin: 8px 0 0 0;
    }

    .user-menu {
        width: 100%;
        margin: 8px 0 0 0;
    }

    .user-btn {
        width: 100%;
        justify-content: center;
    }

    .user-dropdown {
        left: 0;
        right: 0;
        width: 100%;
    }

    .auth-btn {
        width: 100%;
        text-align: center;
        margin: 8px 0 0 0;
        display: block;
    }

    .user-name {
        max-width: 120px;
    }
}
