/* 🗺️ ROUTE MAP COMPONENT - ESTILOS INTERATIVOS */

.route-map-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  overflow: hidden;
}

/* 🗺️ CONTAINER DO MAPA */
.map-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.google-map {
  width: 100% !important;
  height: 100% !important;
  border: none;
  outline: none;
  display: block;
}

/* 🗺️ CONTAINER DO SVG */
.map-svg-container {
  flex: 1;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

.route-map-svg {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
}

/* 🎯 PINS DO MAPA */
.map-pins {
  .map-pin {
    cursor: pointer;
    transition: all 0.3s ease;

    &:hover {
      transform: scale(1.1);
      filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));

      .pin-tooltip {
        opacity: 1;
        visibility: visible;
      }
    }

    &.selected {
      transform: scale(1.2);
      filter: drop-shadow(0 6px 12px rgba(0, 123, 255, 0.4));

      .pin-tooltip {
        opacity: 1;
        visibility: visible;
      }
    }
  }
}

.pin-circle {
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.pin-icon {
  pointer-events: none;
  user-select: none;
}

.sequence-badge {
  transition: all 0.3s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.sequence-text {
  pointer-events: none;
  user-select: none;
}

/* 💬 TOOLTIPS DOS PINS */
.pin-tooltip {
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;

  &.visible {
    opacity: 1;
    visibility: visible;
  }

  rect {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
  }

  text {
    user-select: none;
  }
}

/* 🛣️ LINHA DA ROTA */
.route-line {
  animation: dash 20s linear infinite;
  filter: drop-shadow(0 1px 3px rgba(0, 123, 255, 0.3));
}

@keyframes dash {
  to {
    stroke-dashoffset: -100;
  }
}

/* 🔍 INDICADOR DE ZOOM */
.zoom-indicator {
  pointer-events: none;
  user-select: none;

  rect {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }
}

/* ⏳ LOADING STATE */
.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 250, 0.95);
  backdrop-filter: blur(2px);
}

.loading-content {
  text-align: center;
  color: #6c757d;

  .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-bottom: 1rem;
  }

  p {
    margin: 0;
    font-size: 0.9rem;
  }
}

/* 🎛️ CONTROLES DO MAPA */
.map-controls {
  background: white;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #e9ecef;
}

/* 🏷️ LEGENDA */
.legend {
  display: flex;
  gap: 16px;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6c757d;
}

.legend-pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

  &.pickup {
    background: #28a745;
  }

  &.delivery {
    background: #dc3545;
  }

  &.rest {
    background: #ffc107;
  }

  &.fuel {
    background: #007bff;
  }
}

.legend-line {
  width: 20px;
  height: 3px;
  background: #007bff;
  border-radius: 2px;
  opacity: 0.8;
}

/* 🎮 AÇÕES DO MAPA */
.map-actions {
  display: flex;
  gap: 8px;

  .btn {
    border-radius: 6px;
    padding: 6px 10px;
    transition: all 0.2s ease;
    position: relative;

    &:hover {
      transform: translateY(-1px);
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    }

    i {
      font-size: 12px;
    }

    // Destaque especial para o botão de ajuste
    &.btn-outline-success {
      font-weight: 500;
      border-width: 2px;
      
      &:hover {
        background: #28a745;
        border-color: #28a745;
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
      }

      &::before {
        content: '';
        position: absolute;
        top: -1px;
        left: -1px;
        right: -1px;
        bottom: -1px;
        background: linear-gradient(45deg, #28a745, #20c997);
        border-radius: 7px;
        opacity: 0;
        transition: opacity 0.2s ease;
        z-index: -1;
      }

      &:hover::before {
        opacity: 0.1;
      }
    }
  }
}

/* 📱 RESPONSIVO - MOBILE */
@media (max-width: 768px) {
  .route-map-container {
    .map-header {
      padding: 12px 16px;

      .map-stats {
        gap: 12px;

        .stat-item {
          font-size: 12px;

          i {
            font-size: 14px;
          }
        }
      }
    }

    .map-controls {
      padding: 10px 16px;
      flex-direction: column;
      gap: 12px;

      .legend {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
      }

      .map-actions {
        justify-content: center;
      }
    }
  }
}

/* 🎨 ANIMAÇÕES */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.route-map-container {
  animation: fadeIn 0.3s ease-out;
}

/* 🌙 TEMA ESCURO */
:host-context(.dark-theme) {
  .route-map-container {
    background: #1a1a1a;
  }

  .route-map-svg {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  }

  .map-controls {
    background: #2a2a2a;
    border-top-color: #404040;
  }

  .legend-item {
    color: #e0e0e0;
  }

  .zoom-indicator rect {
    fill: rgba(42, 42, 42, 0.9);
    stroke: #404040;
  }

  .zoom-indicator text {
    fill: #e0e0e0;
  }
}

/* 🔧 UTILITÁRIOS */
.text-success { color: #28a745 !important; }
.text-primary { color: #007bff !important; }
.text-danger { color: #dc3545 !important; }

.bg-success { background-color: #28a745 !important; }
.bg-warning { background-color: #ffc107 !important; color: #212529 !important; }

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-outline-primary {
  color: #007bff;
  border-color: #007bff;

  &:hover {
    color: white;
    background-color: #007bff;
    border-color: #007bff;
  }
}

.btn-outline-secondary {
  color: #6c757d;
  border-color: #6c757d;

  &:hover {
    color: white;
    background-color: #6c757d;
    border-color: #6c757d;
  }
}

/* 🗺️ ROUTE MAP COMPONENT - Google Maps Integration */
.map-container {
  flex: 1;
  position: relative;
  min-height: 400px;
}

.google-map {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
}

/* 🎨 Customizações do Google Maps */
.gm-style {
  .gm-style-cc {
    display: none !important;
  }
}

/* 🛣️ CONTROLES AVANÇADOS DAS ROTAS - POSIÇÃO SUPERIOR */
.route-controls-panel {
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  padding: 12px 16px;
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.panel-header {
  display: none;
}

.route-toggles {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.route-toggle-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  min-width: 200px;
  flex: 0 1 auto;
  
  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #007bff;
  }
  
  &.active {
    background: #ffffff;
    border-color: #007bff;
    box-shadow: 0 1px 4px rgba(0, 123, 255, 0.15);
    
    .route-icon {
      transform: scale(1.05);
    }
    
    .route-line-preview {
      opacity: 1;
      animation: routeFlow 2s ease-in-out infinite;
    }
  }
}

.toggle-content {
  position: relative;
  z-index: 2;
}

.toggle-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.route-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  
  i {
    font-size: 12px;
    color: white;
  }
  
  &.planned {
    background: linear-gradient(135deg, #007bff, #0056b3);
  }
  
  &.gps {
    background: linear-gradient(135deg, #dc3545, #b02a37);
  }
  
  &.current {
    background: linear-gradient(135deg, #28a745, #1e7e34);
  }
}

.route-info {
  flex: 1;
  
  h6 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #343a40;
    line-height: 1.2;
  }
  
  .route-description {
    font-size: 10px;
    color: #6c757d;
    line-height: 1.2;
    margin-top: 1px;
  }
}

/* 🎛️ TOGGLE SWITCH CUSTOMIZADO - VERSÃO COMPACTA */
.toggle-switch {
  position: relative;
  flex-shrink: 0;
}

.toggle-input {
  display: none;
}

.toggle-label {
  width: 36px;
  height: 18px;
  background: #ccc;
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  
  &::after {
    content: '';
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }
}

.toggle-input:checked + .toggle-label {
  background: #007bff;
  
  &::after {
    transform: translateX(18px);
  }
}

/* 🎨 PREVIEW DAS LINHAS DE ROTA - REMOVIDO */
.route-line-preview {
  display: none;
}

@keyframes routeFlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 📱 RESPONSIVO PARA CONTROLES - VERSÃO COMPACTA */
@media (max-width: 768px) {
  .route-controls-panel {
    padding: 8px 12px; /* Ainda mais compacto em mobile */
  }
  
  .route-toggles {
    flex-direction: column; /* Empilha verticalmente em mobile */
    gap: 8px;
  }
  
  .route-toggle-card {
    padding: 6px 10px; /* Ainda menor em mobile */
    min-width: auto;
    width: 100%;
    max-width: 280px;
  }
  
  .toggle-header {
    gap: 6px;
  }
  
  .route-icon {
    width: 24px; /* Ainda menor */
    height: 24px;
    
    i {
      font-size: 10px;
    }
  }
  
  .route-info h6 {
    font-size: 11px;
  }
  
  .route-info .route-description {
    font-size: 9px;
  }
  
  .toggle-label {
    width: 32px; /* Menor em mobile */
    height: 16px;
    border-radius: 8px;
    
    &::after {
      width: 12px;
      height: 12px;
    }
  }
  
  .toggle-input:checked + .toggle-label::after {
    transform: translateX(16px);
  }
}

/* 🌙 TEMA ESCURO PARA CONTROLES */
:host-context(.dark-theme) {
  .route-controls-panel {
    background: #2a2a2a;
    border-bottom-color: #404040;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  .panel-header h5 {
    color: #e0e0e0;
  }
  
  .route-toggle-card {
    background: #1a1a1a;
    border-color: #404040;
    
    &:hover {
      border-color: #007bff;
    }
    
    &.active {
      background: #2a2a2a;
    }
  }
  
  .route-info h6 {
    color: #e0e0e0;
  }
  
  .route-info .route-description {
    color: #a0a0a0;
  }
}
