/* header.css — mobile-first (≈90% of traffic is mobile).
   Base rules target small screens; desktop refinements are added
   inside the min-width query near the bottom. Tokens come from base.css. */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 253, 250, 0.97);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0);
  transition: box-shadow 0.2s ease;
}
.site-header.is-compact { box-shadow: 0 6px 18px rgba(74, 41, 21, 0.08); }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  min-height: 56px;
}

/* Hamburger — animated 3-line icon, 44px touch target */
.menu-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.menu-toggle span { width: 19px; height: 2px; border-radius: 2px; background: var(--brand-strong); transition: transform 0.2s ease, opacity 0.2s ease; }
.menu-toggle:hover { background: var(--surface-soft); border-color: var(--gold); }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.brand {
  text-decoration: none;
  color: var(--brand-strong);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  justify-self: center;
}
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 9px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; overflow: hidden; }
.brand-text strong { font-size: 14.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text em { font-style: normal; font-size: 10.5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 359px) {
  .brand-text em { display: none; }
  .topbar-actions { gap: 4px; }
  .icon-btn { padding: 0 9px; }
}

/* Desktop inline search — hidden on mobile, shown from the tablet breakpoint up */
.search-form { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 6px; justify-self: end; }

.icon-btn {
  text-decoration: none;
  color: var(--brand-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 11px;
  font-weight: 700;
  font-size: 13px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
button.icon-btn { border: 1px solid var(--line); }

.cart-count {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  position: absolute;
  top: -4px;
  left: -4px;
}

.user-label { display: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mobile collapsible search row */
.mobile-search-row {
  overflow: hidden;
  max-height: 0;
  border-top: 1px solid transparent;
  transition: max-height 0.22s ease, border-color 0.22s ease;
}
.mobile-search-row.open { max-height: 78px; border-top-color: var(--line); }
body.search-open { --search-h: 78px; }
.mobile-search-row[hidden] { display: none; }
.mobile-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
}
.mobile-search-form .search-icon { color: var(--muted); flex-shrink: 0; }
.mobile-search-form input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  padding: 11px 4px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.mobile-search-form button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
}

/* Primary nav row — desktop only (mobile relies on the side drawer) */
.nav-links { display: none; }

/* ============ Unified Side Drawer ============ */
.side-menu {
  position: fixed;
  inset: 0;
  background: rgba(20, 13, 8, 0.45);
  z-index: 999;
  display: flex;
  justify-content: flex-start; /* drawer docks to the right in RTL */
  opacity: 0;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(3px);
}
.side-menu.open { opacity: 1; }
.side-menu[hidden] { display: none; }

.side-menu-panel {
  width: min(340px, 86vw);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: max(16px, env(safe-area-inset-top)) 16px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.side-menu.open .side-menu-panel { transform: translateX(0); }

.menu-close {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 20px;
  line-height: 1;
  color: var(--brand-strong);
  cursor: pointer;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.side-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; background: var(--surface-soft); }
.side-brand div { display: flex; flex-direction: column; gap: 2px; }
.side-brand strong { font-size: 14.5px; color: var(--brand-strong); }
.side-brand span { font-size: 11.5px; color: var(--muted); }

.side-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(135deg, var(--surface-soft), var(--beige));
  border: 1px solid var(--gold-r);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  min-height: 44px;
}
.side-user-card svg { color: var(--brand-strong); flex-shrink: 0; }
.side-user-card div { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.side-user-card strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-card span { font-size: 11px; color: var(--muted); }
.side-user-card .chev { color: var(--muted); flex-shrink: 0; }

.side-nav-group { display: flex; flex-direction: column; gap: 2px; }
.side-group-title { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 0 4px 4px; }
.side-nav-group a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 12px;
  min-height: 44px;
  border-radius: 12px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.side-nav-group a svg { color: var(--brand-strong); flex-shrink: 0; }
.side-nav-group a:active { background: var(--surface-soft); }
.side-nav-group a:hover { background: var(--surface-soft); transform: translateX(2px); }
.side-nav-group a.active { background: linear-gradient(135deg, var(--beige), var(--honey)); color: var(--brand-strong); }

.side-badge {
  margin-inline-start: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.side-whatsapp {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  background: #25d366;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 14px;
  min-height: 48px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.side-whatsapp img { width: 22px; height: 22px; border-radius: 50%; }

/* ===================== Tablet / Desktop ===================== */
@media (min-width: 700px) {
  .topbar { grid-template-columns: auto auto 1fr auto; padding: 12px 0; }
  .brand { justify-self: start; }
  .brand-logo { width: 42px; height: 42px; }
  .brand-text strong { font-size: 16px; }
  .brand-text em { font-size: 11.5px; }

  .search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 6px 0 14px;
  }
  .search-icon { color: var(--muted); flex-shrink: 0; }
  .search-form input {
    min-width: 0;
    flex: 1;
    border: none;
    outline: none;
    padding: 11px 6px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
  }
  .search-form button {
    border: none;
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: #fff;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
  }

  .search-toggle { display: none; }
  .mobile-search-row { display: none !important; }
  .user-label { display: inline; }

  .nav-links {
    display: flex;
    gap: 22px;
    padding: 0 0 12px;
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 10px;
  }
  .nav-links a { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; position: relative; padding: 2px 0; }
  .nav-links a::after {
    content: "";
    position: absolute;
    right: 0; left: 0; bottom: -3px;
    height: 2px;
    background: var(--brand);
    transform: scaleX(0);
    transition: transform 0.18s ease;
  }
  .nav-links a.active,
  .nav-links a:hover { color: var(--brand-strong); }
  .nav-links a.active::after,
  .nav-links a:hover::after { transform: scaleX(1); }
}
