/* ============================================================
   TransApp PWA · Estilos
   Colores corporativos: azul #0063B7, naranja #E66912
   ============================================================ */

:root {
  --azul: #0063B7;
  --azul-osc: #004a8a;
  --naranja: #E66912;
  --bg: #eef0f3;
  --card: #ffffff;
  --texto: #1a1d21;
  --texto-sec: #5f6672;
  --borde: rgba(0,0,0,0.10);
  --verde-ok: #E1F5EE;
  --verde-txt: #0F6E56;
  --amber-bg: #FAEEDA;
  --amber-txt: #854F0B;
  --rojo-bg: #FAECE7;
  --rojo-txt: #993C1D;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--texto);
  height: 100%;
}

/* Contenedor tipo móvil, pero a pantalla completa en el dispositivo */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---- Barra superior ---- */
.topbar {
  background: var(--azul);
  color: white;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 600; flex: 1; }
.topbar .sub { font-size: 12px; opacity: 0.85; font-weight: 400; }
.topbar-back {
  background: none; border: none; color: white; cursor: pointer;
  font-size: 22px; padding: 0; display: flex; align-items: center;
}
.topbar-logout {
  background: rgba(255,255,255,0.15); border: none; color: white;
  cursor: pointer; font-size: 13px; padding: 6px 12px; border-radius: 8px;
}

/* ---- Contenido ---- */
.contenido { padding: 16px; flex: 1; }

/* ---- Pantalla de login ---- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; padding: 32px 24px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .icono {
  font-size: 56px; color: var(--azul); margin-bottom: 12px;
}
.login-logo h1 { font-size: 26px; color: var(--azul); font-weight: 700; }
.login-logo p { font-size: 14px; color: var(--texto-sec); margin-top: 4px; }
.campo { margin-bottom: 18px; }
.campo label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--texto-sec); margin-bottom: 6px;
}
.campo input {
  width: 100%; padding: 15px; border-radius: 12px;
  border: 1px solid var(--borde); font-size: 17px;
  background: var(--card); color: var(--texto);
}
.campo input:focus { outline: 2px solid var(--azul); border-color: var(--azul); }

/* ---- Botones ---- */
.btn {
  width: 100%; padding: 16px; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  border: none; text-align: center; display: flex;
  align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--azul); color: white; }
.btn-naranja { background: var(--naranja); color: white; }
.btn-sec {
  background: var(--card); color: var(--texto);
  border: 1px solid var(--borde);
}
.btn-warn { background: var(--rojo-bg); color: var(--rojo-txt); }
.btn-fila { display: flex; gap: 10px; }
.btn-fila .btn { margin-top: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn + .btn, .btn { margin-top: 10px; }
.btn-fila .btn { margin-top: 0; }

/* ---- Tarjetas de viaje ---- */
.viaje-card {
  background: var(--card); border-radius: 14px; border: 1px solid var(--borde);
  padding: 16px; margin-bottom: 12px; cursor: pointer;
}
.viaje-card:active { background: #fafafa; }
.viaje-top {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.viaje-id { font-size: 14px; font-weight: 600; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 12px; font-weight: 600; }
.badge-0 { background: var(--amber-bg); color: var(--amber-txt); }
.badge-1 { background: var(--verde-ok); color: var(--verde-txt); }
.badge-2 { background: #E6F1FB; color: var(--azul); }

.ruta { margin-bottom: 12px; }
.ruta-linea { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-o { background: #378ADD; }
.dot-d { background: var(--naranja); }
.ruta-dash { border-left: 2px dotted var(--borde); height: 14px; margin-left: 4px; }

.viaje-meta {
  display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px;
  color: var(--texto-sec); padding-top: 10px; border-top: 1px solid var(--borde);
}
.viaje-meta i { vertical-align: -1px; }

/* ---- Pestañas ---- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 16px; border-radius: 20px; font-size: 14px;
  white-space: nowrap; border: 1px solid var(--borde);
  color: var(--texto-sec); background: var(--card); cursor: pointer;
}
.tab.on { background: var(--naranja); color: white; border-color: var(--naranja); }

/* ---- Secciones y datos ---- */
.sec-titulo {
  font-size: 12px; font-weight: 600; color: var(--texto-sec);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 4px 0 10px;
}
.datos {
  background: var(--card); border-radius: 14px; border: 1px solid var(--borde);
  padding: 14px 16px; margin-bottom: 14px;
}
.dato-fila {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--borde); font-size: 14px;
}
.dato-fila:last-child { border-bottom: none; }
.dato-label { color: var(--texto-sec); flex-shrink: 0; }
.dato-valor { font-weight: 600; text-align: right; }

/* ---- Pasos de estado ---- */
.pasos { margin-bottom: 16px; }
.paso { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.paso-num {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.paso-done { background: var(--verde-ok); color: var(--verde-txt); }
.paso-actual { background: var(--naranja); color: white; }
.paso-pend { background: #e8eaed; color: var(--texto-sec); }
.paso-txt { font-size: 15px; padding-top: 6px; }
.paso-txt .sub { color: var(--texto-sec); font-size: 12px; }

/* ---- Contenedores (recogida) ---- */
.cont-fila {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borde);
}
.cont-fila:last-child { border-bottom: none; }
.cont-info { font-size: 14px; }
.cont-badge {
  display: inline-block; background: #E6F1FB; color: var(--azul);
  padding: 4px 10px; border-radius: 7px; font-size: 13px; font-weight: 600;
}
.cont-tipo { font-size: 12px; color: var(--texto-sec); margin-top: 3px; }
.btn-marcar {
  padding: 9px 14px; border-radius: 9px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--borde);
  background: var(--card); color: var(--texto); white-space: nowrap;
}
.btn-marcar.recogido {
  background: var(--verde-ok); color: var(--verde-txt);
  border-color: #9FE1CB;
}
.btn-marcar.incidencia {
  background: var(--rojo-bg); color: var(--rojo-txt); border-color: #e8c4b5;
}

/* ---- Firma ---- */
.firma-canvas {
  width: 100%; height: 200px; background: white;
  border: 2px dashed #9Fc4e8; border-radius: 14px; touch-action: none;
  display: block;
}
.firma-label { font-size: 13px; color: var(--azul-osc); margin: 12px 0 6px; }

/* ---- Pesaje ---- */
.peso-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.peso-campo label {
  font-size: 12px; color: var(--texto-sec); display: block; margin-bottom: 6px;
}
.peso-campo input {
  width: 100%; padding: 14px 10px; border-radius: 11px;
  border: 1px solid var(--borde); font-size: 20px; font-weight: 600;
  text-align: center; background: var(--card); color: var(--texto);
}
.peso-neto {
  background: var(--verde-ok); border-radius: 12px; padding: 16px;
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.peso-neto .label { font-size: 14px; color: var(--verde-txt); }
.peso-neto .valor { font-size: 24px; font-weight: 700; color: var(--verde-txt); }

/* ---- Incidencia ---- */
.inci-txt {
  width: 100%; min-height: 140px; padding: 14px; border-radius: 12px;
  border: 1px solid var(--borde); font-size: 15px; font-family: inherit;
  background: var(--card); color: var(--texto); resize: vertical;
}

/* ---- Pantalla completado ---- */
.done-wrap { text-align: center; padding: 40px 24px; }
.done-icono { font-size: 64px; color: var(--verde-txt); margin-bottom: 16px; }
.done-wrap h2 { font-size: 20px; margin-bottom: 8px; }
.done-wrap p { font-size: 14px; color: var(--texto-sec); margin-bottom: 24px; }

/* ---- Estados vacío / carga ---- */
.vacio, .cargando {
  text-align: center; padding: 48px 24px; color: var(--texto-sec);
}
.vacio i, .cargando i { font-size: 44px; margin-bottom: 12px; display: block; color: #b8bcc4; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--borde);
  border-top-color: var(--azul); border-radius: 50%;
  animation: giro 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes giro { to { transform: rotate(360deg); } }

/* ---- Toast (avisos) ---- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--texto); color: white; padding: 13px 20px;
  border-radius: 10px; font-size: 14px; max-width: 88%; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 100;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--rojo-txt); }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .btn:active { transform: none; }
}
