/* =============================================================================
   XARITA QATLAMLARI PANELI USLUBLARI (layers-panel.css) — spec 12
   Fayl: platform/platform-core/public/layers-panel.css

   Bo'limlar:
     1. Rang o'zgaruvchilari (kunduzgi + tungi rejim)
     2. Tugma (o'ng tomonda, 48x48 / telefonda 44x44)
     3. Panel qobig'i (sarlavha, ro'yxat, pastki tugmalar)
     4. Guruh va qatorlar (kamera, checkbox)
     5. Moslashuv, harakatni kamaytirish, kuchaytirilgan kontrast

   TUGMALAR: barchasi kamida 44x44px (barmoq uchun).
   ============================================================================= */

/* --------------------------------------------------------------------------
   1. RANG O'ZGARUVCHILARI
   -------------------------------------------------------------------------- */

.mbx-layers-panel,
.mbx-layers-btn {
  --lp-bg: #FFFFFF;
  --lp-fg: #17181C;
  --lp-sub: #5E646E;
  --lp-line: #E7EAF0;
  --lp-soft: #F7F8FA;
  --lp-soft-2: #F4F6F8;
  --lp-hover: #FFF8E1;
  --lp-check: #C6CAD2;
  --lp-on: #FFD21F;
  --lp-on-line: #F2C400;
  --lp-shadow: 0 14px 40px rgba(15, 23, 42, 0.22);
}

/* Tungi rejim: klass, html.mbx-dark yoki [data-theme="dark"] orqali */
.mbx-layers-panel.is-dark,
.mbx-layers-btn.is-dark,
html.mbx-dark .mbx-layers-panel,
html.mbx-dark .mbx-layers-btn,
[data-theme="dark"] .mbx-layers-panel,
[data-theme="dark"] .mbx-layers-btn {
  --lp-bg: #15171C;
  --lp-fg: #F2F4F7;
  --lp-sub: #A9B0BB;
  --lp-line: #2A2D33;
  --lp-soft: #1E2127;
  --lp-soft-2: #22252B;
  --lp-hover: #2A2E36;
  --lp-check: #4A4F58;
  --lp-on: #FFD21F;
  --lp-on-line: #F2C400;
  --lp-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

/* Tizim tungi rejimi (html.mbx-light bilan o'chirish mumkin) */
@media (prefers-color-scheme: dark) {
  html:not(.mbx-light):not([data-theme="light"]) .mbx-layers-panel:not(.is-light),
  html:not(.mbx-light):not([data-theme="light"]) .mbx-layers-btn:not(.is-light) {
    --lp-bg: #15171C;
    --lp-fg: #F2F4F7;
    --lp-sub: #A9B0BB;
    --lp-line: #2A2D33;
    --lp-soft: #1E2127;
    --lp-soft-2: #22252B;
    --lp-hover: #2A2E36;
    --lp-check: #4A4F58;
    --lp-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  }
}

/* --------------------------------------------------------------------------
   2. TUGMA
   -------------------------------------------------------------------------- */

.mbx-layers-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--lp-line);
  border-radius: 12px;
  background: var(--lp-bg);
  color: var(--lp-fg);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.16);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.mbx-layers-btn:hover {
  background: var(--lp-hover);
}

.mbx-layers-btn:active {
  transform: scale(0.95);
}

.mbx-layers-btn.is-on {
  background: var(--lp-on);
  border-color: var(--lp-on-line);
  color: #17181C;
}

.mbx-layers-btn:focus-visible {
  outline: 3px solid var(--lp-fg);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--lp-on);
}

.mbx-layers-btn__count {
  position: absolute;
  top: -7px;
  right: -7px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--lp-fg);
  color: var(--lp-bg);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.mbx-layers-btn__count.is-visible {
  display: flex;
}

/* Tugma pastda bo'lsa */
.mbx-layers-btn.pos-bottom-right {
  top: auto;
  bottom: 12px;
}

/* Panel host sifatida body ishlatilsa (xarita konteyneri yo'q) */
.mbx-layers-btn.is-floating {
  position: fixed;
}

.mbx-layers-panel.is-floating {
  position: fixed;
}

/* --------------------------------------------------------------------------
   3. PANEL QOBIG'I
   -------------------------------------------------------------------------- */

.mbx-layers-panel {
  position: absolute;
  top: 70px;
  right: 12px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  width: 340px;
  width: min(340px, calc(100% - 24px));
  max-height: calc(100% - 88px);
  border: 1px solid var(--lp-line);
  border-radius: 14px;
  background: var(--lp-bg);
  color: var(--lp-fg);
  box-shadow: var(--lp-shadow);
  overflow: hidden;
}

.mbx-layers-panel[hidden] {
  display: none;
}

.mbx-layers-panel.pos-bottom-right {
  top: auto;
  bottom: 70px;
}

.mbx-layers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--lp-line);
  background: var(--lp-bg);
}

.mbx-layers-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.mbx-layers-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--lp-soft-2);
  color: var(--lp-fg);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mbx-layers-close:hover {
  background: var(--lp-hover);
}

.mbx-layers-close:focus-visible {
  outline: 3px solid var(--lp-fg);
  outline-offset: 2px;
}

.mbx-layers-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 6px 8px;
}

.mbx-layers-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--lp-line);
  background: var(--lp-bg);
}

.mbx-layers-action {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--lp-line);
  border-radius: 12px;
  background: var(--lp-soft);
  color: var(--lp-fg);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mbx-layers-action:hover {
  background: var(--lp-hover);
}

.mbx-layers-action:focus-visible {
  outline: 3px solid var(--lp-fg);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   4. GURUH VA QATORLAR
   -------------------------------------------------------------------------- */

.mbx-layers-group {
  margin-bottom: 4px;
}

.mbx-layers-group__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--lp-soft);
  color: var(--lp-sub);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mbx-layers-group__head:focus-visible {
  outline: 3px solid var(--lp-fg);
  outline-offset: 2px;
}

.mbx-layers-group__title {
  flex: 1 1 auto;
}

.mbx-layers-group__count {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--lp-soft-2);
  color: var(--lp-fg);
  font-size: 12px;
  font-weight: 800;
}

.mbx-layers-chev {
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 3px;
  border-right: 2px solid var(--lp-sub);
  border-bottom: 2px solid var(--lp-sub);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.mbx-layers-group.is-collapsed .mbx-layers-chev {
  transform: rotate(-45deg);
}

.mbx-layers-group.is-collapsed .mbx-layers-group__list {
  display: none;
}

.mbx-layers-group__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 2px;
}

.mbx-layers-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--lp-fg);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mbx-layers-row:hover {
  background: var(--lp-soft);
}

.mbx-layers-row:focus-visible {
  outline: 3px solid var(--lp-fg);
  outline-offset: 2px;
}

.mbx-layers-check {
  position: relative;
  flex: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--lp-check);
  border-radius: 7px;
  background: var(--lp-bg);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.mbx-layers-row.is-on .mbx-layers-check {
  background: var(--lp-on);
  border-color: var(--lp-on-line);
}

.mbx-layers-row.is-on .mbx-layers-check::after {
  content: "\2713";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #17181C;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.mbx-layers-name {
  flex: 1 1 auto;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   5. MOSLASHUV VA FOYDALANUVCHI SOZLAMALARI
   -------------------------------------------------------------------------- */

@media (max-width: 599px) {
  .mbx-layers-btn {
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
  }

  .mbx-layers-btn.pos-bottom-right {
    top: auto;
    bottom: 8px;
  }

  .mbx-layers-panel {
    top: 62px;
    right: 8px;
    width: calc(100% - 16px);
    max-height: calc(100% - 74px);
  }

  .mbx-layers-panel.pos-bottom-right {
    top: auto;
    bottom: 62px;
  }

  .mbx-layers-row,
  .mbx-layers-name {
    font-size: 14.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mbx-layers-btn,
  .mbx-layers-panel,
  .mbx-layers-close,
  .mbx-layers-check,
  .mbx-layers-chev,
  .mbx-layers-action {
    transition: none;
  }

  .mbx-layers-btn:active {
    transform: none;
  }
}

@media (prefers-contrast: more) {
  .mbx-layers-btn,
  .mbx-layers-panel,
  .mbx-layers-action,
  .mbx-layers-close {
    border: 2px solid #101216;
  }

  .mbx-layers-panel.is-dark .mbx-layers-action,
  .mbx-layers-panel.is-dark .mbx-layers-close,
  .mbx-layers-panel.is-dark .mbx-layers-btn {
    border-color: #FFFFFF;
  }

  .mbx-layers-name,
  .mbx-layers-title {
    font-weight: 800;
  }

  .mbx-layers-check {
    border-color: #101216;
  }
}

/* --------------------------------------------------------------------------
   122-buyruq: TUGMA CHAP-YUQORIGA (egasi talabi).
   Ilgari o'ng-yuqorida edi va Taksi/Kuryer tanlovi ORTIDA qolib ko'rinmasdi
   (faqat «3» belgisi chiqib turardi). Endi chap-yuqorida, to'liq ko'rinadi.
   -------------------------------------------------------------------------- */
.mbx-layers-btn {
  left: 12px;
  right: auto;
  top: 12px;
}
.mbx-layers-panel {
  left: 12px;
  right: auto;
  top: 70px;
}
/* Tor ekranda ham chapga yopishib turadi */
@media (max-width: 480px) {
  .mbx-layers-btn { left: 10px; top: 10px; }
  .mbx-layers-panel { left: 10px; top: 66px; }
}

/* --------------------------------------------------------------------------
   123-buyruq: IKKI TUGMA BIRLASHTIRILDI.
   Egasi: ikkita qatlamlar tugmasi bir xil ko'rinishda — bittasi ortiqcha.
   Endi xarita (map.js) dagi OQ «Qatlamlar» tugmasi shu panelni ochadi,
   sariq tugma (badge bilan) YASHIRILADI — ma'lumot (27 qatlam + badge) oqqa o'tdi.
   -------------------------------------------------------------------------- */
.mbx-layers-btn { display: none !important; }
