/* ===================================================================
   UNIFIED HEADER DESIGN - InfiniteGridDashboard
   Professional dark theme header with SVG logo
   =================================================================== */

/* CSS Variables for Header */
:root {
    --hdr-bg: rgba(20, 25, 35, 0.95);
    --hdr-border: #23293A;
    --hdr-text: #E7ECF5;
    --hdr-muted: #A7B0C1;
    --hdr-accent: #3B82F6;
    --hdr-accent-hover: #60A5FA;
    --hdr-focus: #93C5FD;
    --hdr-height: 64px;
    --hdr-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Main Header Container */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--hdr-bg);
    border-bottom: 1px solid var(--hdr-border);
    box-shadow: var(--hdr-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background 0.3s ease;
    /* Prevent animation conflicts on auth pages */
    opacity: 1;
    animation: none;
}

.header-container {
    max-width: 100%;
    padding: 0 1.5rem;
    height: var(--hdr-height);
    display: grid;
    grid-template-columns: minmax(250px, 1fr) auto minmax(250px, 1fr);
    align-items: center;
    gap: 1.5rem;
}

/* ===================================================================
   LEFT SECTION: Logo + Workspace
   =================================================================== */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    grid-column: 1;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--hdr-text);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem;
    border-radius: 8px;
}

.header-brand:hover {
    color: #FFFFFF;
    background: rgba(59, 130, 246, 0.1);
}

.header-brand:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.header-logo {
    color: var(--hdr-accent);
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.header-brand:hover .header-logo {
    transform: scale(1.05);
    color: var(--hdr-accent-hover);
}

.header-wordmark {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    white-space: nowrap;
}

/* ===================================================================
   CENTER SECTION: Navigation
   =================================================================== */
.header-nav {
    grid-column: 2;
    justify-self: center;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link-item {
    position: relative;
    display: inline-block;
    padding: 0.5rem 1rem;
    color: var(--hdr-text);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--hdr-accent);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link-item:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
}

.nav-link-item:hover::after {
    width: 80%;
}

.nav-link-item:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.nav-link-item.active {
    color: var(--hdr-accent);
    background: rgba(59, 130, 246, 0.1);
}

.nav-link-item.active::after {
    width: 80%;
}

/* ===================================================================
   RIGHT SECTION: User Info & Auth
   =================================================================== */
.header-right {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Logged-in User Section */
.header-user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--hdr-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-user-link:hover {
    color: var(--hdr-text);
    background: rgba(255, 255, 255, 0.05);
}

.header-user-link:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.user-icon {
    color: var(--hdr-accent);
    flex-shrink: 0;
}

.user-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-form {
    margin: 0;
}

.header-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    padding: 0 1rem;
    background: transparent;
    border: 1px solid #2F3447;
    border-radius: 6px;
    color: var(--hdr-text);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-logout-btn:hover {
    border-color: var(--hdr-accent);
    color: var(--hdr-accent);
    background: rgba(59, 130, 246, 0.1);
}

.header-logout-btn:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.header-logout-btn:active {
    transform: scale(0.98);
}

/* Logged-out Auth Section */
.header-auth-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-auth-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    color: var(--hdr-text);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-auth-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
}

.header-auth-link:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.header-auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 1.25rem;
    background: var(--hdr-accent);
    border: 1px solid var(--hdr-accent);
    border-radius: 6px;
    color: #FFFFFF;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-auth-btn:hover {
    background: var(--hdr-accent-hover);
    border-color: var(--hdr-accent-hover);
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.header-auth-btn:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

.header-auth-btn:active {
    transform: translateY(0);
}

/* ===================================================================
   MOBILE HAMBURGER TOGGLE
   =================================================================== */
.header-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--hdr-border);
    border-radius: 6px;
    color: var(--hdr-text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--hdr-accent);
    color: var(--hdr-accent);
}

.header-mobile-toggle:focus {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

/* ===================================================================
   RESPONSIVE DESIGN
   =================================================================== */

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
    .header-container {
        grid-template-columns: 1fr auto;
        gap: 1rem;
    }

    .header-nav {
        display: none;
        grid-column: 1 / -1;
        justify-self: stretch;
        margin-top: 0.5rem;
    }

    .header-nav.show {
        display: block;
    }

    .nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        padding: 0.5rem 0;
    }

    .nav-link-item {
        padding: 0.75rem 1rem;
    }

    .header-mobile-toggle {
        display: flex;
        grid-column: 2;
    }

    .header-right {
        grid-column: 1 / -1;
        justify-self: stretch;
        border-top: 1px solid var(--hdr-border);
        padding-top: 1rem;
        margin-top: 1rem;
    }

    .header-wordmark {
        display: none;
    }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
    .header-container {
        padding: 0 1rem;
        height: auto;
        min-height: var(--hdr-height);
        grid-template-columns: 1fr auto;
    }

    .header-left {
        gap: 0.5rem;
    }

    .header-user-section {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }

    .header-auth-section {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }

    .header-user-link,
    .header-auth-link,
    .header-auth-btn {
        width: 100%;
        justify-content: center;
    }

    .user-name {
        max-width: none;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .header-container {
        padding: 0 0.75rem;
    }

    .header-logo {
        width: 24px;
        height: 24px;
    }
}

/* ===================================================================
   ACCESSIBILITY ENHANCEMENTS
   =================================================================== */

/* Keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--hdr-focus);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .header-brand,
    .header-logo,
    .nav-link-item,
    .header-user-link,
    .header-logout-btn,
    .header-auth-link,
    .header-auth-btn,
    .header-mobile-toggle {
        transition: none;
    }

    .nav-link-item::after {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .app-header {
        border-bottom: 2px solid var(--hdr-text);
    }

    .header-logout-btn,
    .header-auth-btn {
        border-width: 2px;
    }
}
