/**
 * Header Component - Linear-Inspired Design
 * Shared header component used across authenticated pages
 */

/* ============================================================================
   Header Container
   ============================================================================ */

.header,
.dashboard-header,
.app-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: max(0.75rem, env(safe-area-inset-top, 0px)) 1.5rem 0.75rem 1.5rem;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: var(--z-sticky);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: visible; /* Ensure dropdown isn't clipped */
    box-sizing: border-box;
}

/* Dashboard/app headers use space-between */
.dashboard-header,
.app-header {
    justify-content: space-between;
}

/* Push page content below the fixed header.
   The header is ~65px (padding + logo + border), plus safe-area on iOS.
   Using the same env() as the header padding so they stay in sync. */
body:has(> .dashboard-header) {
    padding-top: calc(max(0.75rem, env(safe-area-inset-top, 0px)) + 0.75rem + 48px + 1px);
}

.page-title {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary);
    margin: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-self: end;
}

/* For centered headers, position right content absolutely */
.header .header-right {
    position: absolute;
    right: 2rem;
}

/* ============================================================================
   Logo
   ============================================================================ */

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.logo-icon {
    display: block;
    width: 48px;
    height: 48px;
    color: var(--text-primary);
    transition: color 0.2s ease;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.logo-container:hover .logo-icon {
    color: var(--text-secondary);
}

.logo-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ============================================================================
   Header Action Buttons (Calendar, Games, etc.)
   ============================================================================ */

.header-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--gray-1);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.header-action-btn:hover {
    background: var(--gray-2);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.header-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.header-action-btn .btn-label {
    display: inline;
}

/* ============================================================================
   Header Buttons (Notifications, Profile)
   ============================================================================ */

.notification-btn,
.profile-btn {
    background: var(--gray-1);
    border: 1px solid var(--border-subtle);
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-btn {
    overflow: hidden;
}

.notification-btn svg,
.profile-btn svg {
    width: 20px;
    height: 20px;
}

.notification-btn:hover,
.profile-btn:hover {
    background: var(--gray-2);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* ============================================================================
   Profile Avatar
   ============================================================================ */

.profile-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background: var(--gray-2, #2a2a2a);
    border: 1px solid var(--border-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    /* Reset font-size for initials display */
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

/* Signed-in: initial letter via ::before, photo via background-image */
.profile-avatar[data-initials] {
    background-color: var(--avatar-fallback);
    background-position: center;
    color: var(--text-on-accent);
}
.profile-avatar[data-initials]::before {
    content: attr(data-initials);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}

/* ============================================================================
   Profile Dropdown
   ============================================================================ */

.profile-dropdown {
    position: relative;
}

.profile-menu {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    min-width: 220px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: var(--z-dropdown);
}

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

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none !important;
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.profile-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.profile-menu-item:first-child {
    border-radius: 12px 12px 0 0;
}

.profile-menu-item:last-child {
    border-radius: 0 0 12px 12px;
}

.profile-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.profile-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.5rem 0;
}

.profile-menu-item.sign-out {
    color: var(--accent-danger);
}

.profile-menu-item.sign-out:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}
/* ============================================================================
   Upgrade Button (Get Pro)
   ============================================================================ */

.header-action-btn.header-upgrade-btn {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    opacity: 0;
    transition: opacity 0.4s ease, background 0.15s ease, border-color 0.15s ease;
}

.header-action-btn.header-upgrade-btn.visible {
    opacity: 1;
}

.header-action-btn.header-upgrade-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #3b82f6;
}

/* ============================================================================
   Mobile Responsive
   ============================================================================ */
@media (max-width: 768px) {
    .header,
    .dashboard-header,
    .app-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .header .header-right {
        right: 1rem;
    }

    .header-action-btn .btn-label {
        display: none;
    }

    .profile-menu {
        max-width: calc(100vw - 2rem);
        right: -0.5rem;
    }
}

@media (max-width: 480px) {
    .logo-name {
        display: none;
    }
}
