/* ── Catalog CSS ──────────────────────────────────────────────────── */
:root {
  --c-bg: #F9FAFB;
  --c-surface: #FFFFFF;
  --c-border: #E5E7EB;
  --c-text: #111827;
  --c-muted: #6B7280;
  --c-accent: #2563EB;
  --c-accent-hover: #1D4ED8;
  --c-danger: #EF4444;
  --c-success: #10B981;
  --c-badge: #FEF3C7;
  --c-badge-text: #92400E;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --r: 10px;
  --font: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); font-size: 15px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Layout ── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ── Header ── */
.site-header { background: #fff; border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 40; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.site-logo { font-size: 18px; font-weight: 700; color: var(--c-accent); letter-spacing: -0.02em; }
.site-logo span { color: var(--c-text); font-weight: 400; }
.cart-btn { display: flex; align-items: center; gap: 8px; background: var(--c-accent); color: #fff; border: none; padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background 200ms; }
.cart-btn:hover { background: var(--c-accent-hover); }
.cart-count { background: #fff; color: var(--c-accent); border-radius: 999px; padding: 1px 7px; font-size: 12px; font-weight: 700; min-width: 22px; text-align: center; }

/* ── Breadcrumb ── */
.breadcrumb { padding: 14px 0; font-size: 13px; color: var(--c-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--c-accent); }
.breadcrumb-sep { color: var(--c-border); }

/* ── Page layout ── */
.catalog-layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; padding: 24px 0 80px; }

/* ── Sidebar ── */
.sidebar { position: sticky; top: 80px; align-self: start; }
.sidebar-title { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-muted); margin-bottom: 12px; }
.cat-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.cat-item a { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; font-size: 14px; transition: background 150ms, color 150ms; }
.cat-item a:hover { background: var(--c-bg); color: var(--c-accent); }
.cat-item.active a { background: #EFF6FF; color: var(--c-accent); font-weight: 500; }
.cat-count { font-size: 12px; color: var(--c-muted); background: var(--c-bg); padding: 1px 7px; border-radius: 999px; }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.view-btn { width: 34px; height: 34px; border: 1px solid var(--c-border); background: #fff; border-radius: 8px; cursor: pointer; display: grid; place-items: center; transition: border-color 150ms, background 150ms; }
.view-btn.active, .view-btn:hover { border-color: var(--c-accent); background: #EFF6FF; color: var(--c-accent); }
.sort-select { border: 1px solid var(--c-border); background: #fff; padding: 8px 12px; border-radius: 8px; font-size: 14px; color: var(--c-text); cursor: pointer; outline: none; }
.sort-select:focus { border-color: var(--c-accent); }
.results-count { font-size: 13px; color: var(--c-muted); }

/* ── Products Grid ── */
.products-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.products-grid.list-view { grid-template-columns: 1fr; }

/* ── Product Card ── */
.product-card { background: var(--c-surface); border-radius: var(--r); border: 1px solid var(--c-border); overflow: hidden; transition: transform 300ms, box-shadow 300ms; display: flex; flex-direction: column; cursor: pointer; }
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: transparent; }
.product-card.list-view { flex-direction: row; height: 160px; }

.card-img { aspect-ratio: 1; background: var(--c-bg); position: relative; overflow: hidden; }
.product-card.list-view .card-img { width: 160px; flex-shrink: 0; aspect-ratio: auto; height: 100%; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms; }
.product-card:hover .card-img img { transform: scale(1.04); }
.card-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--c-bg); color: var(--c-muted); font-size: 13px; }

.badge-discount { position: absolute; top: 10px; left: 10px; background: var(--c-danger); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge-featured { position: absolute; top: 10px; right: 10px; background: var(--c-badge); color: var(--c-badge-text); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }

.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-card.list-view .card-body { padding: 20px; justify-content: center; }
.card-cat { font-size: 11px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card-name { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--c-text); }
.product-card.list-view .card-name { font-size: 17px; }
.card-desc { font-size: 13px; color: var(--c-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--c-border); }
.price-block { display: flex; flex-direction: column; gap: 2px; }
.price-current { font-size: 18px; font-weight: 700; color: var(--c-text); }
.price-old { font-size: 12px; color: var(--c-muted); text-decoration: line-through; }
.add-to-cart { background: var(--c-accent); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background 150ms, transform 100ms; white-space: nowrap; }
.add-to-cart:hover { background: var(--c-accent-hover); }
.add-to-cart:active { transform: scale(0.97); }
.add-to-cart.added { background: var(--c-success); }

/* ── Stock ── */
.stock-label { font-size: 12px; }
.stock-ok { color: var(--c-success); }
.stock-low { color: #F59E0B; }
.stock-out { color: var(--c-danger); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 40px; }
.page-btn { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--c-border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--c-text); transition: border-color 150ms, background 150ms; }
.page-btn:hover { border-color: var(--c-accent); color: var(--c-accent); background: #EFF6FF; }
.page-btn.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ── Cart Sidebar ── */
.cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 60; opacity: 0; pointer-events: none; transition: opacity 250ms; }
.cart-overlay.open { opacity: 1; pointer-events: auto; }
.cart-panel { position: fixed; top: 0; right: -420px; width: 420px; max-width: 100vw; height: 100%; background: #fff; z-index: 61; display: flex; flex-direction: column; transition: right 280ms cubic-bezier(0.22,0.61,0.36,1); box-shadow: -8px 0 40px rgba(0,0,0,0.12); }
.cart-panel.open { right: 0; }
.cart-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--c-border); }
.cart-panel-title { font-size: 18px; font-weight: 700; }
.cart-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--c-muted); padding: 4px; line-height: 1; }
.cart-close:hover { color: var(--c-text); }
.cart-items { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.cart-empty { text-align: center; color: var(--c-muted); padding: 60px 0; font-size: 15px; }
.cart-item { display: flex; gap: 12px; padding: 12px; background: var(--c-bg); border-radius: 10px; }
.cart-item-img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--c-border); flex-shrink: 0; }
.cart-item-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.cart-item-name { font-size: 14px; font-weight: 500; }
.cart-item-price { font-size: 13px; color: var(--c-muted); }
.cart-item-qty { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.qty-btn { width: 26px; height: 26px; border: 1px solid var(--c-border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; display: grid; place-items: center; }
.qty-btn:hover { border-color: var(--c-accent); }
.qty-val { font-size: 14px; font-weight: 500; min-width: 20px; text-align: center; }
.cart-item-remove { background: none; border: none; color: var(--c-muted); cursor: pointer; font-size: 16px; padding: 4px; margin-left: auto; align-self: flex-start; }
.cart-item-remove:hover { color: var(--c-danger); }
.cart-panel-foot { padding: 16px 24px; border-top: 1px solid var(--c-border); }
.cart-total { display: flex; justify-content: space-between; margin-bottom: 16px; font-size: 15px; }
.cart-total-amount { font-weight: 700; font-size: 20px; }
.checkout-btn { width: 100%; background: var(--c-accent); color: #fff; border: none; padding: 14px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 150ms; }
.checkout-btn:hover { background: var(--c-accent-hover); }
.cart-demo-note { font-size: 12px; color: var(--c-muted); text-align: center; margin-top: 10px; }

/* ── Product Detail ── */
.product-detail { padding: 32px 0 80px; }
.product-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
.product-gallery-main { aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--c-bg); border: 1px solid var(--c-border); }
.product-gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.product-info { display: flex; flex-direction: column; gap: 20px; }
.product-cat-tag { font-size: 12px; color: var(--c-accent); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.product-title { font-size: 28px; font-weight: 700; line-height: 1.2; }
.product-price-block { display: flex; align-items: baseline; gap: 12px; }
.product-price { font-size: 32px; font-weight: 800; }
.product-old-price { font-size: 18px; color: var(--c-muted); text-decoration: line-through; }
.product-discount { background: var(--c-danger); color: #fff; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 6px; }
.product-desc { font-size: 15px; line-height: 1.7; color: var(--c-muted); }
.product-add-row { display: flex; gap: 12px; align-items: center; }
.qty-control { display: flex; align-items: center; gap: 0; border: 1px solid var(--c-border); border-radius: 10px; overflow: hidden; }
.qty-control .qty-btn { border: none; border-radius: 0; width: 40px; height: 48px; font-size: 18px; }
.qty-control .qty-val { width: 48px; text-align: center; font-size: 16px; font-weight: 600; }
.add-btn-lg { flex: 1; background: var(--c-accent); color: #fff; border: none; padding: 14px 24px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 150ms; }
.add-btn-lg:hover { background: var(--c-accent-hover); }

/* ── Hero section (index) ── */
.catalog-hero { background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); color: #fff; padding: 48px 0 40px; }
.catalog-hero h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; margin-bottom: 10px; letter-spacing: -0.02em; }
.catalog-hero p { font-size: 16px; color: rgba(255,255,255,0.78); max-width: 500px; }
.catalog-demo-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); padding: 6px 14px; border-radius: 999px; font-size: 13px; margin-bottom: 20px; }

/* ── Featured section (index) ── */
.section-label { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-muted); margin-bottom: 16px; }
.section-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; }
.featured-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ── Categories grid (index) ── */
.categories-section { padding: 48px 0; }
.categories-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.cat-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r); padding: 24px 20px; transition: border-color 200ms, box-shadow 200ms, transform 200ms; cursor: pointer; }
.cat-card:hover { border-color: var(--c-accent); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.cat-card-icon { font-size: 28px; margin-bottom: 12px; }
.cat-card-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.cat-card-count { font-size: 13px; color: var(--c-muted); }

/* ── LocalStorage notice ── */
.ls-notice { background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px; padding: 10px 16px; font-size: 13px; color: #92400E; display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .catalog-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .featured-grid { grid-template-columns: repeat(2, 1fr); }
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .product-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .products-grid { grid-template-columns: 1fr; }
  .featured-grid { grid-template-columns: 1fr; }
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .cart-panel { width: 100%; right: -100%; }
}

/* ── Checkout success (inline, вместо alert) ──────────────────── */
.checkout-success {
  margin: 0 24px 16px;
  padding: 20px;
  background: var(--c-success);
  border-radius: 10px;
  color: #fff;
  text-align: center;
  animation: fadeIn 300ms ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.checkout-success-icon  { font-size: 28px; margin-bottom: 8px; }
.checkout-success-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.checkout-success-sub   { font-size: 14px; opacity: .9; margin-bottom: 8px; }
.checkout-success-note  { font-size: 12px; opacity: .7; }

/* ── product-card как <a> — убираем подчёркивание и цвет ссылки ── */
a.product-card {
  display: flex;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.product-card.list-view { flex-direction: row; }

/* ── Шапка каталога — новые элементы ─────────────────────────── */
.site-header .wrap {
  justify-content: space-between;
}
.site-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-muted);
  padding: 7px 12px;
  border-radius: 6px;
  transition: background 150ms, color 150ms;
  white-space: nowrap;
}
.site-nav-link:hover {
  background: var(--c-bg);
  color: var(--c-text);
}
.site-nav-link--admin {
  position: relative;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-weight: 600;
}
.site-nav-link--admin:hover {
  border-color: var(--c-accent);
  background: #EFF6FF;
}
.admin-creds {
  display: inline-block;
  margin-left: 6px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--c-muted);
  background: #fff;
  border: 1px solid var(--c-border);
  padding: 1px 6px;
  border-radius: 4px;
}
