*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:    #f7f2eb;
  --sand:     #e8ddd0;
  --leather:  #c4a882;
  --brown:    #5c3317;
  --dark:     #1a1209;
  --text:     #2d1f0e;
  --muted:    #7a6555;
  --white:    #ffffff;
  --radius:   10px;
  --shadow:   0 2px 16px rgba(28,18,5,0.10);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Georgia', serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--dark);
  color: var(--cream);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  font-weight: normal;
  text-transform: uppercase;
}

.logo span { color: var(--leather); }

nav a {
  color: var(--sand);
  text-decoration: none;
  margin-left: 1.5rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

nav a:hover { color: var(--leather); }

.hero {
  background: var(--brown);
  color: var(--cream);
  text-align: center;
  padding: 4rem 1rem 3rem;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: normal;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.hero p {
  font-family: 'Arial', sans-serif;
  font-size: 1rem;
  opacity: 0.8;
  max-width: 480px;
  margin: 0 auto;
}

.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--sand);
  padding: 0.75rem 2rem;
  position: sticky;
  top: 64px;
  z-index: 90;
  overflow-x: auto;
}

#filter-nav {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.filter-btn {
  background: none;
  border: 1.5px solid var(--sand);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
  white-space: nowrap;
  text-transform: capitalize;
}

.filter-btn:hover, .filter-btn.active {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--cream);
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

#error-msg {
  display: none;
  background: #fdecea;
  border: 1px solid #e57373;
  color: #b71c1c;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.9rem;
}

#product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}

.loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 0;
  color: var(--muted);
  font-family: 'Arial', sans-serif;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--sand);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-family: 'Arial', sans-serif;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(28,18,5,0.14);
}

.card.out-of-stock { opacity: 0.65; }

.card-img-wrap {
  position: relative;
  background: #f0ebe4;
  aspect-ratio: 4/3;
  overflow: hidden;
}

.card-img-inner {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.card-img-inner svg { width: 80px; height: 80px; }

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

.card-color {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Arial', sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: capitalize;
}

.badge-agotado, .badge-oferta, .badge-fotos {
  position: absolute;
  top: 10px; left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: 'Arial', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: bold;
}

.badge-fotos {
  background: rgba(26,18,9,0.55);
  color: #f7f2eb;
  top: auto; bottom: 10px; left: 10px;
}

.badge-agotado { background: #1a1209; color: #f7f2eb; }
.badge-oferta  { background: var(--brown); color: var(--white); top: 10px; left: auto; right: 10px; }

.card-body {
  padding: 1rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.card-categoria {
  font-family: 'Arial', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-nombre {
  font-size: 1.05rem;
  font-weight: normal;
  line-height: 1.3;
}

.card-colors {
  display: flex;
  gap: 6px;
  margin: 2px 0;
}

.color-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.card-pricing {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 2px;
}

.price {
  font-size: 1.1rem;
  color: var(--text);
  font-family: 'Arial', sans-serif;
}

.price-old {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: line-through;
  font-family: 'Arial', sans-serif;
}

.btn-ver {
  margin-top: auto;
  background: var(--dark);
  color: var(--cream);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-ver:hover { background: var(--brown); }

/* ── Galería modal ───────────────────────────────────────────────────────────── */
.gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #f0ebe4;
  overflow: hidden;
}

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

.gallery-prev, .gallery-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: rgba(26,18,9,0.5);
  color: #fff;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}

.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }
.gallery-prev:hover, .gallery-next:hover { background: var(--brown); }

.gallery-count {
  position: absolute;
  bottom: 8px; right: 10px;
  background: rgba(26,18,9,0.5);
  color: #fff;
  font-family: 'Arial', sans-serif;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.gallery-thumbs {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--sand);
  overflow-x: auto;
}

.gallery-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.gallery-thumb.active { border-color: var(--brown); }
.gallery-thumb:hover { border-color: var(--leather); }

#modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,18,9,0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#modal.open { display: flex; }

#modal-box {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-close {
  position: sticky;
  top: 0.8rem;
  float: right;
  margin: 0.8rem 0.8rem 0 0;
  background: var(--sand);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 10;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
}

.modal-close:hover { background: var(--leather); color: white; }

.modal-media {
  width: 100%;
  max-height: 380px;
  overflow: hidden;
  background: #f0ebe4;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-media--placeholder svg { width: 100px; height: 100px; }

.modal-video {
  aspect-ratio: 9/16;
  max-height: 320px;
  background: #000;
}

.modal-video iframe { width: 100%; height: 100%; }

.modal-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-cat {
  font-family: 'Arial', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-nombre {
  font-size: 1.5rem;
  font-weight: normal;
}

.modal-pricing {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.modal-price {
  font-size: 1.4rem;
  font-family: 'Arial', sans-serif;
}

.modal-price-old {
  font-size: 1rem;
  color: var(--muted);
  text-decoration: line-through;
  font-family: 'Arial', sans-serif;
}

.stock-ok { color: #2e7d32; font-family: 'Arial', sans-serif; font-size: 0.85rem; }
.stock-no { color: #c62828; font-family: 'Arial', sans-serif; font-size: 0.85rem; }

.modal-colors-label {
  font-family: 'Arial', sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.color-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.8rem;
  border: 1.5px solid var(--sand);
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font-family: 'Arial', sans-serif;
  font-size: 0.82rem;
  color: var(--text);
  transition: all 0.2s;
  position: relative;
}

.color-btn .color-dot { width: 12px; height: 12px; }
.color-btn:hover { border-color: var(--brown); }
.color-btn.active { border-color: var(--dark); background: var(--cream); font-weight: bold; }
.color-btn.sin-stock { opacity: 0.45; }
.color-btn.sin-stock s {
  position: absolute; inset: 0;
  border-radius: 999px;
  border-top: 1.5px solid var(--muted);
  transform: rotate(-20deg);
}

.modal-medidas {
  font-family: 'Arial', sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--cream);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
}

.modal-desc {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}

.modal-desc .desc-intro { margin-bottom: 0.5rem; }

.modal-desc ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-desc ul li::before {
  content: '▫️ ';
  font-size: 0.75em;
}

.btn-contacto {
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.9rem 1.5rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-contacto:hover { background: #1ebe5d; }

footer {
  background: var(--dark);
  color: var(--sand);
  text-align: center;
  padding: 2rem 1rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.82rem;
  margin-top: 4rem;
  letter-spacing: 0.05em;
}

footer span { color: var(--leather); }

@media (max-width: 600px) {
  header { padding: 0 1rem; }
  nav a { margin-left: 0.8rem; font-size: 0.78rem; }
  main { padding: 0 1rem; margin-top: 1.5rem; }
  #product-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .filter-bar { padding: 0.6rem 1rem; }
  .modal-video { max-height: 240px; }
}

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