/* File: header.css */
/* Styles specifically for the main header, navigation (desktop & mobile), dropdowns, logo, and actions. */

/* ==========================================================================
   1. Root Variables (Required by Header Styles)
   ========================================================================== */
:root {
  /* Core brand colors */
  --color-primary: #05782f;       /* Main Green */
  --color-primary-dark: #128C7E;    /* Darker Teal/Green */
  --color-primary-light: #1f4e2d;   /* Darker shade for light elements on dark bg */
  --color-whatsapp-green: #25D366; /* Bright WhatsApp Green */
  --color-whatsapp-link: #53bdeb;   /* WhatsApp link blue */

  /* Dark Theme Palette (Relevant for Header) */
  --color-background: #121212;    /* Very Dark Grey/Black (Used for body context) */
  --color-surface: #1e1e1e;       /* Slightly lighter surface (cards, sections) */
  --color-surface-light: #2c2c2c; /* Lighter surface for hover/emphasis */
  --color-text: #e0e0e0;         /* Light Grey Text (Primary) */
  --color-text-secondary: #a0a0a0; /* Medium Grey Text */
  --color-text-muted: #757575;     /* Darker Grey Text */
  --color-text-inverse: #121212;   /* Text for light backgrounds */
  --color-white: #FFFFFF;
  --color-black: #000000;
  --color-border: rgba(255, 255, 255, 0.1);  /* Subtle light border */
  --color-border-dark: rgba(255, 255, 255, 0.15); /* Slightly stronger border */
  --color-accent: #FFD700;       /* Gold Accent */

  /* Specific Component Colors */
  --color-header-bg-start: var(--color-primary);
  --color-header-bg-end: var(--color-primary-dark);
  --color-header-text: var(--color-white);
  --color-header-link-hover-bg: rgba(255, 255, 255, 0.1);
  --color-mobile-nav-bg: var(--color-surface); /* Use surface color for mobile nav */
  --color-mobile-nav-link-hover: var(--color-surface-light); /* Lighter surface for mobile hover */

  /* Spacing system */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-family-base: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  --font-family-heading: 'Roboto', sans-serif;
  --font-size-base: 1rem; /* 16px default */
  --font-size-xs: 0.75rem;  /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-md: 1rem;    /* 16px */
  --font-size-lg: 1.125rem; /* 18px */
  --font-size-xl: 1.375rem;/* 22px */

  /* Effects */
  --radius-sm: 4px;
  --radius-md: 8px; /* Main radius */
  --radius-lg: 12px;
  --radius-xl: 20px; /* For pill buttons etc */
  --radius-pill: 999px;
  --radius-circle: 50%;
  --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.2); /* Dark theme shadows */
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 15px rgba(37, 211, 102, 0.3); /* Green Glow */
  --transition-fast: 0.2s ease;
  --transition-md: 0.3s ease;
}

/* Optional: Include Font Import if not loaded globally and needed ONLY for the header */
/* @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap'); */

/* ==========================================================================
   2. Header Base Styles
   ========================================================================== */
.main-header {
    background: linear-gradient(135deg, var(--color-header-bg-start), var(--color-header-bg-end));
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    transition: padding 0.3s ease, background 0.3s ease;
}

.main-header.scrolled {
    padding: 6px 16px;
    background: var(--color-header-bg-end); /* Solid color when scrolled */
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   3. Logo Styles
   ========================================================================== */
.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-header-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.logo:hover {
    opacity: 0.9;
    transform: scale(1.03);
}

.logo-icon {
    width: 24px;
    height: 24px;
    stroke: var(--color-header-text);
    fill: none; /* Important for stroke SVGs */
}

.logo-text {
    font-family: var(--font-family-heading);
}

/* ==========================================================================
   4. Main Navigation (Desktop)
   ========================================================================== */
.main-nav {
    display: flex; /* Hidden on mobile via media query */
    align-items: center;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    gap: 12px;
}

.nav-item {
    position: relative;
}

/* Style both <a> and <button> used as nav links */
.nav-link {
    color: var(--color-header-text);
    text-decoration: none;
    padding: 10px 14px;
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: var(--radius-md);
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    line-height: normal; /* Reset line height */
    white-space: nowrap; /* Prevent wrapping */
}

.nav-link:hover,
.nav-link.active { /* Style for active link if needed */
    background-color: var(--color-header-link-hover-bg);
    color: var(--color-white);
}

/* Specifically target button-like nav links if needed */
button.nav-link {
    appearance: none; /* Remove default button styles */
    text-align: left; /* Align text left */
}

/* ==========================================================================
   5. Dropdown Styles (Desktop)
   ========================================================================== */
.dropdown-toggle {
    /* Style is covered by .nav-link */
    display: flex; /* Ensure icon aligns */
    align-items: center;
    gap: 5px;
}

.dropdown-icon {
    font-size: 0.7rem;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-block; /* Align properly */
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 5px); /* Add small gap */
    left: 0;
    background-color: var(--color-surface-light); /* Use lighter surface */
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); /* Use large dark shadow */
    min-width: 220px; /* Wider dropdown */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98); /* Start slightly scaled down */
    transform-origin: top left;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 1001;
    max-height: 350px; /* Increased max height */
    overflow-y: auto;
    border: 1px solid var(--color-border-dark); /* Use dark border */
    padding: 8px 0; /* Add padding top/bottom */
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-section { /* Optional title within dropdown */
    padding: 10px 20px 5px 20px;
    font-weight: 700;
    color: var(--color-whatsapp-green); /* Use WA Green */
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.dropdown-item {
    display: block;
    padding: 10px 20px;
    color: var(--color-text); /* Use primary text color */
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap; /* Prevent wrapping */
}

.dropdown-item:hover {
    background-color: var(--color-surface); /* Darken slightly */
    color: var(--color-whatsapp-green); /* Highlight color */
}

.dropdown-loading {
    padding: 15px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* ==========================================================================
   6. Header Actions (CTA Button)
   ========================================================================== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cta-btn { /* Submit Group Button in Header */
    background-color: var(--color-whatsapp-green); /* WA Green Background */
    color: var(--color-black); /* Black text */
    padding: 9px 18px;
    border-radius: var(--radius-xl); /* Pill shape */
    text-decoration: none;
    font-weight: 700; /* Bolder */
    font-size: 0.85rem;
    transition: all var(--transition-md);
    white-space: nowrap;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.cta-btn:hover,
.cta-btn:focus-visible {
    background-color: #1fbb5b; /* Slightly darker green */
    color: var(--color-black);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow); /* Add glow */
    outline: none;
}

/* ==========================================================================
   7. Mobile Menu Toggle & Styles
   ========================================================================== */
.mobile-menu-toggle {
    display: none; /* Hidden by default */
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1002; /* Above nav and overlay */
    position: relative; /* Needed for z-index */
}

.hamburger-icon {
    display: block;
    position: relative;
    width: 24px;
    height: 3px;
    background-color: var(--color-header-text); /* Icon color */
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--color-header-text); /* Icon color */
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

.hamburger-icon::before { top: -8px; }
.hamburger-icon::after { top: 8px; }

/* Hamburger animation to X when toggle has .active class */
.mobile-menu-toggle.active .hamburger-icon {
    background-color: transparent; /* Center bar disappears */
}
.mobile-menu-toggle.active .hamburger-icon::before {
    transform: translateY(8px) rotate(45deg); /* Moves down and rotates */
}
.mobile-menu-toggle.active .hamburger-icon::after {
    transform: translateY(-8px) rotate(-45deg); /* Moves up and rotates */
}

/* Mobile Overlay */
.mobile-overlay {
    /* Initial state: Hidden */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Dark overlay */
    z-index: 998; /* Below nav */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

/* Active state: Show overlay */
.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0s linear 0s;
}

/* ==========================================================================
   8. Responsive Adjustments (Mobile Header & Nav)
   ========================================================================== */
@media (max-width: 768px) { /* Mobile Breakpoint */
    .main-header {
        padding: 10px 15px;
    }
    .header-container {
        position: relative; /* Keep relative */
    }
    .logo { font-size: 1.1rem; }
    .logo-icon { width: 22px; height: 22px; }

    /* --- MOBILE NAVIGATION SIDEBAR --- */
    .main-nav {
        /* Initial state: Hidden off-screen */
        display: block; /* Override desktop flex */
        position: fixed;
        top: 0;
        left: 0;
        width: 280px; /* Adjust width as needed */
        max-width: 85%;
        height: 100vh;
        background-color: var(--color-mobile-nav-bg);
        transform: translateX(-100%); /* START HIDDEN */
        transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1); /* SMOOTH SLIDE */
        z-index: 999;
        overflow-y: auto;
        box-shadow: 4px 0px 15px rgba(0, 0, 0, 0.3);
        padding-top: 60px; /* Space from top */
        border-right: 1px solid var(--color-border);
    }

    /* Active state: Slide the navigation in */
    .main-nav.mobile-active {
        transform: translateX(0); /* SLIDE IN */
    }

    /* Mobile Nav Menu Structure */
    .nav-menu {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
        padding: 10px 0;
    }
    .nav-item {
        border-bottom: 1px solid var(--color-border);
    }
    .nav-item:last-child { border-bottom: none; }
    .nav-link { /* Style mobile nav links */
        padding: 15px 25px;
        font-size: 1rem;
        font-weight: 500;
        color: var(--color-text);
        border-radius: 0;
        transition: background-color 0.2s ease;
        display: flex; /* Keep flex for alignment */
        justify-content: space-between;
        align-items: center;
    }
    .nav-link:hover {
        background-color: var(--color-mobile-nav-link-hover);
        color: var(--color-whatsapp-green);
    }

    /* Mobile Dropdown Menu Adjustments */
    .nav-item .dropdown-menu { /* Target dropdowns inside mobile nav */
        position: static; /* No longer absolute */
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        border: none;
        max-height: 0; /* Start closed */
        overflow: hidden;
        transition: max-height 0.35s ease-out, padding 0.35s ease-out;
        background-color: rgba(0, 0, 0, 0.15); /* Nested background */
        min-width: auto;
        padding: 0; /* Reset padding */
        margin-top: 0; /* Remove desktop gap */
        border-top: 1px solid var(--color-border); /* Separator */
    }
    .nav-item .dropdown-menu.show {
        max-height: 600px; /* Allow height */
        padding: 5px 0; /* Add padding when open */
    }
    .dropdown-section { /* Indent mobile section titles */
        padding: 10px 25px 5px 35px;
        font-size: 0.7rem;
        color: var(--color-text-muted);
    }
    .dropdown-item { /* Indent mobile dropdown items */
        padding: 12px 25px 12px 40px;
        font-size: 0.9rem;
        color: var(--color-text);
    }
     .dropdown-item:hover {
        background-color: var(--color-mobile-nav-link-hover);
        color: var(--color-whatsapp-green);
    }
    .dropdown-loading { /* Mobile loading state */
        padding: 15px 25px;
        text-align: left;
    }
    /* --- END MOBILE NAVIGATION --- */

    .mobile-menu-toggle {
        display: block; /* Show the toggle button */
    }
    .header-actions { gap: 8px; }
    .cta-btn { padding: 7px 14px; font-size: 0.8rem; }
}

/* Further adjustments for very small screens */
@media (max-width: 480px) {
    .logo { font-size: 1rem; }
    .logo-icon { width: 20px; height: 20px; }
    .cta-btn { padding: 6px 10px; font-size: 0.75rem; }
    .main-nav { width: 250px; } /* Slightly narrower sidebar */
    .nav-link { padding: 14px 20px; font-size: 0.95rem; }
    .dropdown-item { padding: 10px 20px 10px 35px; font-size: 0.85rem; }
}

/* Optional: Prevent body scroll when mobile menu is open (add class via JS) */
body.mobile-nav-open {
    overflow: hidden;
}

/* ==========================================================================
   T13: Mobile Touch Targets (Google UX compliance — scoped to standalone CTAs only)
   .pill and .tag-link inside grid cards are NOT forced to 48px to prevent layout overflow.
   ========================================================================== */

/* Standalone CTA-style buttons: safe to enforce 48px touch target */
.home-btn,
.f-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Inline pill elements inside grid cards: do NOT force min-height */
.pill,
.tag-link {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}

/* Card join buttons on hero pages: safe touch target without layout break */
.c-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}