:root {
  --bg: #131312;
  --bg-card: #1e1e1c;
  --bg-card-hover: #262624;
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.15);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --border: rgba(255, 255, 255, 0.08);
  --header-h: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

img {
  max-width: 100%;
  height: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(19, 19, 18, 0.92);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

.site-header__inner,
.page-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

.site-header__inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-family: Outfit, Inter, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gold);
  letter-spacing: 0.02em;
  min-width: 0;
  flex-shrink: 1;
}

.brand__short { display: none; }

.nav-links {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 20px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  min-width: 0;
}

.nav-links a {
  color: var(--muted);
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--gold);
}

.nav-links a.nav-promo {
  color: #f0c96a;
}

.nav-links a.nav-promo.is-active {
  color: var(--gold);
}

.nav-cart-btn {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-cart-btn:hover,
.nav-cart-btn.is-active {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.4);
  background: rgba(212, 175, 55, 0.1);
}

.nav-cart-btn__icon {
  display: block;
}

.nav-cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #722f37;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--gold);
  pointer-events: none;
}

.nav-cart-badge[hidden] {
  display: none !important;
}

/* Legacy: contador en link texto "Carrito" (nav viejo) */
.nav-cart-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: #722f37;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--gold);
  vertical-align: middle;
}

.nav-cart-count[hidden] {
  display: none !important;
}

/* Legacy: ocultar menú hamburguesa / drawer (HTML viejo en servidor).
   display:flex en .nav-drawer anula el atributo [hidden] — forzar none. */
.nav-toggle,
.nav-backdrop,
.nav-drawer,
.nav-drawer[hidden],
.nav-backdrop[hidden],
#nav-drawer,
#nav-backdrop,
#nav-toggle {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  max-width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  transform: translateX(100%) !important;
}

body.nav-open {
  overflow-x: hidden;
}

.hero {
  padding: 32px 0 20px;
}

.hero h1 {
  margin: 0 0 8px;
  font-family: Outfit, Inter, sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
  font-size: clamp(0.92rem, 2.5vw, 1rem);
}

/* Layout: grid + panel de categorías a la derecha */
.catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
}

.catalog-layout__main {
  min-width: 0;
}

.cat-panel {
  display: block;
}

.cat-panel__inner {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow: auto;
  padding: 22px 18px;
  border-radius: 20px;
  border: 1px solid rgba(212, 175, 55, 0.22);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(212, 175, 55, 0.08), transparent 55%),
    linear-gradient(165deg, #171715 0%, #111110 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.cat-panel__inner::-webkit-scrollbar { width: 4px; }
.cat-panel__inner::-webkit-scrollbar-track { background: transparent; }
.cat-panel__inner::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.22);
  border-radius: 999px;
}

.cat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.cat-panel__title {
  margin: 0;
  font-family: Outfit, Inter, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.cat-panel__clear {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.cat-panel__clear:hover {
  color: var(--gold);
  background: var(--gold-soft);
}

.cat-panel__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-panel__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.cat-panel__item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.cat-panel__item.is-active {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.4);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.16), rgba(184, 148, 31, 0.06));
  box-shadow: 0 2px 14px rgba(212, 175, 55, 0.08);
}

.cat-panel__item .cat-item__icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.cat-panel__item .cat-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
}

.cat-panel__item .count {
  flex-shrink: 0;
  min-width: 26px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
}

.cat-panel__item:not(.is-active) .count {
  color: #6e6e73;
  background: rgba(255, 255, 255, 0.05);
}

/* Chips horizontales: solo móvil / tablet */
.cat-bar {
  display: none;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.cat-bar::-webkit-scrollbar { display: none; }

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-chip:hover,
.cat-chip.is-active {
  border-color: rgba(212, 175, 55, 0.4);
  background: var(--gold-soft);
  color: var(--text);
}

.cat-chip .count {
  font-size: 0.7rem;
  color: var(--gold);
}

.cat-chip .cat-item__icon {
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.toolbar-search {
  flex: 1 1 220px;
  max-width: 420px;
  margin: 0;
}

.toolbar-search__input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.toolbar-search__input:focus {
  outline: none;
  border-color: rgba(212, 175, 55, 0.45);
}

.toolbar .summary {
  flex: 1 1 180px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
  border: 1px solid rgba(212, 175, 55, 0.1);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  min-width: 0;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    border-color: rgba(212, 175, 55, 0.28);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  }
}

.card__image {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
}

.card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--gold);
  color: #131312;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
}

.badge--out {
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

.card__body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.card__category {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.card__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
  min-height: 2.7em;
  overflow-wrap: anywhere;
}

.card__sku {
  font-size: 0.78rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.card__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  flex-wrap: wrap;
}

.price {
  font-family: Outfit, Inter, sans-serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 1.05rem;
}

.price-old {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: line-through;
  margin-right: 6px;
  font-weight: 500;
}

.btn-cart {
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: rgba(212, 175, 55, 0.08);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-cart:hover:not(:disabled) {
  background: var(--gold);
  color: #131312;
}

.btn-cart:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 18px;
}

.pagination {
  margin-top: 36px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.page-link {
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.page-link:hover {
  border-color: rgba(212, 175, 55, 0.35);
  color: var(--text);
  background: var(--gold-soft);
}

.page-link.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: #131312;
}

.page-link.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.page-link.is-ellipsis {
  border: none;
  min-width: auto;
  padding: 0 4px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px max(16px, var(--safe-left)) max(40px, var(--safe-bottom)) max(16px, var(--safe-right));
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Tablet / mobile: chips arriba, sin panel sticky */
@media (max-width: 960px) {
  .catalog-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .cat-panel {
    display: none;
  }

  .cat-bar--mobile {
    display: flex;
  }

  .grid {
    gap: 16px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .site-header__inner {
    flex-wrap: nowrap;
    row-gap: 0;
    padding-top: 10px;
    padding-bottom: 10px;
    min-height: var(--header-h);
  }

  /* HTML legacy: nav-links--desktop estaba oculto en móvil */
  .nav-links,
  .nav-links--desktop {
    display: flex !important;
    order: 0;
    flex: 1;
    justify-content: center;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 4px;
    font-size: 0.68rem;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  /* Ocultar link texto "Carrito" solo si ya hay icono de carrito */
  .site-header__inner:has(.nav-cart-btn) .nav-links .nav-cart-link {
    display: none !important;
  }

  .brand__full {
    display: none;
  }

  .brand__short {
    display: inline;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }

  .toolbar-search {
    max-width: none;
  }

  .toolbar .summary {
    font-size: 0.82rem;
  }
}

@media (max-width: 640px) {
  :root {
    --header-h: 64px;
  }

  .page-wrap {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
  }

  .hero {
    padding-top: 24px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .card__body {
    padding: 12px;
  }

  .card__title {
    font-size: 0.82rem;
    min-height: auto;
    line-height: 1.3;
  }

  .card__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-cart {
    width: 100%;
    text-align: center;
    padding: 10px 12px;
  }

  .price {
    font-size: 0.95rem;
  }

  .page-link {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    font-size: 0.82rem;
  }
}

@media (max-width: 380px) {
  .grid {
    grid-template-columns: 1fr;
  }
}
