/* ============================================================================
   AT Driver — App Motorista (PWA)
   Tema: neutro SaaS (Slate / Steel Blue) · Mobile-First · Touch-Friendly
   ==========================================================================*/
:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --navy-3: #273449;
  --gold: #4f46e5;
  --gold-2: #766feb;
  --glow-rgb: 79, 70, 229;
  --on-gold: #ffffff;
  --text: #f1f5f9;
  --muted: #8fa3bd;
  --border: #1e3355;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  /* Tudo self-hosted: compatível com a CSP do servidor. */
}

body { padding-top: var(--safe-t); padding-bottom: var(--safe-b); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-b));
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(var(--glow-rgb), 0.14), transparent 60%),
    var(--navy);
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}
.brand-logo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(var(--glow-rgb), 0.25);
}
.brand h1 { margin: 14px 0 2px; font-size: 24px; letter-spacing: 0.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 52px;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(var(--glow-rgb), 0.18);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; }
.btn-gold { background: var(--gold); color: var(--on-gold); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.login-msg {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

/* ---------- Dashboard ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(10, 22, 40, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header .logo-mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.app-header .titles { flex: 1; min-width: 0; }
.app-header .titles strong { display: block; font-size: 15px; line-height: 1.2; }
.app-header .titles span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--navy-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--navy-3); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 8px;
}
.tab-btn {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--navy-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.tab-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-gold);
}

.list { padding: 8px 16px 24px; }

/* ---------- Cards de serviço (sem tabelas) ---------- */
.service-card {
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.service-num { font-size: 13px; font-weight: 700; color: var(--gold-2); letter-spacing: 0.04em; }
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.status-pendente { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
.status-atribuido { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.status-emcurso { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.status-concluido { background: rgba(143, 163, 189, 0.18); color: var(--muted); }
.status-cancelado, .status-noshow { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.route { margin-bottom: 12px; }
.route-point { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-green { background: var(--green); }
.dot-gold { background: var(--gold); }
.route-text { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.route-line {
  width: 2px;
  height: 14px;
  margin-left: 4px;
  background: linear-gradient(var(--green), var(--gold));
  opacity: 0.5;
}

/* ---------- Waze Deep Linking (2026-08-15) ---------- */
/* Botão-ícone na linha da rota — ÚNICA forma de navegação do card (sem
   redundância). Touch target >= 44x44 (ergonomia iOS/mobile-first). */
.waze-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--navy-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-decoration: none;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.waze-btn:active { transform: scale(0.94); background: rgba(var(--glow-rgb), 0.15); border-color: var(--gold); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.cell .k { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.cell .v { display: block; font-size: 14px; font-weight: 500; margin-top: 1px; word-break: break-word; }
.collect-alert {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(248, 113, 113, 0.14);
  border: 1.5px solid var(--red);
  border-radius: 12px;
  color: #fecaca;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
}

/* ---------- Ciclo de Vida do Serviço (Gestão de Status) 2026-08-15 ---------- */
.status-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.status-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.status-btn:active { transform: scale(0.98); }
.status-btn:disabled { cursor: default; }
.status-btn-green {
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: var(--green);
}
.status-btn-green:active { background: rgba(52, 211, 153, 0.28); }
.status-btn-red {
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--red);
}
.status-btn-red:active { background: rgba(248, 113, 113, 0.28); }
.status-btn-full { width: 100%; min-height: 52px; font-size: 15px; }

/* Ações complementares lado a lado (▶ Iniciar | ✕ Não Apareceu) */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.status-grid .status-btn {
  min-height: 46px;
  font-size: 13px;
  padding: 0 6px;
  white-space: nowrap;
}

/* Banner de espera (cronómetro No-Show dinâmico) */
.wait-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.09);
  border: 1px solid rgba(251, 191, 36, 0.25);
  margin-bottom: 2px;
}
.wait-timer {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  letter-spacing: 0.03em;
}
.wait-text { font-size: 11px; color: var(--muted); }
.wait-unlocked {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green);
}

/* ---------- Toast (feedback de status) ---------- */
.toast-box {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 360px;
}
.toast {
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--navy-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.25s ease;
}
.toast-ok { border-color: rgba(52, 211, 153, 0.5); color: var(--green); }
.toast-err { border-color: rgba(248, 113, 113, 0.5); color: var(--red); }
.toast-hide { opacity: 0; transform: translateY(-6px); transition: all 0.3s ease; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.empty span { font-size: 34px; display: block; margin-bottom: 8px; }
.empty p { margin: 6px 0 12px; }
.empty .btn { max-width: 240px; margin: 0 auto; }

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 10px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
}
