/* ==========================================================
   Hanashi Seguir - CSS Style Sheet
   Otimizado para Mobile e Desktop (Touch & Driving friendly)
   ========================================================== */

:root {
  --bg-dark: #090d16;
  --card-bg: rgba(15, 23, 42, 0.90);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-top: env(safe-area-inset-top, 16px);
}

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

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  user-select: none;
}

/* ================= Mapa ================= */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #1e293b;
}

/* Custom Leaflet Controls */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--card-border) !important;
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-zoom a:hover {
  background-color: var(--primary) !important;
}

/* ================= Top Bar ================= */
.top-nav {
  position: absolute;
  top: var(--safe-top);
  left: 16px;
  right: 16px;
  height: 58px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Botões */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  transition: all 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.btn-secondary {
  height: 40px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary.full-width {
  width: 100%;
}

/* ================= HUD Inferior de Navegação ================= */
.nav-hud {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 12px);
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-hud.hidden {
  transform: translateY(150%);
  opacity: 0;
}

.hud-card {
  pointer-events: auto;
  width: 100%;
  max-width: 520px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-route-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.3);
  padding: 8px 14px;
  border-radius: 12px;
}

.hud-route-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-clock-icon {
  font-size: 16px;
}

.hud-route-title-text {
  display: flex;
  flex-direction: column;
}

.hud-route-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #38bdf8;
}

.hud-route-time-val {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
}

.hud-route-date-badge {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  animation: pulse 1.5s infinite;
}

.status-badge.on-track {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.warning-track {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.off-track {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.hud-icon-btn.active {
  color: var(--primary);
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
}
.hud-icon-btn.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.hud-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metric-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.metric-value-box {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.metric-value {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.metric-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-divider {
  width: 1px;
  height: 24px;
  background: var(--card-border);
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #10b981);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Legenda Ida e Volta */
.route-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(8px);
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.legend-chip.ida .legend-title {
  color: #38bdf8;
  font-weight: 800;
}

.legend-chip.volta .legend-title {
  color: #fb923c;
  font-weight: 800;
}

.legend-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.legend-indicator.ida-dot {
  background: #38bdf8;
  box-shadow: 0 0 8px #0284c7;
}

.legend-indicator.volta-dot {
  background: #fb923c;
  box-shadow: 0 0 8px #ea580c;
}

.legend-km {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.legend-active-leg {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ================= Drawer Lateral ================= */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1100;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}
.drawer-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.routes-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background: var(--bg-dark);
  border-left: 1px solid var(--card-border);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.7);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.routes-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--card-border);
}

.drawer-title {
  font-size: 18px;
  font-weight: 700;
}

.drawer-tabs {
  display: flex;
  padding: 8px 16px;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--card-border);
}

.tab-btn {
  flex: 1;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: rgba(14, 165, 233, 0.15);
  color: var(--primary);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Formulários */
.filter-form {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.quick-periods {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.period-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.period-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}
.period-chip.active {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.form-control {
  height: 42px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: #fff;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-control:focus {
  border-color: var(--primary);
}

.custom-period-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.time-shortcuts-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shortcuts-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.time-shortcuts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.time-shortcut-btn {
  flex: 1;
  min-width: 70px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.time-shortcut-btn:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
  color: #38bdf8;
}

.time-shortcut-btn.active {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.multi-day-container {
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Lista de Viagens */
.trips-list, .saved-routes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trip-card, .saved-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
}
.trip-card:hover, .saved-card:hover {
  border-color: rgba(14, 165, 233, 0.4);
  transform: translateY(-1px);
}

.trip-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trip-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.trip-duration {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.trip-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
}

.trip-stat-item {
  display: flex;
  flex-direction: column;
}

.trip-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.trip-stat-val {
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(14, 165, 233, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Modais */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}
.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-dark);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Marcadores Personalizados no Mapa */
.car-marker {
  width: 32px;
  height: 32px;
  background: #0ea5e9;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px rgba(14, 165, 233, 0.8);
  transition: transform 0.2s ease-out;
}

.car-marker-pulse {
  position: absolute;
  width: 48px;
  height: 48px;
  top: -8px;
  left: -8px;
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.3);
  animation: marker-pulse 2s infinite;
  pointer-events: none;
}

.flag-pin {
  padding: 4px 8px;
  border-radius: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.flag-start {
  background: #10b981;
}
.flag-end {
  background: #ef4444;
}

/* Animações */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
@keyframes marker-pulse {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.highlight-card {
  border: 1px solid rgba(14, 165, 233, 0.5) !important;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(15, 23, 42, 0.95)) !important;
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.2) !important;
}

@media (max-width: 600px) {
  .top-nav {
    left: 8px;
    right: 8px;
    height: 52px;
  }
  .btn-text {
    display: none;
  }
  .routes-drawer {
    max-width: 100%;
  }
  .nav-hud {
    left: 8px;
    right: 8px;
  }
}
