/* =========================================================================
   Repuestos Stone — Sistema de diseño del catálogo (Etapa 2)
   Todos los colores derivan de 5 variables que vienen de Ajustes de Tienda:
     --rs-primary   (color_principal)
     --rs-accent    (color_botones)
     --rs-agotado / --rs-promo / --rs-descuento  (colores de etiqueta)
   El resto (tintes, hovers, bordes) se calcula con color-mix(), así que
   cambiar la paleta en el panel re-tematiza toda la home.
   ========================================================================= */

:root {
  /* Fallbacks; includes/theme.php los sobrescribe con los valores reales */
  --rs-primary: #5700fa;
  --rs-accent:  #ea4881;
  --rs-agotado: #ef4444;
  --rs-promo:   #f97316;
  --rs-descuento: #3b82f6;

  /* Derivados de marca */
  --rs-primary-050: color-mix(in srgb, var(--rs-primary) 5%,  #ffffff);
  --rs-primary-100: color-mix(in srgb, var(--rs-primary) 12%, #ffffff);
  --rs-primary-200: color-mix(in srgb, var(--rs-primary) 22%, #ffffff);
  --rs-primary-600: var(--rs-primary);
  --rs-primary-700: color-mix(in srgb, var(--rs-primary) 82%, #000000);
  --rs-primary-contrast: #ffffff;

  --rs-accent-050: color-mix(in srgb, var(--rs-accent) 6%,  #ffffff);
  --rs-accent-100: color-mix(in srgb, var(--rs-accent) 14%, #ffffff);
  --rs-accent-600: var(--rs-accent);
  --rs-accent-700: color-mix(in srgb, var(--rs-accent) 84%, #000000);
  --rs-accent-contrast: #ffffff;

  /* Neutros */
  --rs-bg:        #fafafa;
  --rs-surface:   #ffffff;
  --rs-surface-2: #f6f6f7;
  --rs-border:    color-mix(in srgb, #0b0b12 8%, transparent);
  --rs-border-strong: color-mix(in srgb, #0b0b12 14%, transparent);
  --rs-ink:       #17171c;
  --rs-ink-soft:  #52525b;
  --rs-ink-mute:  #8a8a94;

  /* Tipografía */
  --rs-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Radios y sombras */
  --rs-r-sm: 10px;
  --rs-r-md: 14px;
  --rs-r-lg: 20px;
  --rs-r-xl: 28px;
  --rs-shadow-sm: 0 1px 2px rgba(16,16,22,.04), 0 1px 3px rgba(16,16,22,.06);
  --rs-shadow-md: 0 4px 12px rgba(16,16,22,.06), 0 2px 6px rgba(16,16,22,.05);
  --rs-shadow-lg: 0 18px 40px -12px rgba(16,16,22,.18);
  --rs-ring: 0 0 0 4px color-mix(in srgb, var(--rs-primary) 18%, transparent);

  /* Ritmo vertical de secciones */
  --rs-section-gap: clamp(2.5rem, 6vw, 4.5rem);
}

/* ----------------------------- Base ------------------------------------- */
body.rs {
  background: var(--rs-bg);
  color: var(--rs-ink);
  font-family: var(--rs-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.rs *, .rs *::before, .rs *::after { box-sizing: border-box; }

.rs-container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }

/* --------------------------- Tipografía -------------------------------- */
.rs-h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.08; color: var(--rs-ink); }
.rs-h2 { font-size: clamp(1.25rem, 2.4vw, 1.6rem); font-weight: 800; letter-spacing: -.015em; color: var(--rs-ink); }
.rs-lead { font-size: clamp(1rem, 1.6vw, 1.075rem); color: var(--rs-ink-soft); line-height: 1.6; }
.rs-eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--rs-primary-600); }

/* Encabezado de sección con barrita de marca */
.rs-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: clamp(1.1rem, 2.5vw, 1.75rem); }
.rs-section-title { position: relative; padding-left: .9rem; font-size: clamp(1.15rem, 2.2vw, 1.5rem); font-weight: 800; letter-spacing: -.015em; color: var(--rs-ink); }
.rs-section-title::before { content: ""; position: absolute; left: 0; top: .12em; bottom: .12em; width: 4px; border-radius: 4px; background: linear-gradient(var(--rs-primary), var(--rs-accent)); }
.rs-section-link { flex-shrink: 0; font-size: .8rem; font-weight: 700; color: var(--rs-primary-600); text-decoration: none; white-space: nowrap; transition: color .2s; }
.rs-section-link:hover { color: var(--rs-primary-700); }

/* ----------------------------- Botones -------------------------------- */
.rs-btn { --_bg: var(--rs-primary-600); --_fg: var(--rs-primary-contrast);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-weight: 700; font-size: .82rem; letter-spacing: .02em;
  padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid transparent;
  background: var(--_bg); color: var(--_fg); cursor: pointer;
  transition: transform .18s ease, box-shadow .22s ease, background .22s ease, color .22s ease, border-color .22s ease;
  box-shadow: var(--rs-shadow-sm);
}
.rs-btn:hover { transform: translateY(-1px); box-shadow: var(--rs-shadow-md); }
.rs-btn:active { transform: translateY(0) scale(.98); }
.rs-btn:focus-visible { outline: none; box-shadow: var(--rs-ring); }
.rs-btn--accent { --_bg: var(--rs-accent-600); --_fg: var(--rs-accent-contrast); }
.rs-btn--accent:hover { --_bg: var(--rs-accent-700); }
.rs-btn--ghost { --_bg: transparent; --_fg: var(--rs-ink); border-color: var(--rs-border-strong); box-shadow: none; }
.rs-btn--ghost:hover { --_bg: var(--rs-surface-2); }

/* Botón WhatsApp: al pasar el ratón se rellena de verde y salta un poco */
.rs-btn--wa { --_bg: transparent; --_fg: #128C4B; border-color: #25D366; box-shadow: none; }
.rs-btn--wa:hover {
  --_bg: #25D366; --_fg: #ffffff; border-color: #25D366;
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 14px 28px -12px rgba(37, 211, 102, .55);
}
.rs-btn--wa:active { transform: translateY(0) scale(.98); }
.rs-btn--block { width: 100%; }
.rs-btn--sm { padding: .5rem .85rem; font-size: .75rem; }

/* ----------------------------- Chips --------------------------------- */
.rs-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; color: var(--rs-ink-soft); background: var(--rs-surface);
  border: 1px solid var(--rs-border); cursor: pointer; transition: all .18s ease; white-space: nowrap; }
.rs-chip:hover { border-color: var(--rs-border-strong); color: var(--rs-ink); }
.rs-chip[aria-selected="true"], .rs-chip.is-active {
  background: var(--rs-primary-600); border-color: var(--rs-primary-600); color: var(--rs-primary-contrast);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--rs-primary) 55%, transparent);
}

/* ----------------------------- Badges -------------------------------- */
.rs-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .6rem; border-radius: 999px;
  font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.rs-badge--promo { background: var(--rs-promo); }
.rs-badge--descuento { background: var(--rs-descuento); }
.rs-badge--agotado { background: var(--rs-agotado); }
.rs-tag { font-size: .625rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--rs-ink-mute); background: var(--rs-surface-2); border: 1px solid var(--rs-border);
  padding: .2rem .5rem; border-radius: 7px; }

/* --------------------------- Tarjeta producto ------------------------ */
.rs-card { position: relative; display: flex; flex-direction: column; background: var(--rs-surface);
  border: 1px solid var(--rs-border); border-radius: var(--rs-r-lg); overflow: hidden;
  box-shadow: var(--rs-shadow-sm); transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.rs-card:hover { transform: translateY(-4px); box-shadow: var(--rs-shadow-lg);
  border-color: color-mix(in srgb, var(--rs-primary) 30%, var(--rs-border)); }
.rs-card__media { position: relative; aspect-ratio: 1 / 1; background: var(--rs-surface-2); overflow: hidden; cursor: pointer; }
.rs-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.7,.2,1); display: block; }
.rs-card:hover .rs-card__media img { transform: scale(1.06); }
.rs-card__badges { position: absolute; top: .7rem; left: .7rem; display: flex; flex-direction: column; gap: .35rem; z-index: 2; }
.rs-card__sold { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, #0b0b12 32%, transparent); z-index: 3; }
.rs-card__sold span { background: var(--rs-agotado); color: #fff; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; font-size: .72rem; padding: .5rem 1.1rem; border-radius: 999px; box-shadow: var(--rs-shadow-md); }
.rs-card__body { display: flex; flex-direction: column; gap: .55rem; padding: clamp(.8rem, 2vw, 1.1rem); flex: 1; }
.rs-card__title { font-size: .95rem; font-weight: 700; line-height: 1.3; color: var(--rs-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.rs-card__title:hover { color: var(--rs-primary-700); }
.rs-card__tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.rs-card__price-row { margin-top: auto; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.rs-price { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; color: var(--rs-ink); line-height: 1; }
.rs-price--muted { color: var(--rs-ink-mute); }
.rs-price__was { font-size: .8rem; font-weight: 700; color: var(--rs-ink-mute); text-decoration: line-through; }
.rs-price__from { font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--rs-ink-mute); }
.rs-card__actions { display: flex; flex-direction: column; gap: .4rem; margin-top: .3rem; }
.rs-card__more { background: none; border: 0; cursor: pointer; font-size: .68rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: var(--rs-primary-600); padding: .15rem; transition: color .2s; }
.rs-card__more:hover { color: var(--rs-primary-700); }

/* ------------------------------ Grid -------------------------------- */
.rs-grid { display: grid; gap: clamp(.7rem, 2vw, 1.5rem);
  grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px)  { .rs-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .rs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* --------------------------- Skeleton ------------------------------ */
.rs-skel { position: relative; overflow: hidden; background: var(--rs-surface-2); }
.rs-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); z-index: 1;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, #fff 65%, transparent), transparent);
  animation: rs-shimmer 1.4s infinite; }
@keyframes rs-shimmer { 100% { transform: translateX(100%); } }

/* Imagen de tarjeta: se desvanece al cargar (solo si el JS marca el estado) */
.rs-card__media.is-loading img { opacity: 0; }
.rs-card__media img.is-loaded { opacity: 1; }
.rs-card__media img { transition: opacity .45s ease, transform .5s cubic-bezier(.2,.7,.2,1); }

/* ----------------------- Reveal al hacer scroll -------------------- */
.rs-reveal { opacity: 0; transform: translateY(16px); transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); }
.rs-reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .rs-reveal { opacity: 1; transform: none; transition: none; }
  .rs-card, .rs-card__media img, .rs-btn { transition: none !important; }
}

/* ------------------------------ Hero ------------------------------- */
.rs-hero { position: relative; overflow: hidden; border-radius: var(--rs-r-xl);
  background:
    radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, var(--rs-primary) 16%, transparent), transparent 55%),
    radial-gradient(120% 120% at 100% 100%, color-mix(in srgb, var(--rs-accent) 16%, transparent), transparent 55%),
    var(--rs-surface);
  border: 1px solid var(--rs-border);
  padding: clamp(1.75rem, 5vw, 3.5rem);
}
/* Si hay imagen de fondo configurada (Ajustes -> Identidad Visual): la foto
   queda a la derecha y un degradé del color de superficie a la izquierda
   mantiene el texto legible encima, sin importar la foto que se suba.
   El "background-image" (degradé + url de la foto) se pone inline en el HTML
   -- no acá -- porque una url() dentro de una variable CSS usada desde este
   archivo se resuelve relativa a la carpeta de theme.css, no a la página. */
.rs-hero--img {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.rs-hero__search { display: flex; align-items: center; gap: .5rem; background: var(--rs-surface);
  border: 1px solid var(--rs-border-strong); border-radius: 999px; padding: .5rem .5rem .5rem 1.1rem;
  box-shadow: var(--rs-shadow-md); max-width: 560px; }
.rs-hero__search input { flex: 1; border: 0; outline: none; background: transparent; font-size: .95rem; color: var(--rs-ink); }
.rs-hero__search input::placeholder { color: var(--rs-ink-mute); }
.rs-trust { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1.4rem; }
.rs-trust span { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 600; color: var(--rs-ink-soft); }
.rs-trust svg { width: 1.05rem; height: 1.05rem; color: var(--rs-primary-600); flex-shrink: 0; }

/* ===================== Ficha de producto (PDP) ===================== */
.rs-crumb { display: flex; align-items: center; gap: .5rem; font-size: 12.5px; color: var(--rs-ink-mute); margin-bottom: 1.25rem; flex-wrap: wrap; }
.rs-crumb a { color: var(--rs-ink-soft); text-decoration: none; }
.rs-crumb a:hover { color: var(--rs-primary); }
.rs-crumb__cur { color: var(--rs-ink); font-weight: 600; }

.rs-pdp { display: grid; grid-template-columns: 1fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
@media (min-width: 900px) { .rs-pdp { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); } }

.rs-pdp__gallery { position: sticky; top: 96px; display: flex; flex-direction: column; gap: .75rem; }
@media (max-width: 899px) { .rs-pdp__gallery { position: static; } }
.rs-pdp__stage { position: relative; border-radius: var(--rs-r-lg); overflow: hidden; }
.rs-pdp__stage img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; cursor: zoom-in; }
.rs-pdp__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--rs-border);
  background: color-mix(in srgb, var(--rs-surface) 92%, transparent); color: var(--rs-ink); cursor: pointer; }
.rs-pdp__nav--prev { left: 12px; } .rs-pdp__nav--next { right: 12px; }
.rs-pdp__thumbs { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .25rem; }
/* .hidden (utilidad) debe poder ocultar estos elementos aunque las clases rs-* fijen display */
.rs-pdp__nav.hidden, .rs-pdp__thumbs.hidden { display: none !important; }
.thumb-galeria { width: 68px; height: 68px; border-radius: 12px; object-fit: cover; cursor: pointer;
  border: 2px solid transparent; background: var(--rs-surface); flex-shrink: 0; transition: border-color .18s; }
.thumb-galeria:hover, .thumb-galeria.is-active { border-color: var(--rs-primary); }

.rs-pdp__buy { display: flex; flex-direction: column; }
.rs-pdp__rating { display: flex; align-items: center; gap: .5rem; font-size: 12.5px; color: var(--rs-ink-soft); margin-bottom: .5rem; font-weight: 600; }
.rs-stars { --v: 5; display: inline-block; width: 84px; height: 15px; background:
  linear-gradient(90deg, #f5b301 calc(var(--v) / 5 * 100%), color-mix(in srgb, var(--rs-ink) 15%, transparent) 0);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 12px, transparent 12px 16.8px);
          mask: repeating-linear-gradient(90deg, #000 0 12px, transparent 12px 16.8px); }
.rs-pdp__meta { display: flex; flex-wrap: wrap; gap: .4rem; margin: .9rem 0 0; }
.rs-pdp__price { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin: 1.1rem 0 .25rem; }
.rs-pdp__stock { font-size: 12.5px; font-weight: 700; color: var(--rs-ink-soft); margin: .9rem 0 1rem; display: flex; align-items: center; gap: .35rem; }
.rs-pdp__actions { display: flex; gap: .7rem; align-items: stretch; }
@media (max-width: 480px) { .rs-pdp__actions { flex-wrap: wrap; } }

.rs-qty { display: inline-flex; align-items: center; border: 1px solid var(--rs-border-strong); border-radius: 999px; background: var(--rs-surface); height: 52px; }
.rs-qty button { width: 44px; height: 100%; border: 0; background: none; font-size: 20px; font-weight: 700; color: var(--rs-ink-soft); cursor: pointer; }
.rs-qty button:hover { color: var(--rs-primary); }
.rs-qty span { min-width: 30px; text-align: center; font-weight: 800; color: var(--rs-ink); }

.rs-select { position: relative; }
.rs-select select { width: 100%; appearance: none; -webkit-appearance: none; border: 1px solid var(--rs-border-strong);
  border-radius: var(--rs-r-md); padding: .8rem 2.5rem .8rem 1rem; font-size: 14px; font-weight: 600; color: var(--rs-ink);
  background: var(--rs-surface); cursor: pointer; }
.rs-select select:focus { outline: none; box-shadow: var(--rs-ring); border-color: var(--rs-primary); }
.rs-select svg { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--rs-ink-mute); pointer-events: none; }

.rs-pdp__link { display: inline-flex; align-items: center; gap: .4rem; background: none; border: 0; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: var(--rs-ink-soft); padding: .3rem 0; }
.rs-pdp__link:hover { color: var(--rs-primary); }
.rs-pdp__link svg { width: 15px; height: 15px; }
.rs-pdp__desc { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rs-border); }

/* Descripción con formato (HTML del editor) */
.rs-richtext { font-size: 14px; line-height: 1.7; color: var(--rs-ink-soft); margin-top: .6rem; }
.rs-richtext > :first-child { margin-top: 0; }
.rs-richtext p { margin: .6rem 0; }
.rs-richtext h2 { font-size: 1.15rem; font-weight: 800; color: var(--rs-ink); margin: 1.2rem 0 .5rem; letter-spacing: -.01em; }
.rs-richtext h3 { font-size: 1rem; font-weight: 700; color: var(--rs-ink); margin: 1rem 0 .4rem; }
.rs-richtext ul, .rs-richtext ol { margin: .6rem 0; padding-left: 1.4rem; }
.rs-richtext li { margin: .25rem 0; }
.rs-richtext a { color: var(--rs-primary); text-decoration: underline; text-underline-offset: 2px; }
.rs-richtext strong, .rs-richtext b { color: var(--rs-ink); font-weight: 700; }
.rs-richtext blockquote { margin: .8rem 0; padding: .5rem 0 .5rem 1rem; border-left: 3px solid var(--rs-primary);
  color: var(--rs-ink); background: var(--rs-primary-050); border-radius: 0 8px 8px 0; }
.rs-richtext img { max-width: 100%; height: auto; border-radius: var(--rs-r-md); margin: .8rem 0; display: block; }
.rs-richtext iframe { max-width: 100%; width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--rs-r-md); margin: .8rem 0; }
.rs-richtext .ql-align-center { text-align: center; }
.rs-richtext .ql-align-right { text-align: right; }

/* Reseñas de producto en la ficha */
.rs-reviews { display: grid; gap: .8rem; }
@media (min-width: 720px) { .rs-reviews { grid-template-columns: 1fr 1fr; } }
.rs-review { background: var(--rs-surface); border: 1px solid var(--rs-border); border-radius: var(--rs-r-md); padding: 1rem 1.1rem; }
.rs-review__head { display: flex; align-items: center; gap: .65rem; margin-bottom: .55rem; }
.rs-review__avatar { width: 34px; height: 34px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  color: var(--rs-primary-contrast); background: var(--rs-primary); }
.rs-review__meta { flex: 1; min-width: 0; }
.rs-review__name { font-weight: 700; font-size: 13px; color: var(--rs-ink); line-height: 1.2; }
.rs-review__stars { display: inline-flex; margin-top: 2px; }
.rs-review__date { font-size: 11px; font-weight: 600; color: var(--rs-ink-mute); white-space: nowrap; }
.rs-review__text { font-size: 13.5px; line-height: 1.6; color: var(--rs-ink-soft); }

/* Barra de compra fija en móvil */
.rs-pdp-sticky { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: none;
  align-items: center; gap: .75rem; padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--rs-surface) 94%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--rs-border); box-shadow: 0 -8px 24px -16px rgba(16,16,22,.3); }
#view-product:not(.hidden) ~ .rs-pdp-sticky { }
.rs-pdp-sticky__price { font-weight: 800; font-size: 18px; color: var(--rs-ink); white-space: nowrap; }
@media (max-width: 720px) { body.pdp-open .rs-pdp-sticky { display: flex; } }

/* --------------------------- Utilidades --------------------------- */
.rs-muted { color: var(--rs-ink-soft); }
.rs-surface { background: var(--rs-surface); border: 1px solid var(--rs-border); border-radius: var(--rs-r-lg); }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
