/* =========================================================
   CandyCloud — Custom Header
   Complete, Polished Design with Scroll Hide/Show
   ========================================================= */

/* =========================================================
   DESIGN TOKENS
   ========================================================= */

   :root {
    --header-row1-height: 70px;
    --header-row1-height-mobile: 60px;
    --header-row2-height: 50px;
    --header-row2-height-mobile: 45px;
    --header-total-height: calc(var(--header-row1-height) + var(--header-row2-height));
    --header-total-height-mobile: calc(var(--header-row1-height-mobile) + var(--header-row2-height-mobile));
    
    --header-bg: rgba(11, 11, 16, 0.95);
    --header-border: rgba(255, 47, 146, 0.2);
    --text-primary: #E8E9F3;
    --text-secondary: #B8BBD6;
    --text-muted: #8B8FA3;
    --accent-primary: #FF2F92;
    --accent-secondary: #C77DFF;
    --accent-gradient: linear-gradient(135deg, #FF2F92 0%, #C77DFF 100%);
    
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --blur: blur(20px);
  }
  
  /* =========================================================
     CUSTOM HEADER (Sticky with Scroll Hide/Show)
     ========================================================= */
  
  .cc-custom-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--header-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--shadow-md);
    z-index: 99998;
    transition: transform var(--transition-base);
    will-change: transform;
  }
  
  /* Ensure WordPress admin bar stays on top */
  #wpadminbar {
    z-index: 99999 !important;
    position: fixed !important;
  }
  
  /* Hide header when scrolling down */
  .cc-custom-header.scroll-down {
    transform: translateY(calc(-100% - 0px));
  }
  
  /* Show header when scrolling up */
  .cc-custom-header.scroll-up {
    transform: translateY(0);
  }
  
  /* Account for admin bar when hiding */
  .admin-bar .cc-custom-header.scroll-down {
    transform: translateY(calc(-100% - 32px));
  }
  
  @media screen and (max-width: 782px) {
    .admin-bar .cc-custom-header.scroll-down {
      transform: translateY(calc(-100% - 46px));
    }
  }
  
  /* =========================================================
     HEADER STRUCTURE (Two Rows)
     ========================================================= */
  
  .cc-header__inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
  }
  
  /* Row 1: Logo, Search, Cart */
  .cc-header__row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    height: var(--header-row1-height);
    gap: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 47, 146, 0.1);
  }
  
  /* Row 2: Navigation */
  .cc-header__row2 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--spacing-lg);
    height: var(--header-row2-height);
    background: rgba(255, 255, 255, 0.02);
    position: static; /* Ensure no positioning context */
  }
  
  /* =========================================================
     LOGO
     ========================================================= */
  
  .cc-header__logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }
  
  .cc-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: var(--transition-base);
  }
  
  .cc-logo-link:hover {
    opacity: 0.9;
    transform: scale(1.05);
  }
  
  .cc-logo-img {
    max-height: 48px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
  }
  
  /* =========================================================
     SEARCH BAR
     ========================================================= */
  
  .cc-header__search {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
  }
  
  .cc-search-wrapper {
    position: relative;
    width: 100%;
  }
  
  .cc-search-input {
    width: 100%;
    height: 44px;
    padding: 0 50px 0 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-base);
    outline: none;
    font-family: inherit;
  }
  
  .cc-search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
  }
  
  .cc-search-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(255, 47, 146, 0.2);
  }
  
  .cc-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition-base);
    padding: 0;
  }
  
  .cc-search-btn:hover {
    color: var(--accent-primary);
    background: rgba(255, 47, 146, 0.12);
  }
  
  .cc-search-btn:active {
    transform: translateY(-50%) scale(0.95);
  }
  
  /* Search Results Dropdown */
  .cc-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 450px;
    overflow-y: auto;
    display: none;
    z-index: 100000;
    padding: var(--spacing-sm);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
  }
  
  .cc-search-results.active {
    display: block;
  }
  
  .cc-search-results__item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    text-decoration: none;
    color: var(--text-primary);
  }
  
  .cc-search-results__item:hover {
    background: rgba(255, 47, 146, 0.12);
  }
  
  .cc-search-results__item-image {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    display: block;
  }
  
  /* Fallback placeholder for missing images */
  .cc-search-results__item-image:not([src]),
  .cc-search-results__item-image[src=""],
  .cc-search-results__item-image[src="undefined"] {
    background: rgba(255, 47, 146, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 24px;
  }
  
  .cc-search-results__item-content {
    flex: 1;
    min-width: 0;
  }
  
  .cc-search-results__item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    line-height: 1.3;
  }
  
  .cc-search-results__item-price {
    font-size: 13px;
    color: var(--accent-primary);
    font-weight: 700;
  }
  
  .cc-search-results__empty,
  .cc-search-results__loading {
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
  }
  
  .cc-search-results__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
  }
  
  .cc-search-results__loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--header-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  /* =========================================================
     CART ICON
     ========================================================= */
  
  .cc-header__cart {
    flex-shrink: 0;
  }
  
  /* Hide header cart on mobile (footer nav has cart) */
  @media (max-width: 768px) {
    .cc-header__cart {
      display: none !important;
    }
  }
  
  .cc-cart-link {
    position: relative;
    min-width: 100px;
    width: 100px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 var(--cc-spacing-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-base);
    cursor: pointer;
    box-sizing: border-box;
  }
  
  .cc-cart-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin: 0;
  }
  
  .cc-cart-total {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-secondary);
    transition: var(--transition-base);
    margin: 0;
  }
  
  .cc-cart-link:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 47, 146, 0.12);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 47, 146, 0.3);
  }
  
  .cc-cart-link:hover .cc-cart-total {
    color: var(--accent-primary);
  }
  
  .cc-cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent-gradient);
    color: #0B0B10;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(255, 47, 146, 0.5);
  }
  
  /* =========================================================
     NAVIGATION MENU (Row 2)
     ========================================================= */
  
  .cc-header__nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .cc-nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    width: 100%;
    justify-content: center;
  }
  
  .cc-nav-item,
  .cc-nav-menu > li {
    margin: 0;
  }
  
  /* =========================================================
     PRIMARY MENU: Hide utility links on desktop (keep for mobile hamburger)
     - Works even if you don't/can't add menu item CSS classes (uses :has + href)
     ========================================================= */
  /* Desktop-only: also require a fine pointer/hover so phones don't get caught by odd viewport scaling */
  @media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
    /* Preferred: if you've added the class via Appearance → Menus */
    .cc-nav-menu > li.cc-mobile-only {
      display: none !important;
    }
  
    /* Fallback: hide by URL (About / Contact / My Account) */
    .cc-nav-menu > li:has(> a[href$="/about/"]),
    .cc-nav-menu > li:has(> a[href$="/about"]),
    .cc-nav-menu > li:has(> a[href$="/contact/"]),
    .cc-nav-menu > li:has(> a[href$="/contact"]),
    .cc-nav-menu > li:has(> a[href$="/my-account/"]),
    .cc-nav-menu > li:has(> a[href$="/my-account"]) {
      display: none !important;
    }
  }
  
  .cc-nav-link,
  .cc-nav-menu > li > a {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: var(--transition-base);
    border-radius: 8px;
    position: relative;
    white-space: nowrap;
    height: 36px;
  }
  
  .cc-nav-link::after,
  .cc-nav-menu > li > a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 60%;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: var(--transition-base);
    opacity: 0;
  }
  
  .cc-nav-link:hover,
  .cc-nav-menu > li > a:hover {
    color: var(--text-primary);
    background: rgba(255, 47, 146, 0.1);
  }
  
  .cc-nav-link:hover::after,
  .cc-nav-menu > li > a:hover::after {
    transform: translateX(-50%) scaleX(1);
    opacity: 1;
  }
  
  .cc-nav-item.current-menu-item > .cc-nav-link,
  .cc-nav-menu > li.current-menu-item > a,
  .cc-nav-menu > li.current_page_item > a,
  .cc-nav-menu > li.current-menu-ancestor > a,
  .cc-nav-menu > li.current_page_ancestor > a,
  .cc-nav-link.active {
    color: var(--accent-primary);
    background: rgba(255, 47, 146, 0.15);
  }
  
  .cc-nav-item.current-menu-item > .cc-nav-link::after,
  .cc-nav-menu > li.current-menu-item > a::after,
  .cc-nav-menu > li.current_page_item > a::after,
  .cc-nav-menu > li.current-menu-ancestor > a::after,
  .cc-nav-menu > li.current_page_ancestor > a::after,
  .cc-nav-link.active::after {
    transform: translateX(-50%) scaleX(1);
    opacity: 1;
  }
  
  /* WordPress sub-menus (if your Primary menu has dropdowns) */
  .cc-nav-menu .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  /* =========================================================
     MOBILE MENU TOGGLE
     ========================================================= */
  
  .cc-mobile-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--header-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    position: relative;
  }
  
  .cc-mobile-toggle:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 47, 146, 0.12);
    color: var(--accent-primary);
  }
  
  .cc-mobile-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: var(--transition-base);
  }
  
  .cc-mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  
  .cc-mobile-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  
  .cc-mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }
  
  /* =========================================================
     ADMIN BAR SUPPORT
     ========================================================= */
  
  /* Account for WordPress admin bar */
  .admin-bar .cc-custom-header {
    top: 32px;
  }
  
  /* Prevent admin bar from being sticky (if it's set to sticky) */
  #wpadminbar {
    position: fixed !important;
    top: 0 !important;
  }
  
  @media screen and (max-width: 782px) {
    .admin-bar .cc-custom-header {
      top: 46px;
    }
    
    #wpadminbar {
      position: fixed !important;
      top: 0 !important;
    }
  }
  
  /* =========================================================
     MOBILE STYLES
     ========================================================= */
  
  @media (max-width: 1024px) {
    :root {
      --header-row1-height: var(--header-row1-height-mobile);
      --header-row2-height: var(--header-row2-height-mobile);
    }
  
    /* Account for admin bar on mobile */
    .admin-bar .cc-custom-header {
      top: 46px;
    }
  
    .cc-custom-header.scroll-down {
      transform: translateY(calc(-100% - 0px));
    }
  
    .admin-bar .cc-custom-header.scroll-down {
      transform: translateY(calc(-100% - 46px));
    }
  
    .cc-header__row1 {
      padding: 0 var(--spacing-md);
      gap: var(--spacing-md);
    }
  
    .cc-header__row2 {
      padding: 0 var(--spacing-md);
      /* Keep visible but collapsed - allows fixed menu to work */
      height: 0;
      overflow: visible;
      position: relative;
    }
  
    /* Hide the nav wrapper visually but keep it in DOM */
    .cc-header__row2 .cc-header__nav {
      position: static !important;
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
      overflow: visible !important; /* Ensure no clipping */
    }
    
    /* But the menu itself should be visible when active - break out completely */
    .cc-header__row2 .cc-nav-menu {
      position: fixed !important;
      visibility: visible !important;
      opacity: 1 !important;
      display: flex !important;
      left: -100% !important;
      margin-left: 0 !important;
      padding-left: 0 !important;
    }
    
    /* Ensure menu breaks out of hidden parent - remove all positioning context */
    .cc-header__row2 {
      contain: none !important;
      position: static !important;
      transform: none !important;
      overflow: visible !important; /* Ensure no clipping */
    }
    
    /* When menu is in body (moved by JS), ensure it's visible */
    body > .cc-nav-menu {
      position: fixed !important;
      z-index: 99996 !important;
    }
    
    /* When active, position from viewport, not parent */
    .cc-header__row2 .cc-nav-menu.active,
    body > .cc-nav-menu.active {
      left: 0 !important;
      margin-left: 0 !important;
    }
  
    .cc-logo-img {
      max-height: 40px;
    }
  
    .cc-header__search {
      max-width: 300px;
    }
  
    .cc-search-input {
      height: 40px;
      font-size: 13px;
    }
  
    .cc-cart-link {
      width: 40px;
      height: 40px;
    }
  
    .cc-mobile-toggle {
      display: flex;
    }
  
    /* Mobile Navigation Menu - Slider */
    .cc-nav-menu {
      /* Force viewport-relative positioning */
      position: fixed !important;
      top: var(--header-row1-height-mobile) !important;
      left: -100% !important; /* Start off-screen */
      right: auto !important;
      bottom: 0 !important;
      margin: 0 !important;
      margin-left: 0 !important;
      padding: var(--spacing-lg) !important;
      padding-left: var(--spacing-lg) !important;
      
      /* Visual styles */
      background: var(--header-bg) !important;
      flex-direction: column !important;
      align-items: stretch !important;
      overflow-y: auto !important;
      transform: none !important;
      transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
      z-index: 99996 !important;
      box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5) !important;
      gap: 0 !important;
      width: 85% !important;
      max-width: 400px !important;
      justify-content: flex-start !important;
      border-right: 1px solid var(--header-border) !important;
      -webkit-overflow-scrolling: touch !important;
      display: flex !important;
      visibility: visible !important;
      opacity: 1 !important;
      list-style: none !important;
      
      /* Break out of any parent positioning context */
      contain: none !important;
      isolation: isolate !important;
    }
  
    /* Account for admin bar on mobile */
    .admin-bar .cc-nav-menu {
      top: calc(46px + var(--header-row1-height-mobile)) !important;
    }
  
    .cc-nav-menu.active {
      left: 0 !important;
      margin-left: 0 !important;
      padding-left: var(--spacing-lg) !important;
      transform: none !important;
      /* Force viewport positioning - override any parent calculations */
      right: auto !important;
      inset-inline-start: 0 !important;
      inset-inline-end: auto !important;
    }
  
    /* Mobile menu overlay */
    .cc-mobile-menu-overlay {
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      background: rgba(0, 0, 0, 0.6) !important;
      z-index: 99995 !important;
      opacity: 0 !important;
      pointer-events: none !important;
      transition: opacity 0.4s ease !important;
    }
  
    .cc-mobile-menu-overlay.active {
      opacity: 1 !important;
      pointer-events: all !important;
    }
  
    .cc-nav-item {
      width: 100%;
      border-bottom: 1px solid rgba(255, 47, 146, 0.1);
    }
  
    .cc-nav-menu > li {
      width: 100%;
      border-bottom: 1px solid rgba(255, 47, 146, 0.1);
    }
  
    .cc-nav-item:last-child {
      border-bottom: none;
    }
  
    .cc-nav-menu > li:last-child {
      border-bottom: none;
    }
  
    .cc-nav-link {
      width: 100%;
      padding: 16px 20px;
      justify-content: space-between;
      border-radius: 0;
      text-align: left;
      height: auto;
    }
  
    .cc-nav-menu > li > a {
      width: 100%;
      padding: 16px 20px;
      justify-content: space-between;
      border-radius: 0;
      text-align: left;
      height: auto;
    }
  
    .cc-nav-link::after {
      display: none;
    }
  
    .cc-nav-menu > li > a::after {
      display: none;
    }
  }
  
  @media (max-width: 768px) {
    .cc-header__row1 {
      padding: 0 var(--spacing-sm);
      gap: var(--spacing-sm);
    }
  
    .cc-logo-img {
      max-height: 36px;
    }
  
    .cc-header__search {
      max-width: 200px;
    }
  
    .cc-search-input {
      height: 38px;
      font-size: 12px;
      padding: 0 42px 0 12px;
    }
  
    .cc-search-btn {
      width: 28px;
      height: 28px;
      right: 6px;
    }
  
    .cc-cart-link {
      width: 38px;
      height: 38px;
    }
  
    .cc-mobile-toggle {
      width: 38px;
      height: 38px;
    }
  }
  
  /* =========================================================
     ACCESSIBILITY
     ========================================================= */
  
  .cc-search-input:focus-visible,
  .cc-nav-link:focus-visible,
  .cc-cart-link:focus-visible,
  .cc-mobile-toggle:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
    border-radius: 4px;
  }
  
  /* =========================================================
     REDUCED MOTION
     ========================================================= */
  
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  
    .cc-custom-header {
      transition: none;
    }
  }
  