/* [fix-all v3] F5.62 */
/* ─────────────────────────────────────────────────────────────────────────
   F5.62 — без !important. Специфичность: поднимает выше
   брендовые селекторы и #id из views.js.
   ───────────────────────────────────────────────────────────────────────── */

/* [1] Панель: overlay на 821-1180 (как на мобильном), колонка на 1181+ */
@media (min-width: 821px) and (max-width: 1180px) {
  .wrap {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .wrap > .panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 320;
    width: min(360px, 100%);
    max-height: none;
    border-radius: 22px 0 0 22px;
    transform: translateX(105%);
    transition: transform .35s cubic-bezier(.2, 1, .3, 1);
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    overflow-y: auto;
  }
  .wrap > .panel.open { transform: none; }
}
@media (min-width: 1181px) {
  .wrap {
    grid-template-columns: 92px minmax(0, 1fr) 350px;
    gap: 22px;
    max-width: 1480px;
  }

}

/* [2] Desktop topbar (821px+): 4 колонки venue | brand | mbonus | profile, явные размеры, первая строка не сжимается */
@media (min-width: 821px) {
  .topbar .venueToggle {
    height: 44px;
    font-size: 14px;
    padding: 0 14px;
    gap: 6px;
  }
}

/* Desktop (1181px+): панель вмещается в колонку 350px и не уезжает под шапку */
@media (min-width: 1181px) {
    .wrap > .panel {
    position: sticky;
    width: 100%;
    min-width: 0;
    max-width: 350px;
    justify-self: stretch;
    top: 112px;
    max-height: calc(100vh - 128px);
    margin-top: 0;
    transform: none;
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }
  .wrap > .panel > * {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .wrap > section {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  /* Desktop: в «Пятнице» панель всегда видна в колонке, мобильная шторка не применяется */
html .wrap > #panel:not(.open):not(.show) {
  position: sticky;
  top: 112px;
  transform: none;
  visibility: visible;
  pointer-events: auto;
}
}

/* [3] Mobile topbar: строгая 3-колоночная сетка 1fr auto 1fr для идеального центрирования логотипа */
@media (max-width: 820px) {
  .topbar,
  header.topbar {
    width: calc(100% - 16px);
    max-width: 100%;
    margin-inline: auto;
    border-radius: 0 0 14px 14px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    height: calc(60px + env(safe-area-inset-top, 0px));
    min-height: calc(60px + env(safe-area-inset-top, 0px));
    padding: calc(env(safe-area-inset-top, 0px) + 4px) 12px 4px;
    box-sizing: border-box;
  }
  body.is-cashier header.topbar,
  body.is-admin header.topbar,
  header.topbar:has(#modeSeg:not([hidden])) {
    height: auto;
  }
  .topbar .venueWrap,
  header.topbar div.venueWrap {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    order: 1;
    min-width: 0;
  }
  .topbar .brand,
  header.topbar div#headerBrand.brand {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    order: 2;
    margin: 0;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topbar #profileTopBtn,
  header.topbar button#profileTopBtn.ava {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    order: 3;
    margin: 0;
    position: static;
    display: grid;
    place-items: center;
  }
  .topbar #modeSeg,
  header.topbar #modeSeg {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 10;
    justify-self: center;
    width: max-content;
    max-width: 100%;
    height: 46px;
    min-height: 46px;
    padding: 0;
    overflow-x: auto;
  }
}
/* Short landscape has little vertical space: keep the venue switcher compact like mobile. */
@media (min-width: 821px) and (orientation: landscape) and (max-height: 480px) {
  html body header.topbar .venueWrap {
    position: relative;
    display: flex;
    flex: 0 0 52px;
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    justify-content: flex-start;
  }
  html body header.topbar .venueWrap > #venueToggle.venueToggle {
    box-sizing: border-box;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    padding: 0;
    gap: 3px;
    justify-content: center;
  }
  html body header.topbar .venueWrap > #venueToggle.venueToggle .vt-label {
    display: none;
  }
  html body header.topbar .venueWrap > #venueToggle.venueToggle .vt-arrow {
    display: inline-block;
    font-size: 10px;
    margin-left: 0;
  }
}

/* [4] Search на 821-1180: не растягивается */
@media (min-width: 821px) and (max-width: 1180px) {
  .mh-top .mh-right {
    width: auto;
    max-width: 360px;
    flex: 0 1 360px;
    margin-left: auto;
  }
  .mh-top .search,
  .mh-top .mh-right .search {
    width: auto;
    min-width: 200px;
    max-width: 360px;
    flex: 1 1 auto;
  }
}
/* [5] Mobile search is constrained by the grid track inside the full-width menu head. */
@media (max-width:820px) {
  #menuView .mh-top,
  #deliveryView .mh-top {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:32px 40px;
    gap:4px;
    width:100%;
    min-width:0;
    max-width:100%;
    box-sizing:border-box;
  }
  #menuView .mh-top > div:first-child,
  #deliveryView .mh-top > div:first-child {
    grid-column:1;
    grid-row:1;
    width:100%;
    min-width:0;
    max-width:100%;
  }
  #menuView .mh-top > .mh-right,
  #deliveryView .mh-top > .mh-right {
    display:flex;
    grid-column:1;
    grid-row:2;
    flex:0 1 auto;
    width:100%;
    max-width:100%;
    min-width:0;
    overflow:hidden;
    margin-left:0;
    box-sizing:border-box;
  }
  #menuView .mh-top > .mh-right .search,
  #deliveryView .mh-top > .mh-right .search {
    display:flex;
    flex:1 1 0%;
    width:100%;
    max-width:100%;
    min-width:0;
    box-sizing:border-box;
  }
}
/* [fix-all v3] END F5.62 */
/* Keep the staff mode switch at the same reserved height before and after auth hydration. */
@media (max-width: 820px) {
  html[data-staff-role] body header.topbar #modeSeg {
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    margin-top: 0;
    padding: 0;
    box-sizing: border-box;
  }
}

@media (min-width: 821px) {
  header.topbar, .topbar {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
    row-gap: 0;
  }
}
