/* ============================================================================
   SISTEMA DE CÁLCULO DE DISTÂNCIAS
   ============================================================================ */

/* ===== CONTAINER PRINCIPAL ===== */
.vitrola-distancias-wrap {
  max-width: 1000px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.distancias-header {
  margin-bottom: 20px;
}

.distancias-header h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.distancias-descricao {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #c21a26;
  font-size: 14px;
  color: #555;
  line-height: 1.6;
}

.distancias-descricao strong {
  color: #333;
}

/* ===== STATS ===== */
.distancias-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.distancias-stats .stats-item {
  font-size: 14px;
  color: #666;
}

.distancias-stats .stats-item strong {
  color: #c21a26;
  font-size: 16px;
}

.distancias-stats .stats-loading {
  color: #999;
  font-style: italic;
}

/* ===== FILTRO POR CÓDIGO ===== */
.distancias-filtro {
  background: #fff;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.distancias-filtro label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-size: 14px;
}

.filtro-grupo {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filtro-grupo input[type="text"] {
  flex: 1;
  min-width: 150px;
  max-width: 200px;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.filtro-grupo input[type="text"]:focus {
  outline: none;
  border-color: #c21a26;
}

.filtro-grupo input[type="text"]::placeholder {
  color: #999;
}

.filtro-grupo .btn-buscar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #c21a26;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.filtro-grupo .btn-buscar:hover {
  background: #a50d17;
}

.filtro-grupo .btn-buscar svg {
  flex-shrink: 0;
}

.filtro-grupo .btn-limpar {
  padding: 10px 16px;
  background: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filtro-grupo .btn-limpar:hover {
  background: #e0e0e0;
  color: #333;
}

@media (max-width: 480px) {
  .filtro-grupo {
    flex-direction: column;
    align-items: stretch;
  }

  .filtro-grupo input[type="text"] {
    max-width: none;
  }

  .filtro-grupo .btn-buscar,
  .filtro-grupo .btn-limpar {
    justify-content: center;
  }
}

/* ===== LISTA DE CLIENTES ===== */
.distancias-lista-container {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.distancias-lista {
  max-height: 600px;
  overflow-y: auto;
}

.distancias-lista .loading {
  padding: 40px;
  text-align: center;
  color: #666;
  font-style: italic;
}

.distancias-lista .error {
  padding: 20px;
  background: #f8d7da;
  color: #721c24;
  border-radius: 4px;
  margin: 15px;
}

.distancias-lista .sem-clientes {
  padding: 40px;
  text-align: center;
  color: #28a745;
  font-size: 16px;
}

/* ===== ITEM DO CLIENTE ===== */
.vitrola-distancias-wrap .cliente-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s;
}

.vitrola-distancias-wrap .cliente-item:hover {
  background-color: #fafafa;
}

.vitrola-distancias-wrap .cliente-item:last-child {
  border-bottom: none;
}

.vitrola-distancias-wrap .cliente-info {
  flex: 1;
  min-width: 0;
}

.vitrola-distancias-wrap .cliente-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.vitrola-distancias-wrap .cliente-codigo {
  font-size: 12px;
  color: #999;
  font-weight: 500;
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
}

.vitrola-distancias-wrap .cliente-nome {
  font-weight: 600;
  color: #333;
  font-size: 15px;
}

.vitrola-distancias-wrap .cliente-endereco {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
  line-height: 1.4;
}

.vitrola-distancias-wrap .cliente-email {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

.vitrola-distancias-wrap .cliente-distancias {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.vitrola-distancias-wrap .distancia-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.vitrola-distancias-wrap .distancia-badge.preenchido {
  background: #d4edda;
  color: #155724;
}

.vitrola-distancias-wrap .distancia-badge.vazio {
  background: #fff3cd;
  color: #856404;
}

/* ===== BOTÕES DE AÇÃO ===== */
.vitrola-distancias-wrap .cliente-acoes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 16px;
  flex-shrink: 0;
}

.btn-calcular {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 125px;
  text-align: center;
}

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

.btn-calcular-fw {
  background: #c21a26;
  color: #fff;
}

.btn-calcular-fw:hover:not(:disabled) {
  background: #a50d17;
}

.btn-calcular-no {
  background: #1976D2;
  color: #fff;
}

.btn-calcular-no:hover:not(:disabled) {
  background: #1565C0;
}

.btn-calcular-ambos {
  background: #28a745;
  color: #fff;
}

.btn-calcular-ambos:hover:not(:disabled) {
  background: #218838;
}

/* ===== PAGINAÇÃO ===== */
.distancias-paginacao {
  padding: 16px 20px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.distancias-paginacao .paginacao-info {
  text-align: center;
  margin-bottom: 12px;
  color: #666;
  font-size: 14px;
}

.distancias-paginacao .paginacao-navegacao {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.distancias-paginacao .paginacao-numeros {
  display: flex;
  gap: 5px;
}

.distancias-paginacao .pag-btn {
  background: #fff;
  border: 1px solid #dee2e6;
  color: #495057;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-width: 40px;
}

.distancias-paginacao .pag-btn:hover:not(.disabled):not(.active) {
  background: #e9ecef;
  border-color: #adb5bd;
}

.distancias-paginacao .pag-btn.active {
  background: #c21a26;
  border-color: #c21a26;
  color: #fff;
}

.distancias-paginacao .pag-btn.disabled {
  background: #f8f9fa;
  color: #adb5bd;
  cursor: not-allowed;
}

/* ===== MODAL ===== */
.distancias-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  overflow-y: auto;
}

.distancias-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.distancias-modal-content {
  background: #fff;
  border-radius: 12px;
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.distancias-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #c21a26 0%, #e74c3c 100%);
  color: #fff;
  border-radius: 12px 12px 0 0;
}

.distancias-modal-header h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.distancias-modal-header .fechar-modal {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 20px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.distancias-modal-header .fechar-modal:hover {
  background: rgba(255, 255, 255, 0.3);
}

.distancias-modal-body {
  padding: 20px;
}

.modal-info {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #c21a26;
}

.modal-info .info-item {
  font-size: 14px;
  color: #555;
}

.modal-info .info-item strong {
  color: #333;
}

/* ===== CONTAINERS DOS MAPAS ===== */
.modal-mapas-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.mapa-container {
  flex: 1;
  min-width: 300px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

.mapa-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.mapa-label {
  font-weight: 600;
  font-size: 14px;
}

.mapa-label-fw {
  color: #c21a26;
}

.mapa-label-no {
  color: #1976D2;
}

.distancia-valor {
  font-weight: 700;
  font-size: 16px;
  color: #333;
}

.mapa-view {
  width: 100%;
  height: 350px;
  background: #e5e3df;
}

.btn-confirmar {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-confirmar-fw {
  background: #c21a26;
  color: #fff;
}

.btn-confirmar-fw:hover:not(:disabled) {
  background: #a50d17;
}

.btn-confirmar-no {
  background: #1976D2;
  color: #fff;
}

.btn-confirmar-no:hover:not(:disabled) {
  background: #1565C0;
}

.btn-confirmar.salvo {
  background: #28a745 !important;
  color: #fff;
}

/* ===== BOTÃO CONFIRMAR AMBOS ===== */
.confirmar-ambos-container {
  margin-top: 20px;
  text-align: center;
}

.btn-confirmar-ambos {
  padding: 16px 40px;
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-confirmar-ambos:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.btn-confirmar-ambos:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-confirmar-ambos.salvo {
  background: linear-gradient(135deg, #155724 0%, #0d6630 100%);
}

/* ===== RESPONSIVO ===== */
@media (max-width: 768px) {
  .cliente-item {
    flex-direction: column;
    gap: 12px;
  }

  .cliente-acoes {
    margin-left: 0;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .btn-calcular {
    flex: 1;
    min-width: 120px;
    text-align: center;
  }

  .modal-mapas-container {
    flex-direction: column;
  }

  .mapa-container {
    min-width: 100%;
  }

  .mapa-view {
    height: 280px;
  }

  .distancias-stats {
    flex-direction: column;
    gap: 8px;
  }

  .distancias-paginacao .paginacao-navegacao {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .cliente-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .cliente-distancias {
    flex-direction: column;
    gap: 6px;
  }

  .btn-calcular {
    width: 100%;
  }

  .mapa-view {
    height: 250px;
  }

  .btn-confirmar-ambos {
    width: 100%;
    padding: 14px 20px;
  }
}