/* =============================================================================
   Магазин сантехники — клиентская часть
   ========================================================================== */

:root {
  --primary: #047857;
  --primary-dark: #035f46;
  --primary-soft: #e6f4ee;
  --dark: #0b3a2a;
  --orange: #f07a1a;
  --orange-dark: #d4640a;
  --green: #1f9d55;
  --green-soft: #e5f6ec;
  --red: #d64545;
  --red-soft: #fdecec;
  --yellow-soft: #fff6db;
  --text: #1b2430;
  --muted: #6b7684;
  --line: #e3e7ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
  --container: 1240px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding-inline: 16px; }
main { flex: 1; padding-block: 24px 48px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  background: var(--primary); color: #fff; transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--orange); }
.btn-accent:hover { background: var(--orange-dark); }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--line); }
.btn-outline:hover { background: var(--primary-soft); color: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-link { background: none; color: var(--primary); padding: 0; border: 0; font-weight: 500; }
.btn-link:hover { background: none; color: var(--primary-dark); text-decoration: underline; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* ---------- Шапка ---------- */
.topbar { background: var(--dark); color: #b6d3c6; font-size: 13px; }
.topbar .container { display: flex; justify-content: space-between; gap: 16px; padding-block: 6px; flex-wrap: wrap; }
.topbar a { color: #fff; }

.header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-main { display: flex; align-items: center; gap: 20px; padding-block: 14px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--text); white-space: nowrap; }
.logo:hover { color: var(--text); }
.logo-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary);
  display: grid; place-items: center; color: #fff; font-size: 20px;
}
.search { position: relative; flex: 1; min-width: 0; }
.search form { display: flex; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; font: inherit;
  border: 2px solid var(--primary); border-right: 0; border-radius: 8px 0 0 8px; outline: none;
}
.search button { border-radius: 0 8px 8px 0; height: 44px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60;
}
.suggest a { display: flex; align-items: center; gap: 12px; padding: 8px 14px; color: var(--text); }
.suggest a:hover, .suggest a.active { background: var(--primary-soft); }
.suggest img, .suggest .ph { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: var(--bg); flex-shrink: 0; }
.suggest .s-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-price { font-weight: 700; white-space: nowrap; }
.suggest .s-cat { font-size: 13px; color: var(--muted); padding: 8px 14px 0; }

.header-actions { display: flex; gap: 6px; align-items: center; }
.header-action {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 10px; color: var(--text); font-size: 12px; border-radius: 8px;
}
.header-action:hover { background: var(--bg); color: var(--text); }
.header-action svg { width: 24px; height: 24px; }
.badge-count {
  position: absolute; top: -2px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--orange); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.badge-count[data-count="0"] { display: none; }

.catnav { border-top: 1px solid var(--line); }
.catnav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.catnav ul::-webkit-scrollbar { display: none; }
.catnav a { display: block; padding: 10px 12px; color: var(--text); white-space: nowrap; font-size: 14px; }
.catnav a:hover, .catnav a.active { color: var(--primary); }

/* ---------- Сообщения ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.message { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; background: var(--primary-soft); }
.message.success { background: var(--green-soft); color: #145c34; }
.message.error { background: var(--red-soft); color: #8f2626; }
.message.warning { background: var(--yellow-soft); color: #7a5a00; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #1b2430; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 100;
  box-shadow: var(--shadow-lg); transition: .25s; max-width: calc(100% - 32px);
  display: flex; gap: 14px; align-items: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast a { color: #7fd6ad; white-space: nowrap; }

/* ---------- Карточки и блоки ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.card-title h2, .card-title h3 { margin: 0; }
.section { margin-top: 36px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }

.breadcrumbs { font-size: 14px; color: var(--muted); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span::before { content: "/"; margin-right: 6px; color: #b5bdc6; }

/* ---------- Hero ---------- */
.hero {
  border-radius: 14px; padding: 36px; color: #fff; display: grid; gap: 20px;
  background: linear-gradient(120deg, var(--primary) 0%, #06402f 100%);
  grid-template-columns: 1.4fr 1fr; align-items: center;
}
.hero h1 { font-size: 32px; margin-bottom: 10px; }
.hero p { color: #cfe6da; margin: 0 0 20px; }
.hero-points { display: grid; gap: 10px; }
.hero-point { background: rgba(255,255,255,.1); border-radius: 10px; padding: 12px 14px; }
.hero-point b { display: block; }
.hero-point span { font-size: 13px; color: #cfe6da; }

/* ---------- Категории ---------- */
.categories { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.category-tile {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: box-shadow .15s, transform .15s;
}
.category-tile:hover { box-shadow: var(--shadow-lg); color: var(--primary); transform: translateY(-2px); }
.category-tile img, .category-tile .ph { height: 92px; object-fit: contain; }
.category-tile .ph { display: grid; place-items: center; font-size: 34px; background: var(--primary-soft); border-radius: 8px; }
.category-tile b { font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 6px 12px; border-radius: 20px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Товары ---------- */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.product-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
  display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s;
}
.product-card:hover { box-shadow: var(--shadow-lg); }
.product-card .thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: #fafbfc; border-radius: 8px; overflow: hidden; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.ph-img { font-size: 44px; color: #b9c3ce; }
.product-card .name { color: var(--text); font-weight: 600; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 45px; }
.product-card .name:hover { color: var(--primary); }
.product-card .meta { font-size: 12px; color: var(--muted); }
.product-card .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.price { font-size: 20px; font-weight: 800; }
.price-old { font-size: 13px; color: var(--muted); text-decoration: line-through; margin-left: 6px; font-weight: 400; }
.stock { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.stock::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stock.in { color: var(--green); }
.stock.low { color: #c98a00; }
.stock.out { color: var(--muted); }

.qty { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.qty button { width: 34px; border: 0; background: var(--bg); font-size: 18px; cursor: pointer; color: var(--text); }
.qty button:hover { background: var(--primary-soft); }
.qty input[type=number] { width: 52px; border: 0; border-radius: 0; padding: 0; text-align: center; font: inherit; box-shadow: none; -moz-appearance: textfield; }
.qty input[type=number]:focus { box-shadow: none; background: var(--primary-soft); }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.add-form { display: flex; gap: 6px; }
.add-form .btn { flex: 1; padding-inline: 8px; }

/* ---------- Каталог ---------- */
.catalog { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.filters { position: sticky; top: 140px; max-height: calc(100vh - 160px); overflow-y: auto; }
.filter-group { border-bottom: 1px solid var(--line); padding-block: 14px; }
.filter-group:first-child { padding-top: 0; }
.filter-group:last-of-type { border-bottom: 0; }
.filter-group h4 { margin: 0 0 10px; font-size: 14px; }
.filter-group label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; font-size: 14px; }
.filter-group .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.filter-list { max-height: 210px; overflow-y: auto; }
.price-range { display: flex; gap: 8px; }
.price-range input { width: 100%; }
.filters-toggle { display: none; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select { width: auto; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: 8px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); color: var(--text);
}
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

.empty { text-align: center; padding: 48px 20px; }
.empty .icon { font-size: 48px; margin-bottom: 8px; }

/* ---------- Карточка товара ---------- */
.product-page { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.gallery-main { aspect-ratio: 1; background: #fff; border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs button { width: 64px; height: 64px; padding: 4px; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.gallery-thumbs button.active { border-color: var(--primary); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: contain; }
.buy-box { display: flex; flex-direction: column; gap: 14px; }
.buy-box .price { font-size: 32px; }
.personal-note { background: var(--green-soft); color: #145c34; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.specs { width: 100%; border-collapse: collapse; }
.specs td { padding: 8px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.specs td:first-child { color: var(--muted); width: 45%; padding-right: 12px; }

/* ---------- Формы ---------- */
label { font-weight: 500; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd6de; border-radius: 8px; font: inherit;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(4, 120, 87, .18); }
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field .errors { color: var(--red); font-size: 13px; margin-top: 4px; list-style: none; padding: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-errors { background: var(--red-soft); color: #8f2626; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.radio-cards > div { display: contents; }
.radio-cards label {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 10px; cursor: pointer; font-weight: 500;
}
.radio-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.auth-box { max-width: 420px; margin: 20px auto; }
.auth-box h1 { text-align: center; }

/* ---------- Корзина / оформление ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.summary { position: sticky; top: 140px; }
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary-total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-size: 20px; font-weight: 800; }
.cart-item { display: grid; grid-template-columns: 80px 1fr auto auto 32px; gap: 16px; align-items: center; padding-block: 14px; border-bottom: 1px solid var(--line); }
.cart-item:last-child { border-bottom: 0; }
.cart-item .thumb { width: 80px; height: 80px; background: #fafbfc; border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.cart-item .thumb img { width: 100%; height: 100%; object-fit: contain; }
.cart-item .line-total { font-weight: 700; min-width: 100px; text-align: right; }
.remove-btn { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.remove-btn:hover { color: var(--red); }
.warn { color: #b25e00; font-size: 13px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; }

/* ---------- Статусы ---------- */
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.status-new { background: #fff0e0; color: #b4560c; }
.status-confirmed { background: #ece8fb; color: #5b3fc4; }
.status-assembling { background: #fff6cc; color: #8a6a00; }
.status-delivering, .status-ready { background: #def5f7; color: #0b7682; }
.status-completed { background: var(--primary-soft); color: #06603f; }
.status-cancelled { background: var(--red-soft); color: #b03030; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }

.progress { display: flex; gap: 4px; margin: 16px 0; }
.progress-step { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.progress-step::before { content: ""; display: block; height: 6px; border-radius: 3px; background: var(--line); margin-bottom: 6px; }
.progress-step.done { color: var(--text); }
.progress-step.done::before { background: var(--primary); }

/* ---------- Кабинет ---------- */
.cabinet { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.side-nav { padding: 8px; }
.side-nav a { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.side-nav a:hover { background: var(--bg); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-nav form button { width: 100%; text-align: left; padding: 10px 12px; color: var(--red); font-weight: 400; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 800; }
.order-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding-block: 14px; border-bottom: 1px solid var(--line); }
.order-row:last-child { border-bottom: 0; }

.notification { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.notification:hover { color: var(--text); background: #fafbfc; }
.notification.unread b::before { content: "● "; color: var(--orange); }

/* ---------- Подвал ---------- */
.footer { background: var(--dark); color: #aec9bb; padding-block: 32px; font-size: 14px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer h4 { color: #fff; margin: 0 0 10px; }
.footer a { color: #cfe6da; }
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin-bottom: 6px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1000px) {
  .catalog { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; display: none; }
  .filters.open { display: block; }
  .filters-toggle { display: inline-flex; }
  .cart-layout, .product-page, .cabinet { grid-template-columns: 1fr; }
  .summary { position: static; }
  .hero { grid-template-columns: 1fr; padding: 24px; }
}

@media (max-width: 700px) {
  h1 { font-size: 22px; }
  .header-main { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .header-actions { margin-left: auto; }
  .header-action span.label { display: none; }
  .topbar .hide-sm { display: none; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card { padding: 8px; }
  .price { font-size: 17px; }
  .add-form { flex-direction: column; }
  .add-form .qty { width: 100%; }
  .add-form .qty input { flex: 1; }
  .cart-item { grid-template-columns: 64px 1fr 32px; gap: 10px; }
  .cart-item .thumb { width: 64px; height: 64px; }
  .cart-item .qty-cell { grid-column: 2; }
  .cart-item .line-total { grid-column: 2; text-align: left; }
  .cart-item .remove-cell { grid-row: 1; grid-column: 3; }
  .order-row { grid-template-columns: 1fr auto; }
  .order-row .actions { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
}

.btn.disabled { pointer-events: none; opacity: .5; }
