/* =========================================================
   EL JAROCHO · estilos base (compartidos por todos los modulos)
   Paleta: cafe y blanco
   ========================================================= */

:root {
  --cafe: #6b4423;          /* color principal */
  --cafeoscuro: #4a2f18;    /* texto fuerte / presionado */
  --cafemedio: #8a6a4f;     /* texto secundario */
  --cafeclaro: #efe4d8;     /* fondos suaves, chip activo */
  --crema: #f6f1ea;         /* tarjetas */
  --fondo: #fbf9f6;         /* fondo general */
  --blanco: #ffffff;        /* superficies (hojas, barra, ventanas) */
  --textoclaro: #ffffff;    /* texto sobre botones de color */
  --linea: #e6ddd2;         /* bordes */
  --rojo: #b3402a;          /* agotado / cancelar */
  --rojoclaro: #f6dfd8;
  --ambar: #a86b12;         /* stock bajo / fiado */
  --ambarclaro: #f6e8cf;
  --verde: #3f7a4a;         /* descuento / pagado */
  --verdeclaro: #dfeedd;
  --azul: #2f5f8a;          /* transferencia */
  --azulclaro: #dde8f2;

  --radio: 22px;
  --sombra: 0 6px 20px rgba(74, 47, 24, 0.12);

  --acento: #6b4423;        /* textos destacados (chip activo, enlaces) */

  --letra: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --letratitulo: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pesotitulo: 700;
  --flechaselect: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%234a2f18' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

/* ---------- Tema OSCURO "Grafito" (se elige en Ajustes) ----------
   Solo negro, gris y blanco. El color queda para las alertas. */
:root[data-tema="oscuro"] {
  --cafe: #e6e6e6;          /* botones y tarjeta elegida: blanco suave */
  --acento: #ffffff;        /* textos destacados */
  --cafeoscuro: #ededed;    /* texto principal */
  --cafemedio: #9e9e9e;     /* texto secundario */
  --cafeclaro: #3a3a3a;     /* chip activo, fondos suaves */
  --crema: #1e1e1e;         /* tarjetas */
  --fondo: #121212;         /* fondo general */
  --blanco: #1a1a1a;        /* barra inferior, hojas, ventanas */
  --textoclaro: #121212;    /* texto sobre botones claros */
  --linea: #2c2c2c;         /* bordes */
  --rojo: #f2867a;
  --rojoclaro: #3b1f1c;
  --ambar: #f0b85a;
  --ambarclaro: #3a2f17;
  --verde: #7fd18f;
  --verdeclaro: #1c3022;
  --azul: #8ab4f8;
  --azulclaro: #1c2836;
  --sombra: 0 6px 20px rgba(0, 0, 0, 0.6);
  --flechaselect: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ededed' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--letra);
  background: var(--fondo);
  color: var(--cafeoscuro);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body.conventana {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

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

.icono {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.oculto {
  display: none !important;
}

/* ---------- Estructura de cada pantalla ---------- */
.vista {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

body.sinnav .vista {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.encabezadovista {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.titulovista {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 28px;
  line-height: 1.1;
}

.subtitulo {
  margin-top: 4px;
  color: var(--cafemedio);
}

.etiquetaseccion {
  margin: 20px 4px 8px;
  color: var(--cafemedio);
  font-size: 15px;
}

.vacio {
  margin-top: 40px;
  text-align: center;
  color: var(--cafemedio);
}

.botonregresar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  color: var(--cafeoscuro);
}

.botonregresar .icono {
  width: 28px;
  height: 28px;
}

/* ---------- Botones ---------- */
.botonprincipal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 58px;
  border-radius: 29px;
  background: var(--cafe);
  color: var(--textoclaro);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(107, 68, 35, 0.3);
}

.botonprincipal:active {
  background: var(--cafeoscuro);
}

.botonsecundario,
.botonpeligro,
.botonsuave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  padding: 0 18px;
  border-radius: 27px;
  font-weight: 700;
}

.botonsecundario {
  background: var(--crema);
  border: 1px solid var(--linea);
}

.botonpeligro {
  background: var(--rojo);
  color: var(--textoclaro);
}

.botonsuave {
  background: var(--rojoclaro);
  color: var(--rojo);
}

.botontexto {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  width: 100%;
  font-weight: 600;
}

.botonancho {
  width: 100%;
}

.botonpastilla {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 18px;
  background: var(--crema);
  border: 1px solid var(--linea);
  border-radius: 25px;
  font-weight: 600;
  white-space: nowrap;
}

.botonpastilla.oscuro {
  background: var(--cafe);
  border-color: var(--cafe);
  color: var(--textoclaro);
}

.botonredondo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--crema);
  border: 1px solid var(--linea);
  color: var(--cafeoscuro);
}

.botonpastilla:active,
.botonredondo:active,
.botonsecundario:active {
  background: var(--cafeclaro);
}

/* ---------- Buscador ---------- */
.buscador {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 16px;
  background: var(--crema);
  border: 1px solid var(--linea);
  border-radius: 25px;
  color: var(--cafemedio);
}

.buscador input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--cafeoscuro);
  font-size: 16px; /* 16px evita que el iPhone haga zoom */
}

.buscador input::placeholder {
  color: var(--cafemedio);
}

.buscador:focus-within {
  border-color: var(--cafe);
}

/* ---------- Chips de filtro ---------- */
.filtros {
  display: flex;
  gap: 8px;
  margin: 14px -16px 0;
  padding: 0 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filtros::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--crema);
  border: 1px solid var(--linea);
  font-weight: 600;
  white-space: nowrap;
}

.chip.activo {
  background: var(--cafeclaro);
  border-color: var(--cafeclaro);
  color: var(--acento);
}

/* ---------- Selector segmentado (Efectivo | Transferencia | Fiado) ---------- */
.segmentado {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: var(--crema);
  border: 1px solid var(--linea);
  border-radius: 26px;
}

.segmentado button {
  height: 44px;
  border-radius: 22px;
  color: var(--cafemedio);
  font-weight: 600;
}

.segmentado button.activo {
  background: var(--blanco);
  color: var(--cafeoscuro);
  box-shadow: 0 2px 8px rgba(74, 47, 24, 0.1);
}

/* ---------- Etiquetas de color ---------- */
.etiquetas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.etiqueta.agotado,
.etiqueta.cancelada     { background: var(--rojoclaro);  color: var(--rojo); }
.etiqueta.bajo,
.etiqueta.fiado         { background: var(--ambarclaro); color: var(--ambar); }
.etiqueta.granel        { background: var(--cafeclaro);  color: var(--acento); }
.etiqueta.oferta,
.etiqueta.efectivo,
.etiqueta.pagado        { background: var(--verdeclaro); color: var(--verde); }
.etiqueta.transferencia { background: var(--azulclaro);  color: var(--azul); }

/* ---------- Campos de formulario ---------- */
.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.campo > span {
  padding-left: 6px;
  color: var(--cafemedio);
  font-size: 15px;
}

.entrada {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  background: var(--crema);
  border: 1px solid var(--linea);
  border-radius: 18px;
  outline: none;
  font-size: 16px;
}

textarea.entrada {
  height: 84px;
  padding: 14px 18px;
  resize: none;
}

select.entrada {
  appearance: none;
  background-image: var(--flechaselect);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 24px;
}

.entrada:focus {
  border-color: var(--cafe);
  background-color: var(--blanco);
}

.entrada.error {
  border-color: var(--rojo);
}

.entradaconicono {
  position: relative;
}

.entradaconicono .entrada {
  padding-right: 56px;
}

.entradaconicono button {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--acento);
}

.fila2,
.fila3 {
  display: grid;
  gap: 10px;
}

.fila2 { grid-template-columns: 1fr 1fr; }
.fila3 { grid-template-columns: 1fr 1fr 1fr; }

.nota {
  display: flex;
  gap: 8px;
  padding: 0 6px;
  color: var(--cafemedio);
  font-size: 14px;
  line-height: 1.4;
}

.formulario {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Interruptor (switch) */
.opcioninterruptor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--crema);
  border-radius: 20px;
  cursor: pointer;
}

.opcioninterruptor strong {
  display: block;
  font-weight: 600;
}

.opcioninterruptor small {
  color: var(--cafemedio);
  font-size: 14px;
}

.interruptor {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 32px;
  appearance: none;
  background: var(--linea);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.interruptor::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.interruptor:checked {
  background: var(--cafe);
}

.interruptor:checked::after {
  transform: translateX(24px);
}

/* Botones de foto (tomar / galeria) */
.botonesfoto {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.botonesfoto label {
  cursor: pointer;
}

.botonesfoto input {
  display: none;
}

.vistafoto {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 20px;
  overflow: hidden;
  background: var(--crema);
  display: grid;
  place-items: center;
  color: var(--cafemedio);
  font-family: var(--letratitulo);
  font-size: 26px;
  font-weight: 600;
  flex-shrink: 0;
}

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

.quitarfoto {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(40, 25, 12, 0.7);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 18px;
}

/* ---------- Ventanas (modales tipo hoja) ---------- */
.ventana {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(40, 25, 12, 0.5);
  z-index: 50;
}

.ventanacaja {
  width: 100%;
  max-width: 560px;
  max-height: 94vh;
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
  background: var(--blanco);
  border-radius: 30px 30px 0 0;
  padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  animation: subir 0.22s ease;
}

.ventanacuerpo {
  flex: 1;
  overflow-y: auto;
  margin: 0 -20px;
  padding: 4px 20px 8px;
}

.ventanapie {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  padding-top: 14px;
}

.ventanapie .botonprincipal {
  height: 54px;
}

@media (min-width: 600px) {
  .ventana {
    align-items: center;
    padding: 16px;
  }
  .ventanacaja {
    border-radius: 30px;
  }
}

@keyframes subir {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ventanatitulo {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ventanatitulo h2 {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 24px;
  line-height: 1.1;
}

.ventanacentro {
  align-items: center;
  padding: 16px;
}

.ventanacentro .ventanacaja {
  max-width: 360px;
  border-radius: 26px;
  text-align: center;
  padding-bottom: 18px;
}

.ayuda {
  margin-top: 8px;
  text-align: center;
  color: var(--cafemedio);
  font-size: 14px;
}

.preguntabotones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.lectorcamara {
  width: 100%;
  min-height: 220px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--crema);
}

/* ---------- Teclado numerico ---------- */
.teclado {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tecla {
  height: 54px;
  border-radius: 18px;
  background: var(--crema);
  font-family: var(--letratitulo);
  font-size: 22px;
  font-weight: 600;
  display: grid;
  place-items: center;
  user-select: none;
}

.tecla:active {
  background: var(--cafeclaro);
}

.tecla .icono {
  width: 28px;
  height: 28px;
}

/* Pantalla grande donde se ve lo que se teclea */
.pantallamonto {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 62px;
  padding: 10px 18px;
  background: var(--crema);
  border-radius: 20px;
}

.pantallamonto span {
  color: var(--cafemedio);
}

.pantallamonto strong {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 26px;
  text-align: right;
  overflow-wrap: anywhere;
}

.pantallamonto strong.vaciomonto {
  color: var(--linea);
}

/* Caja de total grande */
.cajatotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px 22px;
  background: var(--cafeclaro);
  border-radius: 24px;
  color: var(--acento);
}

.cajatotal span {
  font-weight: 700;
}

.cajatotal strong {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 36px;
  line-height: 1;
}

/* ---------- Resumen con filas ---------- */
.resumen {
  padding: 16px 20px;
  background: var(--crema);
  border-radius: var(--radio);
}

.filaresumen {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  color: var(--cafemedio);
}

.filaresumen strong {
  color: var(--cafeoscuro);
  text-align: right;
}

.filaresumen.verde strong { color: var(--verde); }
.filaresumen.ambar strong { color: var(--ambar); }

.filatotal {
  border-top: 1px solid var(--linea);
  margin-top: 6px;
  padding-top: 14px;
  color: var(--cafeoscuro);
  font-size: 19px;
  font-weight: 600;
}

.filatotal strong {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 32px;
}

/* ---------- Barra de navegacion inferior ---------- */
.navegacion {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 7px;
  background: var(--blanco);
  border-radius: 32px;
  box-shadow: var(--sombra);
  z-index: 20;
  max-width: 560px;
  margin: 0 auto;
}

body.sinnav .navegacion {
  display: none;
}

.navboton {
  text-decoration: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border-radius: 24px;
  color: var(--cafemedio);
  font-size: 12px;
}

.navboton.activo {
  background: var(--cafeclaro);
  color: var(--acento);
  font-weight: 700;
}

.navglobo {
  position: absolute;
  top: 2px;
  left: calc(50% + 4px);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--cafe);
  color: var(--textoclaro);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* ---------- Aviso flotante (toast) ---------- */
.aviso {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  transform: translate(-50%, -200%);
  background: var(--cafeoscuro);
  color: var(--fondo);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: var(--sombra);
  transition: transform 0.25s ease;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}

.aviso.visible {
  transform: translate(-50%, 0);
}

/* ---------- Ayudantes de espacio ---------- */
.espacioarriba { margin-top: 14px; }
.espacio { margin-top: 16px; }
.sinmargen { margin-top: 0 !important; }
.columna { flex-direction: column; align-items: flex-start; }
.titulovista.chico { font-size: 24px; }
.encabezadovista.inicio { justify-content: flex-start; }
.encabezado { display: flex; gap: 10px; align-items: center; }

.filafoto {
  display: flex;
  align-items: center;
  gap: 14px;
}

.equivalente {
  margin-top: 8px;
  text-align: center;
  color: var(--cafemedio);
  font-weight: 600;
  min-height: 22px;
}

.titulopregunta {
  font-family: var(--letratitulo);
  font-weight: var(--pesotitulo);
  font-size: 22px;
}

.lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 380px) {
  .titulovista { font-size: 26px; }
  .navboton { font-size: 11px; }
}

/* Imagen grande (comprobante, logo) */
.imagengrande {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 16px;
}

/* En oscuro el boton crema no lleva brillo cafe alrededor */
:root[data-tema="oscuro"] .botonprincipal {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}
