@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");
@import url("https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", sans-serif;
    background: #020617;
    color: #e5e7eb;
    overflow: hidden;
}

/* ===========================
   PANEL LATERAL - NUEVO DISEÑO
   =========================== */

.col-dispositivos {
    position: fixed;
    top: 115px;
    left: 0;
    width: 360px;
    height: calc(100vh - 115px);
    background: radial-gradient(circle at top left, #0f172a 0%, #020617 45%, #020617 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 12px 0 45px rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(26px);
    z-index: 3;
    transition:
        width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.28s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #e2e8f0;
}

.col-dispositivos.collapsed {
    width: 76px;
    box-shadow: 6px 0 30px rgba(15, 23, 42, 0.6);
}

.panel-header {
    padding: 16px 18px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
    background: radial-gradient(circle at top left, #1d2437 0%, #020617 70%);
}

.panel-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-logo {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: conic-gradient(from 180deg at 50% 50%, #22c55e, #3b82f6, #a855f7, #22c55e);
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-logo i {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 10%, #1e293b 0%, #020617 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    font-size: 20px;
}

.panel-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-title-text {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f9fafb;
}

.panel-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    color: #7dd3fc;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.panel-subtitle {
    font-size: 11px;
    opacity: 0.8;
    color: #cbd5f5;
}

/* Botón plegar */
.collapse-toggle {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    transition: all 0.2s ease;
}

.collapse-toggle:hover {
    background: rgba(30, 64, 175, 0.8);
    border-color: rgba(129, 140, 248, 0.9);
    transform: translateY(-1px) scale(1.03);
}

/* Chips de resumen */
.panel-header-stats {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid transparent;
    background: rgba(15, 23, 42, 0.9);
}

.status-chip .chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.status-chip .chip-count {
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.8);
    font-weight: 600;
    font-size: 10px;
}

.chip-online {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.4);
    background: linear-gradient(to right, rgba(22, 163, 74, 0.12), rgba(21, 128, 61, 0.2));
}

.chip-offline {
    color: #f97373;
    border-color: rgba(248, 113, 113, 0.4);
    background: linear-gradient(to right, rgba(248, 113, 113, 0.12), rgba(220, 38, 38, 0.18));
}

.chip-unknown {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.45);
    background: linear-gradient(to right, rgba(251, 191, 36, 0.12), rgba(217, 119, 6, 0.18));
}

/* Ocultar detalles en modo colapsado */
.col-dispositivos.collapsed .panel-text,
.col-dispositivos.collapsed .panel-header-stats,
.col-dispositivos.collapsed .search-bar,
.col-dispositivos.collapsed .header,
.col-dispositivos.collapsed .vehicle-list {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-6px);
}

/* Cuerpo del panel */
.panel-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Barra de búsqueda */
.search-bar {
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.85);
    background: radial-gradient(circle at top, rgba(30, 64, 175, 0.35) 0%, rgba(15, 23, 42, 0.96) 42%, #020617 100%);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input-container {
    position: relative;
    flex: 1;
}

.search-input-container svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    z-index: 1;
}

.search-input {
    width: 100%;
    padding: 9px 14px 9px 34px;
    border-radius: 999px;
    border: 1px solid rgba(51, 65, 85, 0.9);
    background: rgba(15, 23, 42, 0.98);
    font-size: 12px;
    color: #e5e7eb;
    transition: all 0.2s ease;
    font-family: "Inter", sans-serif;
}

.search-input::placeholder {
    color: #64748b;
}

.search-input:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.9);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.8), 0 0 20px rgba(79, 70, 229, 0.35);
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Botón icono */
.icon-button {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(51, 65, 85, 0.9);
    background: radial-gradient(circle at 30% 0%, rgba(148, 163, 184, 0.25), rgba(15, 23, 42, 0.95));
    color: #cbd5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.icon-button:hover {
    border-color: rgba(129, 140, 248, 0.9);
    color: #e5e7eb;
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 0 18px rgba(59, 130, 246, 0.35);
}

.icon-button.has-filters {
    background: radial-gradient(circle at 30% 0%, rgba(251, 113, 133, 0.3), rgba(15, 23, 42, 0.98));
    border-color: rgba(248, 113, 113, 0.9);
}

/* Indicador de filtros activos */
.filter-indicator {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    background: #f97373;
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.9);
}

/* Encabezado de la lista */
.header {
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid rgba(31, 41, 55, 0.9);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #9ca3af;
}

.header svg {
    color: #818cf8;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header svg:hover {
    color: #a5b4fc;
    transform: scale(1.1);
}

/* Lista de vehículos */
.vehicle-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 14px;
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.98), #020617 70%);
}

.vehicle-list::-webkit-scrollbar {
    width: 6px;
}

.vehicle-list::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 999px;
}

.vehicle-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.8);
    border-radius: 999px;
}

.vehicle-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 1);
}

/* Grupo de dispositivos */
.group-header {
    padding: 8px 8px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    background: rgba(15, 23, 42, 0.98);
    border-radius: 999px;
    margin: 8px 2px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 1px solid rgba(31, 41, 55, 0.95);
}

.group-header:hover {
    background: radial-gradient(circle at 30% 0%, rgba(129, 140, 248, 0.35), rgba(15, 23, 42, 0.96));
    color: #e5e7eb;
    border-color: rgba(129, 140, 248, 0.95);
}

.group-header i {
    transition: transform 0.2s ease;
    color: #818cf8;
}

.group-header.collapsed i {
    transform: rotate(-90deg);
}

.group-devices {
    margin-bottom: 4px;
}

/* Items de vehículos */
.vehicle-item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 10px;
    margin: 6px 0;
    background: radial-gradient(circle at top left, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.96));
    border-radius: 14px;
    border: 1px solid rgba(30, 64, 175, 0.7);
    cursor: pointer;
    position: relative;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.7);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    animation: fadeInUp 0.45s ease-out;
}

.vehicle-item:hover {
    transform: translateY(-2px) translateX(1px);
    border-color: rgba(129, 140, 248, 0.95);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.95);
    background: radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.28), rgba(15, 23, 42, 1));
}

.vehicle-item.selected {
    border-color: rgba(34, 197, 94, 0.95);
    background: radial-gradient(circle at 10% 0%, rgba(34, 197, 94, 0.28), rgba(15, 23, 42, 1));
}

.vehicle-item.selected::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from 180deg at 50% 50%, rgba(34, 197, 94, 0.85), rgba(56, 189, 248, 0.8), rgba(129, 140, 248, 0.9), rgba(34, 197, 94, 0.85));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
}

/* Checkbox */
.registro-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #6366f1;
    margin-top: 4px;
}

/* Icono del vehículo */
.vehicle-icon {
    font-size: 20px;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.vehicle-icon-offline {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.vehicle-icon-unknown {
    background: linear-gradient(135deg, #eab308, #f97316);
}

/* Info del vehículo */
.vehicle-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vehicle-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.vehicle-header-main {
    min-width: 0;
}

.vehicle-name {
    font-weight: 600;
    font-size: 13px;
    color: #f9fafb;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vehicle-time {
    font-size: 11px;
    color: #94a3b8;
}

.vehicle-speed {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #a5b4fc;
}

/* Estados */
.vehicle-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 4px;
}

.vehicle-status-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dispositivos-accesorios {
    width: 14px;
    height: 14px;
    color: #e5e7eb;
    opacity: 0.85;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.dispositivos-accesorios:hover {
    transform: scale(1.15);
    opacity: 1;
}

/* Estados de conexión */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid transparent;
}

.connection-indicator.online {
    border-color: rgba(34, 197, 94, 0.6);
    color: #4ade80;
    background: rgba(22, 163, 74, 0.18);
}

.connection-indicator.offline {
    border-color: rgba(239, 68, 68, 0.7);
    color: #fca5a5;
    background: rgba(220, 38, 38, 0.16);
}

.connection-indicator.unknown {
    border-color: rgba(251, 191, 36, 0.7);
    color: #facc15;
    background: rgba(251, 191, 36, 0.16);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    animation: pulse 1.7s infinite;
    box-shadow: 0 0 8px currentColor;
}

/* Botón menú contextual */
.menu-trigger {
    background: transparent !important;
    border: none !important;
    font-size: 16px !important;
    color: #9ca3af !important;
    cursor: pointer !important;
    padding: 4px !important;
    border-radius: 999px !important;
    transition: all 0.15s ease !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    z-index: 10 !important;
}

.menu-trigger:hover {
    background: rgba(30, 64, 175, 0.9) !important;
    color: #e5e7eb !important;
    transform: translateY(-1px) scale(1.05) !important;
}

.menu-trigger.active {
    background: rgba(15, 23, 42, 0.9) !important;
    color: #a5b4fc !important;
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.85);
}

/* ===========================
   MENÚ FLOTANTE
   =========================== */

.floating-context-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    border: none;
    padding: 8px;
    z-index: 999999;
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.floating-context-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.floating-context-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    text-decoration: none;
}

.floating-context-menu .menu-item:hover {
    background: #f8fafc;
    color: #667eea;
    text-decoration: none;
}

.floating-context-menu .menu-item i {
    font-size: 16px;
    width: 18px;
    color: #64748b;
    flex-shrink: 0;
}

.floating-context-menu .menu-item:hover i {
    color: #667eea;
}

/* Eliminar menús contextuales inline antiguos */
.context-menu {
    display: none !important;
}

/* ===========================
   MAPA
   =========================== */

#map_canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

#metro {
    position: fixed;
    bottom: 195px;
    left: 340px;
    width: calc(100% - 340px);
    /* Ancho restante */
    height: 50px;
    z-index: 4;
}

/* ===========================
   STREET VIEW CONTROL
   =========================== */

.street-view-control {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
}

.street-view-control:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* ===========================
   ELEMENTOS OCULTOS COORDENADAS
   =========================== */

#mylat1,
#mylong1,
#mylat2,
#mylong2,
#mylat3,
#mylong3,
[id^="mylat"],
[id^="mylong"] {
    display: none !important;
}

/* ===========================
   MODAL DE FILTROS
   =========================== */

.filter-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.filter-modal.active {
    display: flex;
}

.filter-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.filter-modal.active .filter-content {
    transform: scale(1);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.filter-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.close-filter {
    background: none;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.close-filter:hover {
    background: #f1f5f9;
    color: #334155;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-option:hover {
    color: #667eea;
}

.filter-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
}

.filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.filter-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn.primary {
    background: #667eea;
    color: white;
}

.filter-btn.primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.filter-btn.secondary {
    background: #f1f5f9;
    color: #64748b;
}

.filter-btn.secondary:hover {
    background: #e2e8f0;
    color: #334155;
}

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 768px) {
    .col-dispositivos {
        position: absolute;
        top: 0;
        left: 0;
        height: 100vh;
        width: 86%;
        max-width: 380px;
        transform: translateX(-100%);
        border-radius: 0 18px 18px 0;
    }

    .col-dispositivos.mobile-open {
        transform: translateX(0);
    }

    .mobile-toggle {
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 1500;
        background: rgba(15, 23, 42, 0.96);
        border: 1px solid rgba(148, 163, 184, 0.9);
        border-radius: 999px;
        width: 44px;
        height: 44px;
        box-shadow: 0 12px 26px rgba(15, 23, 42, 0.85);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #e5e7eb;
    }

    .mobile-toggle i {
        font-size: 20px;
    }

    .floating-context-menu {
        min-width: 220px;
        max-width: calc(100vw - 40px);
    }
}

/* ===========================
   ANIMACIONES
   =========================== */

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.9);
    }
}
