/* css/layout/header.css */

/* =================================================================
   0. MINIMAL HEADER (Brand Campaign Pages)
   ================================================================= */
.minimal-header {
    background-color: var(--color-white);
    height: 72px;
    border-bottom: 1px solid var(--color-gray-200);
    width: 100%;
    box-shadow: var(--shadow-sm);
}

.minimal-header__container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
}

.minimal-header__container a {
    display: flex;
    align-items: center;
    transition: opacity var(--transition-fast);
}

.minimal-header__container a:hover {
    opacity: 0.8;
}

.minimal-header img {
    height: 36px;
    width: auto;
}

@media (max-width: 767px) {
    .minimal-header {
        height: 64px;
    }
    .minimal-header img {
        height: 28px;
    }
    .minimal-header__container {
        padding: 0 var(--space-4);
    }
}

/* =================================================================
   1. SHARED HEADER STRUCTURE (Public & Member)
   ================================================================= */
   .header, .member-header {
    background-color: var(--color-white);
    height: 72px; /* Standardized height */
    border-bottom: 1px solid var(--color-gray-200);
    position: sticky;
    /* DYNAMIC OFFSET: Respects hellobar height via JS variable */
    top: var(--header-offset, 0px);
    z-index: 1000; /* Standard z-index for header */
    width: 100%;
    transition: top 0.2s ease-out; /* Smooth adjustment */
}

.header-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    max-width: 1400px; /* Match dashboard grid max-width */
    margin: 0 auto;
    position: relative;
}

.member-header .header-container {
    max-width: 100%; /* Member header spans full width usually */
    padding: 0 24px;
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo img {
    height: 32px; /* Desktop Height */
    width: auto;
    transition: opacity 0.2s ease;
}

.header-logo a:hover img {
    opacity: 0.8;
}

/* =================================================================
   2. PUBLIC NAVIGATION (.main-nav)
   ================================================================= */
.main-nav {
    display: flex;
    height: 100%;
    align-items: center;
}

.main-nav ul {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-nav li {
    position: relative;
    display: flex;
    align-items: center;
}

/* 
   TOUCH TARGET OPTIMIZATION:
   Ensure minimum 44px height for clickable areas on public nav.
   Excludes .btn classes to prevent padding conflicts.
*/
.main-nav a:not(.btn):not(.btn-youtube) {
    color: var(--color-gray-600);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 10px 0; /* Add vertical padding for links only */
    display: inline-block;
}

/* Hover State for Standard Links */
.main-nav a:not(.btn):not(.btn-youtube):hover {
    color: var(--color-primary);
}

/* "For Brands" nav link — visible alongside other nav items (revenue page) */
/* Specificity: (0,3,1) matches .main-nav a:not(.btn):not(.btn-youtube), wins by source order */
.main-nav a.nav-brands-link:not(.btn) {
    color: var(--color-gray-500);
    font-size: 0.95rem;
}
.main-nav a.nav-brands-link:not(.btn):hover {
    color: var(--color-primary);
}

/* Avatar in Public Nav (Logged In State) */
.nav-avatar-item {
    display: flex;
    align-items: center;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-gray-100);
    transition: border-color 0.2s ease;
    background-color: var(--color-gray-50);
}

.nav-avatar--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--color-gray-600);
    font-size: 0.85rem;
}

.avatar-btn:hover .nav-avatar {
    border-color: var(--color-primary);
}

/* =================================================================
   3. MEMBER HEADER ELEMENTS (Command Center)
   ================================================================= */
.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

/*
   CONVERSION OPTIMIZATION: The "Velvet Rope" Upgrade Button
   Darker indigo to maintain premium feel while aligning with primary brand color.
*/
.header-upgrade-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px; /* Generous touch target */
    padding: 0 20px;
    /* DARKER INDIGO FOR PREMIUM */
    background-color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-dark);
    color: #ffffff;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3); /* Enhanced indigo glow */
    white-space: nowrap;
}

/* Hover State */
.header-upgrade-btn:hover {
    background-color: #3730a3; /* Even darker indigo */
    border-color: #3730a3;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(67, 56, 202, 0.4);
}

.header-upgrade-btn i {
    font-size: 0.9em;
    color: #ffffff; /* Ensure icon is white */
}

/* Mobile: Compact Icon Variant */
@media (max-width: 767px) {
    .header-upgrade-btn {
        display: none; /* Overlap fix: Remove from mobile header to save space */
    }
}

/* User Menu Trigger */
.user-menu { position: relative; z-index: 1001; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 99px;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
    border: 1px solid transparent;
}

.user-menu-trigger:hover {
    background-color: #f1f5f9;
}

/* Desktop-only chevron arrow next to avatar */
.user-menu-arrow {
    display: none;
    font-size: 0.8rem;
    color: var(--color-gray-500);
}
@media (min-width: 992px) {
    .user-menu-arrow {
        display: block;
    }
}

/* Avatar (Shared Style) */
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #64748b;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; }

/* Desktop Dropdown (Modern Diffuse Shadow) */
.user-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: 260px;
    background-color: #ffffff;
    border-radius: 12px;
    /* Updated Shadow: Softer, more modern */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Dropdown Header */
.dropdown-user-info { 
    padding: 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    background-color: #f8fafc; 
    border-bottom: 1px solid #e2e8f0; 
}
.dropdown-user-info strong { 
    color: #0f172a; 
    font-size: 0.95rem; 
    font-weight: 700;
}
.dropdown-user-info span { 
    font-size: 0.8rem; 
    color: #64748b; 
    overflow: hidden; 
    text-overflow: ellipsis;
}

.dropdown-divider { 
    height: 1px; 
    background-color: #f1f5f9; 
    margin: 4px 0;
}

/* Dropdown Items */
.dropdown-item {
    display: flex; 
    align-items: center; 
    gap: 12px; 
    padding: 10px 16px;
    color: #475569; 
    text-decoration: none; 
    font-size: 0.9rem; 
    font-weight: 500; 
    transition: all 0.15s ease-out;
}

.dropdown-item:hover { 
    background-color: #f8fafc; 
    color: #2563eb; 
    text-decoration: none; 
}

.dropdown-item i { 
    width: 18px; 
    text-align: center; 
    color: #94a3b8; 
    font-size: 0.9rem;
}

.dropdown-item:hover i { 
    color: #2563eb; 
}

/* =================================================================
   4. MOBILE NAVIGATION (Hamburger & Slide-out)
   ================================================================= */
.dashboard-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    align-items: flex-end; 
    z-index: 1100;
    /* Added Margin to separate from avatar on right */
    margin-left: 8px;
}

.dashboard-toggle span {
    display: block;
    height: 2px;
    background-color: #1e293b;
    border-radius: 99px;
    transition: all 0.2s ease-in-out;
}
.dashboard-toggle span:nth-child(1) { width: 22px; }
.dashboard-toggle span:nth-child(2) { width: 22px; }
.dashboard-toggle span:nth-child(3) { width: 14px; }

.dashboard-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); width: 22px; }
.dashboard-toggle.active span:nth-child(2) { opacity: 0; }
.dashboard-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); width: 22px; }

/* Mobile Sidebar (Slide Out) */
.mobile-nav-overlay {
    position: fixed; inset: 0; background-color: rgba(15, 23, 42, 0.5); z-index: 10000;
    backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease;
}
.mobile-nav-overlay.active { opacity: 1; visibility: visible; }

.mobile-nav-panel {
    position: fixed; top: 0; right: 0; width: 320px; max-width: 85vw; height: 100%;
    background-color: #ffffff; z-index: 10001;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex; flex-direction: column;
    box-shadow: -8px 0 30px rgba(15, 23, 42, 0.12), -2px 0 8px rgba(15, 23, 42, 0.06);
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-panel.active { transform: translateX(0); }

/* Scroll lock when mobile menu is open */
body.mobile-nav-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: calc(-1 * var(--scroll-y, 0px));
}

/* --- User Profile Header --- */
.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--color-gray-200);
    flex-shrink: 0;
    background-color: var(--color-gray-50);
}

.mobile-nav-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mobile-nav-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--color-gray-200);
    background-color: var(--color-gray-100);
}

.mobile-nav-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mobile-nav-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-gray-600);
    background-color: var(--color-gray-100);
}

.mobile-nav-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.mobile-nav-user-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.mobile-nav-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.mobile-nav-plan-badge--free {
    color: var(--color-gray-500);
}

.mobile-nav-plan-badge--starter,
.mobile-nav-plan-badge--growth,
.mobile-nav-plan-badge--pro {
    color: var(--color-primary);
}

.mobile-nav-plan-badge i {
    color: var(--color-success);
    font-size: 0.65rem;
}

/* --- Close Button (Clear X icon) --- */
.mobile-nav-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
    color: var(--color-gray-400);
    font-size: 1.15rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.mobile-nav-close-btn:hover {
    background-color: var(--color-gray-100);
    color: var(--color-gray-700);
}

.mobile-nav-close-btn:active {
    background-color: var(--color-gray-200);
}

.mobile-nav-body {
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 30px;
}

/* =========================================================
   MOBILE MENU COMPONENTS (Styled in sidebar.css via checkbox-hack)
   Action grid, flat links, badges, dividers live here as shared styles.
   ========================================================= */

/* --- FLAT LINKS (Common Style) --- */
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    min-height: 48px;
    color: var(--color-gray-600);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border-left: 3px solid transparent;
}

/* Icons */
.mobile-nav-link i {
    width: 20px;
    text-align: center;
    color: var(--color-gray-400);
    font-size: 1.1rem;
    transition: color 0.15s ease;
}

/* Active (current page) */
.mobile-nav-link.is-active {
    background-color: #eff6ff;
    color: var(--color-info);
    border-left-color: var(--color-info);
}

.mobile-nav-link.is-active i {
    color: var(--color-info);
}

/* Touch/press feedback */
.mobile-nav-link:active {
    background-color: var(--color-gray-100);
}

/* Disabled items (SOON badges) */
.mobile-nav-link.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- D. VISUAL SEPARATORS (Meta Actions) --- */
.mobile-nav-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 8px 24px; /* Align with text indentation */
    opacity: 0.6;
}

/* Danger Link (Logout) */
.mobile-nav-link.text-danger {
    color: var(--color-danger);
}
.mobile-nav-link.text-danger i {
    color: var(--color-danger);
}
.mobile-nav-link.text-danger:active {
    background-color: #fef2f2;
    border-left-color: #fecaca;
}

/* --- FLAT GROUP (Dashboard) --- */
.mobile-flat-group {
    border-bottom: 1px solid var(--color-gray-100);
    padding: 4px 0;
}
.mobile-flat-group .mobile-nav-link {
    padding-left: 20px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-gray-800);
    min-height: 48px;
}
.mobile-flat-group .mobile-nav-link i {
    color: var(--color-gray-500);
}

/* --- BADGES --- */
.mobile-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.mobile-badge--hot { background: #fee2e2; color: #991b1b; }
.mobile-badge--new { background: #dbeafe; color: #1e40af; }
.mobile-badge--soon { background: var(--color-gray-100); color: var(--color-gray-400); border: 1px solid var(--color-gray-200); }

/* =================================================================
   MOBILE MENU FOOTER (Sticky & Solid)
   ================================================================= */
.mobile-nav-footer {
    padding: 16px 20px;
    margin-top: auto;
    border-top: 1px solid var(--color-gray-200);
    background-color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
    position: sticky;
    bottom: 0;
    z-index: 50;
}

.mobile-nav-footer .sidebar-plan-card {
    width: 100%;
    margin-bottom: 0;
    border: 1px solid var(--color-gray-200);
    box-shadow: none;
}

@media (max-width: 360px) {
    .mobile-nav-footer {
        padding: 12px;
    }
}

/* =================================================================
   5. MOBILE FLOATING ACTION BUTTON (FAB)
   ================================================================= */
.mobile-fab {
    /* DEFAULT: Hide on Desktop */
    display: none;
}

/* MOBILE: Show and Position Correctly */
@media (max-width: 991px) {
    .mobile-fab {
        display: flex; /* Restore flex display */
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        background-color: var(--color-primary); /* Brand Red */
        border-radius: 50%;
        color: white;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
        z-index: 2000; /* High z-index to float above content */
        text-decoration: none;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    
    .mobile-fab:hover {
        transform: scale(1.1);
        text-decoration: none;
        color: white;
    }

    .mobile-fab i {
        font-size: 24px;
    }
}

/* =================================================================
   6. RESPONSIVE BREAKPOINTS
   ================================================================= */
@media (max-width: 991px) {
    .header, .member-header {
        position: fixed;
    }

    .header-container, .member-header .header-container {
        gap: 12px; /* Prevent logo/wallet overlap */
    }

    .header-user {
        flex-shrink: 1; /* Allow right side to shrink on mobile */
        min-width: 0; /* Enable text truncation in children */
        gap: 8px; /* Tighter spacing between wallet/avatar/hamburger */
    }

    .dashboard-toggle {
        display: flex;
    }

    /* Member header: Avatar IS the menu trigger — hide redundant hamburger */
    .member-header .dashboard-toggle {
        display: none;
    }

    /* Mobile avatar: subtle ring to indicate tappability */
    .member-header .user-avatar {
        width: 36px;
        height: 36px;
        border: 2px solid #e2e8f0;
        box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
    }

    .user-dropdown {
        display: none;
    }

    /* Reduce logo size on all mobile/tablet devices */
    .header-logo img {
        height: 24px;
    }

    /* Wallet pill: allow shrinking but keep readable */
    .unified-wallet-pill {
        flex-shrink: 1;
        min-width: 0;
    }

    .wallet-section span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Public Nav Mobile */
    .main-nav {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 4px 10px -5px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 1.5rem;
        align-items: stretch;
    }

    .main-nav.active { display: flex; }
    
    .main-nav ul {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .main-nav a {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid #f1f5f9;
        font-size: 1rem;
        min-height: 44px; /* Touch target safety */
    }
}

@media (max-width: 480px) {
    .header-container, .member-header .header-container { padding: 0 12px; }
    .header-wallet-pill { padding: 0 12px; font-size: 0.85rem; height: 36px; }

    .header-user {
        gap: 6px;
    }
}

/* --- Mobile Menu Footer (Monetization Area) --- */
.mobile-nav-footer {
    padding: 16px 20px;
    margin-top: auto; 
    border-top: 1px solid #f1f5f9;
    background-color: #ffffff;
    flex-shrink: 0; 
}

.mobile-nav-footer .sidebar-plan-card {
    width: 100%;
    margin-bottom: 0;
}

/* --- Locked Wallet Pill (Unverified State) --- */
/* Compound selector (0,2,0) beats .unified-wallet-pill (0,1,0) */
.unified-wallet-pill.header-wallet-pill--locked {
    background-color: #f1f5f9; /* Slate-100 */
    border: 1px dashed #cbd5e1; /* Dashed Border */
    color: #64748b; /* Muted Text */
    cursor: pointer;
}

.unified-wallet-pill.header-wallet-pill--locked:hover {
    background-color: #e2e8f0;
    border-color: #94a3b8;
    color: #475569;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.unified-wallet-pill.header-wallet-pill--locked .wallet-icon {
    color: #94a3b8; /* Gray Icon */
    font-size: 0.9rem;
}

/* =================================================================
   UNIFIED WALLET PILL (Credits + Cash)
   ================================================================= */
.unified-wallet-pill {
    display: inline-flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    height: 40px;
    padding: 0 4px; /* Minimal padding, inner sections handle spacing */
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    overflow: hidden; /* Ensures hover effects stay contained */
}

.unified-wallet-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.08);
    text-decoration: none;
    border-color: #cbd5e1;
}

/* Sections */
.wallet-section {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 700;
    height: 100%;
}

/* Credits Side (Yellow/Gold) */
.wallet-section.credits {
    color: #0f172a;
}
.wallet-section.credits i {
    color: #fbbf24; /* Amber-400 */
}

/* Divider */
.wallet-divider {
    width: 1px;
    height: 20px;
    background-color: #e2e8f0;
    display: block;
}

/* Cash Side (Brand Green) */
.wallet-section.cash {
    color: #065f46; /* Dark Green Text */
    background-color: #f0fdf4; /* Light Green Bg */
    border-radius: 0 99px 99px 0; /* Rounded right side */
    margin-right: -4px; /* Compensate for parent padding */
    padding-right: 16px;
}

.wallet-section.cash i {
    color: #059669; /* Brand Green */
}

/* Locked State for Cash (Grayed Out) */
.wallet-section.cash.locked {
    background-color: #f8fafc;
    color: #94a3b8;
}
.wallet-section.cash.locked i {
    color: #cbd5e1;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .unified-wallet-pill {
        height: 34px;
        padding: 0 3px;
    }
    .wallet-section {
        padding: 0 6px;
        font-size: 0.8rem;
        gap: 4px;
    }
    .wallet-section.cash {
        padding-right: 10px;
    }
    .wallet-divider {
        height: 16px;
    }
}

/* Tiny phones (360px and below — iPhone SE, Galaxy S series compact) */
@media (max-width: 360px) {
    .unified-wallet-pill {
        height: 32px;
        padding: 0 2px;
    }
    .wallet-section {
        padding: 0 5px;
        font-size: 0.75rem;
        gap: 3px;
    }
    .wallet-section.cash {
        padding-right: 8px;
    }
    .wallet-section i {
        font-size: 0.7rem;
    }
}