/* ============================================
   SGTI - Mapa de Rutas Styles
   ============================================ */

.mapa-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 140px);
}

.mapa-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.mapa-main {
    flex: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    position: relative;
}

#mapaLeaflet {
    width: 100%;
    height: 100%;
}

/* Legend */
.mapa-legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.8rem;
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 500;
}

.mapa-legend h4 {
    font-size: 0.75rem;
    margin-bottom: 8px;
    color: var(--navy-900);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ============================================
   Vehiculos en Tiempo Real (seguimiento GPS)
   ============================================ */
.vehiculos-live-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.vehiculo-live-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.vehiculo-live-item:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
}

.vehiculo-live-item.active {
    border-color: var(--accent-blue);
    background: rgba(46, 134, 171, 0.05);
}

.live-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.live-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.live-info strong {
    font-size: 0.85rem;
    color: var(--navy-900);
}

.live-info small {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.live-info .live-sub {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Detalle del vehiculo seleccionado */
.vehiculo-live-detalle {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
}

.vld-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--navy-900);
    margin-bottom: 10px;
}

.vld-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.vld-grid i {
    color: var(--accent-blue);
    margin-right: 4px;
}

.vld-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.vld-actions .btn-sm {
    flex: 1;
}

.vld-recorrido {
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vld-recorrido-controles {
    display: flex;
    gap: 8px;
}

.vld-recorrido-controles select,
.vld-recorrido-controles input {
    flex: 1;
    padding: 7px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--navy-900);
}

.vld-recorrido-controles .btn-sm {
    flex: 1;
}

/* GPS Simulation Controls */
.gps-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.gps-controls .btn-sm {
    flex: 1;
    min-width: 100px;
}

/* ============================================
   WolfTrak Global: estado de conexion GPS
   ============================================ */
.gps-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--navy-900);
    margin-bottom: 4px;
}

.gps-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.gps-status-dot.ok {
    background: #2EC4B6;
    box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.18);
}

.gps-status-dot.error {
    background: #E63946;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.18);
}

.gps-last-update {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
}

/* =========================================================
   Google Maps Navigation 3D Top-Down Vehicle Marker (Compact & Realistic)
   ========================================================= */

.gm-vehicle-marker-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 44px;
    cursor: pointer;
    user-select: none;
    transform: translateY(calc(var(--scale, 1) * 50%)) scale(var(--scale, 1));
    transform-origin: center center;
    transition: opacity 0.3s ease, filter 0.2s ease;
}

.gm-vehicle-marker-box:hover {
    filter: brightness(1.15) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

/* Vehicle Rotator (turns smoothly towards GPS heading) */
.gm-vehicle-rotator {
    width: 20px;
    height: 40px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transform-origin: center center;
}

/* Realistic Ground Shadow under the 3D car */
.gm-vehicle-ground-shadow {
    position: absolute;
    width: 18px;
    height: 38px;
    border-radius: 9px;
    background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.42) 0%, rgba(15, 23, 42, 0.15) 60%, rgba(15, 23, 42, 0) 80%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

/* 3D Top-Down Car Image (Google Maps Navigation Style) */
.gm-vehicle-car-img {
    width: 18px;
    height: 38px;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 1.5px 3px rgba(0, 0, 0, 0.35));
    pointer-events: none;
}

/* Discreet mini status dot on the roof */
.gm-vehicle-status-dot {
    position: absolute;
    bottom: 2px;
    right: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2EC4B6;
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    z-index: 4;
    pointer-events: none;
}

.gm-vehicle-marker-box.is-stationary .gm-vehicle-status-dot {
    opacity: 0.85;
}

/* Estilos para el InfoWindow de Google Maps (popup de vehiculo) */
.gm-style-iw {
    padding: 10px 14px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18) !important;
    font-family: var(--font-family, 'Inter', sans-serif);
    line-height: 1.45;
}
.gm-style-iw-d {
    overflow: hidden !important;
    max-height: none !important;
}
.gm-style-iw button.gm-ui-hover-effect {
    top: 4px !important;
    right: 4px !important;
}

/* Metadatos del detalle del vehiculo (coordenadas, device_id, fecha) */
.vld-meta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    line-height: 1.5;
}

.vld-meta b {
    color: var(--navy-900);
}

@media (max-width: 1024px) {
    .mapa-container {
        flex-direction: column;
        height: auto;
    }
    .mapa-sidebar {
        width: 100%;
        max-height: 300px;
    }
    .mapa-main {
        height: 400px;
    }
}

/* ============================================
   Viajes (rastreo GPS real) - v6
   ============================================ */

/* Badge EN VIAJE en la lista de vehiculos */
.badge-viaje {
    display: inline-block;
    font-size: 0.62rem;
    padding: 2px 7px;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse-dot 1.6s ease-in-out infinite;
}

/* Banner de viaje activo en el detalle del vehiculo */
.vld-viaje-activo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #157f76;
    background: rgba(46, 196, 182, 0.12);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 8px 0;
}

.vld-viajes {
    margin-top: 10px;
}

.vld-viajes > button {
    width: 100%;
}

/* Lista del historial de viajes */
.viaje-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 6px;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.78rem;
}

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

.viaje-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.viaje-info small {
    color: var(--text-muted);
}