:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-dark: #1e293b;
  --accent: #0284c7;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --whatsapp: #25d366;
  --instagram: #e1306c;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden; /* Proibido scroll horizontal */
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
}

/* TOPBAR */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* BOTÕES DE CONTATO */
.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: #ffffff;
  transition: opacity 0.2s;
}

.btn-contact:hover {
  opacity: 0.9;
}

.btn-whatsapp {
  background-color: var(--whatsapp);
}

.btn-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* CARDS DE METRICAS */
.kpi-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-top: 2px;
}

.kpi-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* LAYOUT PRINCIPAL */
.main-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 550px;
}

@media (min-width: 900px) {
  .main-wrapper {
    flex-direction: row;
  }
}

/* SIDEBAR / LISTA DE CLIENTES */
.sidebar {
  width: 100%;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 380px;
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .sidebar {
    width: 420px;
    height: 100%;
  }
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.search-box {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus {
  border-color: var(--primary-light);
}

.filter-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.select-filter {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  background: #fff;
  outline: none;
}

.colab-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.colab-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.colab-card:hover, .colab-card.active {
  border-color: var(--primary-light);
  background: #f0f7ff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
}

.colab-card.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-light);
  border-radius: 8px 0 0 8px;
}

.colab-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.colab-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.colab-cargo {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.badge-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-corp {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-proprio {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-afastado {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-van {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-custo {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-alert-red {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  font-weight: 800;
}

.badge-dist {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-dist.warning {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.colab-address {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.colab-points {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
}

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

.point-label {
  color: var(--text-muted);
}

.point-val {
  font-weight: 600;
  color: var(--primary-dark);
}

/* ÁREA DO MAPA CARTO */
.map-container {
  flex: 1;
  position: relative;
  background: #e2e8f0;
  height: 100%;
  min-height: 400px;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 10;
}

/* CONTROLES FLUTUANTES DO MAPA */
.map-overlay-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
}

.map-layer-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}

.map-layer-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.map-layer-btn.btn-dest {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}
.map-layer-btn.btn-dest:hover {
  background: #1e293b;
}

.map-layer-btn.btn-van {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #c4b5fd;
  font-weight: 700;
}
.map-layer-btn.btn-van.active {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

.pick-dest-banner {
  display: none;
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 600;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  justify-content: space-between;
  align-items: center;
  border-left: 5px solid #38bdf8;
  animation: slideDown 0.2s ease-out;
}

.pick-dest-banner.active {
  display: flex !important;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PAINEL DE DETALHES FLUTUANTE */
.floating-detail-card {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 420px;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 600;
  border: 1px solid var(--border);
  display: none;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* ESTILOS PARA IMPRESSÃO DA FOLHA DE BORDO DO MOTORISTA */
@media print {
  .topbar, .kpi-container, .sidebar, .map-container, .modal-backdrop:not(#itineraryModal) {
    display: none !important;
  }
  #itineraryModal {
    display: block !important;
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
  }
  #itineraryModal .modal-content {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
  .no-print {
    display: none !important;
  }
}

.itinerary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.8rem;
}

.itinerary-table th, .itinerary-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.itinerary-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--primary-dark);
}

.itinerary-table tr:nth-child(even) {
  background: #f8fafc;
}

