// 🚚 Vehicle Location Tracker Component
// Componente para exibir localização atual do veículo usando dados existentes

.vehicle-location-tracker {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem;
  background: var(--surface-color, #ffffff);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  // 🎨 Variáveis de cores adaptáveis
  --primary-color: #2196F3;
  --success-color: #4CAF50;
  --warning-color: #FF9800;
  --error-color: #F44336;
  --text-primary: #333333;
  --text-secondary: #666666;
  --surface-color: #ffffff;
  --border-color: #e0e0e0;
  --background-light: #f8f9fa;

  // 🌙 Dark theme support
  :host-context(.dark-theme) & {
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --surface-color: #2d2d2d;
    --border-color: #404040;
    --background-light: #383838;
  }
}

// ⏳ Estado de Carregamento
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--background-light);
  border-radius: 12px;
  border: 2px dashed var(--border-color);

  .loading-icon {
    margin-bottom: 1.5rem;

    i {
      font-size: 3rem;
      color: var(--primary-color);
      animation: spin 1s linear infinite;
    }
  }

  .loading-content {
    h4 {
      margin: 0 0 0.5rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-primary);
    }

    p {
      margin: 0;
      font-size: 0.9rem;
      color: var(--text-secondary);
      line-height: 1.5;
    }
  }
}

// 📍 Card de Informações de Localização
.location-info-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

  .info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);

    h3 {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin: 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-primary);

      i {
        color: var(--primary-color);
        font-size: 1.4rem;
      }
    }

    .update-status {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 1rem;
      background: var(--background-light);
      border-radius: 20px;
      font-size: 0.875rem;
      color: var(--text-secondary);
      transition: all 0.3s ease;

      &.updating {
        background: rgba(33, 150, 243, 0.1);
        color: var(--primary-color);

        i {
          animation: spin 1s linear infinite;
        }
      }

      i {
        font-size: 0.875rem;
      }
    }
  }
}

// 📋 Grid de Localização (Estilo fiel à imagem)
.location-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;

  @media (max-width: 1024px) {
    grid-template-columns: repeat(2, 1fr);
  }

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }

  .location-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--background-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;

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

    &.full-width {
      grid-column: 1 / -1;
    }

    &.half-width {
      grid-column: span 2;

      @media (max-width: 1024px) {
        grid-column: span 1;
      }
    }

    i {
      color: var(--primary-color);
      font-size: 1.1rem;
      margin-top: 0.25rem;
      min-width: 20px;
      flex-shrink: 0;
    }

    .item-content {
      flex: 1;
      min-width: 0;

      label {
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.25rem;
      }

      span {
        display: block;
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-primary);
        word-break: break-word;
        line-height: 1.4;

        &.status-badge {
          display: inline-block;
          padding: 0.25rem 0.75rem;
          border-radius: 20px;
          font-size: 0.75rem;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;

          &.status-moving {
            background: #e8f5e8;
            color: #2e7d32;
          }

          &.status-parked {
            background: #fff3e0;
            color: #f57c00;
          }

          &.status-stopped {
            background: #ffebee;
            color: #d32f2f;
          }
        }

        &.signal-badge {
          display: inline-block;
          padding: 0.25rem 0.75rem;
          border-radius: 20px;
          font-size: 0.75rem;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;

          &.strong {
            background: #e8f5e8;
            color: #2e7d32;
          }

          &.weak {
            background: #fff3e0;
            color: #f57c00;
          }

          &.none {
            background: #ffebee;
            color: #d32f2f;
          }
        }

        &.alert-badge {
          display: inline-block;
          padding: 0.25rem 0.75rem;
          border-radius: 20px;
          font-size: 0.75rem;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;

          &.active {
            background: #ffebee;
            color: #d32f2f;
          }

          &.inactive {
            background: #f5f5f5;
            color: #757575;
          }
        }
      }
    }
  }
}

// 🗺️ Container do Mapa
.map-container {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

  .map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--background-light);
    border-bottom: 1px solid var(--border-color);

    h4 {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin: 0;
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-primary);

      i {
        color: var(--primary-color);
      }
    }

    .map-controls {
      display: flex;
      gap: 0.5rem;

      .map-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover:not(:disabled) {
          background: #1976D2;
          transform: translateY(-1px);
        }

        &:disabled {
          opacity: 0.6;
          cursor: not-allowed;
        }

        i {
          font-size: 0.875rem;

          &.fa-spin {
            animation: spin 1s linear infinite;
          }
        }
      }
    }
  }

  .map-wrapper {
    position: relative;
    height: 500px; /* ✅ CORREÇÃO: Altura aumentada para o Google Maps renderizar corretamente */
    background: var(--background-light);

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

    .map-overlay {
      position: absolute;
      bottom: 1rem;
      right: 1rem;
      background: rgba(0, 0, 0, 0.8);
      color: white;
      padding: 0.5rem 1rem;
      border-radius: 6px;
      font-size: 0.875rem;
      font-family: monospace;
      backdrop-filter: blur(4px);
    }
  }
}

// 📜 Detalhes do Endereço
.address-details-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

  .details-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--success-color);

    h4 {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin: 0;
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-primary);

      i {
        color: var(--success-color);
      }
    }
  }

  .address-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;

    .address-item {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      padding: 0.75rem;
      background: var(--background-light);
      border-radius: 6px;
      border-left: 3px solid var(--success-color);

      label {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
      }

      span {
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-primary);
        word-break: break-word;
      }
    }
  }
}

// ❌ Estado sem Localização
.no-location-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 2rem;
  background: var(--background-light);
  border-radius: 12px;
  border: 2px dashed var(--border-color);

  .no-location-icon {
    margin-bottom: 1.5rem;

    i {
      font-size: 4rem;
      color: var(--text-secondary);
      opacity: 0.6;
    }
  }

  .no-location-content {
    max-width: 400px;

    h4 {
      margin: 0 0 0.5rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-primary);
    }

    p {
      margin: 0 0 1.5rem 0;
      color: var(--text-secondary);
      line-height: 1.5;
    }

    .vehicle-info {
      padding: 1rem;
      background: var(--surface-color);
      border-radius: 8px;
      border: 1px solid var(--border-color);
      font-size: 0.9rem;
      line-height: 1.6;
      color: var(--text-primary);
    }
  }
}

// ❌ Estado de Erro
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 2rem;
  background: rgba(244, 67, 54, 0.05);
  border-radius: 12px;
  border: 2px solid rgba(244, 67, 54, 0.2);

  .error-icon {
    margin-bottom: 1.5rem;

    i {
      font-size: 4rem;
      color: var(--error-color);
    }
  }

  .error-content {
    max-width: 400px;

    h4 {
      margin: 0 0 0.5rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--error-color);
    }

    p {
      margin: 0 0 1.5rem 0;
      color: var(--text-secondary);
      line-height: 1.5;
    }

    .retry-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1.5rem;
      background: var(--error-color);
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;

      &:hover {
        background: #d32f2f;
        transform: translateY(-1px);
      }

      i {
        font-size: 0.875rem;
      }
    }
  }
}

// 🎯 Animações
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// 📱 Responsividade
@media (max-width: 768px) {
  .vehicle-location-tracker {
    padding: 1rem 0.5rem;
    gap: 1rem;
  }

  .location-info-card,
  .address-details-card {
    padding: 1rem;
  }

  .map-container .map-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;

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

  .map-wrapper {
    height: 400px; /* ✅ CORREÇÃO: Altura adequada também para mobile */
  }

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

// 🔧 Utilitários
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 🎯 Badges de Status
.status-badge, .signal-badge, .equipment-badge {
  padding: 0.25rem 0.75rem !important;
  border-radius: 12px !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
}

.status-badge {
  &[data-status="moving"] {
    background: #e8f5e8 !important;
    color: #2e7d32 !important;
  }
  &[data-status="parked"] {
    background: #fff3e0 !important;
    color: #f57c00 !important;
  }
  &[data-status="stopped"] {
    background: #ffebee !important;
    color: #d32f2f !important;
  }
  &[data-status="unknown"] {
    background: #f5f5f5 !important;
    color: #757575 !important;
  }
}

.signal-badge {
  &[data-signal="strong"] {
    background: #e8f5e8 !important;
    color: #2e7d32 !important;
  }
  &[data-signal="weak"] {
    background: #fff3e0 !important;
    color: #f57c00 !important;
  }
  &[data-signal="none"] {
    background: #ffebee !important;
    color: #d32f2f !important;
  }
}

.equipment-badge {
  &[data-status="active"] {
    background: #e8f5e8 !important;
    color: #2e7d32 !important;
  }
  &[data-status="inactive"] {
    background: #ffebee !important;
    color: #d32f2f !important;
  }
  &[data-status="maintenance"] {
    background: #fff3e0 !important;
    color: #f57c00 !important;
  }
}

// 📜 Histórico de Localizações
.location-history {
  background: var(--surface-variant);
  border: 1px solid var(--divider);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

  .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--divider);

    .header-left {
      display: flex;
      align-items: center;
      gap: 1.5rem;
      flex: 1;

      h4 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0;
        color: var(--primary);
        font-size: 1.1rem;
        font-weight: 600;
        white-space: nowrap;

        i {
          color: var(--primary);
        }
      }

      .header-stats {
        display: flex;
        align-items: center;
        gap: 1rem;

        .stat-item {
          display: flex;
          align-items: center;
          gap: 0.25rem;
          padding: 0.25rem 0.75rem;
          border-radius: 12px;
          font-size: 0.75rem;
          font-weight: 600;
          white-space: nowrap;

          &:first-child {
            background: var(--primary-light);
            color: var(--primary);
          }

          &:last-child {
            background: var(--success-color);
            color: white;
          }

          i {
            font-size: 0.7rem;
          }
        }
      }
    }

    .header-right {
      display: flex;
      align-items: center;

      .clear-markers-btn {
        background: var(--danger-color);
        color: white;
        border: none;
        border-radius: 6px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
        white-space: nowrap;

        &:hover {
          background: var(--danger-hover);
          transform: translateY(-1px);
          box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
        }

        &:active {
          transform: translateY(0);
        }

        i {
          font-size: 0.75rem;
        }
      }
    }
  }

  .history-list {
    max-height: 300px; // Reduzido de 400px para 300px
    overflow-y: auto;
    overflow-x: hidden;
    
    // 🎨 Scrollbar personalizada
    &::-webkit-scrollbar {
      width: 6px;
    }
    
    &::-webkit-scrollbar-track {
      background: var(--background-light);
      border-radius: 3px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
      
      &:hover {
        background: var(--text-secondary);
      }
    }

    .history-item {
      display: flex;
      align-items: flex-start;
      gap: 1rem;
      padding: 1rem 1.5rem;
      border-bottom: 1px solid var(--divider);
      transition: all 0.2s ease;
      cursor: pointer;
      position: relative;

      &:last-child {
        border-bottom: none;
      }

      &:hover {
        background: var(--surface);
        transform: translateX(2px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      }

      &:active {
        transform: translateX(1px);
      }

      // Indicador visual de clique
      &::after {
        content: '📍';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        opacity: 0;
        transition: opacity 0.2s ease;
      }

      &:hover::after {
        opacity: 0.5;
      }

      &.current {
        background: var(--primary-light);
        border-left: 4px solid var(--primary);
      }

      .history-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        border-radius: 50%;
        background: var(--surface);
        border: 2px solid var(--divider);
        flex-shrink: 0;

        i {
          font-size: 0.875rem;

          &.text-success { color: #2e7d32; }
          &.text-warning { color: #f57c00; }
          &.text-danger { color: #d32f2f; }
          &.text-muted { color: #757575; }
        }
      }

      .history-content {
        flex: 1;
        min-width: 0;

        .history-address {
          font-size: 0.875rem;
          font-weight: 500;
          color: var(--text-primary);
          margin-bottom: 0.5rem;
          line-height: 1.4;
        }

        .history-details {
          display: flex;
          align-items: center;
          gap: 1rem;
          flex-wrap: wrap;

          .history-time {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.75rem;
            color: var(--text-secondary);

            i {
              font-size: 0.625rem;
            }
          }

          .history-status {
            padding: 0.125rem 0.5rem;
            border-radius: 8px;
            font-size: 0.625rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;

            &[data-status="moving"] {
              background: #e8f5e8;
              color: #2e7d32;
            }
            &[data-status="parked"] {
              background: #fff3e0;
              color: #f57c00;
            }
            &[data-status="stopped"] {
              background: #ffebee;
              color: #d32f2f;
            }
            &[data-status="unknown"] {
              background: #f5f5f5;
              color: #757575;
            }
          }
        }
      }

      .history-actions {
        display: flex;
        align-items: center;

        .current-badge {
          padding: 0.25rem 0.75rem;
          background: var(--primary);
          color: white;
          border-radius: 12px;
          font-size: 0.625rem;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }
    }
  }
}

// 🔄 Estados de Loading e Erro
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--surface-variant);
  border: 1px solid var(--divider);
  border-radius: 8px;
  min-height: 200px;
}

.loading-state {
  color: var(--text-secondary);

  .loading-spinner {
    margin-bottom: 1rem;

    i {
      font-size: 2rem;
      color: var(--primary);
    }
  }

  span {
    font-size: 0.875rem;
  }
}

.error-state {
  color: var(--text-secondary);

  .error-icon {
    margin-bottom: 1rem;

    i {
      font-size: 2rem;
      color: #d32f2f;
    }
  }

  .error-content {
    h4 {
      margin: 0 0 0.5rem 0;
      color: var(--text-primary);
      font-size: 1.1rem;
    }

    p {
      margin: 0 0 1.5rem 0;
      color: var(--text-secondary);
      font-size: 0.875rem;
    }

    .retry-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1.5rem;
      background: var(--primary);
      color: white;
      border: none;
      border-radius: 4px;
      font-size: 0.875rem;
      cursor: pointer;
      transition: background-color 0.2s ease;

      &:hover {
        background: var(--primary-dark);
      }

      i {
        font-size: 0.75rem;
      }
    }
  }
}

// 🎨 Animações
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// 📱 Responsividade
@media (max-width: 768px) {
  .vehicle-location-tracker {
    padding: 0.75rem;
    gap: 1rem;
  }

  .location-info-card,
  .map-container,
  .location-history {
    .info-header,
    .map-header {
      padding: 0.75rem 1rem;
      flex-direction: column;
      align-items: flex-start;
      gap: 0.75rem;

      .map-controls {
        width: 100%;
        justify-content: space-between;
      }
    }

    .history-header {
      padding: 0.75rem 1rem;
      flex-direction: column;
      align-items: stretch;
      gap: 0.75rem;

      .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;

        .header-stats {
          gap: 0.75rem;
        }
      }

      .header-right {
        justify-content: center;

        .clear-markers-btn {
          width: 100%;
          justify-content: center;
        }
      }
    }
  }

  .location-grid {
    grid-template-columns: 1fr !important;

    .location-item {
      &.half-width {
        grid-column: span 1;
      }
    }
  }

  .map-wrapper {
    height: 300px;
  }

  .history-list {
    max-height: 250px; // Altura reduzida para mobile
    
    .history-item {
      padding: 0.75rem 1rem;

      .history-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
      }
    }
  }
}

// 🌙 Suporte ao tema escuro
:host-context(.dark-theme) {
  .location-info-card,
  .map-container,
  .location-history {
    background: var(--surface-dark);
    border-color: var(--divider-dark);
  }

  .detail-item {
    background: var(--surface-variant-dark);
    border-color: var(--divider-dark);
  }

  .map-overlay .coordinates-info {
    background: rgba(0, 0, 0, 0.8);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
  }

  .history-item {
    &:hover {
      background: var(--surface-variant-dark);
    }

    &.current {
      background: rgba(var(--primary-rgb), 0.1);
    }
  }
}

// 🏃 Estilos para card de estatísticas de velocidade
.speed-stats-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;

  &:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  .stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);

    h4 {
      margin: 0;
      color: var(--text-primary);
      font-size: 1.1rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        color: #FF6B35;
        font-size: 1rem;
      }
    }

    .stats-count {
      padding: 0.25rem 0.75rem;
      background: #FF6B35;
      color: white;
      border-radius: 12px;
      font-size: 0.75rem;
      font-weight: 600;
    }
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;

    .stat-item {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 1rem;
      background: var(--background-light);
      border-radius: 8px;
      border: 1px solid var(--border-color);
      transition: all 0.2s ease;

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

      &.highlight-max {
        background: linear-gradient(135deg, #FF6B35 0%, #FF8E53 100%);
        color: white;
        border-color: #FF6B35;

        .stat-icon i {
          color: white;
        }

        &.clickable {
          cursor: pointer;
          position: relative;
          
          &:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 20px rgba(255, 107, 53, 0.4);
          }

          &:active {
            transform: translateY(-2px);
          }
        }
      }

      &.highlight-frequent {
        background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
        color: white;
        border-color: #4CAF50;

        .stat-icon i {
          color: white;
        }
      }

      .stat-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);

        i {
          font-size: 1.2rem;
          color: var(--primary-color);
        }
      }

      .stat-content {
        flex: 1;

        .stat-label {
          font-size: 0.8rem;
          font-weight: 500;
          opacity: 0.8;
          margin-bottom: 0.25rem;
        }

        .stat-value {
          font-size: 1.5rem;
          font-weight: 700;
          line-height: 1;

          .stat-unit {
            font-size: 0.9rem;
            font-weight: 500;
            opacity: 0.8;
          }
        }

        .stat-hint {
          font-size: 0.7rem;
          opacity: 0.8;
          margin-top: 0.25rem;
          display: flex;
          align-items: center;
          gap: 0.25rem;
          font-weight: 500;

          i {
            font-size: 0.6rem;
          }
        }
      }
    }
  }
}

// 🛑 Estilos para card de estatísticas de paradas
.stop-stats-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;

  &:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  .stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);

    h4 {
      margin: 0;
      color: var(--text-primary);
      font-size: 1.1rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        color: #ff9800;
        font-size: 1.2rem;
      }
    }

    .stats-count {
      background: rgba(255, 152, 0, 0.1);
      color: #ff9800;
      padding: 0.25rem 0.75rem;
      border-radius: 20px;
      font-size: 0.8rem;
      font-weight: 600;
    }
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;

    .stat-item {
      background: var(--background-light);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      padding: 1rem;
      display: flex;
      align-items: flex-start;
      gap: 0.75rem;
      transition: all 0.3s ease;

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

      &.highlight-stops {
        border-color: #f44336;
        background: linear-gradient(135deg, rgba(244, 67, 54, 0.05), rgba(244, 67, 54, 0.02));

        .stat-icon i {
          color: #f44336;
        }
      }

      &.highlight-parked {
        border-color: #2196f3;
        background: linear-gradient(135deg, rgba(33, 150, 243, 0.05), rgba(33, 150, 243, 0.02));

        .stat-icon i {
          color: #2196f3;
        }
      }

      .stat-icon {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 152, 0, 0.1);
        flex-shrink: 0;

        i {
          font-size: 1.2rem;
          color: #ff9800;
        }
      }

      .stat-content {
        flex: 1;

        .stat-label {
          font-size: 0.8rem;
          color: var(--text-secondary);
          margin-bottom: 0.25rem;
          font-weight: 500;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }

        .stat-value {
          font-size: 1.5rem;
          font-weight: 700;
          color: var(--text-primary);
          line-height: 1.2;

          .stat-unit {
            font-size: 0.8rem;
            font-weight: 400;
            color: var(--text-secondary);
            margin-left: 0.25rem;
          }
        }

        .stat-detail {
          font-size: 0.75rem;
          color: var(--text-secondary);
          margin-top: 0.5rem;
          display: flex;
          align-items: center;
          gap: 0.25rem;

          i {
            font-size: 0.7rem;
            opacity: 0.7;
          }
        }
      }
    }
  }
}

// 🏃 Estilos para velocidade na lista do histórico
.history-speed {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #FF6B35;
  font-weight: 600;

  i {
    color: #FF6B35;
  }
}

// 📄 Estilos para botão "Carregar mais registros"
.history-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--background-light);

  .history-load-more {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    &:hover:not(:disabled) {
      background: var(--primary-color);
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    }

    &:active:not(:disabled) {
      transform: translateY(0);
    }

    &:disabled {
      background: var(--border-color);
      color: var(--text-secondary);
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    &.loading {
      background: var(--warning-color);
    }

    i {
      font-size: 0.8rem;
    }
  }
}

// 📍 Estilos específicos para o novo card de histórico
.location-history-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;

  &:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;

    h4 {
      margin: 0;
      color: var(--text-primary);
      font-size: 1.1rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        color: #666;
        font-size: 1rem;
      }
    }

    .history-count {
      background: #f5f5f5;
      color: #666;
      padding: 0.25rem 0.75rem;
      border-radius: 20px;
      font-size: 0.85rem;
      font-weight: 500;
    }
  }

  .history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px; // Altura máxima para scroll
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem; // Espaço para scrollbar
    
    // 🎨 Scrollbar personalizada
    &::-webkit-scrollbar {
      width: 6px;
    }
    
    &::-webkit-scrollbar-track {
      background: var(--background-light);
      border-radius: 3px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
      
      &:hover {
        background: var(--text-secondary);
      }
    }

    .history-item {
      display: flex;
      align-items: flex-start;
      gap: 1rem;
      padding: 1rem;
      border: 1px solid #f0f0f0;
      border-radius: 8px;
      transition: all 0.3s ease;
      position: relative;

      &:hover {
        border-color: #e0e0e0;
        background: #fafafa;
        transform: translateY(-1px);
      }

      &.latest {
        border-color: #4caf50;
        background: #f8fff8;

        &::before {
          content: 'ATUAL';
          position: absolute;
          top: -8px;
          right: 12px;
          background: #4caf50;
          color: white;
          padding: 2px 8px;
          border-radius: 4px;
          font-size: 0.7rem;
          font-weight: 600;
        }
      }

      // 🎯 Item selecionado no mapa
      &.selected {
        background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.08));
        border-color: #ffc107;
        box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
        
        .history-icon {
          position: relative;
          
          i {
            color: #ffc107 !important;
            animation: selectedPulse 1.5s infinite;
          }
        }

        &:hover {
          background: linear-gradient(135deg, rgba(255, 193, 7, 0.25), rgba(255, 193, 7, 0.15));
          border-color: #e0a800;
          transform: translateY(-3px);
          box-shadow: 0 6px 16px rgba(255, 193, 7, 0.4);
        }
      }

      .history-icon {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        position: relative;

        // 🎯 Número do marcador
        .marker-number {
          position: absolute;
          top: -8px;
          right: -8px;
          background: #ffc107;
          color: #000;
          border: 2px solid #fff;
          border-radius: 50%;
          width: 24px;
          height: 24px;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 0.75rem;
          font-weight: 700;
          box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
          animation: markerBounce 0.6s ease-out;
        }

        i.status-moving {
          background: #e3f2fd;
          color: #1976d2;
          border-radius: 50%;
          width: 100%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        i.status-parked {
          background: #e8f5e8;
          color: #388e3c;
          border-radius: 50%;
          width: 100%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        i.status-stopped {
          background: #fff3e0;
          color: #f57c00;
          border-radius: 50%;
          width: 100%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }

      .history-content {
        flex: 1;
        min-width: 0;

        .history-address {
          display: flex;
          flex-direction: column;
          gap: 0.25rem;
          margin-bottom: 0.5rem;

          strong {
            color: var(--text-primary);
            font-weight: 600;
            font-size: 0.95rem;
          }

          .history-city {
            color: #666;
            font-size: 0.85rem;
          }
        }

        .history-meta {
          display: flex;
          gap: 1rem;
          flex-wrap: wrap;

          .history-date,
          .history-duration {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            color: #666;
            font-size: 0.8rem;

            i {
              font-size: 0.75rem;
              opacity: 0.7;
            }
          }
        }
      }

      .history-status {
        flex-shrink: 0;
        position: relative;

        // 🎯 Indicador de remoção
        .remove-indicator {
          position: absolute;
          top: -8px;
          right: -8px;
          width: 20px;
          height: 20px;
          background: #dc3545;
          border: 2px solid #fff;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 0.7rem;
          color: white;
          cursor: pointer;
          opacity: 0.8;
          transition: all 0.2s ease;
          animation: removeIndicatorPulse 2s infinite;
          z-index: 10;

          &:hover {
            opacity: 1;
            transform: scale(1.1);
            background: #c82333;
          }

          i {
            font-size: 0.6rem;
          }
        }

        .status-badge {
          padding: 0.25rem 0.75rem;
          border-radius: 20px;
          font-size: 0.75rem;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;

          &.status-moving {
            background: #e3f2fd;
            color: #1976d2;
          }

          &.status-parked {
            background: #e8f5e8;
            color: #388e3c;
          }

          &.status-stopped {
            background: #fff3e0;
            color: #f57c00;
          }
        }
      }
    }
  }

  .history-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
    text-align: center;

    .history-load-more {
      background: transparent;
      border: 1px solid #e0e0e0;
      color: #666;
      padding: 0.75rem 1.5rem;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.3s ease;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin: 0 auto;
      font-size: 0.9rem;

      &:hover {
        background: #f5f5f5;
        border-color: #ccc;
        color: #333;
      }
    }
  }
}

// 📱 Responsividade específica para o card de histórico
@media (max-width: 768px) {
  .speed-stats-card {
    padding: 1rem;
    margin-bottom: 1rem;

    .stats-grid {
      grid-template-columns: 1fr;
      gap: 0.75rem;

      .stat-item {
        padding: 0.75rem;
        gap: 0.75rem;

        .stat-icon {
          width: 35px;
          height: 35px;

          i {
            font-size: 1rem;
          }
        }

        .stat-content {
          .stat-value {
            font-size: 1.3rem;
          }
        }
      }
    }
  }

  .location-history-card {
    padding: 1rem;

    .history-item {
      padding: 0.75rem;
      gap: 0.75rem;

      .history-meta {
        flex-direction: column;
        gap: 0.5rem;
      }
    }

    .history-header {
      flex-direction: column;
      gap: 0.75rem;
      align-items: flex-start;
    }

    .time-between-indicator {
      padding: 0.4rem 0.75rem;
      margin: 0.2rem 0;

      .time-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        font-size: 0.75rem;

        .time-separator {
          display: none; // Ocultar separadores no mobile
        }
      }
    }
  }

  // ⏱️ Indicador de tempo entre pontos
  .time-between-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 1rem;
    margin: 0.25rem auto;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 20px;
    position: relative;
    width: fit-content;
    max-width: 90%;

    .time-content {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      font-size: 0.8rem;
      color: var(--text-secondary);

      span {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        white-space: nowrap;

        i {
          font-size: 0.7rem;
        }
      }

      .time-duration {
        font-weight: 600;
        color: var(--primary-color);

        i {
          color: var(--primary-color);
        }
      }

      .time-separator {
        color: var(--text-tertiary);
        font-weight: bold;
        font-size: 0.6rem;
      }

      .time-distance {
        color: var(--info-color);
        font-weight: 500;

        i {
          color: var(--info-color);
        }
      }

      .time-speed {
        color: var(--success-color);
        font-weight: 500;

        i {
          color: var(--success-color);
        }

        &.high-speed {
          color: #ff6b35;
          font-weight: 700;
          background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(255, 140, 83, 0.1) 100%);
          padding: 0.25rem 0.5rem;
          border-radius: 12px;
          border: 1px solid rgba(255, 107, 53, 0.3);
          animation: pulse-speed 2s ease-in-out infinite;

          i {
            color: #ff6b35;
          }

          .fa-bolt {
            color: #ffc107;
            animation: flash 1.5s ease-in-out infinite;
            margin-left: 0.25rem;
          }
        }
      }

      .time-stationary {
        color: var(--warning-color);
        font-weight: 600;
        background: rgba(255, 193, 7, 0.15);
        padding: 0.25rem 0.5rem;
        border-radius: 12px;
        border: 1px solid rgba(255, 193, 7, 0.3);

        i {
          color: var(--warning-color);
        }
      }
    }

    // Animação sutil
    &:hover {
      background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
      transform: scale(1.02);
      transition: all 0.2s ease;
    }
  }

  // 🏠 Estilos para endereço do motorista
  .location-item {
    &.clickable {
      cursor: pointer;
      transition: all 0.2s ease;

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        background: var(--surface-hover);
      }
    }

    &.near-home {
      background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(102, 187, 106, 0.1) 100%);
      border-left-color: var(--success-color);
      
      .proximity-indicator {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        color: var(--success-color);
        font-weight: 600;
        font-size: 0.75rem;
        margin-left: 0.5rem;
        padding: 0.25rem 0.5rem;
        background: rgba(76, 175, 80, 0.15);
        border-radius: 12px;
        animation: pulse-near-home 2s ease-in-out infinite;

        i {
          font-size: 0.7rem;
        }
      }
    }

    .near-home-icon {
      color: var(--success-color) !important;
      animation: pulse-home-icon 1.5s ease-in-out infinite;
    }

    .home-action {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      background: var(--primary-color);
      color: white;
      border-radius: 50%;
      font-size: 0.8rem;
      opacity: 0.7;
      transition: all 0.2s ease;

      &:hover {
        opacity: 1;
        transform: scale(1.1);
      }
    }
  }

  // 🎯 Animações para velocidade alta
  @keyframes pulse-speed {
    0%, 100% {
      box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4);
    }
    50% {
      box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
    }
  }

  @keyframes flash {
    0%, 100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.7;
      transform: scale(1.1);
    }
  }

  // 🏠 Animações para proximidade da residência
  @keyframes pulse-near-home {
    0%, 100% {
      box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% {
      box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
    }
  }

  @keyframes pulse-home-icon {
    0%, 100% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.1);
    }
  }

  // 🎯 Animação para itens selecionados
  @keyframes selectedPulse {
    0%, 100% {
      transform: scale(1);
      opacity: 1;
    }
    50% {
      transform: scale(1.05);
      opacity: 0.8;
    }
  }

  // 🎯 Animação para número do marcador
  @keyframes markerBounce {
    0% {
      transform: scale(0);
      opacity: 0;
    }
    50% {
      transform: scale(1.2);
      opacity: 0.8;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
  }

  // 🎯 Animação para indicador de remoção
  @keyframes removeIndicatorPulse {
    0%, 100% {
      transform: scale(1);
      opacity: 0.8;
    }
    50% {
      transform: scale(1.05);
      opacity: 1;
    }
  }
} 