:root {
  --bg: #F5F7FA;
  --bg-elevated: #ffffff;
  --text: #1F2A3A;
  --text-muted: #7A8494;
  --border: #E2E6EB;
  --accent: #37D0A9;
  --accent-soft: #1F2A3A;
  --status-green: #37D0A9;
  --status-red: #FF6A5A;
  --btn_primary_text: #FFFFFF;
  --btn-secondary-bg: transparent;
  --btn-secondary-border: #E2E6EB;
  --btn-secondary-text: #1F2A3A;
  --color-price-regular:   #1F2A3A; /* основная цена */
  --color-price-old:       #7A8494; /* старая цена + line-through */
  --color-price-discount:  #37D0A9; /* цена со скидкой или "выгодная" */
  --color-icon-default:   #7A8494;
  --color-border-subtle:  #E2E6EB;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F141A;
    --bg-elevated: #171C23;
    --text: #F5F7FA;
    --text-muted: #A9B1BA;
    --border: #252F3A;
    --accent-soft: #1E252F;
    --status-green: #37D0A9;
    --status-red: #f97373;
    --btn_primary_text: #0F141A;
    --btn-secondary-bg: transparent;
    --btn-secondary-border: #252F3A;
    --btn-secondary-text: #F5F7FA;
    --color-price-regular:    #F5F7FA;
    --color-price-old:        #A9B1BA; /* + line-through */
    --color-price-discount:   #37D0A9;
    --color-icon-default:    #C8D0D8;
    --color-border-subtle:   #252F3A;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  -webkit-font-smoothing: antialiased;
}

.app#app {
  min-height: 100vh;
  padding: 8px 8px calc(64px + env(safe-area-inset-bottom, 0));
}

/* generic */

[hidden] {
  display: none !important;
}

/* views */

.view {
  display: none;
}
.view.active {
  display: block;
}

/* sticky header: поиск + фильтры */

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;

  /* тянем фон до краёв экрана */
  margin: 0 -8px;
  padding: 8px 8px 6px;

  background: var(--bg-elevated); /* как секции корзины/таббар */
}

/* поиск */

.searchbar {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.search-input {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  padding: 0 10px;
}

.search-input input {
  width: 100%;
  border-radius: 12px;
  border: none;
  padding: 7px 0 7px 4px;
  font-size: 14px;
  background: transparent;
  color: var(--text);
}

.search-input input::placeholder {
  color: var(--text-muted);
}

.search-icon-img {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.empty-placeholder {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}

.empty-placeholder-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.empty-placeholder-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-placeholder-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 260px;
  margin: 0 auto;
}


/* кнопка фильтров */

.btn-icon {
  border: none;
  background: transparent;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.filter-icon-img {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

/* панель фильтров */

.filters {
  background: var(--bg-elevated);
  border-radius: 0;                 /* без скруглений, как таббар */
  padding: 6px 8px 8px;             /* отступы слева/справа как у карточек */
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}


.filters select,
.filters input {
  flex: 1;
  min-width: 40%;
  border-radius: 10px;
  border: none; /* убираем границы */
  padding: 6px 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

/* buttons */

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

.btn {
  border-radius: 10px;
  border: none;
  background: var(--bg);
  color: var(--text);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 500;
}

.btn-primary {
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--btn_primary_text);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}

/* Кнопка "Применить" в секции фильтров — без акцентного синего */
.filters .btn-primary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
  font-weight: 500;
}

.btn-secondary {
  border-radius: 10px;
  border: var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 500;
}

.btn-cta {
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--btn_primary_text);
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 600;
}

.btn-cta.disabled,
.btn-cta[aria-disabled="true"] {
  opacity: 0.6;
}

/* grid + карточки */

.grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  padding-bottom: 12px;
}

.card {
  background: var(--bg-elevated); /* как секции в корзине */
  border-radius: 12px;
  border: none;
  overflow: hidden;
}

.card img {
  width: 100%;
  display: block;
  border-radius: 0;
  object-fit: contain;
  background: var(--bg-elevated);
  max-height: 190px;
}

.card-body {
  padding: 4px 10px 10px;
}

/* верхняя строка с датой и типом */

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0px;      /* чтобы совпадал с отступом brand → title */
  margin-bottom: 6px;   /* слегка визуально расправляет строку */
}


.type-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
}

.type-tag-inline {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-muted);
}

/* линия с датой */

.delivery-line {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.delivery-spacer {
  min-width: 40px;
}

/* цена, бренд, название */

.price-row {
  margin-top: 4px; /* от картинки до строки с ценой/доставкой */
  display: flex;
  align-items: center;
  justify-content: space-between;

}

.price {
  margin-top: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-price-regular); /* зелёный, как ты просила ранее */
}
.price-block {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

/* старая цена — серая и зачёркнутая */
.price-old {
  font-size: 13px;
  color: var(--color-price-old);
  text-decoration: line-through;
}

/* новая цена — акцентная (логично оставить тот же акцент, который у тебя уже есть) */
.price-new {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-price-discount);
}

.brand-line {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.card .title {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 6px;
}

/* счётчик */

.qty-ctrl {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--bg);
  border: none;
  padding: 2px 4px;
}

.qty-ctrl .btn-qty {
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1; /* центрирование символа */
  color: var(--text);
}

.qty-ctrl .qty-val {
  min-width: 22px;
  text-align: center;
  font-size: 14px;
}

/* низ карточки */

.controls {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Скоро в наличии */

.reserve-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reserve-info {
  font-size: 12px;
}

.hint-available {
  color: var(--text-muted);
}

.user-reserved {
  margin-top: 2px;
  font-weight: 600;
  color: var(--accent);
}

/* сообщение */

#msg {
  margin-top: 8px;
  min-height: 18px;
  font-size: 13px;
  color: #e53935;
}

/* pager */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 4px;
}

.pager-btn {
  border-radius: 999px;
  border: none;
  background: var(--bg);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
}

.pager-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* TABBAR */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  height: calc(56px + env(safe-area-inset-bottom, 0));
  display: flex;
  background: var(--bg-elevated); /* как секции в корзине */
  border-top: none;               /* без границы */
  z-index: 99999;
}

.tabbar .tab {
  flex: 1;
  margin: 0;
  padding: 4px 2px 6px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.tabbar .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tabbar .tab .tab-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* маска по SVG, цвет задаётся background-color */
  background-color: var(--color-icon-default); /* серый для неактивной */
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

/* Привязка файлов-иконок к конкретным табам */
.tab-icon-catalog {
  -webkit-mask-image: url("icons/catalog.svg");
  mask-image: url("icons/catalog.svg");
}

.tab-icon-instock {
  -webkit-mask-image: url("icons/instock.svg");
  mask-image: url("icons/instock.svg");
}

.tab-icon-coming {
  -webkit-mask-image: url("icons/coming.svg");
  mask-image: url("icons/coming.svg");
}

.tab-icon-cart {
  -webkit-mask-image: url("icons/cart.svg");
  mask-image: url("icons/cart.svg");
}

/*.tabbar .tab .tab-icon img {*/
/*  width: 100%;*/
/*  height: 100%;*/
/*  display: block;*/
/*}*/

.tabbar .tab .tab-label {
  font-size: 10px;
}

.tabbar .tab.active {
  color: var(--accent);
}

.tabbar .tab.active .tab-icon {
  background-color: var(--accent); /* ← иконка становится синей */
}

/* Корзина */

.cart-empty {
  padding: 16px 4px;
  font-size: 14px;
  color: var(--text-muted);
}

.cart-section {
  margin-bottom: 16px;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: none; /* убираем внешнюю границу */
  overflow: hidden;
}

.cart-section-header {
  padding: 10px 10px 6px;
}

.cart-section-title {
  font-size: 14px;
  font-weight: 600;
}

.cart-section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* карточки внутри корзины */

.cart-card {
  background: transparent;
  border-radius: 0;
  border-bottom: 0.5px solid var(--color-border-subtle); /* тонкая граница между товарами */
  padding: 8px 10px;
  margin: 0;
  position: relative;
}

.cart-section .cart-card:last-child {
  border-bottom: none;
}

.cart-card .inner {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
}

.cart-card img {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: contain;
  background: rgba(148, 163, 184, 0.12);
}

.cart-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cart-card-top {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cart-card-top .title {
  font-size: 13px;
  font-weight: 600;
}

.cart-card-bottom {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* крестик удаления */

.cart-card .btn-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center; /* по центру */
  line-height: 1;
}

/* summary */

.cart-summary {
  position: sticky;
  bottom: calc(56px + env(safe-area-inset-bottom, 0));
  margin-top: 8px;
  padding: 8px 4px 10px;
  background: var(--bg);
}

.cart-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

/* Модалки */

#modal,
#delivery-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  z-index: 100000;
}

#modal .modal-inner,
#delivery-modal .modal-inner {
  position: relative;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  border: none;
  padding: 16px;
  max-width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

#modal-img {
  width: 100%;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(148, 163, 184, 0.12);
  margin-bottom: 8px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.modal-body {
  font-size: 13px;
  margin-top: 8px;
}

/* крестик в модалке */

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;

  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

/* Модалка брони */

.reserve-modal {
  position: fixed;
  inset: 0;
  background: var(--bg-elevated);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100001;
}

.reserve-modal.visible {
  display: flex;
}

.reserve-modal-inner {
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  border: none;
  padding: 16px;
  max-width: 90%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.reserve-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.reserve-product-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.reserve-available {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.reserve-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.reserve-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Busy overlay */

.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100002;
}

.busy-overlay.visible {
  display: flex;
}

.busy-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-top-color: var(--accent);
  animation: busy-spin 0.8s linear infinite;
}

@keyframes busy-spin {
  to { transform: rotate(360deg); }
}
