/* Qulay Makon — Header (AliExpress style ko'k versiyasi)
 * Spek: header_aliexpress_blue_prompt.md
 * Yangilanish (header_restructure_prompt): top-bar olib tashlandi,
 * kontaktlar va til switcher subheader o'ngiga ko'chirildi.
 * Tartib: tokens.css → main.css → components.css → header.css (oxirgi, override)
 */


.alibar {
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 0;
  border-bottom: 1px solid #E5E7EB;
}

.alibar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Logo */
.alibar__logo {
  color: #0a0a0a;
  text-decoration: none;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.alibar__logo span { font-weight: 400; }

/* Logo rasmi (site_settings.logo dan) */
.alibar__logo {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.alibar__logo-img {
  display: block;
  height: 56px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  transition: opacity 0.2s ease;
}
/* Default holat — logo har doim ko'rinadi (oq fonda yoki yagona logo bo'lsa). */
.alibar__logo-img--default { opacity: 1; }
/* Scrolled holat (faqat IKKALA logo yuklangan bo'lsa kerak):
   `--scrolled` versiyasi default tepasiga absolyut joylashadi. */
.alibar__logo-img--scrolled {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
}
/* Body scroll qilinganda `--default` yashirinadi, `--scrolled` ko'rinadi. */
body.is-scrolled .alibar__logo-img--default { opacity: 0; }
body.is-scrolled .alibar__logo-img--scrolled { opacity: 1; }

/* Kichik ikonkalar (kategoriyalar, profile-mini) */
.alibar__mini {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: #1F2937;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
}
.alibar__mini:hover { background: rgba(0, 0, 0, 0.06); }
.alibar__mini svg { display: block; }

/* Katalog — alohida yumaloq kulrang pill tugma */
.alibar__catalog {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #F1F3F5;
  color: #1F2937;
  text-decoration: none;
  border: 1px solid #E5E7EB;
  padding: 0 18px;
  height: 48px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  white-space: nowrap;
}
.alibar__catalog:hover {
  background: #E9ECEF;
  border-color: #D1D5DB;
  color: #1F2937;
}
.alibar__catalog svg { display: block; flex-shrink: 0; }

/* Search — yumaloq oq pill konteyner. Qidirish tugmasi ichkarida
   alohida kulrang pill (Katalog bilan vizual mos), 4px breath bilan. */
.alibar__search {
  flex: 1;
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 999px;
  padding: 4px;
  padding-left: 20px;
  height: 48px;
  min-width: 0;
}
.alibar__search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  height: 100%;
  min-width: 0;
  padding: 0 12px 0 0;
  color: var(--color-text);
  font-family: inherit;
  /* WebKit type=search default rectangle decoration olib tashlash */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}
.alibar__search input::placeholder { color: var(--color-text-muted); }
/* type=search default ichki tugmalarni o'chirish */
.alibar__search input::-webkit-search-decoration,
.alibar__search input::-webkit-search-cancel-button,
.alibar__search input::-webkit-search-results-button,
.alibar__search input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  display: none;
}

/* "Qidirish" tugmasi — Katalog bilan vizual mos kulrang yumaloq pill */
.alibar__search-btn {
  background: #F1F3F5;
  color: #1F2937;
  border: 1px solid #E5E7EB;
  height: 38px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.alibar__search-btn:hover {
  background: #E9ECEF;
  border-color: #D1D5DB;
}

/* === User dropdown menu === */
.alibar__user {
  position: relative;
  flex-shrink: 0;
}
.alibar__action--btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 1000;
}
.user-menu-dropdown[hidden] { display: none; }
.user-menu-dropdown__form {
  margin: 0;
  border-top: 1px solid #F1F3F5;
  margin-top: 4px;
  padding-top: 4px;
}
.user-menu-dropdown__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #1F2937;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.user-menu-dropdown__link:hover {
  background: #F1F3F5;
  color: #1F2937;
}
.user-menu-dropdown__link--accent {
  color: #023E8A;
  font-weight: 600;
}
.user-menu-dropdown__link--logout {
  color: #DC2626;
}
.user-menu-dropdown__link--logout:hover {
  background: #FEE2E2;
  color: #B91C1C;
}
.user-menu-dropdown__link svg {
  flex-shrink: 0;
}

/* === Dropdown linklarini header rang override'idan himoya qilish ===
   `body.layout-body.is-scrolled .alibar a { color: #FFFFFF !important }`
   qoidasi dropdown ichidagi linklarni ham oqqa aylantirib qo'yardi —
   oq fonda oq matn → linklar ko'rinmasdi. Endi yuqori specificity bilan
   o'z ranglari saqlanadi. */
body .user-menu-dropdown a.user-menu-dropdown__link,
body.layout-body .alibar a.user-menu-dropdown__link,
body.layout-body.is-scrolled .alibar a.user-menu-dropdown__link {
  color: #1F2937 !important;
}
body .user-menu-dropdown a.user-menu-dropdown__link--accent,
body.layout-body .alibar a.user-menu-dropdown__link--accent,
body.layout-body.is-scrolled .alibar a.user-menu-dropdown__link--accent {
  color: #023E8A !important;
}
body .user-menu-dropdown .user-menu-dropdown__link--logout,
body.layout-body .alibar .user-menu-dropdown__link--logout,
body.layout-body.is-scrolled .alibar .user-menu-dropdown__link--logout {
  color: #DC2626 !important;
}
body .user-menu-dropdown a.user-menu-dropdown__link:hover {
  color: #1F2937 !important;
  background: #F1F3F5 !important;
}

/* O'ng action'lar (rasm tepada + matn pastida) */
.alibar__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #1F2937;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  min-width: 64px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.alibar__action:hover { background: rgba(0, 0, 0, 0.06); color: #0a0a0a; }
.alibar__action svg { display: block; }

/* Responsive (Faza 5'da to'liq, hozir kichik fallback) */
@media (max-width: 1024px) {
  .alibar__catalog span { display: none; }
  .alibar__catalog { padding: 0 14px; }
  .alibar__action span { display: none; }
  .alibar__action { min-width: 44px; padding: 6px 8px; }
}
@media (max-width: 768px) {
  .alibar { padding: 8px 0; }
  .alibar__logo { font-size: 22px; }
  .alibar__mini,
  .alibar__catalog { display: none; }
  .alibar__search { height: 40px; padding: 0; }
  .alibar__search input { padding: 0 14px; }
  .alibar__search-btn { padding: 0 18px; height: 100%; font-size: 14px; }
}

/* ════════════════════════════════════════════
   HEADER SCROLL ANIMATION
   - Top of page: white bg, dark text
   - Scrolled (>80px): blue bg, white text (default .alibar)
   - Hysteresis 80px on / 60px off — JS body.is-scrolled toggle
   ════════════════════════════════════════════ */

.alibar {
  transition:
    background-color 250ms ease,
    border-bottom-color 250ms ease,
    box-shadow 250ms ease;
}
.alibar__logo,
.alibar__logo span,
.alibar__catalog,
.alibar__action,
.alibar__mini,
.alibar__search {
  transition:
    background-color 250ms ease,
    color 250ms ease,
    border-color 250ms ease;
}

/* TOP HOLAT — body.is-scrolled YO'Q
   Border yo'q (zamonaviy e-commerce pattern: Ozon/Shopify/Etsy).
   Faqat search input bg orqali ajraladi (Amazon/Wildberries pattern). */
body:not(.is-scrolled) .alibar {
  background: #FFFFFF;
  border-bottom: none;
}

body:not(.is-scrolled) .alibar__logo,
body:not(.is-scrolled) .alibar__logo span {
  color: var(--color-text);
}

/* Top holat (header oq fon) — Katalog ham kulrang pill bo'lib qoladi */
body:not(.is-scrolled) .alibar__catalog {
  background: #F1F3F5;
  color: #1F2937;
  border-color: #E5E7EB;
}
body:not(.is-scrolled) .alibar__catalog:hover {
  background: #E9ECEF;
  border-color: #D1D5DB;
}

/* Search — top holatda ham oq fon, ichida kulrang Qidirish pill ajralib turadi */
body:not(.is-scrolled) .alibar__search {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    box-shadow 200ms ease;
}
body:not(.is-scrolled) .alibar__search:hover {
  border-color: #D1D5DB;
}
body:not(.is-scrolled) .alibar__search:focus-within {
  background: #FFFFFF;
  border-color: #9CA3AF;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
body:not(.is-scrolled) .alibar__search input {
  color: var(--color-text);
}

/* === Input'ni wrapper bilan to'liq bir butun qilish (box-in-box bug fix) ===
   Input ichida hech qanday ko'rinarli border/outline/halo bo'lmasligi kerak.
   Bu universal qoida — har qanday holatda (focus, top, scrolled). */
.alibar__search input,
.alibar__search input:focus,
.alibar__search input:focus-visible,
.alibar__search input:active {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  -webkit-box-shadow: none !important;
}
.alibar__msearch-input,
.alibar__msearch-input:focus,
.alibar__msearch-input:focus-visible,
.alibar__msearch-input:active {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

body:not(.is-scrolled) .alibar__action {
  color: var(--color-text);
}
body:not(.is-scrolled) .alibar__action:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

body:not(.is-scrolled) .alibar__mini {
  color: var(--color-text);
}
body:not(.is-scrolled) .alibar__mini:hover {
  background: var(--color-primary-light);
}

/* SCROLLED HOLAT — yumshoq soya (border o'rniga) */
body.is-scrolled .alibar {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid #E5E7EB;
}

/* Reduced motion — animatsiyani o'chirish */
@media (prefers-reduced-motion: reduce) {
  .alibar,
  .alibar *,
  .site-header-shell,
  .site-header-shell * {
    transition: none !important;
  }
}


/* ════════════════════════════════════════════════
   SUBHEADER — asosiy navigatsiya
   ════════════════════════════════════════════════ */

.subheader {
  background: #F8F9FA;
  border-top: none;
  border-bottom: 2px solid #FFD23F;
  position: relative;
  z-index: 99;
  transition: background-color 250ms ease;
}

.subheader__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  gap: 24px;
}

/* === Chap: asosiy menyu === */
.mainnav {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
  flex: 0 1 auto;
}

.mainnav__item { margin: 0; padding: 0; }

.mainnav__link {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  color: #1F2937;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, border-bottom-color 150ms ease, background 150ms ease;
}

.mainnav__link:hover {
  color: #023E8A;
  background: rgba(0, 0, 0, 0.04);
}

.mainnav__link--active {
  color: #023E8A;
  font-weight: 700;
}


/* === O'NG: kontaktlar + til (avval top-bar'da edi) === */
.subheader__right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.subheader__contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4B5563;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 0;
  transition: color 150ms ease;
}
.subheader__contact:hover { color: #023E8A; }
.subheader__contact svg {
  flex-shrink: 0;
  opacity: 0.85;
}
.subheader__contact:hover svg { opacity: 1; }

/* Ish vaqti + Online 24/7 — kontaktlar bilan bir qatorda */
.subheader__info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4B5563;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 0;
  cursor: default;
}
.subheader__info svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.subheader__online {
  color: #023E8A;
  font-weight: 600;
}
.subheader__online svg { opacity: 1; }


/* === Til switcher (subheader ichida, oq fonli trigger) === */
.subheader-lang { position: relative; }

.subheader-lang__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  color: #1F2937;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.subheader-lang__trigger:hover {
  background: #F8F9FA;
  border-color: #C0C4C9;
}
.subheader-lang__flag {
  font-size: 14px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
}
.subheader-lang__flag .lang-flag-img {
  width: 18px;
  height: 12px;
  display: block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  object-fit: cover;
}
.subheader-lang__code { font-weight: 600; letter-spacing: 0.5px; }
.subheader-lang__chevron {
  opacity: 0.85;
  transition: transform 200ms ease;
}
.subheader-lang__trigger[aria-expanded="true"] .subheader-lang__chevron {
  transform: rotate(180deg);
}

.subheader-lang__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(2, 62, 138, 0.15);
  min-width: 220px;
  z-index: 1000;
}
.subheader-lang__menu[hidden] { display: none; }
.subheader-lang__item { margin: 0; padding: 0; }
.subheader-lang__item form { margin: 0; }

.subheader-lang__option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  text-align: left;
  font-family: inherit;
  transition: background 100ms ease;
}
.subheader-lang__option:hover { background: var(--color-primary-light); }
.subheader-lang__item--active .subheader-lang__option {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}
.subheader-lang__option-flag {
  font-size: 18px;
  line-height: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.subheader-lang__option-flag .lang-flag-img {
  width: 22px;
  height: 15px;
  display: block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  object-fit: cover;
}
.subheader-lang__option-code {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 13px;
  min-width: 22px;
}
.subheader-lang__option-sep {
  color: var(--color-text-muted);
  font-weight: 300;
}
.subheader-lang__option-name { flex: 1; }
.subheader-lang__option-check {
  margin-left: auto;
  color: var(--color-primary);
}


/* header_restructure: scroll'da rang o'zgarishi olib tashlandi —
   header (alibar) va subheader doim bir xil ko'k rangda qoladi. */
/* body.is-scrolled .subheader {
  background-color: var(--color-primary-hover);
} */


/* === Responsive === */
@media (max-width: 1280px) {
  /* Joy yetishmasa — ish vaqti yashiriladi (24/7 muhim, qoldiriladi) */
  .subheader__hours { display: none; }
}
@media (max-width: 1024px) {
  .subheader__contact--email .subheader__contact-text { display: none; }
  .subheader__right { gap: 12px; }
  .mainnav__link { padding: 0 14px; font-size: 13px; }
  /* 1024px ostida 24/7 ham yashiriladi — sticky CTA o'rnida */
  .subheader__online { display: none; }
}

@media (max-width: 768px) {
  .subheader__inner {
    height: auto;
    flex-direction: column;
    gap: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* mainnav mobil'da yashiriladi (mobile-polish.css) — hamburger menyuda ham bor */
  .mainnav { display: none; }

  .subheader__right {
    width: 100%;
    justify-content: space-between;
    height: 40px;
    padding: 0 4px;
  }

  .subheader__contact { font-size: 12px; }
  .subheader-lang__menu { right: 0; min-width: 200px; }
}

@media (max-width: 480px) {
  /* Eng kichik — email butunlay yashiriladi (faqat telefon va til qoladi) */
  .subheader__contact--email { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .subheader,
  .mainnav__link,
  .subheader-lang__chevron,
  .subheader-lang__trigger,
  .subheader__contact {
    transition: none !important;
  }
}
