@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ============================================
   VARIÁVEIS - Estilo Roteirizador
   ============================================ */
:root {
  /* Cores de fundo */
  --background: #09090b;
  --foreground: #fafafa;
  --card: #0a0a0c;
  --card-foreground: #fafafa;
  --popover: #0a0a0c;
  --popover-foreground: #fafafa;

  /* Cores primárias */
  --primary: #3b82f6;
  --primary-foreground: #ffffff;
  --primary-hover: #2563eb;

  /* Cores secundárias */
  --secondary: #27272a;
  --secondary-foreground: #fafafa;

  /* Cores de estado */
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;

  /* Cores de sucesso/alerta */
  --success: #22c55e;
  --success-foreground: #ffffff;
  --warning: #f59e0b;
  --warning-foreground: #ffffff;
  --danger: #ef4444;

  /* Bordas e sombras */
  --border: #27272a;
  --input: #27272a;
  --ring: #3b82f6;

  /* Sidebar */
  --sidebar: #0a0a0c;
  --sidebar-foreground: #fafafa;
  --sidebar-border: #27272a;
  --sidebar-accent: #27272a;
  --sidebar-accent-foreground: #fafafa;
  --sidebar-primary: #3b82f6;
  --sidebar-primary-foreground: #ffffff;

  /* Raio de borda */
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: var(--background);
  color: var(--foreground);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.container {
  display: flex;
  height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: 320px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  z-index: 1000;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sidebar-foreground);
}

.sidebar-header h1 .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-foreground);
  font-size: 14px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 4px;
  margin-left: 44px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* ============================================
   SEÇÕES
   ============================================ */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 12px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .btn-fechar-secao {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all 0.15s ease;
}

.section-title .btn-fechar-secao:hover {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--card-foreground);
}

.card-description {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 4px;
}

.card-content {
  padding: 16px;
}

/* ============================================
   CARDS DE SELEÇÃO
   ============================================ */
.btn-limpar-selecao {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all 0.15s ease;
}

.btn-limpar-selecao:hover {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.cards-selecao {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 12px;
}

.card-selecao {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  animation: cardIn 0.2s ease;
}

.card-selecao:hover {
  border-color: var(--primary);
  background: var(--accent);
}

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

.card-selecao-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.card-selecao-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.card-selecao-protocolo {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-selecao-rota {
  font-size: 11px;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card-selecao-valor {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
}

.card-selecao-remover {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-selecao-remover:hover {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* Resumo da seleção */
.selecao-resumo {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.selecao-resumo-item {
  flex: 1;
  text-align: center;
}

.selecao-resumo-item .valor {
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
  display: block;
}

.selecao-resumo-item .label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.selecao-resumo-item.urgente .valor {
  color: var(--danger);
}

.selecao-resumo-item.valor-total .valor {
  color: var(--success);
}

.selecao-vazia {
  text-align: center;
  padding: 24px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.selecao-vazia i {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.3;
  display: block;
}

/* ============================================
   MÉTRICAS
   ============================================ */
.metricas-resumo {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.metrica-badge {
  flex: 1;
  min-width: 80px;
  padding: 12px;
  background: var(--secondary);
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.metrica-badge:hover {
  border-color: var(--primary);
}

.metrica-badge.destaque {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1),
    rgba(139, 92, 246, 0.1)
  );
  border-color: var(--primary);
}

.metrica-badge .valor {
  font-size: 20px;
  font-weight: 700;
  color: var(--foreground);
  display: block;
}

.metrica-badge .label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.metrica-badge.success .valor {
  color: var(--success);
}

.metrica-badge.danger .valor {
  color: var(--danger);
}

.metrica-badge.warning .valor {
  color: var(--warning);
}

.metricas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.metrica-card {
  background: var(--secondary);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.metrica-card .label {
  font-size: 11px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metrica-card .valor {
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
  margin-top: 4px;
}

.metrica-card .sub {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.metrica-card.success .valor {
  color: var(--success);
}

.metrica-card.danger .valor {
  color: var(--danger);
}

.metrica-card.warning .valor {
  color: var(--warning);
}

.metricas-info {
  font-size: 11px;
  color: var(--muted-foreground);
  text-align: center;
  padding: 10px;
  background: var(--secondary);
  border-radius: var(--radius);
}

/* ============================================
   ESTATÍSTICAS
   ============================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--secondary);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  transition: all 0.15s ease;
}

.stat-card:hover {
  border-color: var(--primary);
}

.stat-card.urgente {
  border-left: 3px solid var(--danger);
}

.stat-card.alerta {
  border-left: 3px solid var(--warning);
}

.stat-card.selecao {
  border-left: 3px solid var(--primary);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card.urgente .stat-value {
  color: var(--danger);
}

.stat-card.alerta .stat-value {
  color: var(--warning);
}

.stat-card.selecao .stat-value {
  color: var(--primary);
}

.stat-label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  margin-top: 4px;
  letter-spacing: 0.05em;
}

/* ============================================
   INPUTS E FORMULÁRIOS
   ============================================ */
.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 6px;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-group input::placeholder {
  color: var(--muted-foreground);
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-inline {
  margin: 12px 0;
}

.checkbox-inline label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--foreground);
}

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

.info-box {
  padding: 12px;
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-box.warning {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: var(--warning);
  color: var(--warning);
}

.info-box.success {
  background: rgba(34, 197, 94, 0.1);
  border-left-color: var(--success);
  color: var(--success);
}

.info-box.danger {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   BUSCA
   ============================================ */
.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 13px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 14px;
}

/* ============================================
   BOTÕES
   ============================================ */
.btn-group {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: var(--sidebar);
  border-top: 1px solid var(--sidebar-border);
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent);
}

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

.btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--secondary);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
}

.actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.btn-mini {
  padding: 10px 6px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.btn-mini i {
  font-size: 14px;
}

.btn-mini:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--primary);
}

/* ============================================
   FILTROS
   ============================================ */
#filtrosUrgencia {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filtro-badge {
  flex: 1;
  min-width: 70px;
  padding: 8px 10px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted-foreground);
}

.filtro-badge:hover {
  background: var(--accent);
  border-color: var(--primary);
}

.filtro-badge.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.filtro-badge strong {
  font-size: 16px;
  color: var(--foreground);
}

.filtro-badge.active strong {
  color: var(--primary);
}

/* ============================================
   SEQUÊNCIA SIDEBAR
   ============================================ */
#sequenciaContainer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.sequencia-item-sidebar,
.sequencia-cidade-item {
  background: var(--secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: move;
  transition: all 0.15s ease;
  user-select: none;
}

.sequencia-item-sidebar:hover,
.sequencia-cidade-item:hover {
  border-color: var(--primary);
  border-style: solid;
  background: var(--accent);
}

.sequencia-item-sidebar.dragging,
.sequencia-cidade-item.dragging {
  opacity: 0.5;
  border-style: solid;
  border-color: var(--primary);
}

.sequencia-item-sidebar.drag-over,
.sequencia-cidade-item.drag-over {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.seq-handle {
  color: var(--muted-foreground);
  font-size: 14px;
  cursor: grab;
}

.seq-handle:active {
  cursor: grabbing;
}

.seq-numero {
  background: var(--primary);
  color: var(--primary-foreground);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.seq-numero.coleta {
  background: var(--warning);
  color: #0f0f23;
}

.seq-numero.entrega {
  background: var(--success);
  color: #0f0f23;
}

.seq-numero.reposicionamento {
  background: #ff6b35;
  color: white;
}

.seq-info {
  flex: 1;
  min-width: 0;
}

.seq-protocolo,
.seq-cidade {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seq-rota {
  font-size: 11px;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seq-valor {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
}

.seq-tipo-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
}

.seq-tipo-label.coleta {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.seq-tipo-label.entrega {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.seq-detalhe {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 4px;
}

.btn-reordenar-sidebar {
  width: 100%;
  background: var(--success);
  color: var(--success-foreground);
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-reordenar-sidebar:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-reordenar-sidebar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   OPÇÕES DE DESTINO
   ============================================ */
.destino-opcoes {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}

.destino-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-bottom: 12px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.radio-item:hover {
  background: var(--accent);
}

.radio-item input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.radio-item input[type="radio"]:checked + .radio-custom {
  border-color: var(--primary);
}

.radio-item input[type="radio"]:checked + .radio-custom::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.radio-text {
  font-size: 13px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 6px;
}

.radio-item:has(input[type="radio"]:checked) {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
}

.radio-item:has(input[type="radio"]:checked) .radio-text {
  color: var(--foreground);
  font-weight: 500;
}

.radio-item:has(input[value="reposicionamento"]:checked) {
  background: rgba(255, 107, 53, 0.1);
  border-color: #ff6b35;
}

.radio-item:has(input[value="reposicionamento"]:checked) .radio-custom {
  border-color: #ff6b35;
}

.radio-item:has(input[value="reposicionamento"]:checked) .radio-custom::after {
  background: #ff6b35;
}

/* ============================================
   RESUMO FINANCEIRO
   ============================================ */
.resumo-financeiro {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.resumo-linha {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.resumo-linha:last-child {
  border-bottom: none;
}

.resumo-linha.warning {
  color: #ff6b35;
}

.resumo-linha.total {
  padding-top: 12px;
  margin-top: 8px;
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-size: 15px;
  font-weight: 600;
}

.resumo-linha.total.success {
  color: var(--success);
}

.resumo-linha.total.danger {
  color: var(--danger);
}

.valor-positivo {
  color: var(--success);
}

.valor-negativo {
  color: var(--danger);
}

.info-reposicionamento {
  background: rgba(255, 107, 53, 0.15);
  border: 1px solid #ff6b35;
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  color: #ff6b35;
  font-size: 13px;
}

/* ============================================
   ÁREA DO MAPA
   ============================================ */
.map-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

#map {
  flex: 1;
  position: relative;
  background: var(--background);
}

.map-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.map-btn:hover {
  background: var(--secondary);
  border-color: var(--primary);
}

/* ============================================
   LEGENDA DE ROTAS
   ============================================ */
.legenda-rotas {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  z-index: 1000;
  display: flex;
  gap: 20px;
  font-size: 12px;
  box-shadow: var(--shadow-lg);
}

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

.legenda-linha {
  width: 35px;
  height: 4px;
  border-radius: 2px;
}

.legenda-linha.produtiva {
  background: var(--primary);
}

.legenda-linha.reposicionamento {
  background: repeating-linear-gradient(
    90deg,
    #ff6b35 0px,
    #ff6b35 8px,
    transparent 8px,
    transparent 14px
  );
  height: 4px;
}

.legenda-texto {
  color: var(--muted-foreground);
  font-weight: 500;
}

.legenda-texto.warning {
  color: #ff6b35;
}

/* ============================================
   PAINEL DE PARADAS
   ============================================ */
.painel-paradas {
  display: none;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 999;
}

.painel-paradas.show {
  display: block;
  animation: slideDown 0.3s ease;
}

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

.paradas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--primary);
}

.paradas-header h4 {
  font-size: 14px;
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.paradas-actions {
  display: flex;
  gap: 6px;
}

.btn-paradas {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 12px;
}

.btn-paradas:hover {
  background: rgba(255, 255, 255, 0.3);
}

.paradas-content {
  padding: 12px 16px;
  max-height: 120px;
  overflow-x: auto;
  overflow-y: hidden;
}

.paradas-content.minimizado {
  display: none;
}

.paradas-lista-horizontal {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.parada-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--secondary);
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
}

.parada-chip:hover {
  border-color: var(--primary);
}

.parada-chip .numero {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

.parada-chip .numero.origem {
  background: var(--danger);
}

.parada-chip .numero.coleta {
  background: var(--warning);
  color: #0f0f23;
}

.parada-chip .numero.entrega {
  background: var(--success);
  color: #0f0f23;
}

.parada-chip .numero.retorno {
  background: var(--primary);
}

.parada-chip .info {
  display: flex;
  flex-direction: column;
}

.parada-chip .tipo {
  font-size: 9px;
  color: var(--muted-foreground);
  text-transform: uppercase;
}

.parada-chip .cidade {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
}

.parada-chip .distancia {
  font-size: 11px;
  color: var(--primary);
}

.parada-seta {
  color: var(--primary);
  font-size: 16px;
}

.parada-seta.seta-repos {
  color: #ff6b35;
}

.parada-chip.km-vazio {
  border: 2px dashed #ff6b35;
  background: rgba(255, 107, 53, 0.1);
}

.km-vazio-badge {
  background: #ff6b35;
  color: white;
  font-size: 8px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
  font-weight: 700;
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */
.autocomplete-container {
  position: relative;
}

.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--popover);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}

.autocomplete-dropdown.show {
  display: block;
  animation: dropdownIn 0.2s ease;
}

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

.autocomplete-item {
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.1s ease;
  border-bottom: 1px solid var(--border);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent);
}

.autocomplete-item.active {
  border-left: 3px solid var(--primary);
}

.autocomplete-item i {
  color: var(--primary);
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.autocomplete-item .cidade-info {
  flex: 1;
}

.autocomplete-item .cidade-nome {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.autocomplete-item .cidade-uf {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-left: 4px;
}

.autocomplete-item .cidade-highlight {
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
  padding: 0 2px;
  border-radius: 2px;
}

.autocomplete-loading,
.autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 13px;
}

.autocomplete-loading i {
  margin-right: 8px;
  animation: spin 1s linear infinite;
}

.autocomplete-empty i {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  border: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: var(--primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
  font-size: 16px;
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.comparacao-grid-modal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.comp-item {
  background: var(--secondary);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.comp-item .label {
  font-size: 11px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.comp-item .valor {
  font-size: 22px;
  font-weight: 700;
  color: var(--foreground);
}

.comp-item .valor.melhor {
  color: var(--success);
}

.comp-item .valor.melhor::before {
  content: "↓ ";
}

.comp-item .valor.pior {
  color: var(--danger);
}

.comp-item .valor.pior::before {
  content: "↑ ";
}

.comp-item .original {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 6px;
}

.comp-destaque {
  grid-column: 1 / -1;
  background: rgba(59, 130, 246, 0.1);
  border: 2px solid var(--primary);
}

.comp-destaque .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.comp-destaque .resultado {
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
}

/* ============================================
   PREVIEW INFO BOX
   ============================================ */
.preview-info-box {
  position: fixed;
  bottom: 20px;
  left: 340px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  min-width: 340px;
  max-width: 380px;
  transform: translateY(120%);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.preview-info-box.show {
  transform: translateY(0);
}

.preview-info-box.preview-ao-lado {
  left: auto;
  right: 20px;
}

.preview-info-header {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.preview-info-header.inserir-mode {
  background: #ff6b35;
}

.preview-info-header span {
  flex: 1;
}

.btn-fechar-preview {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-fechar-preview:hover {
  background: rgba(255, 255, 255, 0.3);
}

.preview-loading {
  background: rgba(59, 130, 246, 0.1);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--primary);
  font-size: 13px;
}

.preview-info-content {
  padding: 16px;
  max-height: 45vh;
  overflow-y: auto;
}

.preview-info-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.preview-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
}

.preview-label {
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-info-row strong {
  color: var(--foreground);
}

.preview-rota-visual {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  border: 1px solid var(--border);
}

.preview-ao-lado .preview-rota-visual {
  border: 2px dashed #ff6b35;
  background: rgba(255, 107, 53, 0.1);
}

.preview-rota-ponto {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.preview-rota-icone {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.preview-rota-info {
  flex: 1;
}

.preview-rota-tipo {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted-foreground);
  font-weight: 600;
}

.preview-rota-info strong {
  display: block;
  font-size: 15px;
  color: var(--foreground);
  margin-top: 2px;
}

.preview-rota-linha {
  padding: 10px 0;
  margin-left: 17px;
  border-left: 2px dashed var(--primary);
  color: var(--primary);
}

.preview-rota-linha i {
  background: var(--card);
  padding: 4px;
  margin-left: -9px;
}

.preview-valor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius);
  margin-top: 14px;
}

.preview-valor span {
  font-size: 12px;
  color: var(--muted-foreground);
  text-transform: uppercase;
}

.preview-valor strong {
  font-size: 22px;
  color: var(--success);
  font-weight: 700;
}

.preview-info-distancia {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  margin-top: 12px;
}

.preview-info-actions {
  padding: 14px 16px;
  background: var(--secondary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-zoom-preview,
.btn-selecionar-preview,
.btn-inserir-rota {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  font-family: inherit;
  border: none;
}

.btn-zoom-preview {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-zoom-preview:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
}

.btn-selecionar-preview {
  background: var(--success);
  color: var(--success-foreground);
}

.btn-selecionar-preview:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-selecionar-preview.selecionada {
  background: var(--primary);
}

.btn-inserir-rota {
  background: #ff6b35;
  color: white;
}

.btn-inserir-rota:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
#loadingOverlay,
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.loading-content {
  text-align: center;
  color: var(--foreground);
}

.spinner-large,
.loading-spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  border-left: 4px solid var(--success);
}
.toast-success i {
  color: var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}
.toast-error i {
  color: var(--danger);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}
.toast-warning i {
  color: var(--warning);
}

.toast-info {
  border-left: 4px solid var(--primary);
}
.toast-info i {
  color: var(--primary);
}

.toast span {
  flex: 1;
  font-size: 14px;
  color: var(--foreground);
}

/* ============================================
   LEAFLET OVERRIDES
   ============================================ */
.leaflet-routing-container {
  display: none !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--card) !important;
  color: var(--foreground) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 16px !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
  background: var(--secondary) !important;
  color: var(--primary) !important;
}

.leaflet-tooltip {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  color: var(--foreground) !important;
  font-family: "Inter", sans-serif !important;
  padding: 0 !important;
}

.leaflet-tooltip::before {
  border-top-color: var(--card) !important;
}

/* ============================================
   SCROLLBAR GLOBAL
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

::selection {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ============================================
   RESPONSIVO
   ============================================ */
@media (max-width: 1200px) {
  .sidebar {
    width: 300px;
  }

  .preview-info-box {
    left: 320px;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .preview-info-box {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .preview-info-box.preview-ao-lado {
    left: auto;
    right: 10px;
    max-width: 340px;
  }
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 45vh;
  }

  .map-area {
    height: 55vh;
  }

  .preview-info-box,
  .preview-info-box.preview-ao-lado {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }

  .modal-content {
    margin: 16px;
    width: calc(100% - 32px);
  }

  .legenda-rotas {
    left: 10px;
    bottom: 10px;
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px;
  }

  .actions-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sidebar-header h1 {
    font-size: 14px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .stat-value {
    font-size: 16px;
  }

  .metricas-resumo {
    flex-direction: column;
  }

  .metrica-badge {
    min-width: 100%;
  }
}
