/*
 * ============================================================
 * NAV — Instamart-Style 2-Tier Header
 * Design tokens: DESIGN.md (Miro system adapted for ZurichShop)
 * Localization: Swedish (SE)
 * ============================================================
 */

:root {
  /* Colour tokens (from DESIGN.md) */
  --c-primary:      #1c1c1e;
  --c-on-primary:   #ffffff;
  --c-yellow:       #ffd02f;
  --c-blue:         #4262ff;
  --c-canvas:       #ffffff;
  --c-surface:      #f7f8fa;
  --c-hairline:     #e0e2e8;
  --c-hairline-str: #c7cad5;
  --c-ink:          #1c1c1e;
  --c-slate:        #555a6a;
  --c-steel:        #6b6f7e;
  --c-stone:        #8e91a0;
  --c-muted:        #a5a8b5;
  --c-success:      #00b473;
  --c-rose-light:   #fde0f0;
  --c-coral-light:  #ffc6c6;
  --c-teal-light:   #c3faf5;

  /* Spacing */
  --sp-xxs: 4px;  --sp-xs: 8px;   --sp-sm: 12px;
  --sp-md:  16px; --sp-lg: 20px;  --sp-xl: 24px;
  --sp-xxl: 32px; --sp-xxxl: 40px;

  /* Radius */
  --r-xs:   4px;  --r-sm:   6px;  --r-md:  8px;
  --r-lg:   12px; --r-xl:   16px; --r-xxl: 20px;
  --r-xxxl: 28px; --r-feat: 32px; --r-full: 9999px;

  /* Container */
  --container-max: 1280px;
  --container-pad: var(--sp-xxl);

  /* Nav Specific (Instamart) */
  --nav-border-color: #E5E7EB;
  --nav-bg-color: #FFFFFF;
  --nav-search-bg: #F3F4F6;
  --nav-cart-bg: #F1F3F5;
  --nav-accent: #0fbcb0;
  --nav-text-main: #1c1c1e;
  --nav-text-muted: #6b6f7e;
  --nav-text-stone: #8e91a0;
  --nav-height-main: 72px;
  --nav-height-cat: 56px;
}

.hidden-mobile { display: block; }
.hidden-desktop { display: none; }

/* ── LAYOUT CONTAINERS ── */
.ces-header-desktop {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg-color);
  font-family: var(--ces-font-family-base);
}

.ces-container {
  display: flex;
  align-items: center;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
  height: 100%;
}

/* ── ROW 1: PRIMARY BAR ── */
.ces-header__row-1 {
  height: var(--nav-height-main);
  border-bottom: 1px solid var(--nav-border-color);
}

.ces-header__row-1 .ces-container {
  gap: var(--sp-xl);
}

/* Brand Identity */
.ces-header__brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ces-header__logo {
  display: block;
  text-decoration: none;
  color: var(--nav-text-main);
  font-size: 24px;
}
.ces-header__logo img { height: 40px; width: auto; }

.ces-header__separator {
  border-right: 1px solid var(--nav-border-color);
  height: 32px;
  margin: 0 16px;
}

/* Location Selector */
.ces-header__location-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 4px;
}
.ces-header__location-btn svg {
  color: var(--nav-accent);
}
.ces-header__location-text {
  display: flex;
  flex-direction: column;
}
.ces-header__location-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--nav-text-main);
  line-height: 1.2;
}
.ces-header__location-subtitle {
  font-size: 12px;
  color: var(--nav-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Unified Search Bar */
.ces-header__search {
  flex: 1;
  max-width: 100%;
}
.ces-search-form {
  display: flex;
  align-items: stretch;
  height: 44px;
  background: #FFFFFF;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--nav-border-color);
  transition: border-color 0.2s;
}
.ces-search-form.is-focused {
  border-color: var(--nav-accent);
  background: var(--nav-bg-color);
}
.ces-search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 16px;
  font-size: 14px;
  color: var(--nav-text-main);
}
.ces-search-input:focus { outline: none; }
.ces-search-btn {
  background: none;
  border: none;
  padding: 0 16px;
  cursor: pointer;
  color: var(--nav-text-main);
}

/* Right Actions */
.ces-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  margin-left: auto;
}

.ces-header__account-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--nav-text-main);
  font-size: 12px;
  font-weight: 500;
}
.ces-header__account-btn:hover { color: var(--nav-accent); }

/* Cart Pill Button */
.ces-header__cart-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--nav-cart-bg);
  border-radius: 10px;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--nav-text-main);
  transition: background 0.2s;
}
.ces-header__cart-btn:hover { background: #E2E8F0; }
.ces-header__cart-text {
  display: flex;
  flex-direction: column;
}
.ces-header__cart-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.ces-header__cart-totals {
  font-size: 12px;
  color: var(--nav-text-muted);
}

/* ── ROW 2: SECONDARY NAV ── */
.ces-header__row-2 {
  height: var(--nav-height-cat);
  border-bottom: 1px solid var(--nav-border-color);
}

/* All Categories Button */
.ces-header__all-cats-wrap {
  margin-right: var(--sp-xl);
}
.ces-header__all-cats-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--nav-text-main);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Horizontal Nav Menu */
.ces-header__nav-primary {
  flex: 1;
}
.ces-header__nav-primary ul,
.ces-nav-menu {
  display: flex;
  align-items: center;
  gap: 16px; /* standard spacing */
  list-style: none;
  margin: 0;
  padding: 0;
}
.ces-header__nav-primary ul > li > a,
.ces-nav-menu > li > a {
  text-decoration: none;
  color: var(--nav-text-main);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ces-header__nav-primary > div > ul > li > a:hover,
.ces-nav-menu > li > a:hover {
  color: var(--nav-accent);
}

/* Mega Menu Dropdown Styles */
.ces-mega-menu,
.ces-header__nav-primary .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #FFFFFF;
  border: 1px solid var(--nav-border-color);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
  padding: 24px;
  min-width: 250px;
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 1000;
  flex-direction: column; /* override flex row from ul */
  gap: 0;
}
.ces-has-dropdown:hover > .ces-mega-menu,
.menu-item-has-children:hover > .sub-menu,
.page_item_has_children:hover > .children {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.ces-dropdown-menu,
.ces-header__nav-primary .sub-menu,
.ces-header__nav-primary .children {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ces-dropdown-menu a,
.ces-header__nav-primary .sub-menu a,
.ces-header__nav-primary .children a {
  display: block;
  padding: 8px 12px;
  color: var(--nav-text-muted);
  text-decoration: none;
  font-size: 14px;
}
.ces-dropdown-menu a:hover,
.ces-header__nav-primary .sub-menu a:hover,
.ces-header__nav-primary .children a:hover {
  color: var(--nav-text-main);
  background: var(--nav-search-bg);
  border-radius: 6px;
}

/* ── MOBILE & TABLET STYLES (< 1024px) ── */
@media (max-width: 1023px) {
  .hidden-mobile { display: none; }
  .hidden-desktop { display: block; }
  
  .ces-header-mobile {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg-color);
    border-bottom: 1px solid var(--nav-border-color);
  }
  
  /* Mobile Top Row */
  .ces-header-mobile__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }
  
  .ces-header__hamburger {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--nav-text-main);
  }
  
  .ces-header__logo-mobile {
    font-size: 20px;
    text-decoration: none;
    color: var(--nav-text-main);
  }
  .ces-header__logo-mobile img {
    height: 32px;
  }
  
  .ces-header__cart-btn-mobile {
    position: relative;
    color: var(--nav-text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 4px;
  }
  .ces-cart-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--nav-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  /* Mobile Bottom Row */
  .ces-header-mobile__bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 12px;
  }
  
  .ces-header__location-btn-mobile {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--nav-text-main);
    padding: 0;
    flex-shrink: 0;
  }
  .ces-header__location-btn-mobile svg { color: var(--nav-accent); }
  
  .ces-search-form-mobile {
    flex: 1;
    background: #FFFFFF;
    border: 1px solid var(--nav-border-color);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
  }
  .ces-search-input-mobile {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
  }
  .ces-search-input-mobile:focus { outline: none; }
}

/* ── OFF-CANVAS MOBILE DRAWER ── */
.ces-mobile-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: 85%;
  max-width: 360px;
  background: var(--nav-bg-color);
  z-index: 1100;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}
.ces-mobile-drawer.is-open {
  transform: translateX(0);
}

.ces-mobile-drawer__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.ces-mobile-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--nav-border-color);
}
.ces-mobile-drawer__title {
  font-weight: 700;
  font-size: 18px;
}
.ces-mobile-drawer__close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
}

.ces-mobile-drawer__account-loc {
  padding: 16px;
  border-bottom: 8px solid var(--nav-search-bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ces-mobile-drawer__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--nav-text-main);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.ces-mobile-drawer__btn svg { color: var(--nav-accent); }

.ces-mobile-drawer__nav {
  padding: 16px;
  flex: 1;
}
.ces-mobile-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ces-mobile-nav-list a {
  display: block;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--nav-text-main);
  text-decoration: none;
  border-bottom: 1px solid var(--nav-border-color);
}

.ces-mobile-drawer__footer {
  padding: 16px;
  background: var(--nav-search-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ces-mobile-drawer__footer a {
  font-size: 14px;
  color: var(--nav-text-muted);
  text-decoration: none;
}

.ces-mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.ces-mobile-drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
