/* ═══════════════════════════ BASE ══════════════════════════════════ */
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
img  { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ── Header ── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px); z-index: 100;
  display: flex; align-items: center; padding: 0 20px; gap: 14px;
}
.header-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: var(--accent); }
.header-logo-icon { width: 32px; height: 32px; background: var(--accent); color: var(--on-primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.header-logo-img { width: 32px; height: 32px; object-fit: contain; border-radius: var(--radius-sm); }
.header-phone { font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap; transition: color var(--transition); }
.header-phone:hover { color: var(--accent); }
.btn-back { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-2); transition: border-color var(--transition), color var(--transition); background: none; cursor: pointer; margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.btn-back:hover { border-color: var(--accent); color: var(--accent); }

/* ── Page ── */
.page { max-width: 1040px; margin: 0 auto; padding: calc(var(--header-h) + 28px) 20px 48px; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 26px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-2); transition: color var(--transition); }
.breadcrumb a:hover { color: var(--accent); }

/* ── Product layout ── */
.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }

/* ── Image ── */
.product-gallery-col { display: flex; flex-direction: column; gap: 8px; }
.gallery-main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; position: relative; cursor: zoom-in; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.product-image-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 80px; background: var(--bg); }
.product-badge { position: absolute; top: 12px; left: 12px; background: var(--accent); color: var(--on-primary); font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 5px; }
/* ── Lightbox ── */
.lb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 600; align-items: center; justify-content: center; }
.lb-overlay.open { display: flex; }
.lb-overlay img { max-width: 95vw; max-height: 85vh; object-fit: contain; border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.lb-close { position: fixed; top: 16px; right: 20px; font-size: 32px; line-height: 1; color: #fff; cursor: pointer; background: none; border: none; padding: 4px 10px; opacity: .85; transition: opacity .2s; z-index: 601; }
.lb-close:hover { opacity: 1; }

.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumb { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; cursor: pointer; border: 2px solid transparent; flex-shrink: 0; transition: border-color .2s; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb.active { border-color: var(--accent); }

/* ── Info ── */
.product-info { display: flex; flex-direction: column; gap: 16px; }
.product-category { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.product-name { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.product-brand { font-size: 14px; color: var(--text-2); }
.product-unavailable { display: inline-block; background: #fee2e2; color: #dc2626; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 6px; }
.price-row { display: flex; align-items: baseline; gap: 12px; }
.product-price { font-size: 1.8rem; font-weight: 900; color: var(--text); }
.product-old-price { font-size: 1rem; color: var(--text-3); text-decoration: line-through; }
.product-description { font-size: 14px; color: var(--text-2); line-height: 1.7; }

/* ── Specs table ── */
.specs-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.specs-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg); }
.spec-row { display: flex; padding: 8px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
.spec-row:last-child { border-bottom: none; }
.spec-name { color: var(--text-2); min-width: 110px; flex-shrink: 0; }
.spec-val { font-weight: 600; }

/* ── Add to cart ── */
.add-to-cart-wrap { display: flex; gap: 12px; align-items: center; }
.qty-control { display: flex; align-items: center; gap: 0; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.qty-btn { background: var(--bg); border: none; padding: 10px 14px; font-size: 18px; color: var(--text-2); cursor: pointer; transition: background var(--transition); }
.qty-btn:hover { background: var(--border); }
.qty-val { padding: 10px 14px; font-size: 15px; font-weight: 700; min-width: 44px; text-align: center; }
.btn-add-cart { flex: 1; background: var(--accent); color: var(--on-primary); border: none; border-radius: var(--radius-sm); padding: 12px 20px; font-size: 15px; font-weight: 700; cursor: pointer; transition: background var(--transition); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-add-cart:hover { background: var(--accent-hover); }
.btn-add-cart:disabled { background: #ccc; cursor: not-allowed; }
.btn-add-cart.in-cart { background: #22c55e; }

/* ── Sale-type panels ── */
.sale-panel { display: none; }
.sale-panel.active { display: block; }
/* piece panel needs flex restored */
.add-to-cart-wrap.sale-panel.active { display: flex; }
.stv-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 12px 0 6px; }
.width-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.width-btn { background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 7px 14px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.width-btn.selected, .width-btn:hover { background: var(--accent); color: var(--on-primary); border-color: var(--accent); }
.dim-input { width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 15px; font-family: inherit; background: var(--bg); color: var(--text); margin-top: 4px; }
.dim-input:focus { outline: none; border-color: var(--accent); }
.calc-preview { background: var(--accent-light); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; margin: 8px 0; color: var(--text); }
.calc-preview strong { color: var(--accent); font-weight: 800; }
.calc-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; padding: 2px 0; }
.calc-row-total { border-top: 1px solid rgba(0,0,0,.08); margin-top: 5px; padding-top: 5px; font-size: 15px; font-weight: 700; }

/* ── 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); }

/* ── Cart Drawer ── */
.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(--text-2); 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(--text-2); margin-top: 3px; }
.cart-item-detail { font-size: 12px; color: var(--text-2); 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(--text-2); 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: var(--on-primary); border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background var(--transition); }
.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(--text-2); 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(--text-2); 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; background: var(--accent); color: var(--on-primary); border: none; border-radius: 10px; font-weight: 700; cursor: pointer; transition: background var(--transition); }
.btn-submit:hover { background: var(--accent-hover); }
.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(--text-2); line-height: 1.6; margin-bottom: 22px; }
.btn-continue { background: var(--accent); color: var(--on-primary); border: none; border-radius: 10px; padding: 12px 28px; font-size: 15px; font-weight: 700; cursor: pointer; transition: background var(--transition); }
.btn-continue:hover { background: var(--accent-hover); }

/* ── Responsive ── */
@media (max-width: 720px) {
  .product-layout { grid-template-columns: 1fr; gap: 24px; }
  .product-name { font-size: 1.3rem; }
  .product-price { font-size: 1.5rem; }
}
@media (max-width: 500px) {
  .cart-drawer { width: 100%; right: -100%; }
  .btn-back { font-size: 0; padding: 0 11px; gap: 0; }
  .btn-back::before { content: '← Каталог'; font-size: 13px; }
}

/* ── Footer ── */
.footer { background: var(--bg-2); margin-top: 56px; }
.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: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.footer-col a { color: var(--text-2); text-decoration: none; transition: color var(--transition); }
.footer-col a:hover { color: var(--accent); }
.footer-col p { margin: 0; color: var(--text-2); }
.footer-bottom { border-top: 1px solid var(--border); padding: 14px 16px; font-size: 12px; color: var(--muted); text-align: center; }
@media (max-width: 900px) { .footer-inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .footer-inner { grid-template-columns: 1fr; gap: 20px; } }
