/* JEG Logistics - sistema de diseno. Mobile first: todo se disena para 360 px y se amplia desde ahi. */

:root {
  /* Marca (tomada de jegvzla.com) */
  --azul: #0d21a1;
  --azul-osc: #07145f;
  --azul-suave: #e8ebfa;
  --amarillo: #ffbf00;
  --amarillo-suave: #fff4d1;

  /* Superficies y texto */
  --papel: #f7f7f2;
  --tarjeta: #ffffff;
  --tinta: #101219;
  --gris: #626775;
  --gris-claro: #8b8f9b;
  --linea: #dfe1dc;
  --linea-suave: #eceee9;

  /* Estados */
  --ok: #157a3c;
  --ok-suave: #e3f4e8;
  --error: #b42318;
  --error-suave: #fdecea;
  --aviso: #8a5a00;
  --aviso-suave: #fff4d1;
  --info: #0d21a1;
  --info-suave: #e8ebfa;
  --prep: #5b3cc4;
  --prep-suave: #efeafd;
  --listo: #0e7490;
  --listo-suave: #e0f4f8;

  --radio: 14px;
  --radio-sm: 10px;
  --sombra: 0 1px 2px rgba(16, 18, 25, .06), 0 2px 8px rgba(16, 18, 25, .05);
  --sombra-alta: 0 -4px 24px rgba(16, 18, 25, .12);
  --barra-alto: 64px;
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  --seguro-arriba: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--azul); }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.cabecera {
  position: sticky; top: 0; z-index: 20;
  background: var(--azul); color: #fff;
  padding: calc(10px + var(--seguro-arriba)) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.cabecera .marca { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.cabecera h1 { font-size: 18px; line-height: 1.2; margin: 0; font-weight: 700; flex: 1; min-width: 0; }
.cabecera h1 small { display: block; font-size: 12px; font-weight: 500; opacity: .8; }
.cabecera .accion { color: #fff; }

.contenido { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--barra-alto) + 24px + var(--seguro-abajo)); }
.contenido.con-pie { padding-bottom: calc(var(--barra-alto) + 112px + var(--seguro-abajo)); }

.navegacion {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--tarjeta); border-top: 1px solid var(--linea);
  padding-bottom: var(--seguro-abajo);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
}
.navegacion a {
  height: var(--barra-alto); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--gris); text-decoration: none; font-size: 12px; font-weight: 600;
}
.navegacion a > svg { width: 24px; height: 24px; margin: 4px 0; }
.navegacion a .icono svg { width: 24px; height: 24px; }
.navegacion a[aria-current="page"] { color: var(--azul); }
.navegacion a[aria-current="page"] svg { stroke-width: 2.4; }
.navegacion a.principal span.icono {
  width: 48px; height: 32px; border-radius: 16px; display: grid; place-items: center;
  background: var(--amarillo); color: var(--azul-osc);
}

/* Pie fijo sobre la barra (total del pedido, acciones) */
.pie-fijo {
  position: fixed; left: 0; right: 0; bottom: calc(var(--barra-alto) + var(--seguro-abajo)); z-index: 25;
  background: var(--tarjeta); box-shadow: var(--sombra-alta);
  padding: 12px 16px;
}
.pie-fijo .interior { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }

/* ---------- Tipografia y bloques ---------- */
.titulo { font-size: 22px; font-weight: 800; margin: 4px 0 2px; letter-spacing: -.01em; }
.subtitulo { color: var(--gris); margin: 0 0 16px; font-size: 14px; }
.seccion { font-size: 13px; font-weight: 700; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; margin: 20px 0 8px; }
.muted { color: var(--gris); }
.pequeno { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.fila { display: flex; align-items: center; gap: 8px; }
.fila.entre { justify-content: space-between; }
.pila > * + * { margin-top: 12px; }
.crece { flex: 1; min-width: 0; }

.tarjeta {
  background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 14px 16px; border: 1px solid var(--linea-suave);
}
a.tarjeta, button.tarjeta { display: block; width: 100%; text-align: left; color: inherit; text-decoration: none; cursor: pointer; }
a.tarjeta:active, button.tarjeta:active { transform: scale(.99); }
a.tarjeta.fila, button.tarjeta.fila { display: flex; gap: 12px; min-height: 56px; font-weight: 600; }
.fila > svg { width: 22px; height: 22px; flex: none; color: var(--gris); }
.lista > * + * { margin-top: 10px; }

.pedido .arriba { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pedido .id { font-size: 12px; color: var(--gris-claro); font-weight: 600; letter-spacing: .03em; }
.pedido .cliente { font-size: 16px; font-weight: 700; margin: 2px 0 6px; overflow-wrap: anywhere; }
.pedido .resumen { font-size: 14px; color: var(--gris); margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pedido .abajo { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.monto { font-weight: 800; color: var(--azul-osc); font-size: 17px; }
.monto-bs { font-size: 13px; color: var(--gris); }

/* ---------- Chips de estado y filtros ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700;
  background: var(--linea-suave); color: var(--gris);
}
.chip svg { width: 14px; height: 14px; }
.estado-Pendiente { background: var(--aviso-suave); color: var(--aviso); }
.estado-Aprobado { background: var(--info-suave); color: var(--info); }
.estado-En-preparacion { background: var(--prep-suave); color: var(--prep); }
.estado-Listo-para-entregar { background: var(--listo-suave); color: var(--listo); }
.estado-Entregado { background: var(--ok-suave); color: var(--ok); }
.estado-Rechazado, .estado-Cancelado { background: var(--error-suave); color: var(--error); }

.filtros { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtros button {
  flex: none; border: 1px solid var(--linea); background: var(--tarjeta); color: var(--tinta);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px;
}
.filtros button[aria-pressed="true"] { background: var(--azul); border-color: var(--azul); color: #fff; }
.filtros .cuenta { opacity: .7; font-weight: 500; margin-left: 4px; }

/* ---------- Botones ---------- */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 16px; text-decoration: none;
  background: var(--azul); color: #fff;
}
.boton svg { width: 20px; height: 20px; }
.boton:active { filter: brightness(.92); }
.boton:disabled { opacity: .55; cursor: default; }
.boton.bloque { width: 100%; }
.boton.amarillo { background: var(--amarillo); color: var(--azul-osc); }
.boton.secundario { background: var(--tarjeta); color: var(--azul); border: 1.5px solid var(--linea); }
.boton.fantasma { background: transparent; color: var(--azul); padding: 0 10px; }
.boton.peligro { background: var(--tarjeta); color: var(--error); border: 1.5px solid #f2c7c3; }
.boton.chico { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 10px; }
.icono-boton {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: inherit; flex: none;
}
.icono-boton svg { width: 22px; height: 22px; }
.icono-boton:active { background: rgba(0, 0, 0, .06); }

/* ---------- Formularios ---------- */
.campo { display: block; }
.campo > span { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.campo > small { display: block; color: var(--gris); font-size: 12px; margin-top: 4px; }
.entrada {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--linea); background: var(--tarjeta); font-size: 16px; /* 16px evita el zoom en iOS */
}
.entrada:focus { border-color: var(--azul); outline: none; box-shadow: 0 0 0 3px rgba(13, 33, 161, .15); }
textarea.entrada { min-height: 90px; resize: vertical; }
select.entrada { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gris) 50%), linear-gradient(135deg, var(--gris) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.buscador { position: relative; }
.buscador svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--gris); pointer-events: none; }
.buscador .entrada { padding-left: 44px; }
.segmentado { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--linea-suave); border-radius: 12px; padding: 4px; gap: 4px; }
.segmentado button { border: 0; background: transparent; border-radius: 9px; min-height: 40px; font-weight: 600; font-size: 14px; color: var(--gris); cursor: pointer; }
.segmentado button[aria-pressed="true"] { background: var(--tarjeta); color: var(--azul); box-shadow: var(--sombra); }
.grilla-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Selector de cantidad */
.cantidad { display: inline-flex; align-items: center; border: 1.5px solid var(--linea); border-radius: 12px; background: var(--tarjeta); }
.cantidad button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--azul); cursor: pointer; display: grid; place-items: center; }
.cantidad button svg { width: 20px; height: 20px; }
.cantidad input { width: 56px; height: 44px; border: 0; text-align: center; font-weight: 700; font-size: 16px; background: transparent; -moz-appearance: textfield; }
.cantidad input::-webkit-outer-spin-button, .cantidad input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Pasos del pedido ---------- */
.pasos { display: flex; gap: 6px; margin-bottom: 16px; }
.pasos span { flex: 1; height: 4px; border-radius: 4px; background: var(--linea); }
.pasos span.hecho { background: var(--azul); }

/* ---------- Producto en el catalogo ---------- */
.producto { display: flex; gap: 12px; align-items: center; }
.producto .datos { flex: 1; min-width: 0; }
.producto .nombre { font-weight: 650; font-size: 15px; line-height: 1.3; }
.producto .sku { font-size: 12px; color: var(--gris-claro); }
.producto .precio { font-weight: 800; color: var(--azul-osc); white-space: nowrap; }
.producto.en-carrito { border-color: var(--azul); box-shadow: 0 0 0 1.5px var(--azul) inset, var(--sombra); }
.agregar {
  width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer; flex: none;
  background: var(--azul-suave); color: var(--azul); display: grid; place-items: center;
}
.agregar svg { width: 22px; height: 22px; }
.insignia { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--amarillo-suave); color: var(--aviso); }
.insignia.ok { background: var(--ok-suave); color: var(--ok); }

/* ---------- Detalle ---------- */
.dato { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linea-suave); }
.dato:last-child { border-bottom: 0; }
.dato svg { width: 20px; height: 20px; color: var(--gris); flex: none; margin-top: 2px; }
.dato .etiqueta { font-size: 12px; color: var(--gris); }
.linea-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linea-suave); }
.linea-item:last-child { border-bottom: 0; }
.totales { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; margin-top: 4px; border-top: 2px solid var(--linea); }
.enlace-accion { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; font-size: 14px; }
.enlace-accion svg { width: 18px; height: 18px; }
.whatsapp { color: #0b7a5e; }

/* ---------- Hoja inferior (modal movil) ---------- */
.fondo-hoja { position: fixed; inset: 0; z-index: 50; background: rgba(7, 20, 95, .35); display: flex; align-items: flex-end; justify-content: center; animation: aparecer .15s ease-out; }
.hoja {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--papel); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + var(--seguro-abajo)); animation: subir .2s ease-out;
}
.hoja .asa { width: 40px; height: 5px; border-radius: 3px; background: var(--linea); margin: 4px auto 10px; }
.hoja h2 { font-size: 19px; margin: 0 0 14px; }
@media (min-width: 600px) {
  .fondo-hoja { align-items: center; }
  .hoja { border-radius: 20px; }
}

/* ---------- Avisos ---------- */
.aviso { border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.aviso svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.aviso.error { background: var(--error-suave); color: var(--error); }
.aviso.info { background: var(--info-suave); color: var(--azul-osc); }
.aviso.amarillo { background: var(--amarillo-suave); color: var(--aviso); }
.vacio { text-align: center; color: var(--gris); padding: 40px 16px; }
.vacio svg { width: 48px; height: 48px; margin: 0 auto 10px; color: var(--gris-claro); }

.tostada {
  position: fixed; left: 50%; bottom: calc(var(--barra-alto) + 20px + var(--seguro-abajo)); transform: translateX(-50%);
  z-index: 60; background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 15px; font-weight: 600; box-shadow: var(--sombra); max-width: calc(100% - 32px); animation: subir .2s ease-out;
}
.tostada.error { background: var(--error); }

/* Esqueleto de carga */
.esqueleto { background: linear-gradient(90deg, var(--linea-suave), #f6f7f4, var(--linea-suave)); background-size: 200% 100%; animation: brillo 1.2s infinite; border-radius: var(--radio); height: 112px; }
.girando { animation: girar .8s linear infinite; }

@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } }
@keyframes brillo { to { background-position: -200% 0; } }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Inicio de sesion ---------- */
.acceso { min-height: 100dvh; display: flex; flex-direction: column; background: var(--azul); color: #fff; }
.acceso .arriba { padding: calc(48px + var(--seguro-arriba)) 24px 32px; text-align: center; }
.acceso .logo { width: 156px; margin: 0 auto 18px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25), 0 10px 30px rgba(0, 0, 0, .25); }
.acceso .arriba p { margin: 0; opacity: .85; font-size: 15px; }
.acceso .panel {
  flex: 1; background: var(--papel); color: var(--tinta); border-radius: 24px 24px 0 0;
  padding: 28px 20px calc(28px + var(--seguro-abajo));
}
.acceso .panel > div { max-width: 420px; margin: 0 auto; }
.acceso h2 { margin: 0 0 4px; font-size: 22px; }
.clave { position: relative; }
.clave .entrada { padding-right: 52px; }
.clave .icono-boton { position: absolute; right: 2px; top: 2px; color: var(--gris); }
.pie-acceso { text-align: center; font-size: 12px; color: var(--gris-claro); margin-top: 24px; }
@media (min-width: 760px) {
  .acceso { display: grid; grid-template-columns: 1fr 1fr; }
  .acceso .arriba { display: flex; flex-direction: column; justify-content: center; }
  .acceso .logo { width: 220px; }
  .acceso .panel { border-radius: 0; display: flex; align-items: center; }
  .acceso .panel > div { width: 100%; }
}

/* ---------- Escritorio ---------- */
@media (min-width: 900px) {
  .contenido { max-width: 960px; }
  .lista.columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .lista.columnas > * + * { margin-top: 0; }
}

/* ---------- Fotos ---------- */
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.foto { aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--linea-suave); cursor: pointer; }
.foto img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Lista de preparacion ---------- */
.check-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--linea-suave); background: none; text-align: left; cursor: pointer; }
.check-item:last-child { border-bottom: 0; }
.check-item .caja { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--linea); display: grid; place-items: center; flex: none; color: #fff; }
.check-item .caja svg { width: 18px; height: 18px; }
.check-item[aria-pressed="true"] .caja { background: var(--ok); border-color: var(--ok); }
.check-item[aria-pressed="true"] .texto { text-decoration: line-through; color: var(--gris); }
.check-item[disabled] { cursor: default; }
.barra-progreso { height: 8px; border-radius: 8px; background: var(--linea-suave); overflow: hidden; }
.barra-progreso span { display: block; height: 100%; background: var(--ok); border-radius: 8px; transition: width .2s; }

/* ---------- Historial ---------- */
.linea-tiempo { position: relative; padding-left: 22px; }
.linea-tiempo::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--linea); }
.evento { position: relative; padding: 0 0 14px; }
.evento::before { content: ""; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--azul); border: 2px solid var(--papel); }
.evento:last-child { padding-bottom: 0; }

/* ---------- Menu de opciones (admin) ---------- */
.menu-lista .tarjeta { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.menu-lista .tarjeta .crece b { display: block; }
.contador { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--error); color: #fff; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; }
.tabla-simple { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla-simple td, .tabla-simple th { padding: 8px 4px; border-bottom: 1px solid var(--linea-suave); text-align: left; }

/* ---------- Ajustes de componentes ---------- */
svg.mini { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; }
.menu-lista .tarjeta > svg { width: 22px; height: 22px; flex: none; color: var(--gris); }
.menu-lista .tarjeta .crece > span { display: block; }
label.tarjeta.fila { cursor: pointer; min-height: 52px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--azul); flex: none; margin: 0; }
