:root {
  --azul: #2563eb;
  --azul-oscuro: #1d4ed8;
  --morado: #9333ea;
  --morado-oscuro: #7e22ce;
  --gradiente: linear-gradient(90deg, var(--azul), var(--morado));
  --texto: #111827;
  --texto-suave: #6b7280;
  --borde: #e5e7eb;
  --fondo: #f9fafb;
  --blanco: #ffffff;
  --rojo: #dc2626;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(17, 24, 39, .06), 0 4px 14px rgba(17, 24, 39, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

img { max-width: 100%; display: block; }

button, input, select { font: inherit; }

/* ---------- Topbar ---------- */

.topbar {
  background: var(--gradiente);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--sombra);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  color: #fff;
}

.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; opacity: .85; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.catalogo-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 13px;
  background: rgba(255,255,255,.15);
  padding: 6px 10px;
  border-radius: 999px;
}

.catalogo-select-wrap select {
  background: transparent;
  color: #fff;
  border: none;
  font-weight: 600;
}

.catalogo-select-wrap select option { color: #111827; }

/* ---------- Botones ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradiente);
  color: #fff;
}

.btn-primary:hover { opacity: .92; }

.btn-ghost {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.btn-ghost:hover { background: rgba(255,255,255,.25); }

.btn-ghost.activo {
  background: #fff;
  color: var(--morado-oscuro);
}

.btn-link {
  background: none;
  color: var(--azul-oscuro);
  padding: 4px 2px;
  text-decoration: underline;
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 230px 1fr 320px;
  gap: 20px;
  align-items: start;
}

.layout.layout-sin-cotizacion {
  grid-template-columns: 230px 1fr;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .filtros, .cotizacion { position: static; }
}

.filtros, .cotizacion {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 16px;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.filtros h2, .cotizacion h2 {
  font-size: 14px;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texto-suave);
}

.grupo-filtro { margin-bottom: 16px; }
.grupo-filtro h3 {
  font-size: 12px;
  margin: 0 0 6px;
  color: var(--texto);
  font-weight: 700;
}

.chip-filtro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--borde);
  background: var(--fondo);
  border-radius: 999px;
  padding: 5px 10px;
  margin: 0 6px 6px 0;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.chip-filtro input { accent-color: var(--morado); }

.chip-filtro.activo {
  background: #ede9fe;
  border-color: var(--morado);
  color: var(--morado-oscuro);
  font-weight: 600;
}

/* ---------- Catálogo ---------- */

.catalogo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

#buscador {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--borde);
  background: var(--blanco);
}

.contador { font-size: 12px; color: var(--texto-suave); white-space: nowrap; }

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

.sin-resultados {
  text-align: center;
  color: var(--texto-suave);
  padding: 40px 0;
}

.tarjeta {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tarjeta-img-wrap {
  aspect-ratio: 1 / 1;
  background: var(--fondo);
  position: relative;
  overflow: hidden;
}

.tarjeta-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tarjeta-cuerpo {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tarjeta-titulo {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  min-height: 35px;
}

.badges { display: flex; flex-wrap: wrap; gap: 5px; }

.badge {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--fondo);
  color: var(--texto-suave);
  border: 1px solid var(--borde);
  white-space: nowrap;
}

.badge-tecnica { background: #eff6ff; color: var(--azul-oscuro); border-color: #dbeafe; }

.colores-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--borde);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  background: var(--fondo);
}

.swatch img { width: 100%; height: 100%; object-fit: cover; }

.swatch.activo { border-color: var(--morado); }

.swatch-mas {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px dashed var(--borde);
  background: var(--fondo);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--texto-suave);
  cursor: pointer;
}

.color-nombre {
  font-size: 11px;
  color: var(--texto-suave);
}

.color-contador { color: #9ca3af; }

.tallas-info {
  font-size: 11.5px;
  color: var(--texto-suave);
  background: var(--fondo);
  border-radius: 6px;
  padding: 5px 8px;
}

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

.talla-cantidad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.talla-cantidad label {
  font-size: 10px;
  color: var(--texto-suave);
  font-weight: 600;
}

.talla-cantidad input {
  width: 100%;
  text-align: center;
  padding: 4px 2px;
  border-radius: 6px;
  border: 1px solid var(--borde);
}

.talla-cantidad input:disabled {
  background: var(--fondo);
  color: #d1d5db;
}

.sku-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(17, 24, 39, .78);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 4px 9px;
  border-radius: 999px;
}

.btn-copiar-link {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.9);
  cursor: pointer;
  font-size: 14px;
  box-shadow: var(--sombra);
}

.badge-incluye { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.tabla-precios-tarjeta {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  background: var(--fondo);
  border-radius: 8px;
  overflow: hidden;
}

.tabla-precios-tarjeta td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--borde);
}

.tabla-precios-tarjeta tr:last-child td { border-bottom: none; }
.tabla-precios-tarjeta td.num { text-align: right; font-weight: 700; }

.preview-precio {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--borde);
  padding-top: 8px;
  margin-top: 2px;
  font-size: 12.5px;
  font-weight: 700;
}

.preview-subtotal.preview-vacio { color: var(--texto-suave); font-weight: 500; }

.btn-agregar {
  margin-top: 4px;
  width: 100%;
}

.tarjeta-resaltada {
  outline: 3px solid var(--morado);
  outline-offset: 2px;
}

.nota-general {
  max-width: 1400px;
  margin: 10px auto 0;
  padding: 0 20px;
  font-size: 12.5px;
  color: var(--texto-suave);
  text-align: center;
}

.botones-envio {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-whatsapp {
  width: 100%;
  background: #25d366;
  color: #fff;
}

.btn-whatsapp:hover { opacity: .92; }

.btn-ghost-oscuro {
  background: var(--fondo);
  color: var(--texto);
  border: 1px solid var(--borde);
}

/* ---------- Modal "Pedir cotización" ---------- */

.modal-cotizar {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.modal-cotizar[hidden] { display: none !important; }

.modal-caja {
  background: #fff;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-cerrar {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--texto-suave);
}

.modal-caja h3 { margin: 0 0 4px; font-size: 16px; }
.modal-sub { font-size: 12.5px; color: var(--texto-suave); margin: 0 0 14px; }

#modal-tallas {
  margin-bottom: 12px;
}

#modal-mensaje {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--borde);
  padding: 10px 12px;
  font-size: 12.5px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
  background: var(--fondo);
}

.modal-acciones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Lightbox de imágenes ---------- */

.tarjeta-img-wrap img { cursor: zoom-in; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, .92);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox[hidden] { display: none !important; }

.lightbox img {
  max-width: min(90vw, 900px);
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.lightbox-cerrar {
  position: absolute;
  top: 16px;
  right: 20px;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.lightbox-cerrar:hover { background: rgba(255,255,255,.22); }

.lightbox-flecha {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

.lightbox-flecha:hover { background: rgba(255,255,255,.22); }
.lightbox-flecha[disabled] { opacity: .25; cursor: default; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-pie {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  padding: 0 60px;
}

.lightbox-contador { color: rgba(255,255,255,.6); }

@media (max-width: 640px) {
  .lightbox { padding: 16px; }
  .lightbox-flecha { width: 40px; height: 40px; font-size: 20px; }
}

/* ---------- Cotización (carrito) ---------- */

.cotizacion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cliente-datos {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.cliente-datos input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--borde);
}

.lista-cotizacion {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 12px;
}

.lista-cotizacion .vacio {
  color: var(--texto-suave);
  font-size: 12.5px;
  text-align: center;
  padding: 20px 0;
}

.item-cotizacion {
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  position: relative;
}

.item-cotizacion .item-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-weight: 700;
}

.item-cotizacion .item-detalle {
  color: var(--texto-suave);
  font-size: 11.5px;
  margin-top: 2px;
}

.item-cotizacion .item-quitar {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--rojo);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.cotizacion-totales {
  border-top: 1px solid var(--borde);
  padding-top: 10px;
  margin-bottom: 12px;
}

.fila-total {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}

.fila-total.total-grande {
  font-size: 18px;
  font-weight: 800;
}

.btn-imprimir { width: 100%; }

.nota-print {
  font-size: 10.5px;
  color: var(--texto-suave);
  text-align: center;
  margin-top: 8px;
}

.pie {
  text-align: center;
  font-size: 11px;
  color: var(--texto-suave);
  padding: 24px 20px 40px;
}

/* ---------- Impresión / PDF ---------- */

.solo-print { display: none; }

@media print {
  body * { visibility: hidden; }
  .solo-print, .solo-print * { visibility: visible; }
  .solo-print {
    display: block;
    position: absolute;
    left: 0; top: 0;
    width: 100%;
  }
  .no-print { display: none !important; }
  /* Blindaje extra: el costo de proveedor jamás se imprime, sin importar el toggle en pantalla. */
  .costo-referencia { display: none !important; }
}

#hoja-impresion {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #111827;
  padding: 10mm;
}

#hoja-impresion .doc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 3px solid var(--morado);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

#hoja-impresion .doc-header img { width: 48px; height: 48px; border-radius: 50%; }

#hoja-impresion .doc-header .doc-title { font-size: 20px; font-weight: 800; }
#hoja-impresion .doc-header .doc-sub { font-size: 12px; color: #6b7280; }

#hoja-impresion .doc-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 14px;
  color: #374151;
}

#hoja-impresion table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 16px;
}

#hoja-impresion th, #hoja-impresion td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

#hoja-impresion th {
  background: #f9fafb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

#hoja-impresion td.num, #hoja-impresion th.num { text-align: right; }

#hoja-impresion td.col-img { width: 46px; padding: 4px; }
#hoja-impresion td.col-img img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }

#hoja-impresion .doc-totales {
  margin-left: auto;
  width: 260px;
  font-size: 13px;
}

#hoja-impresion .doc-totales .fila { display: flex; justify-content: space-between; padding: 3px 0; }
#hoja-impresion .doc-totales .fila.total { font-size: 17px; font-weight: 800; border-top: 2px solid #111827; margin-top: 4px; padding-top: 6px; }

#hoja-impresion .doc-pie {
  margin-top: 24px;
  font-size: 10.5px;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
}
