/* ── СушиSELL Shop SPA ── */
:root {
  --red:      #e53935;
  --red-dark: #b71c1c;
  --red-light:#ffebee;
  --green:    #18A052;
  --bg:       #f5f5f5;
  --card-bg:  #fff;
  --text:     #1a1a1a;
  --text2:    #555;
  --text3:    #999;
  --border:   #e0e0e0;
  --radius:   12px;
  --shadow:   0 2px 8px rgba(0,0,0,.10);
  --shadow-lg:0 8px 32px rgba(0,0,0,.18);
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 8px; font-size: .9rem; font-weight: 600;
  cursor: pointer; padding: .6rem 1.2rem;
  transition: opacity .15s, transform .1s; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-outline { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── ════════════════════════════════════════════════════════
   SETUP MODAL OVERLAY — многошаговый выбор (город→тип→филиал)
   Всегда поверх всего, исчезает после завершения
════════════════════════════════════════════════════════════ */
.setup-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  /* Backdrop blur на поддерживаемых браузерах */
  backdrop-filter: blur(3px);
}
.setup-overlay.hidden { display: none; }

.setup-modal {
  background: #fff; border-radius: 18px;
  width: 100%; max-width: 460px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity:0; transform: scale(.95) translateY(8px); } }

.setup-logo {
  padding: 1.4rem 1.5rem .8rem;
  display: flex; justify-content: center;
  border-bottom: 1px solid var(--border);
}

.setup-step { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.setup-step.active { display: flex; }

.setup-step-title {
  padding: .9rem 1.2rem .5rem;
  font-size: 1rem; font-weight: 700; color: var(--text);
}

.setup-step-back {
  padding: .6rem 1.2rem 0;
  font-size: .8rem; color: var(--red); cursor: pointer;
  font-weight: 500;
}
.setup-step-back:hover { text-decoration: underline; }

/* City list inside modal */
.city-search-wrap { padding: .5rem 1rem; position: relative; }
.city-search {
  width: 100%; padding: .65rem 1rem .65rem 2.2rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .92rem; outline: none; background: #f9f9f9;
  transition: border-color .2s; font-family: inherit;
}
.city-search:focus { border-color: var(--red); background: #fff; }
.city-search-icon {
  position: absolute; left: 1.7rem; top: 50%; transform: translateY(-50%);
  font-size: .85rem; pointer-events: none; color: var(--text3);
}

.city-list {
  flex: 1; overflow-y: auto; padding: .25rem .75rem .75rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.city-item {
  padding: .65rem .9rem; background: #f9f9f9; border-radius: 8px;
  cursor: pointer; border: 1.5px solid transparent;
  transition: border-color .12s, background .12s; font-size: .88rem;
}
.city-item:hover { border-color: var(--red); background: #fff; }
.city-no-results { text-align: center; color: var(--text3); padding: 1.5rem; font-size: .88rem; }

/* Delivery type cards */
.dtype-cards {
  display: flex; gap: .75rem; padding: .75rem 1.2rem 1.4rem;
}
.dtype-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1.25rem .75rem;
  background: #fff; border: 2px solid var(--border); border-radius: 14px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .1s;
}
.dtype-card:hover { border-color: var(--red); box-shadow: var(--shadow); }
.dtype-card:active { transform: scale(.96); }
.dtype-icon { font-size: 2.2rem; }
.dtype-label { font-size: .95rem; font-weight: 700; }
.dtype-sub { font-size: .74rem; color: var(--text3); }

/* ── ════════════════════════════════════════════
   CATALOG (фон, всегда отображается)
═══════════════════════════════════════════════ */
.shop-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff; border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex; align-items: center; padding: 0 1rem; gap: .6rem;
}
.shop-header-city { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cart-btn {
  display: flex; align-items: center; gap: .4rem;
  background: var(--red); color: #fff; border-radius: 8px;
  padding: .4rem .85rem; cursor: pointer; border: none; font-weight: 600;
  font-size: .82rem; white-space: nowrap; flex-shrink: 0;
}
.cart-btn.empty { background: var(--border); color: var(--text3); cursor: default; }
.cart-count { background: rgba(255,255,255,.25); border-radius: 20px; padding: .05rem .4rem; font-size: .78rem; font-weight: 700; }

.cat-nav {
  position: sticky; top: var(--header-h); z-index: 99;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; overflow-x: auto; scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav-item {
  flex: 0 0 auto; padding: .65rem .9rem; font-size: .8rem; font-weight: 500;
  color: var(--text2); cursor: pointer; border-bottom: 2.5px solid transparent;
  white-space: nowrap; transition: color .12s, border-color .12s;
}
.cat-nav-item.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }

.catalog-wrap { padding: 1rem; }
.cat-section { margin-bottom: 2rem; }
.cat-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .75rem; }

.products-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
@media (min-width: 480px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .products-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  cursor: default; transition: box-shadow .12s, transform .1s;
}
.product-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.product-img-wrap { aspect-ratio: 4/3; overflow: hidden; background: #f5f5f5; }
.product-img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; display: block; }
.product-card:hover .product-img { transform: scale(1.04); }
.product-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--border); }

.product-body { padding: .55rem .7rem .7rem; display: flex; flex-direction: column; flex: 1; }
.product-name { font-size: .82rem; font-weight: 600; line-height: 1.3; flex: 1; }
.product-weight { font-size: .7rem; color: var(--text3); margin-top: .15rem; }
.product-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; }
.product-price { font-size: .9rem; font-weight: 700; }

.add-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform .1s;
}
.add-btn:active { transform: scale(.88); }

.qty-ctrl { display: flex; align-items: center; gap: .25rem; }
.qty-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--border); background: #fff;
  font-size: .85rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .12s;
}
.qty-btn:hover { border-color: var(--red); color: var(--red); }
.qty-num { font-size: .82rem; font-weight: 700; min-width: 14px; text-align: center; }

/* ── CART PANEL ── */
.cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none; }
.cart-overlay.open { display: block; }
.cart-panel {
  position: fixed; top: 0; right: -100%; bottom: 0;
  width: min(380px, 100vw); background: #fff; z-index: 201;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  transition: right .24s cubic-bezier(.4,0,.2,1);
}
.cart-panel.open { right: 0; }
@media (max-width: 580px) {
  .cart-panel { top: auto; right: 0; left: 0; height: 85vh; border-radius: 16px 16px 0 0; transform: translateY(100%); transition: transform .24s cubic-bezier(.4,0,.2,1); }
  .cart-panel.open { transform: translateY(0); }
}
.cart-header { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-header h3 { font-size: 1rem; font-weight: 700; }
.cart-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text3); }
.cart-items { flex: 1; overflow-y: auto; padding: .6rem .9rem; }
.cart-empty { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.cart-empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.cart-item { display: flex; align-items: center; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.cart-item-img { width: 48px; height: 48px; border-radius: 7px; object-fit: cover; flex-shrink: 0; background: #f5f5f5; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: .82rem; font-weight: 600; line-height: 1.2; }
.cart-item-price { font-size: .76rem; color: var(--text3); margin-top: .12rem; }
.cart-item-qty { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.cart-footer { padding: .9rem 1.1rem; border-top: 1px solid var(--border); }
.cart-total-row { display: flex; justify-content: space-between; font-size: .95rem; font-weight: 700; margin-bottom: .65rem; }

/* ── CHECKOUT ── */
.screen { display: none; }
.screen.active { display: block; }

.checkout-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1rem; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.checkout-back { background: none; border: none; font-size: 1.2rem; cursor: pointer; }
.checkout-header h2 { font-size: 1rem; font-weight: 700; }
.checkout-body { padding: 1rem; max-width: 560px; margin: 0 auto; padding-bottom: 4rem; }

.delivery-toggle { display: flex; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--border); margin-bottom: 1.1rem; background: #fff; }
.delivery-tab { flex: 1; padding: .6rem .5rem; text-align: center; font-size: .86rem; font-weight: 600; cursor: pointer; color: var(--text2); border: none; background: none; transition: background .12s, color .12s; }
.delivery-tab.active { background: var(--red); color: #fff; }

.form-group { margin-bottom: .9rem; }
.form-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text2); margin-bottom: .28rem; }
.form-input { width: 100%; padding: .65rem .85rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: .92rem; font-family: inherit; outline: none; transition: border-color .2s; }
.form-input:focus { border-color: var(--red); }
.form-input.error { border-color: var(--red); }
.form-row { display: flex; gap: .55rem; }
.form-row .form-group { flex: 1; }

.branch-list { display: flex; flex-direction: column; gap: .35rem; max-height: 240px; overflow-y: auto; }
.branch-item { padding: .65rem .9rem; background: #fff; border-radius: 8px; border: 1.5px solid var(--border); cursor: pointer; font-size: .85rem; transition: border-color .12s; display: flex; align-items: center; gap: .55rem; }
.branch-item.selected { border-color: var(--red); }
.branch-item-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.branch-item.selected .branch-item-dot { background: var(--red); border-color: var(--red); }

.order-summary { background: var(--red-light, #ffebee); border-radius: 10px; padding: .8rem .9rem; margin-top: .9rem; }
.order-summary-title { font-size: .78rem; font-weight: 700; color: var(--red); margin-bottom: .45rem; }
.order-summary-item { display: flex; justify-content: space-between; font-size: .8rem; margin-bottom: .22rem; }
.order-summary-total { display: flex; justify-content: space-between; font-size: .95rem; font-weight: 700; padding-top: .45rem; border-top: 1px solid rgba(229,57,53,.25); }

.form-error { font-size: .72rem; color: var(--red); margin-top: .2rem; display: none; }
.form-error.show { display: block; }

/* ── DELIVERY MAP ── */
.delivery-map-section { margin-bottom: .9rem; }

.map-search-wrap { position: relative; margin-bottom: .5rem; }
.map-search-input { padding-left: .85rem; }

.addr-results {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-lg); z-index: 300; max-height: 200px; overflow-y: auto;
}
.addr-result-item {
  padding: .55rem .85rem; font-size: .82rem; cursor: pointer;
  border-bottom: 1px solid var(--border); line-height: 1.3;
}
.addr-result-item:last-child { border-bottom: none; }
.addr-result-item:hover { background: #f5f5f5; }

.delivery-map-container {
  height: 240px; border-radius: 10px; overflow: hidden;
  border: 1.5px solid var(--border); z-index: 1;
}
@media (min-width: 480px) { .delivery-map-container { height: 280px; } }

.map-hint { font-size: .72rem; color: var(--text3); margin: .3rem 0 .5rem; text-align: center; }

/* ── ETA ── */
.eta-box {
  padding: .65rem .9rem; border-radius: 8px; font-size: .86rem;
  font-weight: 600; text-align: center; margin-bottom: .85rem;
}
.eta-ok   { background: #e8f5e9; color: #2e7d32; }
.eta-warn { background: #fff3e0; color: #e65100; }

/* ── Extras configurator ── */
.extras-config {
  background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: .85rem .9rem; margin-bottom: .9rem;
}
.extras-config-title { font-size: .88rem; font-weight: 700; margin-bottom: .6rem; color: var(--text); }
.ext-stepper-group { margin-bottom: .65rem; }
.ext-stepper-label { font-size: .84rem; font-weight: 600; color: var(--text); }
.ext-stepper-hint  { font-size: .72rem; color: var(--text3); margin-bottom: .25rem; }
.extras-total-line {
  text-align: right; font-size: .88rem; font-weight: 700; color: var(--red);
  padding-top: .45rem; border-top: 1px solid var(--border); margin-top: .35rem;
}

/* ── Steppers (специи/приборы) ── */
.stepper-group { margin-bottom: .85rem; }
.stepper-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text2); margin-bottom: .35rem; }
.stepper-row   { display: flex; align-items: center; gap: .6rem; }
.stepper-btn   {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--card-bg); color: var(--text); font-size: 1.15rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-weight: 700; transition: border-color .15s, background .15s;
}
.stepper-btn:hover { border-color: var(--red); background: var(--red-light); }
.stepper-val   { min-width: 28px; text-align: center; font-size: 1.05rem; font-weight: 700; }

.zone-info-card {
  padding: .6rem .85rem; border-radius: 8px; font-size: .83rem;
  font-weight: 600; margin-bottom: .75rem; text-align: center;
}
.zone-idle    { background: #f5f5f5; color: var(--text3); }
.zone-checking{ background: #fff9e6; color: #b45309; }
.zone-ok      { background: #e8f5e9; color: #2e7d32; }
.zone-out     { background: #ffebee; color: var(--red-dark, #b71c1c); }

/* ── SUCCESS ── */
.success-title { font-size: 1.4rem; font-weight: 800; margin-bottom: .45rem; }
.success-id { font-size: .82rem; color: var(--text3); margin-bottom: .65rem; font-family: monospace; }
.success-msg { font-size: .92rem; color: var(--text2); margin-bottom: 1.8rem; max-width: 300px; }

/* ── Misc ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: flex; justify-content: center; padding: 3rem 1rem; }
.loading-text { color: var(--text3); font-size: .86rem; margin-top: .45rem; text-align: center; }
.alert { padding: .7rem .9rem; border-radius: 8px; font-size: .86rem; }
.alert-error { background: #ffebee; color: var(--red-dark, #b71c1c); }
.alert-info  { background: #e3f2fd; color: #1565c0; }
