/* =========================================================================
   CATÁLOGO DE CLIENTES — DISEÑO v4 (prueba del diseño nuevo)
   Pensado primero para celular, estilo tienda online. Si gusta, la idea
   es llevar estos mismos tokens al vendedor y al panel.
   Todo color/medida sale de este bloque :root.
   ========================================================================= */
:root {
  /* Marca */
  --amarillo: #ffbe0c;
  --amarillo-suave: #fff4d1;
  --tinta-sobre-amarillo: #1a1400;
  --rojo: #b71d16;
  --verde: #1f8a4c;
  --verde-suave: #e3f4ea;

  /* Superficies y texto */
  --fondo: #f5f4f0;
  --superficie: #ffffff;
  --superficie-2: #efeee9;
  --borde: #e4e2dc;
  --texto: #16150f;
  --texto-suave: #6d6b64;
  --texto-tenue: #9b988f;

  /* Forma */
  --radio-s: 10px;
  --radio-m: 16px;
  --radio-l: 24px;
  --sombra-1: 0 1px 2px rgba(20, 18, 10, .06), 0 2px 8px rgba(20, 18, 10, .05);
  --sombra-2: 0 12px 40px rgba(20, 18, 10, .18);
  --fuente: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif;
  --ancho-max: 1180px;
  --gutter: 16px;
  --rapido: 160ms cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --amarillo-suave: #3a2f0c;
    --verde-suave: #143322;
    --fondo: #111110;
    --superficie: #1b1b19;
    --superficie-2: #252522;
    --borde: #2e2e2a;
    --texto: #f3f2ee;
    --texto-suave: #a9a69d;
    --texto-tenue: #77746c;
    --sombra-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sombra-2: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--fuente);
  font-size: 16px;
  line-height: 1.4;
  background: var(--fondo);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg { fill: currentColor; }

main { max-width: var(--ancho-max); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Barra superior ---------- */
.barra-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: #111110;
  color: #fff;
}
.marca img { height: 40px; width: auto; }
.barra-top-acciones { display: flex; align-items: center; gap: 8px; }
.btn-fantasma {
  background: transparent; border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; border-radius: 999px; padding: 7px 14px; font-size: .85rem;
}
.btn-pedido {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: var(--amarillo); color: var(--tinta-sobre-amarillo);
  display: grid; place-items: center;
}
.btn-pedido svg { width: 22px; height: 22px; }
.contador {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--rojo); color: #fff; font-size: .72rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #111110;
}
.btn-pedido.pulso { animation: pulso 400ms var(--rapido); }
@keyframes pulso { 50% { transform: scale(1.15); } }

/* ---------- Hero ---------- */
.hero { padding: 22px 0 8px; }
.hero h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
.hero p { margin: 4px 0 0; color: var(--texto-suave); font-size: .95rem; max-width: 46ch; }

/* ---------- Selector de catálogos ---------- */
.catalogos {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px;
  scrollbar-width: none;
}
.catalogos::-webkit-scrollbar { display: none; }
.btn-catalogo {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 16px; border-radius: var(--radio-m);
  background: var(--superficie); border: 2px solid var(--borde);
  box-shadow: var(--sombra-1); font-weight: 600; font-size: .9rem;
  transition: border-color var(--rapido), transform var(--rapido);
}
.btn-catalogo img { height: 30px; width: auto; max-width: 110px; object-fit: contain; }
.btn-catalogo.activo { border-color: var(--amarillo); background: var(--amarillo-suave); }
.btn-catalogo:active { transform: scale(.97); }

/* ---------- Buscador + chips (fijos al scrollear) ---------- */
.filtros-sticky {
  position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 20;
  margin: 0 calc(var(--gutter) * -1);
  padding: 10px var(--gutter) 8px;
  background: color-mix(in srgb, var(--fondo) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.buscador {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 16px; border-radius: 999px;
  background: var(--superficie); border: 1px solid var(--borde);
  box-shadow: var(--sombra-1);
}
.buscador svg { width: 20px; height: 20px; color: var(--texto-tenue); flex: 0 0 auto; }
.buscador input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1rem; }
.buscador:focus-within { border-color: var(--amarillo); }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-top: 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--borde); background: var(--superficie);
  font-size: .88rem; font-weight: 500; white-space: nowrap;
  transition: background var(--rapido), color var(--rapido);
}
.chip.activo { background: var(--texto); color: var(--fondo); border-color: var(--texto); }
.chips-sub .chip { height: 30px; font-size: .8rem; background: transparent; }
.chips-sub .chip.activo { background: var(--amarillo); color: var(--tinta-sobre-amarillo); border-color: var(--amarillo); }

.resultado-info { margin: 8px 0 10px; font-size: .82rem; color: var(--texto-suave); }

/* ---------- Grilla de productos ---------- */
.grilla {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .grilla { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 960px) { .grilla { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tarjeta {
  display: flex; flex-direction: column;
  background: var(--superficie); border-radius: var(--radio-m);
  overflow: hidden; box-shadow: var(--sombra-1);
  border: 1px solid var(--borde);
}
.tarjeta-foto {
  position: relative; aspect-ratio: 1; background: #fff;
  border: 0; padding: 0; display: block; width: 100%;
}
.tarjeta-foto img { width: 100%; height: 100%; object-fit: contain; padding: 10px; opacity: 0; transition: opacity 250ms; }
.tarjeta-foto img.cargada { opacity: 1; }
.tarjeta-foto.cargando::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(0, 0, 0, .05) 50%, transparent 70%) #f3f2ee;
  background-size: 200% 100%; animation: brillo 1.2s infinite linear;
}
@keyframes brillo { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.sin-foto { position: absolute; inset: 0; display: grid; place-items: center; color: #c9c6bd; font-size: 2rem; }
.etiqueta {
  position: absolute; top: 8px; left: 8px;
  font-size: .68rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px;
}
.etiqueta-oferta { background: var(--rojo); color: #fff; }
.etiqueta-stock { background: #111110; color: #fff; }

.tarjeta-cuerpo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.tarjeta-marca { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--texto-tenue); }
.tarjeta-nombre {
  font-size: .92rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  background: none; border: 0; padding: 0; text-align: left;
}
.tarjeta-desc { font-size: .78rem; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.precio { margin-top: auto; padding-top: 6px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.precio-actual { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.precio-tachado { font-size: .8rem; color: var(--texto-tenue); text-decoration: line-through; }
.tarjeta-pie { padding: 0 12px 12px; }
.tarjeta.agotada .tarjeta-foto img { filter: grayscale(1); opacity: .45; }

/* Botón agregar / control de cantidad */
.btn-agregar {
  width: 100%; height: 40px; border-radius: var(--radio-s); border: 0;
  background: var(--amarillo); color: var(--tinta-sobre-amarillo);
  font-weight: 700; font-size: .9rem;
  transition: transform var(--rapido), filter var(--rapido);
}
.btn-agregar:active { transform: scale(.97); }
.btn-agregar:disabled { background: var(--superficie-2); color: var(--texto-tenue); cursor: not-allowed; }
.cantidad {
  display: flex; align-items: center; height: 40px;
  border-radius: var(--radio-s); background: var(--texto); color: var(--fondo); overflow: hidden;
}
.cantidad button { width: 44px; height: 100%; border: 0; background: transparent; color: inherit; font-size: 1.25rem; font-weight: 600; }
.cantidad input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: inherit;
  text-align: center; font-weight: 700; font-size: 1rem; -moz-appearance: textfield;
}
.cantidad input::-webkit-outer-spin-button, .cantidad input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cantidad.chica { height: 34px; width: 120px; }
.cantidad.chica button { width: 36px; }

.vacio { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--texto-suave); }
.vacio strong { display: block; color: var(--texto); font-size: 1.05rem; margin-bottom: 4px; }
.cargando-catalogo { grid-column: 1 / -1; }
.esqueleto { height: 290px; border-radius: var(--radio-m); background: var(--superficie); border: 1px solid var(--borde); }

/* ---------- Barra inferior del pedido ---------- */
.barra-pedido {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--fondo) 60%, transparent);
}
.barra-pedido button {
  width: 100%; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 18px; border: 0; border-radius: var(--radio-m);
  background: #111110; color: #fff; box-shadow: var(--sombra-2); font-size: .92rem;
}
.barra-total { margin-left: auto; font-weight: 700; }
.barra-cta { background: var(--amarillo); color: var(--tinta-sobre-amarillo); padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem; }

/* ---------- Hojas (bottom sheet en celu, modal en PC) ---------- */
.hoja-fondo {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 10, 8, .5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 200ms;
}
.hoja-fondo.visible { opacity: 1; pointer-events: auto; }
.hoja {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--superficie); border-radius: var(--radio-l) var(--radio-l) 0 0;
  padding: 22px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  transform: translateY(30px); transition: transform 240ms var(--rapido);
  overscroll-behavior: contain;
}
.hoja-fondo.visible .hoja { transform: none; }
@media (min-width: 720px) {
  .hoja-fondo { align-items: center; }
  .hoja { border-radius: var(--radio-l); padding: 28px; }
}
.hoja-cerrar {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--superficie-2); font-size: .9rem;
}
.hoja h2 { margin: 0 0 4px; font-size: 1.3rem; letter-spacing: -.01em; }
.hoja .sub { margin: 0 0 16px; color: var(--texto-suave); font-size: .9rem; }

/* Detalle de producto */
.detalle-fotos { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: -4px 0 14px; }
.detalle-fotos .foto { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 1; max-height: 360px; background: #fff; border-radius: var(--radio-m); display: grid; place-items: center; }
.detalle-fotos img { max-height: 100%; object-fit: contain; padding: 12px; }
.detalle-meta { font-size: .8rem; color: var(--texto-tenue); margin-top: 4px; }
.detalle-desc { color: var(--texto-suave); margin: 8px 0 0; }
.detalle-acciones { display: flex; gap: 10px; margin-top: 18px; }
.detalle-acciones .cantidad { width: 140px; flex: 0 0 auto; height: 52px; }
.btn-principal {
  flex: 1; height: 52px; border: 0; border-radius: var(--radio-m);
  background: var(--amarillo); color: var(--tinta-sobre-amarillo); font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn-principal:disabled { opacity: .5; cursor: wait; }
.btn-whatsapp { background: #25d366; color: #062b14; }
.btn-secundario {
  flex: 1; height: 48px; border-radius: var(--radio-m); border: 1px solid var(--borde);
  background: transparent; font-weight: 600; display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn-secundario { color: var(--texto); }
.pila-botones { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
/* En columna, flex:1 pisa el alto de los botones: acá van con su alto fijo. */
.pila-botones > *, .pedido-acciones > * { flex: none; }
@media (min-width: 640px) { .pedido-acciones > * { flex: 1; } }

/* Carrito */
.linea {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--borde);
}
.linea-foto { width: 56px; height: 56px; border-radius: var(--radio-s); background: #fff; border: 1px solid var(--borde); overflow: hidden; display: grid; place-items: center; color: #c9c6bd; }
.linea-foto img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.linea-nombre { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.linea-precio { font-size: .8rem; color: var(--texto-suave); margin-top: 2px; }
.linea-der { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.linea-quitar { border: 0; background: none; color: var(--texto-tenue); font-size: .78rem; padding: 0; text-decoration: underline; }
.resumen { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 4px; font-weight: 700; font-size: 1.1rem; }
.nota-precio { font-size: .8rem; color: var(--texto-suave); margin: 0; }

.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: .85rem; font-weight: 600; }
.campo input, .campo textarea {
  width: 100%; padding: 13px 14px; border-radius: var(--radio-s);
  border: 1px solid var(--borde); background: var(--fondo); font-size: 1rem; outline: 0;
}
.campo input:focus, .campo textarea:focus { border-color: var(--amarillo); }
.campo small { color: var(--texto-tenue); font-size: .78rem; }

.listo-icono { width: 64px; height: 64px; border-radius: 50%; background: var(--verde-suave); color: var(--verde); display: grid; place-items: center; font-size: 2rem; margin: 6px 0 14px; }
.link-pedido { display: flex; gap: 8px; margin-top: 4px; }
.link-pedido input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: var(--radio-s); border: 1px solid var(--borde); background: var(--fondo); font-size: .85rem; color: var(--texto-suave); }
.link-pedido button { border: 0; border-radius: var(--radio-s); background: var(--superficie-2); padding: 0 14px; font-weight: 600; font-size: .85rem; }

/* ---------- Vista de un pedido (link compartido) ---------- */
.pedido-cabecera { padding: 22px 0 12px; }
.pedido-cabecera h1 { margin: 6px 0 2px; font-size: 1.5rem; letter-spacing: -.02em; }
.pedido-cabecera p { margin: 0; color: var(--texto-suave); font-size: .9rem; }
.estado-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.estado-nuevo { background: var(--amarillo-suave); color: #8a6200; }
.estado-cotizado { background: var(--verde-suave); color: var(--verde); }
@media (prefers-color-scheme: dark) { .estado-nuevo { color: var(--amarillo); } }
.tarjeta-blanca { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-m); padding: 4px 16px 16px; box-shadow: var(--sombra-1); max-width: 720px; }
.tabla-pedido { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla-pedido td { padding: 12px 0; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla-pedido td.num { text-align: right; white-space: nowrap; padding-left: 10px; }
.tabla-pedido .cant { color: var(--texto-suave); font-weight: 700; width: 44px; }
.tabla-pedido .muted { color: var(--texto-tenue); font-size: .78rem; }
.nota-cotizacion { margin-top: 14px; padding: 12px 14px; border-radius: var(--radio-s); background: var(--amarillo-suave); font-size: .9rem; white-space: pre-wrap; }
.pedido-acciones { max-width: 720px; display: flex; flex-direction: column; gap: 10px; margin: 18px 0 30px; }
@media (min-width: 640px) { .pedido-acciones { flex-direction: row; } }

/* ---------- Aviso flotante ---------- */
.aviso {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%);
  background: #111110; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .88rem; box-shadow: var(--sombra-2);
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- Ingreso / registro ---------- */
.acceso { max-width: 440px; margin: 0 auto; padding: 28px 0 40px; }
.acceso h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -.02em; }
.acceso .sub { margin: 0 0 18px; color: var(--texto-suave); font-size: .95rem; }
.pestanas { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: var(--superficie-2); margin-bottom: 18px; }
.pestanas button { flex: 1; height: 40px; border: 0; border-radius: 999px; background: transparent; font-weight: 600; color: var(--texto-suave); }
.pestanas button.activo { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-1); }
.tarjeta-acceso { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-l); padding: 22px 18px; box-shadow: var(--sombra-1); }
.tarjeta-acceso .btn-principal { width: 100%; margin-top: 6px; }
.mensaje-error { min-height: 1.2em; margin: 0 0 12px; color: var(--rojo); font-size: .88rem; }
.opcional { font-weight: 400; color: var(--texto-tenue); }
.acceso-ayuda { font-size: .82rem; color: var(--texto-suave); text-align: center; margin-top: 16px; }
.cuenta-datos { font-size: .9rem; color: var(--texto-suave); line-height: 1.6; margin: 0 0 16px; }
.cuenta-datos strong { color: var(--texto); }
.separador { height: 1px; background: var(--borde); margin: 18px 0; }

/* ---------- v5: estados del pedido, stock, acceso ---------- */
.etiqueta-pocas { background: var(--amarillo); color: var(--tinta-sobre-amarillo); }
.btn-link { background: none; border: 0; color: var(--texto-suave); text-decoration: underline; font-size: .85rem; margin-top: 12px; align-self: center; }
#formIngresar { display: flex; flex-direction: column; }
.campo select { width: 100%; padding: 13px 14px; border-radius: var(--radio-s); border: 1px solid var(--borde); background: var(--fondo); font-size: 1rem; color: var(--texto); }
.btn-whatsapp-borde { border-color: #25d366; }
.estado-recibido { background: var(--amarillo-suave); color: #8a6200; }
.estado-confirmado, .estado-preparando, .estado-despachado { background: #e3ecfa; color: #1f4e9c; }
.estado-entregado { background: var(--verde-suave); color: var(--verde); }
.estado-cancelado { background: var(--superficie-2); color: var(--texto-suave); }
@media (prefers-color-scheme: dark) {
  .estado-recibido { color: var(--amarillo); }
  .estado-confirmado, .estado-preparando, .estado-despachado { background: #17284a; color: #9cbcf2; }
}
.pasos { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 720px; }
.paso { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 4px solid var(--borde); font-size: .78rem; color: var(--texto-tenue); }
.paso.hecho { border-color: var(--verde); color: var(--texto-suave); }
.paso.actual { border-color: var(--amarillo); color: var(--texto); font-weight: 700; }
.paso-fecha { font-weight: 400; color: var(--texto-tenue); }
@media (max-width: 480px) { .paso-nombre { font-size: .7rem; } }
