/* ═══════════════════════════════════════════
   Tema v4 (Comercial) — base compartida de las páginas
   Prefijo: v4-  · Solo se carga en páginas del tema v4 (los colores viven en chrome.css)
═══════════════════════════════════════════ */

body.theme-v4 {
  --app-bg: #ffffff;
  margin: 0;
  padding-top: 0;
  background: #ffffff;
  color: var(--v4-ink, #111827);
  font-family: var(--v4-font, "Inter", sans-serif);
}

.v4-main {
  font-family: var(--v4-font);
  color: var(--v4-ink);
  padding-bottom: 72px;
}

.v4-main *,
.v4-main *::before,
.v4-main *::after {
  box-sizing: border-box;
}

/* Baja especificidad: los enlaces heredan el color, pero cualquier clase (botones, tarjetas) manda */
:where(.v4-main) a {
  color: inherit;
}

.v4-wrap {
  width: 100%;
  max-width: var(--v4-wrap);
  margin: 0 auto;
  padding: 0 24px;
}

.v4-section {
  margin-top: 56px;
}

.v4-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.v4-eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--v4-accent);
}

.v4-eyebrow--sale {
  color: var(--v4-sale-ink);
}

.v4-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.v4-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--v4-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.v4-link:hover {
  color: var(--v4-accent);
}

/* ── Botones ── */
.v4-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 26px;
  border-radius: 10px;
  border: 1.5px solid var(--v4-ink);
  background: #ffffff;
  color: var(--v4-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.v4-btn:hover {
  background: var(--v4-soft);
}

.v4-btn--dark {
  background: var(--v4-ink);
  color: #ffffff;
}

.v4-btn--dark:hover {
  background: #000000;
}

.v4-btn--accent {
  background: var(--v4-accent);
  border-color: var(--v4-accent);
  color: #ffffff;
}

.v4-btn--accent:hover {
  background: color-mix(in srgb, var(--v4-accent) 88%, #000000);
}

.v4-btn--block {
  width: 100%;
}

/* ── Grilla de productos ── */
.v4-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 32px 20px;
}

/* Carrusel horizontal (en celular); en computadora se vuelve grilla */
.v4-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 32px 20px;
}

/* ── Tarjeta de producto: mismo alto siempre ── */
.v4-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  height: 100%;
}

.v4-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--v4-radius);
  background: var(--v4-soft);
  overflow: hidden;
}

.v4-card-media > a {
  display: block;
  width: 100%;
  height: 100%;
}

.v4-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8%;
  mix-blend-mode: multiply;
  transition: transform 0.3s ease;
}

.v4-card:hover .v4-card-media img {
  transform: scale(1.04);
}

.v4-card.is-out .v4-card-media img {
  opacity: 0.55;
}

.v4-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
}

.v4-badge--sale {
  background: var(--v4-sale);
  color: #ffffff;
}

.v4-badge--muted {
  background: var(--v4-ink);
  color: #ffffff;
}

.v4-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: #ffffff;
  color: var(--v4-ink);
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.v4-card-fav.active,
.v4-card-fav.is-active {
  color: var(--v4-sale);
}

.v4-card-fav.active path,
.v4-card-fav.is-active path {
  fill: currentColor;
}

.v4-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
  min-width: 0;
}

.v4-card-cat {
  margin: 0;
  height: 16px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--v4-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v4-card-name {
  margin: 0;
  height: 40px; /* 2 líneas fijas */
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.v4-card-name a {
  text-decoration: none;
  color: var(--v4-ink);
}

.v4-card-name a:hover {
  color: var(--v4-accent);
}

.v4-card-price {
  margin: 4px 0 0;
  height: 24px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.v4-price {
  flex-shrink: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--v4-ink);
}

.v4-price.is-sale {
  color: var(--v4-sale);
}

.v4-price-old {
  min-width: 0;
  font-size: 13px;
  color: var(--v4-muted);
  text-decoration: line-through;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v4-card-add {
  margin-top: auto;
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--v4-ink);
  background: #ffffff;
  color: var(--v4-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.v4-card-add:hover {
  background: var(--v4-ink);
  color: #ffffff;
}

.v4-card-add.is-muted {
  border-color: var(--v4-line);
  color: var(--v4-muted);
}

.v4-card-add.is-loading {
  opacity: 0.6;
  cursor: progress;
}

.v4-card-add.is-done {
  background: var(--v4-ok);
  border-color: var(--v4-ok);
  color: #ffffff;
}

.v4-card-add-short {
  display: none;
}

/* ── Vacío ── */
.v4-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--v4-muted);
  background: var(--v4-soft);
  border-radius: 16px;
}

/* ── Celular ── */
@media (max-width: 1023px) {
  .v4-wrap {
    padding: 0 12px;
  }

  .v4-section {
    margin-top: 36px;
  }

  .v4-section-head {
    margin-bottom: 14px;
    padding: 0 4px;
  }

  .v4-title {
    font-size: 21px;
  }

  .v4-eyebrow {
    font-size: 11px;
    margin-bottom: 2px;
  }

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

  .v4-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -12px;
    padding: 0 12px 4px;
    scrollbar-width: none;
  }

  .v4-rail::-webkit-scrollbar {
    display: none;
  }

  .v4-rail > * {
    flex: 0 0 168px;
    scroll-snap-align: start;
  }

  .v4-card {
    gap: 10px;
  }

  .v4-card-name {
    font-size: 14px;
    line-height: 19px;
    height: 38px;
  }

  .v4-price {
    font-size: 15px;
  }

  .v4-price-old {
    font-size: 12px;
  }

  .v4-card-fav {
    width: 36px;
    height: 36px;
    top: 8px;
    right: 8px;
  }

  .v4-badge {
    top: 10px;
    left: 10px;
  }

  .v4-card-add-long {
    display: none;
  }

  .v4-card-add-short {
    display: inline;
  }
}

/* ═══════════════════════════════════════════
   Utilidades de las páginas de cuenta, ayuda y pedidos
   (adaptadas de v2 para que esas páginas conserven su estructura)
═══════════════════════════════════════════ */

.v4-container {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--v4-wrap);
  margin: 0 auto;
  padding: 0 16px;
}

.v4-section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.v4-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.v4-grid--list {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

@media (max-width: 1023px) {
  .v4-grid--list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Entre dos secciones seguidas: línea fina, repartiendo el mismo espacio arriba y abajo */
.v4-section + .v4-section {
  margin-top: 24px;
}

.v4-section + .v4-section::before {
  content: "";
  display: block;
  height: 1px;
  margin-bottom: 24px;
  background: var(--v4-line);
}

.v4-btn--ghost {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.85);
  color: var(--v4-ink);
}

.v4-btn--ghost:hover {
  background: #fff;
}

.v4-btn--outline {
  background: #fff;
  border-color: #d6d6db;
  color: var(--v4-ink);
}

.v4-btn--outline:hover {
  border-color: var(--v4-ink);
}

.v4-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: var(--v4-ink);
  box-shadow: 0 1px 4px rgba(20, 24, 35, 0.1);
}

/* ── Tarjeta de producto ─────────────────── */

/* ── Cabecera de página (recuadro con el tono de la marca) ── */

.v4-pagehead {
  margin-top: 12px;
  padding: 26px 22px 22px;
  border-radius: 24px;
  background: #f5eef1;
  background: color-mix(in srgb, var(--v4-accent) 16%, #ffffff);
  color: var(--v4-ink);
}

.v4-pagehead-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

.v4-pagehead-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

/* ── Tarjeta de categoría (collage) ──────── */

.v4-catcard {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--v4-line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--v4-shadow);
  color: var(--v4-ink);
  text-decoration: none;
  transition: box-shadow 0.2s ease;
}

.v4-catcard:hover {
  box-shadow: var(--v4-shadow-hover);
}

/* 1 grande + 2 chicas */
.v4-catcard-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 6px;
  aspect-ratio: 1 / 1;
}

.v4-catcard-media--2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.v4-catcard-media--3 {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.v4-catcard-media--3 .v4-catcard-tile:first-child {
  grid-row: span 2;
}

.v4-catcard-tile {
  position: relative;
  border-radius: 14px;
  background: var(--v4-soft);
  overflow: hidden;
}

.v4-catcard-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 10px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.v4-catcard-media--3 .v4-catcard-tile:not(:first-child) img {
  padding: 6px;
}

.v4-catcard-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b4b4bb;
}

.v4-catcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 4px 2px 6px;
}

.v4-catcard-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.v4-catcard-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.v4-catcard-count {
  margin-top: 1px;
  color: var(--v4-muted);
  font-size: 12px;
}

.v4-catcard .v4-arrow {
  width: 28px;
  height: 28px;
  background: var(--v4-soft);
  box-shadow: none;
}

/* ── Avisos (css/Toast.css) ──
   Mismo tamaño y letra en todas las páginas del tema, incluido el carrito (.toast de Cart.js). */
body.theme-v4 .cart-toast,
body.theme-v4 .cart-toast * {
  box-sizing: border-box;
}

body.theme-v4 .cart-toast {
  font-family: var(--v4-font);
}

/* ── Campos de formulario en móvil ──
   Safari en iPhone hace zoom al tocar un campo con letra menor a 16px.
   Con 16px no hace zoom (sin bloquear el zoom con los dedos). */
@media (max-width: 1023px) {
  body.theme-v4 input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
  body.theme-v4 select,
  body.theme-v4 textarea {
    font-size: 16px !important;
  }
}

/* ── Panel de búsqueda (components/search.php + js/Header.js) ──
   Solo estilos: la búsqueda en vivo y los recomendados siguen igual. */

body.theme-v4 .search-overlay {
  padding: 16px 16px 40px;
  background: #fff;
  backdrop-filter: none;
  font-family: var(--v4-font);
}

body.theme-v4 .search-overlay *,
body.theme-v4 .search-overlay *::before,
body.theme-v4 .search-overlay *::after {
  box-sizing: border-box;
}

body.theme-v4 .search-box {
  max-width: 720px;
  height: 52px;
  padding: 0 6px 0 48px;
  border: 1px solid #d6d6db;
  border-radius: 999px;
  background: #fff;
  box-shadow: none;
}

body.theme-v4 .search-box:focus-within {
  border-color: var(--v4-ink);
}

/* Lupa dentro del campo */
body.theme-v4 .search-box::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 18px;
  width: 20px;
  height: 20px;
  background: var(--v4-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='7.5'/%3E%3Cpath d='M21 21l-5.2-5.2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='7.5'/%3E%3Cpath d='M21 21l-5.2-5.2'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: translateY(-50%);
  pointer-events: none;
}

/* 16px evita que iPhone haga zoom al escribir */
body.theme-v4 #searchInput {
  height: 100%;
  font-family: var(--v4-font);
  font-size: 16px;
  font-weight: 500;
  color: var(--v4-ink);
}

body.theme-v4 #searchInput::placeholder {
  color: #a3a3aa;
}

/* Cerrar: la imagen original queda transparente (recibe el clic) y se dibuja una X del tema */
body.theme-v4 #closeSearch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--v4-soft);
  transition: background-color 0.2s ease;
}

body.theme-v4 #closeSearch:hover {
  background: #e8e8eb;
  opacity: 1;
  transform: none;
}

body.theme-v4 #closeSearch img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

body.theme-v4 #closeSearch::after {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--v4-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

/* Resultados */
body.theme-v4 .search-results {
  max-width: 1100px;
  margin-top: 22px;
  gap: 14px;
}

body.theme-v4 .search-results-header {
  padding: 0 2px;
  color: var(--v4-ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

body.theme-v4 .search-results-title--recommended::before {
  width: 7px;
  height: 7px;
  background: var(--v4-accent);
}

body.theme-v4 .search-results-count {
  color: var(--v4-muted);
  font-size: 12px;
  font-weight: 500;
}

body.theme-v4 .search-results-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 14px;
}

/* Tarjeta igual a la de la tienda (.v4-card) */
body.theme-v4 .result-item {
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--v4-ink);
}

body.theme-v4 .result-item:hover {
  border: 0;
  box-shadow: none;
  transform: none;
}

body.theme-v4 .result-item .result-media {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--v4-line);
  border-radius: 18px;
  transition: box-shadow 0.2s ease;
}

body.theme-v4 .result-item:hover .result-media {
  box-shadow: var(--v4-shadow-hover);
}

body.theme-v4 .result-item .result-media img {
  padding: 10%;
}

body.theme-v4 .result-item .badge-offer,
body.theme-v4 .result-item .badge-agotado {
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  box-shadow: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: none;
}

body.theme-v4 .result-item .badge-offer {
  background: var(--v4-accent);
}

body.theme-v4 .result-item .badge-agotado {
  border: 1px solid var(--v4-line);
  background: #fff;
  color: var(--v4-muted);
}

body.theme-v4 .result-item .info {
  gap: 6px;
  min-height: 0;
  padding: 0 2px;
}

body.theme-v4 .result-item h4 {
  display: -webkit-box;
  min-height: 2.7em;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

body.theme-v4 .result-item .price,
body.theme-v4 .result-item .price-offer {
  color: var(--v4-ink);
  font-size: 14px;
  font-weight: 600;
}

body.theme-v4 .result-item .price-old {
  color: var(--v4-muted);
  font-size: 12px;
}

body.theme-v4 .search-results .no-results {
  margin-top: 24px;
  color: var(--v4-muted);
  font-size: 14px;
}

@media (min-width: 700px) {
  body.theme-v4 .search-overlay {
    padding: 32px 24px 48px;
  }

  body.theme-v4 .search-results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 26px 16px;
  }
}

@media (min-width: 1024px) {
  body.theme-v4 .search-overlay {
    padding: 48px 32px 56px;
  }

  body.theme-v4 .search-results {
    margin-top: 32px;
  }

  body.theme-v4 .search-results-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 28px 18px;
  }
}


@media (min-width: 700px) {
  .v4-container {
    padding: 0 24px;
  }

  .v4-pagehead {
    padding: 30px 28px 26px;
  }

  .v4-pagehead-title {
    font-size: 34px;
  }
}

@media (min-width: 1024px) {
  .v4-container {
    padding: 0 32px;
  }

  .v4-pagehead {
    margin-top: 20px;
    padding: 40px 36px 34px;
  }

  .v4-pagehead-title {
    font-size: 40px;
  }

  .v4-section-title {
    font-size: 22px;
  }
}

/* Estilo comercial sobre lo adaptado de v2 */
.v4-pagehead {
  border-radius: var(--v4-radius);
}

.v4-pagehead-title {
  font-weight: 800;
  letter-spacing: -0.03em;
}

.v4-btn--outline {
  border-radius: 10px;
}
