/* OptyNex Driver PWA — estilos base */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #077FE3;
  --dark: #0e2a45;
  --accent: #18D4DF;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #14202e;
  --text-muted: #6b7c93;
  --border: #e3e9f1;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(14, 42, 69, 0.10);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: opacity 0.15s ease;
}
#app.od-fade-out { opacity: 0.4; }

button { font-family: inherit; }
input { font-family: inherit; }

a { color: var(--primary); }

/* ---------- Bloqueo de escritorio ---------- */
.od-desktop-blocked #app { display: none; }
.od-desktop-guard {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 48px 24px;
  background: radial-gradient(circle at 20% 0%, #103a5e 0%, var(--dark) 55%, #081826 100%);
  color: #fff;
}
.od-desktop-blocked .od-desktop-guard { display: flex; }
.od-desktop-guard__logo {
  width: 84px; height: 84px;
  object-fit: contain;
  background: #fff;
  border-radius: 20px;
  padding: 12px;
  margin-bottom: 22px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.35);
}
.od-desktop-guard h1 { font-size: 26px; margin: 0 0 14px; font-weight: 700; }
.od-desktop-guard p { color: #b9c9dc; max-width: 420px; line-height: 1.55; margin: 0 auto 6px; font-size: 15px; }
.od-desktop-guard__lead { color: #fff; font-size: 16px; margin-bottom: 18px; }
.od-desktop-guard__actions {
  display: flex; flex-direction: row; gap: 12px;
  width: 100%; max-width: 420px;
  margin: 26px 0 22px;
}
.od-desktop-guard__actions .od-btn { flex: 1; max-width: none; white-space: nowrap; }
.od-desktop-guard__foot { font-size: 13px; color: #7f93aa; margin-top: 8px; }

/* ---------- Layout general ---------- */
.od-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
}

.od-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: var(--dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.od-topbar__back {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.od-topbar__title { font-weight: 600; font-size: 17px; flex: 1; }
.od-topbar__subtitle { font-size: 12px; color: #a9bdd3; }

.od-content {
  flex: 1;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}

/* ---------- Login ---------- */
.od-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
  background: radial-gradient(circle at 20% 0%, #103a5e 0%, var(--dark) 55%, #081826 100%);
  color: #fff;
}
.od-login__brand {
  text-align: center;
  margin-bottom: 32px;
}
.od-login__brand .od-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  display: block;
  object-fit: contain;
  background: #fff;
  padding: 8px;
  margin: 0 auto 14px;
  box-shadow: 0 10px 30px rgba(7,127,227,0.35);
}
.od-login__brand .od-logo--fallback {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-weight: 800; font-size: 22px; color: #fff;
  padding: 0;
}
.od-login__brand h1 { font-size: 20px; margin: 0; }
.od-login__brand p { color: #9db3ca; font-size: 13px; margin: 4px 0 0; }

.od-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}
.od-steps__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: all 0.25s ease;
}
.od-steps__dot--active { background: var(--accent); width: 22px; border-radius: 4px; }
.od-steps__dot--done { background: var(--primary); }

.od-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.od-field { margin-bottom: 16px; }
.od-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #b9c9dc;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.od-field input, .od-field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 17px;
  outline: none;
  transition: border-color 0.15s ease;
}
.od-field input::placeholder { color: #7f93aa; }
.od-field input:focus, .od-field select:focus { border-color: var(--accent); }
.od-field input[type="text"] { letter-spacing: 0.06em; text-transform: uppercase; }

.od-empresa-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.od-empresa-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  text-align: left;
}
.od-empresa-option:active { transform: scale(0.98); }
.od-empresa-option strong { display: block; font-size: 15px; }
.od-empresa-option span { font-size: 12px; color: #9db3ca; }
.od-empresa-option__chevron { color: var(--accent); font-size: 18px; }

.od-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.od-btn:active { transform: scale(0.98); }
.od-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.od-btn--ghost { background: transparent; border: 1.5px solid rgba(255,255,255,0.2); color: #fff; }
.od-btn--danger { background: var(--error); }
.od-btn--success { background: var(--success); }
.od-btn--outline-light { background: #fff; color: var(--primary); }
.od-btn--sm { padding: 10px; font-size: 14px; }

.od-link-btn {
  background: none; border: none; color: #9db3ca;
  font-size: 13px; text-align: center; width: 100%; margin-top: 14px; cursor: pointer;
}

.od-error-msg {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #ffb4b4;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- Ruta hoy / home ---------- */
.od-ruta-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.od-ruta-card__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px;
}
.od-ruta-card__head h2 { margin: 0 0 4px; font-size: 18px; }
.od-ruta-card__head .od-date { font-size: 12px; color: var(--text-muted); }

.od-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.od-badge--planificada { background: #e6f0fd; color: var(--primary); }
.od-badge--en_curso { background: #fff4e0; color: #b5750b; }
.od-badge--completada, .od-badge--finalizada { background: #e4f9ec; color: #178a44; }
.od-badge--cancelada, .od-badge--fallida { background: #fde8e8; color: #c23434; }
.od-badge--pendiente { background: #eef1f6; color: var(--text-muted); }

.od-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.od-stat {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}
.od-stat strong { display: block; font-size: 19px; color: var(--dark); }
.od-stat span { font-size: 11px; color: var(--text-muted); }

.od-progress {
  height: 8px;
  border-radius: 6px;
  background: var(--border);
  overflow: hidden;
  margin: 4px 0 16px;
}
.od-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 6px;
  transition: width 0.3s ease;
}

.od-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.od-empty .od-empty-icon { font-size: 44px; margin-bottom: 14px; }
.od-empty h3 { color: var(--text); margin: 0 0 6px; }
.od-empty__timer { margin-top: 18px; font-size: 13px; color: var(--error); font-weight: 600; }

/* ---------- Paradas ---------- */
.od-filters { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.od-filter-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.od-filter-chip--active { background: var(--dark); color: #fff; border-color: var(--dark); }

.od-summary-row { display: flex; gap: 10px; margin-bottom: 16px; }
.od-summary-pill {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.od-summary-pill strong { display: block; font-size: 17px; }
.od-summary-pill span { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; }

.od-parada-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.od-parada-item__num {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.od-parada-item__body { flex: 1; min-width: 0; }
.od-parada-item__body strong { display: block; font-size: 14.5px; }
.od-parada-item__body span { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.od-parada-item__chevron { color: var(--text-muted); font-size: 16px; }

/* ---------- Pedido detalle ---------- */
.od-info-row { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.od-info-row span:first-child { color: var(--text-muted); }
.od-info-row span:last-child { font-weight: 500; text-align: right; max-width: 60%; }

.od-locked-banner {
  background: #fff4e0;
  color: #93610a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; gap: 8px; align-items: center;
}

.od-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 22px 0 10px; }

/* ---------- Archivos / evidencias ---------- */
.od-file-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.od-file-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border);
}
.od-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.od-file-thumb__del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; border: none; font-size: 13px;
}
.od-upload-btn {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; gap: 6px; background: none;
}

.od-modal-overlay {
  position: fixed; inset: 0; background: rgba(8,16,26,0.7);
  display: flex; align-items: flex-end; z-index: 100;
}
.od-modal-overlay--center { align-items: center; padding: 20px; }
.od-modal-sheet {
  background: var(--surface);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
}
.od-modal-sheet--card { border-radius: 18px; max-width: 420px; margin: 0 auto; }
.od-modal-sheet h3 { margin: 0 0 16px; }
.od-modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 22px; color: var(--text-muted); }

.od-img-preview-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.od-img-preview-overlay img { max-width: 96vw; max-height: 90vh; touch-action: pinch-zoom; }
.od-img-preview-overlay__close { position: absolute; top: calc(16px + var(--safe-top)); right: 16px; background: rgba(255,255,255,0.15); border: none; color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 18px; }

/* ---------- Mapa ---------- */
.od-map-wrap { position: relative; flex: 1; min-height: 0; }
#od-map { position: absolute; inset: 0; }
.od-map-panel {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex; justify-content: space-around; text-align: center;
}
.od-map-panel div strong { display: block; font-size: 16px; }
.od-map-panel div span { font-size: 11px; color: var(--text-muted); }
.od-map-center-btn {
  position: absolute; right: 14px; bottom: 92px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); border: none; box-shadow: var(--shadow);
  font-size: 18px; color: var(--primary);
}
.od-marker-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.od-marker-vehiculo {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--dark); border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ---------- Bottom nav ---------- */
.od-bottom-actions {
  position: sticky; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  display: flex; gap: 10px;
}

/* ---------- Loader ---------- */
.od-loader { display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.od-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: od-spin 0.7s linear infinite;
}
@keyframes od-spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.od-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--dark); color: #fff; padding: 12px 20px;
  border-radius: 30px; font-size: 13.5px; z-index: 999;
  opacity: 0; transition: all 0.25s ease; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  max-width: 88vw; text-align: center;
}
.od-toast--show { opacity: 1; transform: translate(-50%, 0); }
.od-toast--error { background: var(--error); }
.od-toast--success { background: var(--success); }

/* ---------- Confirmación de cierre ---------- */
.od-confirm-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px;
}
.od-confirm-screen .od-check {
  width: 84px; height: 84px; border-radius: 50%;
  background: #e4f9ec; color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; margin-bottom: 20px;
}

.od-radio-group { display: flex; flex-direction: column; gap: 8px; }
.od-radio-option {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}
.od-radio-option--selected { border-color: var(--primary); background: #f0f7fe; }

textarea.od-textarea {
  width: 100%; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  padding: 12px; font-family: inherit; font-size: 14px; resize: vertical; min-height: 70px;
}

@media (min-width: 400px) {
  .od-stats-grid { gap: 12px; }
}
