/* ==========================================================================
   ALFRED — Hoja de estilos única
   Objetivo: Android 4.4 (Chromium 30), pantallas táctiles pequeñas y CPUs lentas.

   Reglas de compatibilidad aplicadas:
     - SIN variables CSS (custom properties)  → no soportadas en Chromium 30
     - SIN CSS Grid                            → no soportado
     - SIN animaciones ni transiciones         → ahorro de CPU/GPU
     - SIN degradados ni sombras difusas       → repintado más barato
     - Flexbox con prefijos -webkit-           → cobertura total
     - Tamaños en px y rem simples             → sin clamp()/min()/max()
     - Áreas táctiles >= 48px                  → dedos en pantalla pequeña
   ========================================================================== */

/* ── Reset mínimo ───────────────────────────────────────────────────────── */
* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: #f1f3f6;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

#root {
  min-height: 100%;
}

.boot,
.noscript {
  padding: 24px 16px;
  text-align: center;
  font-size: 16px;
  color: #4b5563;
}

/* Aviso de fallo al arrancar (se muestra en lugar de "Cargando…") */
.boot-error {
  text-align: left;
  background: #fdecec;
  border: 1px solid #b91c1c;
  border-left: 5px solid #b91c1c;
  color: #7f1d1d;
  padding: 12px;
  margin: 12px;
  font-size: 14px;
  word-wrap: break-word;
}

/* ── Estructura general ─────────────────────────────────────────────────── */
.screen {
  padding: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.topbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  background: #1e3a8a;
  color: #ffffff;
  padding: 10px 12px;
  margin: -12px -12px 12px -12px;
}

.topbar-user {
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
  word-wrap: break-word;
}

.topbar-user strong {
  display: block;
  font-size: 15px;
}

.card {
  background: #ffffff;
  border: 1px solid #d6dbe3;
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  margin: 0 0 12px 0;
  font-size: 17px;
  color: #111827;
}

.brand {
  text-align: center;
  padding: 26px 8px 18px 8px;
}

.brand-title {
  margin: 0;
  font-size: 30px;
  letter-spacing: 4px;
  color: #1e3a8a;
}

.brand-sub {
  margin: 6px 0 0 0;
  font-size: 13px;
  color: #6b7280;
}

/* ── Formularios ────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #374151;
  margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"] {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 10px;
  font-size: 17px;
  font-family: Arial, Helvetica, sans-serif;
  color: #111827;
  background: #ffffff;
  border: 1px solid #9aa5b1;
  border-radius: 4px;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus {
  outline: 2px solid #1e3a8a;
  outline-offset: -1px;
  border-color: #1e3a8a;
}

/* ── Botones ────────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 17px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  text-align: center;
  color: #ffffff;
  background: #1e3a8a;
  border: 1px solid #1e3a8a;
  border-radius: 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.2);
}

.btn:active {
  background: #16307a;
}

.btn[disabled],
.btn[disabled]:active {
  background: #9aa5b1;
  border-color: #9aa5b1;
  cursor: default;
}

.btn-small {
  width: auto;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
}

.btn-secondary {
  background: #ffffff;
  color: #1e3a8a;
  border: 1px solid #1e3a8a;
}

.btn-secondary:active {
  background: #e5e9f2;
}

.btn-link {
  background: transparent;
  border: 1px solid #ffffff;
  color: #ffffff;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  width: auto;
}

.btn-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}

.btn-row .btn {
  margin-right: 8px;
}

.btn-row .btn:last-child {
  margin-right: 0;
}

/* ── Mensajes ───────────────────────────────────────────────────────────── */
.msg {
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 15px;
  border-left: 5px solid;
  word-wrap: break-word;
}

.msg-error {
  background: #fdecec;
  border-color: #b91c1c;
  color: #7f1d1d;
}

.msg-warn {
  background: #fdf6e3;
  border-color: #b45309;
  color: #7c2d12;
}

.msg-ok {
  background: #eafaf0;
  border-color: #15803d;
  color: #14532d;
}

.msg-info {
  background: #eaf1fd;
  border-color: #1e3a8a;
  color: #1e3a8a;
}

/* ── Resultados ─────────────────────────────────────────────────────────── */
.results-head {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 8px;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: block;
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid #d6dbe3;
  border-left: 5px solid #1e3a8a;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  color: #1f2937;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
}

.item:active {
  background: #e5e9f2;
}

.item.is-selected {
  border-left-color: #15803d;
  background: #eafaf0;
}

.item-code {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #1e3a8a;
}

.item-name {
  display: block;
  font-weight: bold;
  margin: 2px 0;
  word-wrap: break-word;
}

.item-meta {
  display: block;
  font-size: 13px;
  color: #6b7280;
  word-wrap: break-word;
}

.item-price {
  display: block;
  font-size: 15px;
  font-weight: bold;
  color: #15803d;
  margin-top: 2px;
}

.empty {
  padding: 18px 12px;
  text-align: center;
  color: #6b7280;
  font-size: 15px;
  background: #ffffff;
  border: 1px dashed #c3cad6;
}

/* ── Detalle / acción ───────────────────────────────────────────────────── */
.detail-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-bottom: 4px;
  font-size: 14px;
}

.detail-label {
  width: 84px;
  color: #6b7280;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

.detail-value {
  -webkit-flex: 1;
  flex: 1;
  font-weight: bold;
  word-wrap: break-word;
}

.qty-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-end;
  align-items: flex-end;
}

.qty-row .field {
  width: 110px;
  margin-right: 10px;
  margin-bottom: 0;
}

.qty-row .btn {
  -webkit-flex: 1;
  flex: 1;
}

.pending-note {
  font-size: 13px;
  color: #7c2d12;
  margin: 8px 0 0 0;
}

.pager {
  margin-top: 4px;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: #9aa5b1;
  padding: 14px 4px 20px 4px;
}

/* ── Pantallas muy pequeñas ─────────────────────────────────────────────── */
@media (max-width: 360px) {
  body { font-size: 15px; }
  .screen { padding: 8px; }
  .topbar { margin: -8px -8px 8px -8px; }
  .brand-title { font-size: 24px; letter-spacing: 2px; }
  .detail-label { width: 70px; }
}
