:root {
    --primary: #007AFF;
    --danger: #FF3B30;
    --success: #34C759;
    --dark: #1C1C1E;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: #f2f2f7;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#mapa-principal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* NAVBAR RESPONSIVA */
.navbar-pro {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 1100px;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    padding: 0 15px;
    z-index: 2000;
    box-shadow: var(--shadow);
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--dark);
    flex-shrink: 0 !important;
}

.logo span {
    color: var(--primary);
}

.auth-group {
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
    flex-shrink: 1 !important;
    justify-content: flex-end !important;
    gap: 8px;
}

.link-btn {
    background: none;
    border: none;
    font-weight: 600;
    cursor: pointer;
    color: var(--dark);
    font-size: 0.85rem;
}

.action-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
}

.perfil-usuario-box {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    max-width: 100%;
}

.perfil-nombre {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    max-width: 120px;
}

.perfil-salir {
    color: var(--danger);
    font-size: 13px;
    font-weight: 800;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid #cbd5e1;
    cursor: pointer;
    flex-shrink: 0;
}

/* === MODIFICACIÓN: PANEL DE FAVORITOS (Integrado en la tarjeta) === */
#panel-favoritos {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}

#panel-favoritos button {
    flex: 1;
    /* Esto hace que se dividan el espacio mitad y mitad */
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #444;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

#panel-favoritos button:hover {
    background: #eef6ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* CONTROLES FLOTANTES (Vista de Escritorio) */
.controles-flotantes {
    position: absolute;
    top: 150px;
    left: max(4%, calc(50% - 550px));
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1500;
    pointer-events: none;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    scrollbar-width: none;
}

.controles-flotantes::-webkit-scrollbar {
    display: none;
}

.drag-handle {
    display: none;
}

/* Oculto en PC */

.tarjeta-control,
.tarjeta-estado,
.btn-panico-pro {
    pointer-events: auto;
}

.cristal {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.grupo-input label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.input-pro {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #ddd;
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
    transition: 0.3s;
    background: white;
}

.input-pro:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.row-botones {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
    gap: 6px;
}

.btn-secundario-link {
    background: rgba(0, 122, 255, 0.08);
    border: 1px solid rgba(0, 122, 255, 0.2);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    transition: 0.3s;
}

.btn-secundario-link:hover {
    background: var(--primary);
    color: white;
}

.color-danger {
    color: var(--danger) !important;
    background: rgba(255, 59, 48, 0.08);
    border-color: rgba(255, 59, 48, 0.2);
}

.color-danger:hover {
    background: var(--danger) !important;
    color: white !important;
}

/* FILTROS Y ESTADO */
.grupo-filtros {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}

.chip input {
    display: none;
}

.chip span {
    display: block;
    padding: 10px 14px;
    background: white;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #eee;
    transition: 0.2s;
    white-space: nowrap;
}

.chip input:checked+span {
    background: #eef6ff;
    color: var(--primary);
    border-color: var(--primary);
}

.header-estado {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.header-estado p {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.texto-estado {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
    line-height: 1.4;
}

.punto-vivo {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(52, 199, 89, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0);
    }
}

/* BOTON DE PÁNICO Y ESTADOS */
.btn-panico-pro {
    background: var(--danger);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
    transition: 0.2s;
}

.btn-panico-pro:active {
    transform: scale(0.96);
}

.btn-cancelar-pro {
    background: #8E8E93 !important;
    color: white !important;
    border: none;
    padding: 18px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(142, 142, 147, 0.3) !important;
    transition: 0.2s;
}

.btn-cancelar-pro:active {
    transform: scale(0.96);
}

.btn-desactivado,
.modo-desactivado {
    background: #E5E5EA !important;
    color: #8E8E93 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
}

/* MODALES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-tarjeta {
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 28px;
    background: white;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-tarjeta h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin: 0 0 25px 0;
    text-align: center;
    font-weight: 800;
}

.btn-cerrar {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #888;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #ddd;
    font-family: inherit;
    font-size: 0.95rem;
    background: #f8f9fa;
    outline: none;
    transition: 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.btn-primario {
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    transition: 0.3s;
}

.tipo-usuario-selector {
    display: flex;
    background: #f1f1f1;
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 20px;
}

.tipo-opt {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #666;
}

.tipo-opt.activo {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* =========================================================
   RESPONSIVO: LA MAGIA DEL "BOTTOM SHEET" (ESTILO UBER/MAPS)
   ========================================================= */

@media (max-width: 1024px) {
    .controles-flotantes {
        width: 320px;
        left: 20px;
    }
}

@media (max-width: 768px) {

    /* HEADER MÓVIL */
    .navbar-pro {
        top: 10px;
        width: 95%;
        height: 55px;
        padding: 0 12px !important;
        border-radius: 16px;
    }

    /* EL PANEL INFERIOR (BOTTOM SHEET) */
    .controles-flotantes {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        transform: none;
        background: white;
        border-radius: 32px 32px 0 0;
        padding: 15px 20px 30px 20px;
        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
        gap: 0;
        pointer-events: auto;
        max-height: 60vh;
    }

    /* LA BARRA ARRASTRABLE VISUAL */
    .drag-handle {
        display: block;
        width: 40px;
        height: 5px;
        background: #E5E5EA;
        border-radius: 5px;
        margin: 0 auto 15px auto;
    }

    /* QUITAR EL EFECTO CRISTAL A LAS TARJETAS INTERNAS EN MÓVIL */
    .cristal {
        background: transparent;
        backdrop-filter: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
        padding: 15px 0;
        border-bottom: 1px solid #F2F2F7;
    }

    .cristal:last-of-type {
        border-bottom: none;
        padding-bottom: 20px;
    }

    /* AJUSTES DE TAMAÑO MÓVIL */
    .grupo-input label {
        font-size: 0.7rem;
    }

    .input-pro {
        font-size: 0.9rem;
        padding: 12px;
    }

    .btn-secundario-link {
        font-size: 0.8rem;
        padding: 10px;
        border-radius: 10px;
    }

    /* MODIFICACIÓN: Ajuste de fuente para los botones favoritos en móvil */
    #panel-favoritos button {
        font-size: 0.8rem;
        padding: 12px;
    }

    /* CHIPS DESLIZABLES EN MÓVIL */
    .grupo-filtros {
        padding-bottom: 10px;
        margin-top: 10px;
    }

    .chip span {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    /* BOTON INFERIOR FIJO */
    .btn-panico-pro {
        position: sticky;
        bottom: 0;
        width: 100%;
        margin-top: 5px;
        font-size: 1rem;
        padding: 16px;
        z-index: 10;
    }

    /* RESTAURAMOS EL RADAR ACTIVO EN MÓVIL */
    .tarjeta-estado {
        display: block;
        background: #F8F9FA;
        border-radius: 16px;
        padding: 12px !important;
        margin-top: 10px;
        border: 1px solid #eee;
    }
}

@media (max-width: 480px) {
    .navbar-pro {
        height: auto !important;
        padding: 10px 12px !important;
        gap: 8px;
    }

    .logo {
        font-size: 1.1rem !important;
    }

    .auth-group {
        gap: 6px !important;
    }

    .link-btn,
    .action-btn {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .perfil-usuario-box {
        padding: 4px 8px !important;
    }

    .perfil-nombre {
        max-width: 80px !important;
        font-size: 12px !important;
    }

    .perfil-salir {
        font-size: 12px !important;
        margin-left: 6px;
        padding-left: 6px;
    }
}