/* Entregas PrinterExpress — hoja única, mobile-first.
   Pensada para usarse a una mano, en la calle y con guantes: objetivos grandes. */

:root {
  --azul: #004aad;
  --azul-oscuro: #003b8a;
  --gris-texto: #1f2430;
  --gris-suave: #6b7280;
  --borde: #dfe3ea;
  --fondo: #f2f4f8;
  --tarjeta: #ffffff;
  --ok: #0f7b46;
  --ok-fondo: #e7f6ee;
  --error: #b3261e;
  --error-fondo: #fdeceb;
  --radio: 12px;
  --sombra: 0 2px 14px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

/* Las clases con display propio (.btn es inline-flex) pisan al atributo
   hidden del navegador, así que se refuerza aquí. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  padding: 0 0 3rem;
  background: var(--fondo);
  color: var(--gris-texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

/* ---------- cabecera ---------- */

.cabecera {
  position: relative;
  background: var(--tarjeta);
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  text-align: center;
  border-bottom: 1px solid var(--borde);
}

.logo { width: 170px; max-width: 60%; height: auto; display: inline-block; }

.salir {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  color: var(--gris-suave);
  text-decoration: none;
}

/* ---------- contenedor ---------- */

.contenedor {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem;
}

.contenedor--angosto { max-width: 380px; }

h1 {
  font-size: 1.25rem;
  text-align: center;
  margin: .5rem 0 1rem;
  letter-spacing: -.01em;
}

form {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.1rem;
}

/* ---------- campos ---------- */

.campo { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gris-suave);
  margin-bottom: .35rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: .8rem .9rem;
  font-size: 1.05rem;
  color: inherit;
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(0, 74, 173, .15);
}

.fila-pedido { display: flex; gap: .5rem; }
.fila-pedido input { flex: 1; }

/* ---------- botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 48px;
  padding: .7rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--azul);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, opacity .15s;
}

.btn:active { background: var(--azul-oscuro); }

.btn--qr { flex: 0 0 auto; padding-inline: .9rem; }

.btn--foto { flex: 1; }
.btn--secundario { background: #5b6472; }
.btn--secundario:active { background: #4a525e; }

.btn--texto {
  background: none;
  color: var(--azul);
  min-height: 36px;
  padding: .2rem .4rem;
  font-weight: 600;
  text-decoration: underline;
}

.btn--enviar { width: 100%; min-height: 54px; font-size: 1.05rem; margin-top: .3rem; }

.btn:disabled {
  background: #c3c9d4;
  cursor: not-allowed;
}

.btn__spinner { display: none; }

.btn.cargando .btn__spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar .7s linear infinite;
}

@keyframes girar { to { transform: rotate(360deg); } }

.fila-foto { display: flex; gap: .5rem; }

/* Tercera vía de adjunto: ocupa la fila completa bajo Cámara/Galería. */
.btn--archivos { width: 100%; margin-top: .5rem; font-size: .95rem; }

/* ---------- ficha del cliente ---------- */

.cliente {
  background: #f7f9fc;
  border: 1px solid var(--borde);
  border-left: 4px solid var(--borde);
  border-radius: 10px;
  padding: .7rem .85rem;
  margin-bottom: 1.1rem;
  transition: border-color .2s;
}

.cliente[data-estado="cargando"] { border-left-color: #b8c2d4; opacity: .7; }
.cliente[data-estado="ok"] { border-left-color: var(--ok); background: var(--ok-fondo); }
.cliente[data-estado="error"] { border-left-color: var(--error); background: var(--error-fondo); }

.cliente__linea {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .18rem 0;
  font-size: .95rem;
}

.cliente__linea span {
  color: var(--gris-suave);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex: 0 0 auto;
  padding-top: .12rem;
}

.cliente__linea strong { text-align: right; font-weight: 600; word-break: break-word; }

/* ---------- lector QR ---------- */

.qr-reader {
  width: 100%;
  margin-bottom: .6rem;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.qr-reader video { width: 100% !important; height: auto !important; display: block; }

/* ---------- previsualización de la foto ---------- */

.previsualizacion { margin-top: .7rem; }

.previsualizacion img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--borde);
  display: block;
}

.previsualizacion__info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .35rem;
  font-size: .85rem;
  color: var(--gris-suave);
}

.previsualizacion__info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ayuda {
  margin: .6rem 0 0;
  font-size: .82rem;
  color: var(--gris-suave);
  text-align: center;
}

/* ---------- banner de modo prueba ---------- */

.banner-prueba {
  background: repeating-linear-gradient(45deg, #fff4d6, #fff4d6 12px, #ffedbe 12px, #ffedbe 24px);
  border: 1px solid #e0b84c;
  border-left: 5px solid #c98a00;
  border-radius: 10px;
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .85rem;
  color: #6b4c00;
}

.banner-prueba strong { display: block; letter-spacing: .08em; margin-bottom: .25rem; }
.banner-prueba ul { margin: 0; padding-left: 1.1rem; }
.banner-prueba li { margin: .15rem 0; }

/* ---------- avisos ---------- */

.avisos { margin-bottom: 1rem; }

.aviso {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .6rem;
  padding: .75rem .9rem;
  border-radius: 10px;
  font-size: .93rem;
  margin-bottom: .5rem;
  border: 1px solid transparent;
}

.aviso--success { background: var(--ok-fondo); color: var(--ok); border-color: #b9e3cd; }
.aviso--error { background: var(--error-fondo); color: var(--error); border-color: #f4c7c4; }

.aviso__cerrar {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 .2rem;
  cursor: pointer;
  opacity: .6;
}

/* ---------- modo oscuro ---------- */

@media (prefers-color-scheme: dark) {
  :root {
    --gris-texto: #e8eaf0;
    --gris-suave: #9aa3b2;
    --borde: #333a47;
    --fondo: #14171d;
    --tarjeta: #1c202a;
    --ok-fondo: #10301f;
    --error-fondo: #3a1a18;
    --ok: #4ecb8a;
    --error: #ff8a80;
    --sombra: 0 2px 14px rgba(0, 0, 0, .4);
  }

  input[type="text"],
  input[type="password"] { background: #12151b; }

  .cliente { background: #171b23; }

  .banner-prueba {
    background: repeating-linear-gradient(45deg, #33280d, #33280d 12px, #3b2f10 12px, #3b2f10 24px);
    border-color: #6b551c;
    border-left-color: #c98a00;
    color: #f0d68a;
  }

  .aviso--success { border-color: #1e5b3c; }
  .aviso--error { border-color: #6b2b26; }
  .btn:disabled { background: #39404e; color: #7f8794; }
}
