/* ZigZag Admin — espelha tokens do app Flutter (theme.dart). */
:root {
  --bg-primary: #0B0D10;
  --bg-surface: #15181C;
  --bg-elevated: #1F242A;
  --bg-raised: #262C33;
  --accent: #F5C300;
  --accent-bright: #FFD60A;
  --accent-muted: #CFA600;
  --text-primary: #FFFFFF;
  --text-secondary: #9CA3AF;
  --text-tertiary: #6B7280;
  --text-on-accent: #0A0A0A;
  --border-subtle: #252A30;
  --border-strong: #3A4049;
  --success: #22C55E;
  --error: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ============================================================ LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(245,195,0,0.08), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(245,195,0,0.04), transparent 60%),
    var(--bg-primary);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4), 0 16px 32px rgba(0,0,0,0.25);
}
.brand { text-align: center; margin-bottom: 32px; }
.brand-dot {
  width: 12px; height: 12px;
  background: var(--accent-bright);
  border-radius: 50%;
  margin: 0 auto 18px;
  box-shadow: 0 0 24px rgba(255,214,10,0.5);
}
.brand-dot.small { width: 8px; height: 8px; margin: 0; box-shadow: none; }
.brand-wordmark {
  font-size: 36px; font-weight: 800; letter-spacing: 4.5px;
  color: var(--text-primary);
}
.brand-tagline {
  margin-top: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2.4px;
  font-weight: 700;
  color: var(--text-secondary);
}

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.4px;
}
.field input,
.filters input,
.filters select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 120ms;
}
.field input:focus,
.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,195,0,0.12);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: background 120ms;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--accent-muted); }
.btn-primary:disabled { background: var(--bg-elevated); color: var(--text-tertiary); cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 120ms;
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text-primary); }

.btn-danger {
  background: var(--error);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
}
.btn-danger:hover { filter: brightness(1.1); }

.error-msg {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--error);
  min-height: 18px;
}

/* ============================================================ DASHBOARD */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}
.sidebar-brand span {
  font-weight: 800;
  letter-spacing: 1.6px;
  font-size: 13px;
}
.sidebar-brand em {
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 2px;
}

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 120ms;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active {
  background: rgba(245,195,0,0.12);
  color: var(--accent);
}
.nav-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.85;
}

.sidebar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  text-decoration: underline;
  text-decoration-color: var(--text-tertiary);
}
.link-btn:hover { color: var(--accent); }

.main {
  padding: 32px 40px;
  overflow-x: hidden;
}

.section { display: none; }
.section.active { display: block; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.muted { color: var(--text-secondary); font-size: 13px; }

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filters input { padding: 8px 14px; font-size: 13px; min-width: 240px; }
.filters select { padding: 8px 14px; font-size: 13px; }

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 120ms;
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

/* ============================================================ KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 20px;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.kpi-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi.success .kpi-value { color: var(--success); }
.kpi.error .kpi-value { color: var(--error); }

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
}
.card h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.chart-card { min-height: 280px; }
.chart-card canvas { max-height: 240px; }

/* ============================================================ MAP */
.map-counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.map-counter {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.map-counter::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.08;
  pointer-events: none;
}
.map-counter.available::before { background: var(--accent); }
.map-counter.busy::before { background: var(--error); }
.map-counter.clients::before { background: #FFFFFF; }
.map-counter-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.map-counter.available .map-counter-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,195,0,0.18), 0 0 12px rgba(245,195,0,0.4);
}
.map-counter.busy .map-counter-dot {
  background: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.18);
}
.map-counter.clients .map-counter-dot {
  background: #FFFFFF;
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.14);
}
.map-counter-body { position: relative; z-index: 1; }
.map-counter-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.05;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.map-counter-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.map {
  height: calc(100vh - 200px);
  min-height: 480px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.leaflet-container { background: var(--bg-elevated); }
.leaflet-popup-content-wrapper {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-radius: 12px;
}
.leaflet-popup-tip { background: var(--bg-raised); }
.leaflet-popup-content { font-family: 'Manrope', sans-serif; font-size: 12.5px; }

/* Marker custom — bolinha amarela com pulso */
.driver-marker {
  position: relative;
  width: 14px; height: 14px;
}
.driver-marker::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-bright);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.6), 0 0 12px rgba(255,214,10,0.5);
}
.driver-marker.busy::before { background: #F87171; box-shadow: 0 0 0 2px rgba(0,0,0,0.6); }

/* Marker de cliente — quadrado branco com cantos arredondados pra contrastar
   com bolinha amarela do motorista. Diamante (rotacionado 45°) deixa fácil
   distinguir mesmo a uma distância. */
.client-marker {
  position: relative;
  width: 12px; height: 12px;
  background: #FFFFFF;
  transform: rotate(45deg);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.6), 0 0 8px rgba(255,255,255,0.4);
  border-radius: 2px;
}

/* Legenda do mapa */
.map-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}
.map-legend-item { display: flex; align-items: center; gap: 6px; }
.map-legend-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
}
.map-legend-swatch.busy { background: #F87171; }
.map-legend-swatch.client {
  border-radius: 2px;
  background: #FFFFFF;
  transform: rotate(45deg);
}

/* ============================================================ TABLE */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 500;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-elevated); }
.table.compact tbody td { padding: 10px 12px; font-size: 12.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.pill.completed { color: var(--success); background: rgba(34,197,94,0.14); }
.pill.cancelled { color: var(--error); background: rgba(239,68,68,0.14); }
.pill.waiting { color: var(--text-secondary); background: rgba(156,163,175,0.14); }
.pill.accepted, .pill.in_progress { color: var(--accent); background: rgba(245,195,0,0.14); }
.pill.blocked { color: var(--error); background: rgba(239,68,68,0.14); }
.pill.deleted { color: var(--text-tertiary); background: rgba(107,114,128,0.14); }
.pill.active { color: var(--success); background: rgba(34,197,94,0.14); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 12px;
}
.pagination button {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 44px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination button:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.pagination .page-info {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ============================================================ TICKETS */
.tickets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.ticket {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}
.ticket-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.ticket-user { font-weight: 700; font-size: 14px; }
.ticket-meta { font-size: 12px; color: var(--text-secondary); }
.ticket-message {
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ticket-ride {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
}
.ticket-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 130px;
}

/* ============================================================ MODAL */
.modal {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 32px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }

.modal h3 {
  font-size: 18px;
  margin-bottom: 8px;
  letter-spacing: -0.1px;
}
.modal p { color: var(--text-secondary); font-size: 13px; margin-bottom: 14px; }
.modal textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
}
.modal textarea:focus { outline: none; border-color: var(--accent); }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

/* ============================================================ TICKET MODAL */
.ticket-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}
.ticket-modal-header h3 { margin-bottom: 0; }
.ticket-modal-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0 -8px 14px;
  padding: 12px 8px;
}
.chat-thread::-webkit-scrollbar { width: 4px; }
.chat-thread::-webkit-scrollbar-track { background: transparent; }
.chat-thread::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.chat-msg.received { align-self: flex-start; }
.chat-msg.sent { align-self: flex-end; align-items: flex-end; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.received .chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 4px;
}
.chat-msg.sent .chat-bubble {
  background: var(--accent);
  color: var(--text-on-accent);
  border-top-right-radius: 4px;
  font-weight: 600;
}
.chat-meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
  letter-spacing: 0.2px;
}
.chat-composer textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 70px;
  margin-bottom: 0;
}
.chat-composer textarea:focus { outline: none; border-color: var(--accent); }

.resolved-notice {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
}

/* ============================================================ RIDE TIMELINE */
.ride-timeline {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.ride-timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}
.ride-timeline-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.1px;
}
.ride-timeline-route {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.ride-timeline-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.timeline-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--accent);
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.timeline-extra {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
.timeline-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.timeline-loc {
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-secondary);
  line-height: 1.45;
}
.timeline-loc a {
  color: var(--accent);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}
.timeline-loc a:hover { text-decoration: underline; }

/* ============================================================ RELATED */
.related-block {
  background: rgba(245,195,0,0.06);
  border: 1px solid rgba(245,195,0,0.25);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.related-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.related-ticket {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 120ms;
}
.related-ticket:last-child { margin-bottom: 0; }
.related-ticket:hover { border-color: var(--accent); }
.related-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.related-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-raised);
  padding: 2px 8px;
  border-radius: 6px;
}
.related-user {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.related-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 4px;
}
.related-time {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

.pill.linked {
  color: #FBBF24;
  background: rgba(251,191,36,0.14);
}

@media (max-width: 768px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
    grid-row: 2;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    padding: 12px;
  }
  .main { padding: 20px 16px; }
  .nav { flex-direction: row; overflow-x: auto; }
}
