/* ═════════════════════════ BASE STYLES ══════════════════════════════ */
:root { --muted: #64748b; }
body.theme-mini-flowers { --muted: #7c6b78; }
body.theme-mini-products,
body.theme-mini-building { --muted: #78716c; }
body.theme-mini-flooring { --muted: #7c6f5e; }
body.theme-mini-tech { --muted: #94a3b8; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ═══════════════════════════ HEADER ════════════════════════════════ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex; align-items: center; gap: 14px;
  padding-top: 11px; padding-bottom: 11px;
}
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}
.logo-img { height: 34px; width: 34px; object-fit: contain; border-radius: 7px; margin-right: 8px; }
.logo-text { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: -.4px; }
.header-search { flex: 1; max-width: 460px; min-width: 0; position: relative; }
.search-wrap { position: relative; width: 100%; z-index: 500; display: flex; }
.search-wrap input {
  flex: 1; border: 1.5px solid var(--border); background: var(--bg);
  padding: 9px 14px; font-size: 14px; outline: none;
  border-radius: 8px 0 0 8px; color: var(--text);
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap button {
  background: var(--accent); border: none;
  padding: 9px 15px; color: #fff; font-size: 15px;
  cursor: pointer; border-radius: 0 8px 8px 0;
  flex-shrink: 0; transition: background .2s;
}
.search-wrap button:hover { background: var(--accent-hover); }
.search-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 0 8px 8px; box-shadow: var(--shadow-hover);
  z-index: 500; max-height: 340px; overflow-y: auto;
}
.search-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .15s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-item-ph {
  width: 40px; height: 40px; background: var(--bg);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.search-item img { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.search-item-info { flex: 1; min-width: 0; }
.search-item-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.search-item-price { font-size: 14px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.header-phones { display: flex; flex-direction: column; gap: 1px; }
.header-phone { font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; transition: color .2s; }
.header-phone:hover { color: var(--accent); }
.cart-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 8px 15px; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; transition: background .2s;
}
.cart-btn:hover { background: var(--accent-hover); }
.cart-count { background: #fff; color: var(--accent); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }

/* ── Category nav ── */
.cat-nav { border-top: 1px solid var(--border); background: var(--surface); }
.cat-nav-inner { display: flex; gap: 0; overflow-x: auto; padding: 0; scrollbar-width: none; }
.cat-nav-inner::-webkit-scrollbar { display: none; }
.cat-btn {
  padding: 9px 16px; background: none; border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--muted); transition: all .2s; cursor: pointer;
}
.cat-btn:hover, .cat-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══════════════════════════ HERO ══════════════════════════════════ */
.hero {
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
  padding: 52px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 640px; margin: 0 auto; }
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  color: var(--hero-text);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 20px; margin-bottom: 14px;
}
.hero-title {
  font-size: 2.4rem; font-weight: 900;
  color: var(--hero-text); letter-spacing: -.02em;
  line-height: 1.15; margin-bottom: 10px;
}
.hero-sub {
  font-size: 1rem; color: var(--hero-sub);
  margin-bottom: 24px; line-height: 1.5;
}
.hero-cta {
  display: inline-block;
  background: rgba(255,255,255,.95);
  color: var(--hero-from);
  font-size: 15px; font-weight: 700;
  padding: 12px 28px; border-radius: 30px;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }

/* ── Category chips strip (below hero, filled by JS) ── */
.cat-strip { padding: 14px 16px 0; overflow-x: auto; scrollbar-width: none; }
.cat-strip::-webkit-scrollbar { display: none; }
.cat-chips { display: flex; gap: 8px; flex-wrap: nowrap; max-width: 1200px; margin: 0 auto; }
.cat-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; white-space: nowrap;
  cursor: pointer; transition: all .18s;
}
.cat-chip:hover, .cat-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ═══════════════════════════ MAIN LAYOUT ═══════════════════════════ */
.main { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 22px 0 40px; }

/* ── Filters ── */
.filters-toggle { display: none; width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; margin-bottom: 14px; }
@media (max-width: 900px) { .filters-toggle { display: block; } #filtersPanel { display: none; } #filtersPanel.open { display: block; } }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 90px; max-height: calc(100vh - 100px); overflow-y: auto; }
.filters-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 15px; font-weight: 700; }
.filters-reset { font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 600; }
.filter-group { margin-bottom: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.filter-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.filter-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; font-size: 13px; }
.filter-item input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; flex-shrink: 0; }
.price-inputs { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 4px; align-items: center; margin-bottom: 8px; }
.price-inputs input { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 6px; padding: 7px 6px; font-size: 13px; background: var(--bg); color: var(--text); }
.price-inputs input:focus { outline: none; border-color: var(--accent); }
.btn-apply { width: 100%; padding: 8px; background: var(--accent); color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-apply:hover { background: var(--accent-hover); }

/* ── Catalog ── */
#catalog { min-width: 0; }
.catalog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.catalog-count { font-size: 13px; color: var(--muted); font-weight: 500; }
.catalog-sort select { border: 1px solid var(--border); border-radius: 7px; padding: 7px 12px; font-size: 13px; background: var(--surface); color: var(--text); cursor: pointer; }
.catalog-sort select:focus { outline: none; }
.products-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Product card ── */
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
  cursor: pointer; position: relative;
}
.product-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.product-img-wrap {
  width: 100%; aspect-ratio: 1; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.product-img-wrap img { width: 100%; height: 100%; object-fit: contain; }
.product-img-ph { font-size: 36px; }
.product-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.product-unavailable-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
}
.product-unavailable-label { color: #fff; font-size: 12px; font-weight: 700; background: rgba(0,0,0,.5); padding: 4px 12px; border-radius: 4px; }
.product-body { padding: 12px; display: flex; flex-direction: column; flex: 1; }
.product-category { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 4px; }
.product-name { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; flex: 1; }
.product-brand { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.product-price-wrap { display: flex; flex-direction: column; }
.product-price { font-size: 17px; font-weight: 800; color: var(--text); }
.product-old-price { font-size: 12px; color: var(--muted); text-decoration: line-through; }
.btn-cart-add {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; width: 34px; height: 34px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .2s;
}
.btn-cart-add:hover { background: var(--accent-hover); }
.btn-cart-add.in-cart { background: #22c55e; }
.btn-cart-add:disabled { background: #ccc; cursor: not-allowed; }

/* ── Empty state ── */
.empty-state { display: none; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state.show { display: block; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; margin-bottom: 20px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 12px 24px; font-size: 15px; font-weight: 700; cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--accent-hover); }

/* ═════════════════════════ FOOTER ══════════════════════════════════ */
.footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; padding: 40px 16px 32px; max-width: 1200px; margin: 0 auto; }
.footer-logo-text { font-size: 19px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.footer-subtitle { font-size: 13px; color: var(--muted); }
.footer-about { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.footer-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 9px; }
.footer-col a { font-size: 13px; color: var(--muted); transition: color .15s; }
.footer-col a:hover { color: var(--accent); }
.footer-col p { font-size: 13px; color: var(--muted); }
.footer-bottom { border-top: 1px solid var(--border); padding: 14px 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ═══════════════════════════ CART ══════════════════════════════════ */
.cart-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; }
.cart-overlay.open { display: block; }
.cart-drawer {
  position: fixed; top: 0; right: -420px; width: 380px; max-width: 100vw;
  height: 100vh; height: 100dvh; background: var(--surface); z-index: 201;
  display: flex; flex-direction: column;
  transition: right .3s ease; box-shadow: -4px 0 20px rgba(0,0,0,.12);
}
.cart-drawer.open { right: 0; }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; }
.cart-head button { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.cart-items { flex: 1; overflow-y: auto; padding: 14px; }
.cart-item { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.cart-img-placeholder { width: 50px; height: 50px; border-radius: 8px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--bg); flex-shrink: 0; }
.cart-item img { width: 50px; height: 50px; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.cart-item-price { font-size: 13px; color: var(--muted); margin-top: 3px; }
.cart-item-detail { font-size: 12px; color: var(--muted); margin-top: 1px; line-height: 1.4; }
.cart-item-subtotal { font-size: 13px; font-weight: 700; color: var(--accent); margin-top: 3px; }
.cart-item-controls { display: flex; align-items: center; gap: 5px; }
.cart-item-controls button { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; width: 26px; height: 26px; font-size: 15px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cart-item-controls span { font-size: 14px; font-weight: 600; min-width: 20px; text-align: center; }
.cart-remove { background: none !important; border: none !important; font-size: 16px !important; color: var(--accent) !important; cursor: pointer; }
.cart-empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
.cart-foot { padding: 14px 20px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-shrink: 0; }
.cart-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.cart-total-row strong { font-size: 19px; }
.btn-checkout { width: 100%; padding: 13px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background .2s; }
.btn-checkout:hover { background: var(--accent-hover); }
.btn-checkout:disabled { background: #ccc; cursor: not-allowed; }

/* ═══════════════════════════ ORDER MODAL ═══════════════════════════ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: 14px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-header button { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.order-summary { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.order-summary-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; }
.order-summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.order-summary-row span:last-child { font-weight: 600; }
.order-summary-total { display: flex; justify-content: space-between; font-size: 15px; font-weight: 800; padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--border); }
.order-summary-total span:last-child { color: var(--accent); }
.modal-body input, .modal-body textarea { border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; font-size: 15px; font-family: inherit; resize: none; width: 100%; background: var(--bg); color: var(--text); }
.modal-body input:focus, .modal-body textarea:focus { outline: none; border-color: var(--accent); }
.modal-body input.error { border-color: #ef4444; }
.field-error { font-size: 12px; color: #ef4444; display: none; margin-top: -6px; }
.field-error.show { display: block; }
.btn-submit { width: 100%; padding: 13px; font-size: 16px; }
.success-body { text-align: center; padding: 32px 22px; }
.success-icon { font-size: 54px; margin-bottom: 10px; }
.success-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.success-text { font-size: 15px; color: var(--muted); line-height: 1.6; margin-bottom: 22px; }
.btn-continue { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 12px 28px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-continue:hover { background: var(--accent-hover); }

/* ═══════════════════════════ TOAST ══════════════════════════════════ */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1a1a; color: #fff; padding: 13px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 600; opacity: 0; transition: all .3s;
  pointer-events: none; z-index: 9999; min-width: 260px; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════ RESPONSIVE ══════════════════════════════ */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 1.8rem; }
}
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; }
  .header-search { order: 3; flex: 1 0 100%; }
  .logo { flex: 1; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .footer-inner { grid-template-columns: 1fr; gap: 20px; }
  .cart-drawer { width: 100%; right: -100%; }
  .header-phones .header-phone + .header-phone { display: none; }
  .hero { padding: 36px 16px; }
  .hero-title { font-size: 1.5rem; }
}
