/* =============================================================================
   Estilo "app" de La Pompeya (sc-1514)
   -----------------------------------------------------------------------------
   Base de las pantallas nuevas pensadas primero para el celular (iPhone): los
   vendedores sin Android usan esta web como si fuera la app. No depende del
   template Apex: las pantallas que la usan cargan solo este archivo.
   ========================================================================== */

/* =============================================================================
   1. Tokens de marca (Fox / La Pompeya)
   ========================================================================== */
:root {
  --am-rojo: #C1121F;            /* acciones principales, totales */
  --am-rojo-oscuro: #8E0D17;     /* hover / presionado */
  --am-carbon: #1C1C1E;          /* fondo de la marca, texto */
  --am-carbon-2: #2C2C2E;
  --am-crema: #F5F3EF;           /* fondo del contenido */
  --am-blanco: #FFFFFF;
  --am-borde: #E2DED6;
  --am-texto: #1C1C1E;
  --am-texto-suave: #6B6863;
  --am-dorado: #C9A227;
  --am-error-fondo: #FDECEC;
  --am-error-texto: #8E0D17;

  --am-radio: 14px;
  --am-radio-chico: 10px;
  --am-alto-toque: 48px;         /* minimo comodo para el dedo */
  --am-fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =============================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* hidden tiene que ganarle a los display de los componentes (.am-btn es flex) */
[hidden] { display: none !important; }

body.am {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--am-fuente);
  font-size: 16px;
  line-height: 1.4;
  color: var(--am-texto);
  background: var(--am-carbon);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* =============================================================================
   3. Pantalla de ingreso
   ========================================================================== */
.am-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Foto arriba que se funde con el carbon de la marca */
.am-login__portada {
  position: relative;
  flex: 0 0 auto;
  height: 38vh;
  min-height: 200px;
  max-height: 340px;
  background: var(--am-carbon) var(--am-foto) center / cover no-repeat;
}
.am-login__portada::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(28, 28, 30, .15) 0%, rgba(28, 28, 30, .55) 60%, var(--am-carbon) 100%);
}

.am-login__logo {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 150px;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .45));
}

/* Hoja clara con el formulario, como las hojas de iOS */
.am-login__hoja {
  flex: 1 0 auto;
  background: var(--am-crema);
  border-radius: 24px 24px 0 0;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.am-login__titulo {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.am-login__bajada {
  margin: 0 0 24px;
  color: var(--am-texto-suave);
  font-size: .95rem;
}

.am-login__pie {
  margin: 28px 0 0;
  text-align: center;
  color: var(--am-texto-suave);
  font-size: .8rem;
}

/* En pantallas grandes la hoja queda como tarjeta centrada sobre la foto */
@media (min-width: 768px) {
  .am-login {
    justify-content: center;
    align-items: center;
    background: var(--am-carbon) var(--am-foto) center / cover no-repeat;
  }
  .am-login__portada {
    height: auto;
    min-height: 0;
    background: none;
    padding-bottom: 24px;
  }
  .am-login__portada::after { display: none; }
  .am-login__logo { position: static; transform: none; display: block; margin: 0 auto; width: 170px; }
  .am-login__hoja { flex: 0 0 auto; border-radius: 24px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
}

/* =============================================================================
   4. Formularios
   ========================================================================== */
.am-campo { margin-bottom: 16px; }

.am-campo__etiqueta {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--am-texto);
}

.am-campo__ayuda {
  display: block;
  margin-top: 6px;
  font-size: .8rem;
  color: var(--am-texto-suave);
}

/* 16px como minimo: con menos, iOS hace zoom al enfocar el campo */
.am-input {
  display: block;
  width: 100%;
  min-height: var(--am-alto-toque);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--am-texto);
  background: var(--am-blanco);
  border: 1px solid var(--am-borde);
  border-radius: var(--am-radio-chico);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.am-input:focus {
  border-color: var(--am-rojo);
  box-shadow: 0 0 0 3px rgba(193, 18, 31, .15);
}

/* Campo de clave con boton para mostrarla */
.am-clave { position: relative; }
.am-clave .am-input { padding-right: 84px; }
.am-clave__ver {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  min-width: 76px;
  padding: 0 14px;
  border: 0;
  background: none;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--am-rojo);
  cursor: pointer;
}

/* =============================================================================
   5. Botones y avisos
   ========================================================================== */
.am-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--am-blanco);
  background: var(--am-rojo);
  border: 0;
  border-radius: var(--am-radio);
  cursor: pointer;
  transition: background-color .15s, transform .05s;
}
a.am-btn { text-decoration: none; }
.am-btn:hover { background: var(--am-rojo-oscuro); color: var(--am-blanco); }
.am-btn:active { transform: scale(.98); background: var(--am-rojo-oscuro); }
.am-btn[disabled] { opacity: .6; cursor: default; }

.am-aviso {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--am-radio-chico);
  font-size: .9rem;
}
.am-aviso--error {
  background: var(--am-error-fondo);
  color: var(--am-error-texto);
}

/* =============================================================================
   6. Pantallas de la app: barra superior, contenido y pie fijo
   ========================================================================== */
body.am--app { background: var(--am-crema); }

.am-barra {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: env(safe-area-inset-top) 8px 0;
  padding-top: calc(env(safe-area-inset-top) + 6px);
  padding-bottom: 6px;
  background: var(--am-carbon);
  color: var(--am-blanco);
}
.am-barra__volver {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--am-blanco);
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
}
.am-barra__textos { flex: 1 1 auto; min-width: 0; }
.am-barra__titulo { margin: 0; font-size: 1.05rem; font-weight: 700; }
.am-barra__subtitulo {
  margin: 1px 0 0;
  font-size: .82rem;
  color: rgba(255, 255, 255, .72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-contenido {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 195px;   /* abajo deja lugar al pie fijo (botones + firma) */
}

.am-seccion-titulo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 6px 2px 10px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--am-texto-suave);
}

.am-tarjeta {
  background: var(--am-blanco);
  border: 1px solid var(--am-borde);
  border-radius: var(--am-radio);
  padding: 14px;
  margin-bottom: 10px;
}

/* Pie fijo con el total y las acciones principales */
.am-pie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--am-blanco);
  border-top: 1px solid var(--am-borde);
  box-shadow: 0 -6px 20px rgba(28, 28, 30, .06);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
.am-pie__interior { max-width: 720px; margin: 0 auto; }
.am-pie__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.am-pie__total-etiqueta { font-size: .9rem; color: var(--am-texto-suave); }
.am-pie__total-valor { font-size: 1.35rem; font-weight: 700; color: var(--am-texto); }
.am-pie__botones { display: flex; gap: 10px; }
.am-pie__botones .am-btn { flex: 1 1 0; }

/* =============================================================================
   7. Items del pedido
   ========================================================================== */
.am-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.am-item:active { background: #FBFAF8; }
.am-item__fila { display: flex; justify-content: space-between; gap: 10px; }
.am-item__nombre { margin: 0 0 2px; font-weight: 600; font-size: .98rem; line-height: 1.3; }
.am-item__codigo { font-size: .78rem; color: var(--am-texto-suave); }
.am-item__detalle { margin-top: 8px; font-size: .88rem; color: var(--am-texto-suave); }
.am-item__subtotal { font-weight: 700; color: var(--am-texto); white-space: nowrap; }
.am-item__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.am-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #F1EEE8;
  color: var(--am-texto);
}
.am-chip--rojo { background: #FBE7E8; color: var(--am-rojo-oscuro); }

.am-vacio {
  padding: 36px 16px;
  text-align: center;
  color: var(--am-texto-suave);
}
.am-vacio__titulo { margin: 0 0 4px; font-weight: 600; color: var(--am-texto); }

/* =============================================================================
   8. Botones secundarios
   ========================================================================== */
.am-btn--secundario { background: var(--am-carbon); }
.am-btn--secundario:hover, .am-btn--secundario:active { background: var(--am-carbon-2); }
.am-btn--contorno {
  background: transparent;
  color: var(--am-rojo);
  border: 1.5px solid var(--am-rojo);
}
.am-btn--contorno:hover, .am-btn--contorno:active { background: #FBE7E8; color: var(--am-rojo-oscuro); }
.am-btn--texto {
  background: none;
  color: var(--am-rojo);
  min-height: 44px;
}
.am-btn--texto:hover, .am-btn--texto:active { background: #FBE7E8; color: var(--am-rojo); }

/* =============================================================================
   9. Hoja a pantalla completa (buscar y editar producto)
   ========================================================================== */
.am-hoja {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--am-crema);
  transform: translateY(100%);
  transition: transform .25s ease;
  visibility: hidden;
}
.am-hoja--abierta { transform: none; visibility: visible; }

@media (min-width: 768px) {
  .am-hoja {
    inset: 5vh auto auto 50%;
    width: 560px;
    height: 90vh;
    margin-left: -280px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    overflow: hidden;
  }
}

.am-hoja__cabecera {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background: var(--am-blanco);
  border-bottom: 1px solid var(--am-borde);
}
.am-hoja__titulo { flex: 1 1 auto; margin: 0; font-size: 1.05rem; font-weight: 700; }
.am-hoja__cerrar {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #F1EEE8;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--am-texto);
  cursor: pointer;
}
.am-hoja__cuerpo {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
}
.am-hoja__pie {
  flex: 0 0 auto;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--am-blanco);
  border-top: 1px solid var(--am-borde);
}

.am-buscador { position: sticky; top: -14px; z-index: 1; margin: -14px -14px 12px; padding: 14px; background: var(--am-crema); }
.am-input--buscar { padding-left: 42px; background: var(--am-blanco) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%236B6863' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 12px center no-repeat; }

.am-resultado {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--am-blanco);
  border: 1px solid var(--am-borde);
  border-radius: var(--am-radio-chico);
  cursor: pointer;
}
.am-resultado:active { background: #FBFAF8; }
.am-resultado__nombre { display: block; font-weight: 600; line-height: 1.3; }
.am-resultado__info { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: .85rem; color: var(--am-texto-suave); }
.am-resultado__precio { color: var(--am-texto); font-weight: 600; white-space: nowrap; }

.am-datos { margin: 0; }
.am-datos__fila { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #EFEBE4; font-size: .92rem; }
.am-datos__fila:last-child { border-bottom: 0; }
.am-datos__fila dt { color: var(--am-texto-suave); }
.am-datos__fila dd { margin: 0; font-weight: 600; text-align: right; }
.am-datos__fila--total dd { font-size: 1.15rem; color: var(--am-texto); }

/* Cantidad con botones grandes de - y + */
.am-stepper { display: flex; align-items: stretch; gap: 8px; }
.am-stepper__btn {
  flex: 0 0 52px;
  min-height: 52px;
  border: 1px solid var(--am-borde);
  border-radius: var(--am-radio-chico);
  background: var(--am-blanco);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--am-texto);
  cursor: pointer;
}
.am-stepper__btn:active { background: #F1EEE8; }
.am-stepper .am-input { text-align: center; font-size: 1.25rem; font-weight: 700; min-height: 52px; }

.am-ayuda-bulto {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: var(--am-radio-chico);
  background: #FFF6DB;
  color: #6B5200;
  font-size: .85rem;
}

/* =============================================================================
   10. Dialogo de confirmacion
   ========================================================================== */
.am-dialogo-fondo {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(28, 28, 30, .45);
  padding: 0 10px calc(10px + env(safe-area-inset-bottom));
}
.am-dialogo-fondo[hidden] { display: none; }
@media (min-width: 768px) { .am-dialogo-fondo { align-items: center; } }
.am-dialogo {
  width: 100%;
  max-width: 420px;
  background: var(--am-blanco);
  border-radius: 18px;
  padding: 20px 18px 14px;
}
.am-dialogo__titulo { margin: 0 0 6px; font-size: 1.1rem; font-weight: 700; }
.am-dialogo__texto { margin: 0 0 16px; color: var(--am-texto-suave); font-size: .95rem; }
.am-dialogo__botones { display: flex; flex-direction: column; gap: 8px; }

/* Aviso flotante corto (reemplaza a toastr en estas pantallas) */
.am-toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--am-carbon);
  color: var(--am-blanco);
  font-size: .92rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.am-toast[hidden] { display: none; }

.am-textarea { min-height: 84px; resize: vertical; }

/* =============================================================================
   11. Listas (pedidos, clientes), filtros y estados
   ========================================================================== */
.am-barra__accion {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  background: none;
  color: var(--am-blanco);
  font: inherit;
  font-size: .85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.am-segmentos {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: #E9E5DD;
}
.am-segmentos button {
  flex: 1 1 0;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: none;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--am-texto-suave);
  cursor: pointer;
}
.am-segmentos button[aria-pressed="true"] { background: var(--am-blanco); color: var(--am-texto); box-shadow: 0 1px 3px rgba(28, 28, 30, .12); }

.am-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.am-fila__texto { min-width: 0; flex: 1 1 auto; }
.am-fila__titulo { margin: 0; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.am-fila__sub { margin: 3px 0 0; font-size: .82rem; color: var(--am-texto-suave); }
.am-fila__lado { flex: 0 0 auto; text-align: right; }
.am-fila__monto { font-weight: 700; white-space: nowrap; }
.am-fila__flecha { color: #B9B4AA; font-size: 1.4rem; line-height: 1; }

.am-chip--verde { background: #E3F4E8; color: #1E6B35; }
.am-chip--gris { background: #ECEAE6; color: #55524D; }
.am-chip--amarillo { background: #FFF1CC; color: #6B5200; }

/* =============================================================================
   12. Firma de ONCA IT
   ========================================================================== */
.am-firma {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: .72rem;
  line-height: 1.2;
  color: var(--am-texto-suave);
  text-decoration: none;
  letter-spacing: .01em;
}
.am-firma strong { font-weight: 700; color: var(--am-texto); }
.am-firma:hover strong, .am-firma:active strong { color: var(--am-rojo); }

/* Pie fijo que solo lleva la firma (pantallas sin botones abajo) */
.am-pie--firma { padding-top: 6px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.am-pie--firma .am-firma { margin-top: 0; }

/* =============================================================================
   13. App instalable: aviso de instalacion, check y toques
   ========================================================================== */
/* Sin zoom por doble toque en lo que se toca seguido */
a, button, input, select, textarea, label { touch-action: manipulation; }

.am-instalar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: var(--am-radio);
  background: var(--am-carbon);
  color: var(--am-blanco);
}
.am-instalar__icono { flex: 0 0 auto; border-radius: 10px; }
.am-instalar__texto { flex: 1 1 auto; min-width: 0; }
.am-instalar__titulo { margin: 0 0 2px; font-weight: 700; font-size: .95rem; }
.am-instalar__pasos { margin: 0; font-size: .82rem; color: rgba(255, 255, 255, .8); line-height: 1.35; }
.am-instalar__pasos strong { color: var(--am-blanco); }
.am-instalar__compartir { width: 16px; height: 16px; vertical-align: -3px; color: #4DA3FF; }
.am-instalar__boton { flex: 0 0 auto; width: auto; min-height: 40px; padding: 8px 14px; font-size: .9rem; }
.am-instalar__cerrar {
  flex: 0 0 auto;
  align-self: flex-start;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: var(--am-blanco);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.am-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 16px;
  font-size: .9rem;
  color: var(--am-texto);
  cursor: pointer;
}
.am-check input { width: 22px; height: 22px; accent-color: var(--am-rojo); flex: 0 0 auto; }

/* =============================================================================
   14. Visor de PDF
   ========================================================================== */
.am-pdf__pagina {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 12px;
  background: var(--am-blanco);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(28, 28, 30, .12);
}
