/* =====================================================================
   OneSource — Header v2  (top utility bar + main header)
   Load AFTER ecom.css so it wins over the legacy .ecom-header rules.
   Prefix: .ec-*  (avoids every existing .ecom-* collision)
   ===================================================================== */

/* ── kill legacy header/branchbar leftovers when v2 is present ─────── */
.ec-header + .ecom-branchbar { display: none; }

/* ═══════════════ TOP UTILITY BAR ═══════════════ */
.ec-topbar {
  background: var(--ec-navy-deep);
  color: #fff;
  font-size: 12.5px;
}
.ec-topbar__inner {
  max-width: var(--ecom-container);
  margin-inline: auto;
  padding: 0 24px;
  min-height: var(--ec-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.ec-topbar__note { display: flex; align-items: center; gap: 8px; opacity: .95; }
.ec-topbar__note i { font-size: 13px; }

.ec-topnav { display: flex; align-items: center; gap: 4px; }
.ec-topnav__link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--ecom-radius-pill);
  color: #fff; font-size: 12px; font-weight: var(--ecom-fw-medium);
  letter-spacing: .04em; background: none; border: 0; cursor: pointer;
  font-family: inherit; transition: background .18s ease, color .18s ease;
}
.ec-topnav__link:hover,
.ec-topnav__link.is-active { background: rgba(255,255,255,.14); }
.ec-topnav__toggle i { font-size: 10px; }

.ec-topnav__drop { position: relative; }
.ec-topnav__panel {
  position: absolute; inset-inline-start: 0; top: calc(100% + 6px); z-index: 90;
  min-width: 250px; padding: 8px;
  background: #fff; border: 1px solid var(--ec-line);
  border-radius: 12px; box-shadow: var(--ecom-shadow-lg);
  max-height: 60vh; overflow-y: auto;
}
.ec-topnav__panel--sm { min-width: 210px; }
.ec-topnav__panel a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--ec-body); font-size: 13px; font-weight: var(--ecom-fw-medium);
  letter-spacing: 0; white-space: nowrap;
}
.ec-topnav__panel a i { width: 18px; text-align: center; color: var(--ec-navy); font-size: 14px; }
.ec-topnav__panel a:hover { background: var(--ec-navy-soft); color: var(--ec-navy); }
.ec-topnav__panel-all {
  margin-top: 4px; border-top: 1px solid var(--ec-line);
  color: var(--ec-coral) !important; justify-content: space-between;
}
.ec-topnav__panel-all i { color: var(--ec-coral) !important; }

/* ═══════════════ MAIN HEADER ═══════════════ */
.ec-header {
  position: sticky; top: 0; z-index: 80;
  background: #fff;
  border-bottom: 1px solid var(--ec-line);
  box-shadow: var(--ec-shadow-soft);
}
.ec-header__inner {
  max-width: var(--ecom-container);
  margin-inline: auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 18px;
}

.ec-logo img { height: 49px; width: auto; object-fit: contain; }

/* ── Shopping Categories pill ── */
.ec-catdrop { position: relative; flex: 0 0 auto; }
.ec-catdrop__btn {
  display: inline-flex; align-items: center; gap: 9px;
  margin-left: 100px;
  height: 40px; padding: 0 18px;
  background: var(--ec-navy); color: #fff;
  border: 0; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: var(--ecom-fw-medium);
  white-space: nowrap; transition: background .18s ease;
}
.ec-catdrop__btn:hover { background: var(--ec-navy-dark); }
.ec-catdrop__caret { font-size: 11px; transition: transform .2s ease; }
.ec-catdrop__caret.is-open { transform: rotate(180deg); }
.ec-catdrop__panel {
  position: absolute; inset-inline-start: 0; top: calc(100% + 8px); z-index: 90;
  min-width: 260px; padding: 8px;
  margin-left: 100px;
  background: #fff; border: 1px solid var(--ec-line);
  border-radius: 12px; box-shadow: var(--ecom-shadow-lg);
  max-height: 65vh; overflow-y: auto;
}
.ec-catdrop__panel a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--ec-body); font-weight: var(--ecom-fw-medium);
}
.ec-catdrop__panel a i { width: 18px; text-align: center; color: var(--ec-navy); }
.ec-catdrop__panel a:hover { background: var(--ec-navy-soft); color: var(--ec-navy); }

/* ── Search ── */
.ec-search {
  flex: 0 1 480px; min-width: 0;   /* design width — no longer stretches */
  margin-inline-end: auto;
  display: flex; align-items: center;
  height: 44px; padding: 4px 4px 4px 6px;
  background: var(--ec-navy-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: border-color .18s ease, background .18s ease;
}
.ec-search:focus-within { background: #fff; border-color: var(--ec-navy); }
.ec-search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  padding-inline: 10px;
  font-family: inherit; font-size: 13.5px; color: var(--ec-ink);
}
.ec-search input::placeholder { color: var(--ec-muted); }
.ec-search__btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 22px;
  background: var(--ec-coral); color: #fff;
  border: 0; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: var(--ecom-fw-medium);
  white-space: nowrap; transition: background .18s ease;
}
.ec-search__btn:hover { background: var(--ec-coral-dark); }

/* ── Right cluster ── */
.ec-header__right { display: flex; align-items: center; gap: 14px; margin-inline-start: auto; }

.ec-iconbtn {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer;
  border-radius: 50%;
  color: var(--ec-navy); font-size: 20px;
  transition: background .18s ease, color .18s ease;
}
.ec-iconbtn:hover { background: var(--ec-navy-soft); color: var(--ec-navy-dark); }

.ec-cart__badge {
  position: absolute; top: 2px; inset-inline-end: 0;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--ec-coral); color: #fff;
  border-radius: var(--ecom-radius-pill);
  font-size: 10px; font-weight: var(--ecom-fw-bold); line-height: 1;
  animation: ecBadgePop .28s ease;
}
/* [hidden] alone loses to display:grid — force it */
.ec-cart__badge[hidden] { display: none !important; }

@keyframes ecBadgePop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .ec-cart__badge { animation: none; }
}

/* ── City / branch widget ── */
.ec-city { position: relative; }
.ec-city__btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: 0; cursor: pointer; font-family: inherit;
  padding: 2px 4px; text-align: start;
}
.ec-city__label {
  font-size: 11px; color: var(--ec-muted); line-height: 1.2;
  white-space: nowrap;
}
.ec-city__value {
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: var(--ecom-fw-bold);
  color: var(--ec-navy); text-decoration: underline; text-underline-offset: 3px;
}
.ec-city__panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 10px); z-index: 90;
  width: 300px; max-width: calc(100vw - 40px); padding: 14px;
  background: #fff; border: 1px solid var(--ec-line);
  border-radius: 12px; box-shadow: var(--ecom-shadow-lg);
}
.ec-city__panel select {
  display: block; box-sizing: border-box;
  width: 100%; max-width: 100%; height: 40px; padding: 0 12px;
  text-overflow: ellipsis;
  border: 1.5px solid var(--ec-line); border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ec-ink);
  background: #fff; outline: 0;
}
.ec-city__panel select:focus { border-color: var(--ec-navy); }
.ec-city__note { margin: 8px 0 0; font-size: 11.5px; color: var(--ec-muted); line-height: 1.5; }

/* ── Account menu ── */
.ec-account { position: relative; }

/* logged-in avatar (initials + online dot) */
.ec-avatar {
  position: relative;
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  background: var(--ec-navy); color: #fff;
  border: 0; border-radius: 50%; cursor: pointer;
  font-family: inherit; transition: background .18s ease, box-shadow .18s ease;
}
.ec-avatar:hover { background: var(--ec-navy-dark); box-shadow: 0 0 0 3px var(--ec-navy-soft); }
.ec-avatar__initials { font-size: 13px; font-weight: var(--ecom-fw-bold); letter-spacing: .02em; line-height: 1; }
.ec-avatar__dot {
  position: absolute; bottom: 1px; inset-inline-end: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #22C55E; border: 2px solid #fff;
}
.ec-avatar--sm { width: 34px; height: 34px; flex: 0 0 34px; cursor: default; }
.ec-avatar--sm .ec-avatar__initials { font-size: 11.5px; }

.ec-account__panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 10px); z-index: 90;
  min-width: 240px; padding: 8px;
  background: #fff; border: 1px solid var(--ec-line);
  border-radius: 12px; box-shadow: var(--ecom-shadow-lg);
}
.ec-account__who {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--ec-line);
}
.ec-account__whotext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ec-account__whotext strong {
  font-size: 13px; font-weight: var(--ecom-fw-bold); color: var(--ec-navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ec-account__whotext em {
  font-style: normal; font-size: 11px; color: #16A34A; font-weight: var(--ecom-fw-medium);
  display: inline-flex; align-items: center; gap: 5px;
}
.ec-account__whotext em::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: #22C55E;
}
.ec-account__panel a,
.ec-account__logout {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 8px;
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: var(--ecom-fw-medium);
  color: var(--ec-body); text-align: start;
}
.ec-account__panel a i,
.ec-account__logout i { width: 18px; text-align: center; color: var(--ec-navy); }
.ec-account__panel a:hover { background: var(--ec-navy-soft); color: var(--ec-navy); }
.ec-account__logout { color: var(--ecom-danger); }
.ec-account__logout i { color: var(--ecom-danger); }
.ec-account__logout:hover { background: #FDECEC; }

/* ── Mobile search row ── */
.ec-search-mobile { display: none; padding: 0 20px 14px; }
.ec-search-mobile form {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 4px 4px 4px 6px;
  background: var(--ec-navy-soft); border-radius: 10px;
}
.ec-search-mobile input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding-inline: 10px; font-family: inherit; font-size: 13.5px;
}
.ec-search-mobile .ec-search__btn { padding: 0 16px; }

/* ── Drawer ── */
.ec-drawer { position: fixed; inset: 0; z-index: 200; background: rgba(16,27,92,.45); }
.ec-drawer__panel {
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: min(320px, 86vw); padding: 18px;
  background: #fff; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .28s ease;
}
.ec-drawer__panel.is-closed { transform: translateX(100%); }
.ec-drawer__panel.is-open   { transform: translateX(0); }
[dir="rtl"] .ec-drawer__panel.is-closed { transform: translateX(-100%); }

.ec-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; margin-bottom: 8px;
  border-bottom: 1px solid var(--ec-line);
  font-size: 15px; font-weight: var(--ecom-fw-bold); color: var(--ec-navy);
}
.ec-drawer__head button { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ec-body); }
.ec-drawer__panel > a,
.ec-drawer__lang {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px; border-radius: 10px;
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: var(--ecom-fw-medium);
  color: var(--ec-body); text-align: start;
}
.ec-drawer__panel > a i,
.ec-drawer__lang i { width: 20px; text-align: center; color: var(--ec-navy); font-size: 16px; }
.ec-drawer__panel > a:hover { background: var(--ec-navy-soft); color: var(--ec-navy); }
.ec-drawer__sep { height: 1px; background: var(--ec-line); margin: 10px 0; }

/* ═══════════════ RESPONSIVE ═══════════════ */
.ec-only-mobile { display: none; }

@media (max-width: 1280px) {
  .ec-search { flex-basis: 380px; }
}

@media (max-width: 1200px) {
  .ec-catdrop__btn span { display: none; }
  .ec-catdrop__btn { padding: 0 14px; }
  .ec-header__inner { gap: 14px; }
  .ec-search { flex-basis: 320px; }
}

@media (max-width: 1024px) {
  .ec-topbar__note span { display: none; }
  .ec-topnav__link { padding: 6px 10px; }
  .ec-city { display: none; }
}

@media (max-width: 860px) {
  .ec-topbar { display: none; }
  .ec-search { display: none; }
  .ec-search-mobile { display: block; }
  .ec-only-mobile { display: grid; }
  .ec-catdrop { display: none; }
  .ec-header__inner { padding: 12px 20px; gap: 10px; }
  .ec-logo img { height: 38px; }
  .ec-header__right { gap: 6px; }
}
