/* ========================================
   FERRARI FIREARMS - HEADER/NAVIGATION CSS
   For Shopify Implementation
   ======================================== */

/* FONT IMPORT - Add to theme.liquid head */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@300;400;500;600;700&display=swap');

/* ========================================
   ROOT VARIABLES
   ======================================== */
:root {
  /* Colors */
  --ferrari-red: #c41e3a;
  --ferrari-red-dark: #a01828;
  --gold-accent: #d4a574;
  --gold-dark: #c49564;
  --dark-bg-1: #0f1821;
  --dark-bg-2: #1a2332;
  --dark-bg-3: #2a3c4d;
  --dark-bg-3-hover: #3a4c5d;
  
  /* Font */
  --font-primary: 'Chakra Petch', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  /* Border Radius - ALL ZERO (no rounded corners) */
  --border-radius: 0px;
}

/* ========================================
   HEADER CONTAINER
   ======================================== */
.site-header {
  background-color: var(--dark-bg-1);
  border-bottom: 1px solid var(--dark-bg-3);
  font-family: var(--font-primary);
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* ========================================
   TOP BAR (Announcement Bar)
   ======================================== */
.header-top-bar {
  background-color: #0a0f14; /* Darker than dark-bg-2 */
  color: #ffffff;
  padding: 0.625rem 1rem 0.375rem 1rem;
  font-size: 1.1rem; /* 17.6px - slightly larger for readability */
  font-style: normal;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-top-bar-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.header-top-bar-separator {
  color: #6b7280; /* gray-500 */
  margin: 0 0.25rem;
}

.header-top-bar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-top-bar-center {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-top-bar a {
  color: #ffffff;
  text-decoration: none;
  transition: color 0.2s;
}

.header-top-bar a:hover {
  color: var(--gold-accent);
}

/* ========================================
   MAIN HEADER
   ======================================== */
.header-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.header-main-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* ========================================
   LOGO
   ======================================== */
.header-logo {
  flex-shrink: 0;
}

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

.header-logo img {
  width: 300px;
  height: 77px;
  display: block;
}

/* ========================================
   SEARCH BAR
   ======================================== */
.header-search {
  flex: 1;
  max-width: 672px;
  width: 672px;
}

.header-search-form {
  position: relative;
  width: 100%;
}

.header-search-input {
  display: flex;
  width: 100%;
  height: 48px;
  padding: 12px 48px 12px 16px;
  align-items: center;
  background-color: var(--dark-bg-3);
  color: #ffffff;
  border: none;
  outline: none;
  transition: all 0.2s;
  font-family: var(--font-primary);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
}

.header-search-input::placeholder {
  color: #99A1AF;
  font-family: "Chakra Petch", var(--font-primary);
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
}

.header-search-input:focus {
  outline: 2px solid var(--gold-accent);
  outline-offset: 0;
  box-shadow: 0 0 0 2px var(--gold-accent);
}

.header-search-button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  width: 36px;
  height: 36px;
  padding: 8px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #D4A574;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: var(--border-radius);
}

.header-search-button:hover {
  background-color: var(--gold-dark);
}

.header-search-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--dark-bg-1);
  display: block;
}

/* ========================================
   HEADER ACTIONS (Account & Cart)
   ======================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}
 
.header-account,
.header-cart {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ffffff;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: none;
  font-family: var(--font-primary);
  font-size: 18px;
  font-style: normal;
}
 
.header-account:hover,
.header-cart:hover {
  color: var(--gold-accent);
}
 
.header-cart {
  position: relative;
}
 
.header-icon {
  width: 26px;
  height: 26px;
}

.header-cart-count {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background-color: var(--ferrari-red);
  color: #ffffff;
  font-size: 0.75rem; /* 12px */
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.header-action-text {
  display: none;
}

@media (min-width: 768px) {
  .header-action-text {
    display: inline;
  }
}

/* ========================================
   NAVIGATION BAR
   ======================================== */
.header-nav {
  background-color: var(--dark-bg-2);
  border-top: 1px solid var(--dark-bg-3);
}

.header-nav-container {
  display: flex;
  width: 1351px;
  max-width: 100%;
  margin: 0 auto;
  padding: 1px 51.5px 0 51.5px;
  flex-direction: column;
  align-items: center;
}

.header-nav-wrapper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Mobile Menu Toggle */
.header-mobile-menu-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem;
  color: #ffffff !important;
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  cursor: pointer;
  transition: color 0.2s;
  height: auto;
}

.mobile-menu-label {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    color: inherit;
    line-height: 1; /* Reset line height */
    font-family: 'Chakra Petch', sans-serif;
    display: block; /* Flex item behavior */
    margin: 0;
    padding: 0;
    transform: translateY(1px); /* Optical adjustment: Push text down slightly */
}

.header-mobile-menu-icon {
  width: 24px;
  height: 24px;
  display: block;
}

@media (min-width: 768px) {
  .header-mobile-menu-toggle {
    display: none !important;
  }
}

/* Desktop Navigation Links */
.header-nav-links,
.header-nav-links ul {
  display: none;
  align-items: center;
  gap: 0.25rem;
  list-style: none; /* Remove bullets */
  margin: 0;
  padding: 0;
}

@media (min-width: 768px) {
  .header-nav-links,
  .header-nav-links ul {
    display: flex;
  }
}

/* Style the LI items to be flex containers or just blocks */
.header-nav-links li {
    display: inline-block;
}

/* Target the A tags inside LIs (WP Menu) OR direct A tags (Fallback) */
.header-nav-link,
.header-nav-links a {
  padding: 0.75rem 1rem;
  color: #FFF;
  font-family: "Chakra Petch", var(--font-primary);
  font-size: 14px;
  font-style: normal;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.header-nav-link:hover,
.header-nav-links a:hover {
  background-color: var(--dark-bg-3);
  color: var(--gold-accent);
}

/* Highlighted nav link (e.g., Training) */
.header-nav-link.highlight {
  color: var(--gold-accent);
}

.header-nav-link.highlight:hover {
  background-color: var(--dark-bg-3);
}

/* Active state (WP adds .current-menu-item) */
.header-nav-link.active,
.header-nav-links li.current-menu-item:not(.menu-item-type-custom) > a, 
.header-nav-links li.current_page_item > a {
  background-color: var(--dark-bg-3);
  color: var(--gold-accent);
}

/* Special Case: Hash Links (like Blog) shouldn't be highlighted just because we are on Home */
.header-nav-links li.menu-item-type-custom.current-menu-item > a[href*="#"] {
    background-color: transparent !important;
    color: #FFF !important; /* Revert to white */
}
.header-nav-links li.menu-item-type-custom.current-menu-item > a[href*="#"]:hover {
    color: var(--gold-accent) !important; /* Allow hover */
}

/* ========================================
   MOBILE MENU (Dropdown/Sidebar)
   ======================================== */
.mobile-menu {
  display: none;
  background-color: var(--dark-bg-2);
  border-bottom: 1px solid var(--dark-bg-3);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.mobile-menu.open {
  display: block;
}

@media (min-width: 768px) {
  .mobile-menu {
    display: none !important;
  }
}

.mobile-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu-item,
.mobile-menu-list li {
  border-bottom: 1px solid var(--dark-bg-3);
  display: block;
}

.mobile-menu-item:last-child,
.mobile-menu-list li:last-child {
  border-bottom: none;
}

.mobile-menu-link,
.mobile-menu-list a {
  display: block;
  padding: 1rem 1rem 1rem 1.5rem !important; /* Added left padding to prevent edge touching */
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  font-family: var(--font-primary);
}

.mobile-menu-link:hover,
.mobile-menu-link.active,
.mobile-menu-list a:hover,
.mobile-menu-list li.current-menu-item > a,
.mobile-menu-list li.current_page_item > a {
  background-color: var(--dark-bg-3);
  color: var(--gold-accent);
}

.mobile-menu-link.highlight,
.mobile-menu-list a.highlight {
  color: var(--gold-accent);
}

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

/* Mobile (< 640px) */
@media (max-width: 639px) {
  .header-top-bar {
    font-size: 0.875rem; /* 14px */
  }
  
  .header-top-bar-container {
    justify-content: center;
  }
  
  .header-top-bar-right {
    display: none;
  }
  
  .header-main-container {
    gap: 1rem;
  }
  
  .header-search {
    display: none; /* Hide search on very small screens, or show in mobile menu */
  }
  
  .header-logo img {
    height: 40px;
  }
}

/* Small Tablet (640px - 767px) */
@media (min-width: 640px) and (max-width: 767px) {
  .header-search {
    max-width: 400px;
  }
  
  .header-search-input {
    font-size: 0.875rem;
  }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .header-main-container {
    gap: 1.5rem;
  }
  
  .header-search {
    max-width: 500px;
  }
}

/* ========================================
   STICKY HEADER STYLES
   ======================================== */
.site-header.sticky {
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Optionally hide top bar when scrolled */
.site-header.scrolled .header-top-bar {
  display: none;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-uppercase {
  text-transform: uppercase;
}

.text-bold {
  font-weight: 700;
}

.text-semibold {
  font-weight: 600;
}

.tracking-wide {
  letter-spacing: 0.05em;
}

.transition-colors {
  transition: color 0.2s ease-in-out;
}

/* =========================================
   MOBILE SEARCH BAR - REFINED & FIXED
   ========================================= */
.mobile-header-search {
    display: none; /* Default hidden */
    width: 100%;
    padding: 10px 15px;
    background-color: #0F1821 !important; /* Dark BG 1 */
    border-bottom: 1px solid #2A3C4D !important;
    box-sizing: border-box;
}

/* Container for input + button */
.mobile-search-form {
    display: flex !important;
    align-items: center !important;
    background-color: #1A2332 !important; /* Dark BG 2 */
    border: 1px solid #2A3C4D !important;
    border-radius: 4px !important;
    height: 48px !important; /* Good touch target */
    overflow: hidden !important;
    position: relative !important;
    width: 100% !important;
    margin: 0 !important;
}

/* Input Field Styling */
.mobile-search-input {
    flex-grow: 1 !important;
    background-color: transparent !important;
    border: none !important;
    color: #FFFFFF !important;
    font-family: 'Chakra Petch', sans-serif !important;
    font-size: 16px !important; /* Prevent iOS zoom */
    padding: 0 16px !important;
    height: 100% !important;
    box-shadow: none !important;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    border-radius: 0 !important;
}

.mobile-search-input::placeholder {
    color: #99A1AF !important;
    opacity: 1 !important;
}

/* Button Styling */
.mobile-search-button {
    width: 48px !important;
    height: 100% !important;
    background-color: #D32F2F !important; /* Brand Red */
    border: none !important;
    color: #FFFFFF !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    cursor: pointer !important;
    border-radius: 0 !important;
    margin: 0 !important;
    line-height: 0 !important;
}

.mobile-search-button svg {
    width: 20px !important;
    height: 20px !important;
    stroke: #FFFFFF !important;
}

/* VISIBILITY LOGIC */

/* Hide explicitly on Desktop */
@media (min-width: 991px) {
    .mobile-header-search {
        display: none !important;
    }
}

/* Show explicitly on Mobile/Tablet */
@media (max-width: 990px) {
    .mobile-header-search {
        display: block !important;
    }
    
    /* Ensure the original Desktop search is hidden */
    .header-search {
        display: none !important;
    }
}

/* ========================================
   CUSTOM DROPDOWN MENUS (Desktop)
   ======================================== */
@media (min-width: 768px) {
    .custom-dropdown-nav {
        display: flex !important;
        align-items: center;
    }
}

.custom-dropdown-nav .nav-item {
    position: relative;
    display: inline-block;
}

.custom-dropdown-nav .header-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.75rem 1rem;
}

.dropdown-icon {
    width: 14px !important;
    height: 14px !important;
    transition: transform 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

.custom-dropdown-nav .nav-item:hover .dropdown-icon {
    transform: rotate(180deg);
}

.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background-color: var(--dark-bg-2);
    border: 1px solid var(--dark-bg-3);
    border-top: 2px solid var(--gold-accent);
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 1000;
    display: flex !important;
    flex-direction: column !important;
}

.custom-dropdown-nav .nav-item:hover .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Force links inside dropdown to stack cleanly */
.custom-dropdown-nav .nav-dropdown a,
.nav-dropdown a {
    display: block !important;
    color: #FFF !important;
    padding: 12px 16px !important;
    text-transform: capitalize !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: normal !important;
    background-color: transparent !important;
}

.custom-dropdown-nav .nav-dropdown a:hover,
.nav-dropdown a:hover {
    background-color: var(--dark-bg-3) !important;
    color: var(--gold-accent) !important;
    padding-left: 20px !important;
}

.nav-dropdown .dropdown-divider {
    height: 1px;
    background-color: rgba(255,255,255,0.1);
    margin: 4px 0;
}

.custom-dropdown-nav .nav-dropdown .shop-all-link {
    text-transform: uppercase !important;
    font-weight: 700 !important;
    color: var(--gold-accent) !important;
}

/* ========================================
   MOBILE ACCORDION MENUS
   ======================================== */
.mobile-nav-item {
    display: flex;
    flex-direction: column;
}

.mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 1.5rem !important; /* Prevent parent categories from touching edge */
}

.mobile-nav-toggle .mobile-menu-link {
    flex: 1;
    border-bottom: none;
}

.mobile-dropdown-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    color: #FFF !important;
    padding: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-dropdown-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.mobile-nav-item.active .mobile-dropdown-btn svg {
    transform: rotate(180deg);
    color: var(--gold-accent);
}

.mobile-dropdown-content {
    display: none;
    background-color: #0f1821;
    padding: 0;
}

.mobile-dropdown-content a {
    display: block;
    padding: 12px 1rem 12px 2.5rem !important; /* Increased left padding and touch height */
    color: #D1D5DB !important;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    text-transform: capitalize !important;
}

.mobile-dropdown-content a:last-child {
    border-bottom: none;
}

.mobile-dropdown-content a:hover {
    color: var(--gold-accent) !important;
    background-color: var(--dark-bg-3);
}

.mobile-dropdown-content .shop-all-link {
    font-weight: 700;
    text-transform: uppercase !important;
    color: var(--gold-accent) !important;
}

/* =========================================
   MOBILE LAYOUT ADJUSTMENTS (< 768px)
   ========================================= */
@media (max-width: 767px) {
    /* Center the Logo on Mobile */
    .header-main-container {
        justify-content: center !important;
        gap: 0 !important;
    }
    
    .header-logo {
        margin: 0 auto !important;
        padding: 0 15px !important; /* Prevent touching screen edges */
    }
    
    .header-logo a {
        display: flex !important;
        justify-content: center !important;
    }
    
    .header-logo img {
        margin: 0 auto !important;
        max-width: 90vw !important;
        height: auto !important;
    }

    /* Justify Menu Toggle to the Left and Actions to the Right */
    .header-nav-container {
        padding: 0 15px !important;
    }
    
    .header-nav-wrapper {
        width: 100% !important;
    }
    
    .header-mobile-right {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-left: 0 !important;
    }
    
    .header-actions-mobile {
        display: flex !important;
        align-items: center !important;
        gap: 16px !important;
        margin-left: auto !important;
    }
}

