/* ═══════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* Colors */
  --c-bg:          #f8fafc;
  --c-surface:     #ffffff;
  --c-border:      #e2e8f0;
  --c-border-soft: #f1f5f9;

  --c-text:        #0f172a;
  --c-text-2:      #475569;
  --c-text-3:      #94a3b8;

  --c-accent:      #2563eb;
  --c-accent-d:    #1d4ed8;
  --c-accent-bg:   #eff6ff;
  --c-accent-mid:  #bfdbfe;

  --c-buy:         #16a34a;
  --c-buy-d:       #15803d;

  /* Shadows */
  --s-xs:  0 1px 2px rgba(0,0,0,.04);
  --s-sm:  0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --s-md:  0 4px 20px rgba(0,0,0,.08), 0 1px 6px rgba(0,0,0,.04);
  --s-lg:  0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --s-xl:  0 24px 64px rgba(0,0,0,.16);

  /* Shape */
  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;
  --r-xl:  20px;

  /* Layout */
  --sidebar-w:  252px;
  --header-h:   60px;

  /* Motion */
  --ease:  cubic-bezier(.4,0,.2,1);
  --t-fast: 140ms;
  --t:      200ms;
  --t-slow: 300ms;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESET
   ═══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue',
    Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; height: auto; }
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
}
.page-wrap { flex: 1; padding-bottom: 64px; }

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
.site-header {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
  /* Subtle blur-glass effect */
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.92);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -.025em;
  color: var(--c-text);
  text-decoration: none;
  flex-shrink: 0;
}
.logo svg { color: var(--c-accent); }
.logo:hover { color: var(--c-accent); text-decoration: none; }

.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav__link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-text-2);
  text-decoration: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.site-nav__link:hover { background: var(--c-bg); color: var(--c-text); text-decoration: none; }
.site-nav__link--active { background: var(--c-accent-bg); color: var(--c-accent); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */
.site-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 20px 0;
  font-size: .8rem;
  color: var(--c-text-3);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE LAYOUT  (sidebar + products)
   ═══════════════════════════════════════════════════════════════════════════ */
.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-top: 28px;
}

/* ── Mobile category toggle ─────────────────────────────────────────────── */
.cat-toggle {
  display: none;
  width: 100%;
  align-items: center;
  gap: 10px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
  margin: 16px 0 0;
}
.cat-toggle:hover { background: var(--c-bg); border-color: var(--c-accent-mid); }
.cat-toggle__arrow {
  margin-left: auto;
  color: var(--c-text-3);
  transition: transform var(--t) var(--ease);
  flex-shrink: 0;
}
.cat-toggle[aria-expanded="true"] .cat-toggle__arrow { transform: rotate(180deg); }
.cat-toggle[aria-expanded="true"] { border-color: var(--c-accent); color: var(--c-accent); }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 2px; }

/* ── Category tree ──────────────────────────────────────────────────────── */
.cat-nav { padding: 8px 0 12px; }
.cat-list { list-style: none; }
.cat-list--root { padding: 0 8px; }
.cat-list--child {
  margin: 2px 0 4px 18px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--c-border-soft);
}
.cat-divider {
  height: 1px;
  background: var(--c-border-soft);
  margin: 10px 12px;
}

.cat-item { margin: 1px 0; }

.cat-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  color: var(--c-text-2);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  line-height: 1.4;
  min-width: 0;
}
.cat-link__icon {
  width: 15px; height: 15px;
  flex-shrink: 0;
  opacity: .45;
  transition: opacity var(--t) var(--ease);
}
.cat-link:hover {
  background: var(--c-accent-bg);
  color: var(--c-accent);
  text-decoration: none;
}
.cat-link:hover .cat-link__icon { opacity: .8; }

/* Root categories */
.cat-list--root > .cat-item > .cat-link {
  font-weight: 600;
  font-size: .9rem;
  color: var(--c-text);
}
.cat-list--root > .cat-item > .cat-link:hover { color: var(--c-accent); }

/* Active */
.cat-link--active {
  background: var(--c-accent) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.cat-link--active .cat-link__icon { opacity: 1; }
.cat-link--active:hover {
  background: var(--c-accent-d) !important;
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRODUCTS AREA
   ═══════════════════════════════════════════════════════════════════════════ */
.products-area { min-width: 0; }

.products-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.products-title {
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -.025em;
  line-height: 1.2;
}
.products-count {
  font-size: .82rem;
  color: var(--c-text-3);
  white-space: nowrap;
}

/* ── Product grid ────────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 16px;
}

/* ── Product card ────────────────────────────────────────────────────────── */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  color: var(--c-text);
  text-decoration: none;
  transition:
    transform var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    border-color var(--t) var(--ease);
  will-change: transform;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--s-lg);
  border-color: transparent;
  text-decoration: none;
}

.product-card__media {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--c-bg);
  flex-shrink: 0;
}
.product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease);
  will-change: transform;
}
.product-card:hover .product-card__media img { transform: scale(1.05); }

.product-card__no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: var(--c-text-3);
}

.product-card__body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 14px 16px;
  flex: 1;
}
.product-card__cat {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-accent);
}
.product-card__title {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card__price {
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--c-text);
  letter-spacing: -.02em;
  margin-top: auto;
  padding-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 20px;
  text-align: center;
}
.empty-state__icon { opacity: .3; }
.empty-state__text { font-size: 1rem; color: var(--c-text-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--r);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background var(--t) var(--ease),
    color var(--t) var(--ease),
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    transform var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}
.btn-primary:hover {
  background: var(--c-accent-d);
  border-color: var(--c-accent-d);
  box-shadow: 0 4px 16px rgba(37,99,235,.3);
  color: #fff;
  text-decoration: none;
}

.btn-buy {
  background: var(--c-buy);
  color: #fff;
  border-color: var(--c-buy);
  padding: 13px 28px;
  font-size: .95rem;
}
.btn-buy:hover {
  background: var(--c-buy-d);
  border-color: var(--c-buy-d);
  box-shadow: 0 4px 16px rgba(22,163,74,.3);
  color: #fff;
  text-decoration: none;
}

.btn-buy--disabled {
  background: var(--c-border);
  border-color: var(--c-border);
  color: var(--c-text-3);
  cursor: not-allowed;
}
.btn-buy--disabled:hover {
  background: var(--c-border);
  box-shadow: none;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--c-accent);
  border-color: var(--c-accent-mid);
}
.btn-outline:hover {
  background: var(--c-accent-bg);
  border-color: var(--c-accent);
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════════════════════════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 18px 0 22px;
  font-size: .82rem;
}
.breadcrumb a { color: var(--c-text-3); transition: color var(--t-fast); }
.breadcrumb a:hover { color: var(--c-accent); }
.breadcrumb__sep { color: var(--c-border); user-select: none; }
.breadcrumb__current { color: var(--c-text-2); font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════════════════
   PRODUCT DETAIL PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 52px;
  align-items: start;
  margin-bottom: 64px;
}

.product-detail__gallery {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}
.product-detail__img {
  width: 100%;
  border-radius: var(--r-xl);
  box-shadow: var(--s-md);
  object-fit: cover;
  max-height: 540px;
  display: block;
}
.product-detail__no-img {
  aspect-ratio: 1;
  border-radius: var(--r-xl);
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--c-text-3);
  font-size: .85rem;
}

.product-detail__info {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 4px;
}

.product-detail__cat {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-accent);
  background: var(--c-accent-bg);
  border: 1px solid var(--c-accent-mid);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
  text-decoration: none;
  transition: background var(--t) var(--ease);
}
.product-detail__cat:hover {
  background: var(--c-accent-mid);
  text-decoration: none;
}

.product-detail__title {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.035em;
  color: var(--c-text);
  margin-bottom: 14px;
}
.product-detail__price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -.04em;
  line-height: 1;
  margin-bottom: 28px;
}

.product-detail__desc {
  background: var(--c-bg);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.product-detail__desc-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-3);
  margin-bottom: 10px;
}
.product-detail__desc p {
  font-size: .95rem;
  line-height: 1.75;
  color: var(--c-text-2);
}

.product-detail__meta {
  font-size: .78rem;
  color: var(--c-text-3);
  margin-bottom: 28px;
}
.product-detail__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RELATED PRODUCTS
   ═══════════════════════════════════════════════════════════════════════════ */
.related { padding: 8px 0 56px; }
.related__title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--c-border-soft);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACK LINK
   ═══════════════════════════════════════════════════════════════════════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--c-text-3);
  font-size: .85rem;
  margin: 16px 0;
  transition: color var(--t-fast);
}
.back-link:hover { color: var(--c-accent); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST  (storefront)
   ═══════════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--s-xl);
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
  pointer-events: auto;
}
.toast.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-accent-bg);
  color: var(--c-accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

  .container { padding: 0 16px; }

  /* Layout: single column */
  .page-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 0;
  }

  /* Category toggle: show */
  .cat-toggle { display: flex; }

  /* Sidebar: hidden, slides down when open */
  .sidebar {
    display: none;
    position: static;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: var(--r);
    margin-bottom: 4px;
  }
  .sidebar.sidebar--open {
    display: block;
    animation: slideDown var(--t-slow) var(--ease);
  }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .products-area { padding-top: 16px; }
  .products-title { font-size: 1.2rem; }
  .product-grid { gap: 12px; }

  /* Product detail: single column */
  .product-detail {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 40px;
  }
  .product-detail__gallery { position: static; }
  .product-detail__title   { font-size: 1.45rem; }
  .product-detail__price   { font-size: 1.6rem; margin-bottom: 20px; }
  .product-detail__actions { flex-direction: column; }
  .product-detail__actions .btn { width: 100%; }
}

/* Small mobile */
@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card__body  { padding: 10px 10px 12px; }
  .product-card__title { font-size: .82rem; }
  .product-card__price { font-size: .95rem; padding-top: 6px; }

  .breadcrumb { padding: 14px 0 18px; }
  .related { padding-bottom: 36px; }
  .site-footer { padding: 16px 0; }
  .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
}
