/* ==========================================================================
   index.css - QR RECOVERY GLOBAL
   VERSIÓN: v28.2.0 - UNIFICADO (v28.1.0 completo + FIX BOTONES PERSONA v28.2.0)
   ==========================================================================
   Este archivo contiene TODOS los estilos que antes estaban en el <style>
   interno de index.html (v27.5.0, 438 reglas, incluidos #chatLoadingOverlay
   y los comentarios de cada módulo), más los estilos nuevos de v28.0.0:
     - #personaActions y los botones .btn-emergency-contact, .btn-medical-card,
       .btn-help-instructions, .btn-found-person, .btn-call-emergency
     - #medicalCardModal (modal de ficha médica) y @keyframes slideUp
   Y los estilos nuevos de v28.2.0:
     - body.is-persona-mode para ocultar botones genéricos (WhatsApp,
       Llamar, Chat Tiempo Real, whatsappMessageGroup, whatsappLocationGroup,
       btnNotificarPropietario) cuando el código consultado es tipo persona.
   Se carga desde index.html con: <link rel="stylesheet" href="index.css" />
   ========================================================================== */

/* ============================================================
   ESTILOS COMPLETOS
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #212529;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    min-height: 100vh;
    font-size: clamp(0.95rem, 2.8vw, 1.1rem);
    padding: 0;
}
:root {
    --primary: #2A6B8F;
    --primary-light: #3A8BBF;
    --primary-dark: #1A4B6F;
    --secondary: #FF9F1C;
    --accent: #2EC4B6;
    --gray: #6C757D;
    --gray-light: #E9ECEF;
    --gray-dark: #4B5563;
    --success: #28A745;
    --error: #DC3545;
    --warning: #FFC107;
    --discount: #FF6B35;
    --gold: #FFD700;
    --border-radius: 12px;
    --box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    --transition: all 0.3s ease;
    --font-xs: clamp(0.7rem, 2vw, 0.85rem);
    --font-sm: clamp(0.8rem, 2.5vw, 0.95rem);
    --font-base: clamp(0.95rem, 2.8vw, 1.1rem);
    --font-lg: clamp(1.05rem, 3.2vw, 1.25rem);
    --font-xl: clamp(1.25rem, 4vw, 1.6rem);
    --font-2xl: clamp(1.5rem, 5vw, 2rem);
    --font-3xl: clamp(1.8rem, 6vw, 2.8rem);
}

/* ============================================================ */
/* ✅ v20.0.0: ANIMACIONES DEL MODAL DE RADAR                    */
/* ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.radar-distance-popup .leaflet-popup-content-wrapper {
    background: #FFFBEB;
    border: 2px solid #FF9F1C;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 159, 28, 0.3);
}
.radar-distance-popup .leaflet-popup-tip {
    background: #FFFBEB;
    border: 2px solid #FF9F1C;
}

/* ============================================================ */
/* ✅ v27.2.0: CONTADOR DE SEGURIDAD (60s) Y ESTADO BLOQUEADO    */
/* ============================================================ */
#securityTimerContainer {
    margin: 12px 0;
}
#securityTimerContainer #securityTimer {
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #F59E0B;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}
#securityTimerContainer #securityTimerBar {
    height: 100%;
    width: 100%;
    background: #F59E0B;
    transition: width 1s linear, background 0.3s ease;
}
#securityTimerContainer.warning #securityTimer {
    color: #EF4444;
}
#securityTimerContainer.warning #securityTimerBar {
    background: #EF4444;
}
#secError.blocked {
    color: #991B1B;
    background: #FEE2E2;
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 4px solid #EF4444;
    font-weight: 600;
    animation: pulseError 1.5s ease-in-out infinite;
}
@keyframes pulseError {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ============================================================ */
/* ✅ v27.3.0: BADGE DE INTENTOS RESTANTES                       */
/* ============================================================ */
#securityAttemptsBadge {
    display: inline-block;
    padding: 4px 10px;
    background: #F3F4F6;
    color: #6B7280;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    transition: background 0.3s ease, color 0.3s ease;
}
@media (max-width: 480px) {
    #securityAttemptsBadge {
        font-size: 0.72rem;
        padding: 3px 8px;
    }
}

/* ============================================================ */
/* ✅ v11.6.0: BANNER OFFLINE SUPERIOR                          */
/* ============================================================ */
#offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: slideDownBanner 0.3s ease;
}
#offline-banner.active { display: flex; }
#offline-banner i {
    font-size: 1rem;
    animation: pulse-offline 2s infinite;
}
@keyframes slideDownBanner {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}
@keyframes pulse-offline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
body.is-offline { padding-top: 36px; }
@media (max-width: 480px) {
    body.is-offline { padding-top: 32px; }
    #offline-banner { font-size: 0.75rem; padding: 6px 10px; }
}

/* ============================================================ */
/* ✅ v15.0.0: BADGE VISUAL FLOTANTE (FALLBACK OPPO/XIAOMI)     */
/* ============================================================ */
#pwaBadgeFallback {
    position: fixed;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.5);
    z-index: 999999;
    display: none;
    animation: pulseBadge 2s infinite;
    min-width: 22px;
    text-align: center;
    font-family: 'Inter', sans-serif;
    border: 2px solid rgba(255,255,255,0.3);
    pointer-events: none;
}
#pwaBadgeFallback.active { display: block; }
@keyframes pulseBadge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 12px rgba(239, 68, 68, 0.5);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 3px 20px rgba(239, 68, 68, 0.8);
    }
}
@media (max-width: 480px) {
    #pwaBadgeFallback {
        top: 6px;
        right: 6px;
        font-size: 0.7rem;
        padding: 3px 8px;
        min-width: 20px;
    }
}

/* ============================================================ */
/* ✅ v12.0.0: BANNER DE NOTIFICACIONES EN INDEX                */
/* ============================================================ */
#notifBannerIndex {
    position: fixed;
    top: 80px;
    right: 16px;
    left: auto;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16,185,129,0.35);
    z-index: 99999;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 340px;
    min-width: 260px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#notifBannerIndex:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(16,185,129,0.5);
}
#notifBannerIndex:active { transform: translateY(0); }
#notifBannerIndex .notif-icon { font-size: 1.4rem; flex-shrink: 0; }
#notifBannerIndex .notif-content { flex: 1; min-width: 0; }
#notifBannerIndex .notif-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
#notifBannerIndex .notif-subtitle {
    font-size: 0.75rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#notifBannerIndex .notif-arrow { font-size: 0.9rem; opacity: 0.8; flex-shrink: 0; }
#notifBannerIndex .notif-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    transition: background 0.2s ease;
}
#notifBannerIndex .notif-close:hover { background: rgba(255,255,255,0.4); }
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(120px); }
    to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 480px) {
    #notifBannerIndex {
        top: 70px;
        right: 8px;
        left: 8px;
        max-width: none;
        min-width: 0;
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}

/* ============================================================ */
/* ✅ v12.0.0: TOAST DE NOTIFICACIÓN EN PRIMER PLANO            */
/* ============================================================ */
#toastNotificacion {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    background: linear-gradient(135deg, #2A6B8F, #3A8BBF);
    color: white;
    padding: 14px 22px;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(42,107,143,0.4);
    z-index: 100000;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    min-width: 280px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
#toastNotificacion.active {
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
#toastNotificacion .toast-icon { font-size: 1.4rem; flex-shrink: 0; }
#toastNotificacion .toast-content { flex: 1; min-width: 0; }
#toastNotificacion .toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
#toastNotificacion .toast-body {
    font-size: 0.8rem;
    opacity: 0.95;
    line-height: 1.4;
}
@media (max-width: 480px) {
    #toastNotificacion {
        left: 8px;
        right: 8px;
        transform: translateY(-120%);
        max-width: none;
        min-width: 0;
    }
    #toastNotificacion.active { transform: translateY(0); }
}

.contenedor-principal { max-width: 1200px; margin: 0 auto; padding: 0 clamp(8px, 2.5vw, 20px); width: 100%; }

/* ============ HEADER ============ */
.header {
    padding: clamp(16px, 4vw, 40px) 0 clamp(10px, 2.5vw, 20px);
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    margin-bottom: clamp(16px, 4vw, 40px);
    box-shadow: var(--box-shadow);
    position: relative;
    overflow: hidden;
    width: 100%;
}
.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" opacity="0.05"><path d="M30,30 Q50,10 70,30 T90,50 Q70,70 50,90 T10,50 Q30,30 50,10 Z" fill="white"/></svg>');
    background-size: 200px;
    pointer-events: none;
}

.navbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: clamp(10px, 2vw, 20px);
    padding: 0 clamp(8px, 2vw, 20px);
    width: 100%;
    position: relative;
    z-index: 5;
}
@media (min-width: 768px) {
    .navbar {
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 15px;
    }
}

.navbar-brand { display: flex; align-items: center; flex-shrink: 0; }

.brand-link {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.brand-link:hover { transform: translateY(-2px); transition: var(--transition); }

.language-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    order: 2;
}
@media (min-width: 768px) { .language-selector-wrapper { order: 0; } }

.language-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.language-dropdown {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: var(--font-sm);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    min-height: 36px;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="white"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
    min-width: 160px;
    max-width: 240px;
}

.language-dropdown:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-dropdown:focus {
    outline: none;
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.language-dropdown option {
    background: #2A6B8F;
    color: white;
    padding: 8px;
    font-size: 0.95rem;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    order: 1;
}
@media (min-width: 768px) {
    .navbar-user { width: auto; order: 0; }
}

.hamburger-menu-btn {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
    flex-shrink: 0;
}
.hamburger-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}
.hamburger-menu-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.4);
}
.hamburger-menu-btn .fa-bars { font-size: 1.2rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}
.sidebar-overlay.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 290px;
    height: 100%;
    background: #ffffff;
    box-shadow: 4px 0 30px rgba(0,0,0,0.15);
    z-index: 2001;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1.2rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}
.sidebar.open { left: 0 !important; }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-light);
    margin-bottom: 1rem;
    flex-shrink: 0;
}
.sidebar-header h3 {
    font-size: var(--font-lg);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.sidebar-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
    padding: 0 4px;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}
.sidebar-close:hover {
    color: var(--error);
    transform: rotate(90deg);
    background: rgba(220, 53, 69, 0.1);
}
.sidebar-close:active {
    transform: rotate(90deg) scale(0.9);
    background: rgba(220, 53, 69, 0.2);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: #212529;
    transition: var(--transition);
    font-weight: 500;
    font-size: var(--font-sm);
}
.sidebar-nav a:hover {
    background: var(--gray-light);
    transform: translateX(4px);
}
.sidebar-nav a i {
    width: 1.5rem;
    text-align: center;
    color: var(--primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar-nav .distributor-link {
    background: linear-gradient(135deg, var(--gold), #f5a623);
    color: #212529;
    font-weight: 700;
}
.sidebar-nav .premium-link {
    background: linear-gradient(135deg, var(--gold), #f5a623);
    color: #212529;
    font-weight: 700;
    border: 2px solid var(--gold);
}
.sidebar-nav .admin-link {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1A1A2E;
    font-weight: 700;
    border: 2px solid #FFD700;
}
.sidebar-nav .admin-link:hover {
    transform: translateX(4px) scale(1.02);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.5);
}
.sidebar-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-light);
    font-size: var(--font-xs);
    color: var(--gray);
    text-align: center;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .hamburger-menu-btn { display: flex !important; }
    .navbar-user .btn-nav { display: none !important; }
    .navbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 4px;
    }
    .navbar-brand { flex: 1; min-width: 0; }
    .brand-link { font-size: clamp(0.9rem, 4vw, 1.3rem); }
    .navbar-user { width: auto; gap: 4px; flex-wrap: nowrap; }
    .navbar-user #userEmail { display: none; }
    .navbar-user .btn { padding: 4px 8px; font-size: var(--font-xs); min-height: 32px; }
    .language-selector-wrapper {
        width: 100%;
        order: 3;
        margin-top: 4px;
        justify-content: center;
        gap: 3px;
    }
    .language-dropdown {
        font-size: 0.8rem;
        min-width: 140px;
        max-width: 200px;
        padding: 5px 25px 5px 10px;
    }
    .sidebar { width: 280px; left: -300px; padding: 1rem; }
    .sidebar.open { left: 0 !important; }
    .header { padding: 12px 0 8px; border-radius: 0 0 10px 10px; }
    .header-content { padding: 0 8px 8px; }
    .title { font-size: var(--font-2xl); }
    .subtitle { font-size: var(--font-base); }
}

@media (min-width: 768px) {
    .hamburger-menu-btn { display: none !important; }
    .navbar-user .btn-nav { display: inline-flex !important; }
}

.btn-nav {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 36px;
}
.btn-nav:hover { background: rgba(255,255,255,0.3); transform: translateY(-1px); }

#userEmail {
    font-size: var(--font-sm);
    opacity: 0.9;
    color: white;
    background: rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-distribuidor {
    background: linear-gradient(135deg, var(--gold), #f5a623);
    color: #212529;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 36px;
}
.btn-distribuidor:hover { transform: scale(1.05); box-shadow: 0 4px 15px rgba(255,215,0,0.3); }

#btnMiCuenta {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 36px;
}
#btnMiCuenta:hover { background: rgba(255,255,255,0.35); transform: translateY(-1px); }

.header-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 clamp(8px, 2vw, 20px) clamp(8px, 2vw, 15px);
    width: 100%;
}
.title {
    font-size: var(--font-3xl);
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.2;
    word-break: break-word;
}
.subtitle {
    font-size: var(--font-lg);
    font-weight: 400;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    word-break: break-word;
}

.header-message-wrapper {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 15px);
    padding: 0 clamp(8px, 2vw, 20px);
    margin-bottom: clamp(8px, 1.5vw, 15px);
    flex-wrap: nowrap;
    justify-content: flex-end;
    width: 100%;
}
.header-message-wrapper .connection-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
}
.header-message-wrapper .connection-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}
.header-message-wrapper .connection-dot.online { background: #4CAF50; box-shadow: 0 0 10px rgba(76,175,80,0.5); }
.header-message-wrapper .connection-dot.offline { background: #f44336; box-shadow: 0 0 10px rgba(244,67,54,0.3); }
.header-message-wrapper .connection-dot.connecting { background: #FFC107; box-shadow: 0 0 10px rgba(255,193,7,0.5); animation: pulse-dot 1s infinite; }
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.header-message-wrapper #mensaje {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    animation: slideIn 0.3s ease;
    border-radius: var(--border-radius);
    padding: clamp(4px, 1.2vw, 12px) clamp(8px, 1.5vw, 20px);
    font-weight: 500;
    font-size: var(--font-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: left;
    white-space: normal;
    word-break: break-word;
    display: none;
}
.header-message-wrapper #mensaje.error { background: #ffe6e6; color: var(--error); border-left: 4px solid var(--error); }
.header-message-wrapper #mensaje.success { background: #e6f4ea; color: var(--success); border-left: 4px solid var(--success); }
.header-message-wrapper #mensaje.warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.header-message-wrapper #mensaje.info { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }

/* ============ MAIN CONTENT ============ */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(16px, 3vw, 30px);
    margin-bottom: clamp(20px, 5vw, 60px);
    width: 100%;
}
@media (min-width: 768px) {
    .main-content { grid-template-columns: 2fr 1fr; }
    .main-content .card:nth-child(3),
    .main-content .card:nth-child(4),
    .main-content .card:nth-child(5),
    .main-content .card:nth-child(6),
    .main-content .card:nth-child(7) { grid-column: 1 / -1; }
}

.card {
    background: white;
    border-radius: var(--border-radius);
    padding: clamp(16px, 3.5vw, 30px);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.05);
    width: 100%;
    overflow: hidden;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 15px 40px rgba(0,0,0,0.12); }

.section-title {
    font-size: var(--font-xl);
    font-weight: 600;
    margin-bottom: clamp(12px, 2.5vw, 20px);
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.section-title i { color: var(--secondary); }

/* ============ SEARCH ============ */
.search-container {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2.5vw, 20px);
    width: 100%;
}
@media (min-width: 480px) { .search-container { flex-direction: row; align-items: flex-end; } }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.input-group label {
    font-weight: 500;
    color: #212529;
    font-size: var(--font-sm);
}
.search-input {
    padding: clamp(10px, 2.5vw, 15px) clamp(12px, 2.5vw, 20px);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-size: var(--font-base);
    transition: var(--transition);
    background: white;
    width: 100%;
    min-height: 48px;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42,107,143,0.1);
}

.button-group {
    display: flex;
    justify-content: center;
    flex: 0 0 auto;
    width: 100%;
    gap: 8px;
    flex-wrap: wrap;
}
@media (min-width: 480px) { .button-group { width: auto; } }

.btn {
    padding: clamp(10px, 2.5vw, 15px) clamp(16px, 3vw, 30px);
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-base);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
    text-decoration: none;
    text-align: center;
    min-height: 48px;
    line-height: 1.2;
}
@media (min-width: 480px) { .btn { width: auto; min-height: 44px; } }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(42,107,143,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(42,107,143,0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.btn-scan {
    background: linear-gradient(135deg, #6f42c1 0%, #9b59b6 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(111,66,193,0.3);
}
.btn-scan:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(111,66,193,0.4); }
.btn-scan.active {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    box-shadow: 0 4px 15px rgba(220,53,69,0.3);
}

.btn-whatsapp { background: #25D366; color: white; }
.btn-whatsapp:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,211,102,0.4); }

.btn-call { background: var(--accent); color: white; }
.btn-call:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(46,196,182,0.4); }

.btn-email { background: #EA4335; color: white; }
.btn-email:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(234,67,53,0.4); }

.btn-secondary { background: var(--gray-light); color: #212529; }
.btn-secondary:hover { background: #dde0e3; }

.btn-talisman {
    background: linear-gradient(135deg, var(--secondary) 0%, #FFB84D 100%);
    color: white;
    display: inline-flex;
    width: auto;
}
.btn-talisman:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,159,28,0.4); }

.btn-chat {
    background: #6f42c1;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: clamp(8px, 2vw, 12px) clamp(12px, 2.5vw, 18px);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    min-height: 40px;
}
.btn-chat:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(111,66,193,0.4); }
.btn-chat:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.btn-free {
    background: linear-gradient(135deg, #FF6B35, #FF4500);
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(255,107,53,0.4);
    animation: pulse-free 2s infinite;
}
.btn-free:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 30px rgba(255,107,53,0.6);
}
@keyframes pulse-free {
    0%, 100% { box-shadow: 0 4px 20px rgba(255,107,53,0.4); }
    50% { box-shadow: 0 4px 35px rgba(255,107,53,0.7); }
}

@keyframes slideIn { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:translateY(0)} }
@keyframes spin { 100%{transform:rotate(360deg)} }

/* ============ QR READER ============ */
#qr-reader {
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin: 10px auto;
    position: relative;
}
#qr-reader video { width: 100%; height: auto; display: block; }
.qr-scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid rgba(46,196,182,0.8);
    border-radius: 12px;
    box-shadow: 0 0 0 4000px rgba(0,0,0,0.4);
    pointer-events: none;
    transition: border-color 0.3s ease;
}
.qr-scanner-overlay.detected { border-color: #4CAF50; box-shadow: 0 0 20px rgba(76,175,80,0.5); }
@media (max-width: 480px) { .qr-scanner-overlay { width: 150px; height: 150px; } }

.qr-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ============ INFO BOX ============ */
.info-box {
    display: flex;
    align-items: flex-start;
    gap: clamp(12px, 2.5vw, 20px);
    background: linear-gradient(135deg, #e6f7ff 0%, #f0f9ff 100%);
    border-left: 4px solid var(--accent);
    flex-direction: column;
    padding: clamp(16px, 3vw, 24px);
    border-radius: var(--border-radius);
}
@media (min-width: 480px) { .info-box { flex-direction: row; } }
.info-icon {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    flex-shrink: 0;
    align-self: center;
}

/* ============ ESTADÍSTICAS ============ */
.stats-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: clamp(12px, 2.5vw, 20px);
}
.stats-header-row .section-title { margin-bottom: 0; }

.btn-refresh-stats {
    background: var(--gray-light);
    color: var(--primary);
    border: 2px solid transparent;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: var(--font-xs);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    width: auto;
    white-space: nowrap;
}
.btn-refresh-stats:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(42,107,143,0.3);
}
.btn-refresh-stats:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}
.btn-refresh-stats i { transition: transform 0.4s ease; }
.btn-refresh-stats:hover:not(:disabled) i { transform: rotate(180deg); }

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin: 20px 0;
}
.stats-container.stats-secondary { margin-top: 8px; }

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 16px 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    border-top: 4px solid var(--accent);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}
.stat-card.primary { border-top-color: var(--primary); }
.stat-card.secondary { border-top-color: var(--secondary); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.accent { border-top-color: var(--accent); }

.stat-number {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}
.stat-number.small {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    min-height: 2rem;
}
.stat-label {
    font-size: var(--font-sm);
    color: var(--gray);
    font-weight: 500;
}

.stat-loading {
    font-size: 1.5rem;
    color: var(--gray);
    opacity: 0.5;
}

.stats-footer-note {
    margin-top: 12px;
    font-size: var(--font-xs);
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.stats-footer-note i { color: var(--accent); }

.stats-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e8f5e9;
    color: var(--success);
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}
.stats-live-indicator .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-live 1.5s infinite;
}
@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ============ REPUTACIÓN ============ */
.reputation-section .section-title i { color: #FFD700; }
.reputation-card { transition: all 0.3s ease; }
.reputation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.15) !important;
}
@media (max-width: 480px) {
    .reputation-section { padding: clamp(12px, 3vw, 20px); }
    .reputation-card { padding: 12px !important; }
}

/* ============ TESTIMONIOS ============ */
.testimonials-container {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}
@media (min-width: 768px) { .testimonials-container { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .testimonials-container { grid-template-columns: repeat(3, 1fr); } }
.testimonial-card {
    background: white;
    border-radius: var(--border-radius);
    padding: clamp(16px, 2.5vw, 25px);
    box-shadow: var(--box-shadow);
    border-left: 4px solid var(--secondary);
}
.testimonial-text { font-style: italic; margin-bottom: 12px; color: #212529; line-height: 1.6; font-size: var(--font-sm); }
.testimonial-author { font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.testimonial-item { font-size: var(--font-xs); color: var(--gray); }

/* ============ FORMS ============ */
.form-group { margin-bottom: clamp(12px, 2vw, 20px); }
.form-input, .form-textarea {
    width: 100%;
    padding: clamp(10px, 2.5vw, 15px);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-size: var(--font-base);
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
    min-height: 44px;
}
.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42,107,143,0.1);
}
.form-textarea { min-height: 100px; resize: vertical; }

.form-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: clamp(16px, 3vw, 30px);
    width: 100%;
}
@media (min-width: 480px) {
    .form-buttons { flex-direction: row; flex-wrap: wrap; }
    .form-buttons .btn { flex: 1 1 auto; }
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}
@media (min-width: 480px) { .form-actions { flex-direction: row; } .form-actions .btn { flex: 1 1 auto; } }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px solid var(--gray-light);
    transition: var(--transition);
    cursor: pointer;
    margin: 8px 0;
}
.checkbox-group:hover { border-color: var(--primary); background: #f0f4f8; }
.checkbox-group input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.checkbox-group label { cursor: pointer; font-weight: 400; font-size: var(--font-sm); color: #212529; }
.checkbox-group .checkbox-icon { font-size: 1.2rem; color: var(--primary); }

/* ============================================================ */
/* ✅ v21.0.1: VERIFICADOR VISUAL DEL MENSAJE DE EMAIL          */
/* ============================================================ */
.email-message-verifier {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    padding: 10px 14px;
    background: #F8FAFC;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    font-size: 0.8rem;
    transition: var(--transition);
}
.email-message-verifier.valid {
    background: #F0FDF4;
    border-color: #A7F3D0;
}
.email-message-verifier.invalid {
    background: #FEF3C7;
    border-color: #FDE68A;
}
.email-message-verifier-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.email-message-verifier-label {
    font-weight: 500;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}
.email-message-verifier-label i {
    font-size: 0.85rem;
}
.email-message-verifier-count {
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.email-message-verifier-count.warning {
    color: #D97706;
}
.email-message-verifier-count.error {
    color: var(--error);
}
.email-message-verifier-count.success {
    color: var(--success);
}
.email-message-verifier-bar {
    width: 100%;
    height: 4px;
    background: #E2E8F0;
    border-radius: 2px;
    overflow: hidden;
}
.email-message-verifier-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #F59E0B, #F97316);
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
}
.email-message-verifier-bar-fill.success {
    background: linear-gradient(90deg, #10B981, #059669);
}
.email-message-verifier-hint {
    font-size: 0.72rem;
    color: #64748B;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}
.email-message-verifier-hint i {
    font-size: 0.75rem;
    color: var(--primary);
}
.email-message-verifier-hint.error {
    color: var(--error);
}
.email-message-verifier-hint.error i {
    color: var(--error);
}
.email-message-verifier-hint.success {
    color: var(--success);
}
.email-message-verifier-hint.success i {
    color: var(--success);
}

/* ============================================================ */
/* ✅ v21.0.1: AVISO DESTACADO DE UBICACIÓN EN EMAIL            */
/* ============================================================ */
.email-location-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-left: 4px solid #F59E0B;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: #78350F;
    line-height: 1.5;
}
.email-location-notice-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1;
}
.email-location-notice-content {
    flex: 1;
    min-width: 0;
}
.email-location-notice-title {
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #92400E;
}
.email-location-notice-title i {
    font-size: 0.9rem;
}
.email-location-notice-text {
    color: #78350F;
    font-size: 0.78rem;
}
.email-location-notice-text strong {
    color: #92400E;
}

@media (max-width: 480px) {
    .email-location-notice {
        font-size: 0.75rem;
        padding: 10px 12px;
    }
    .email-message-verifier {
        font-size: 0.72rem;
        padding: 8px 10px;
    }
    .email-message-verifier-hint {
        font-size: 0.68rem;
    }
}

.discount-badge {
    display: inline-block;
    background: var(--discount);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: var(--font-sm);
    animation: pulse-discount 1.5s infinite;
}
@keyframes pulse-discount { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,53,0.4); } 50% { box-shadow: 0 0 0 10px rgba(255,107,53,0); } }

/* ============ MODALES ============ */
.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    z-index: 1001;
    width: 92%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.modal.show {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(16px, 3vw, 25px) clamp(16px, 3vw, 30px) 0;
    margin-bottom: clamp(12px, 2vw, 20px);
    flex-wrap: wrap;
    gap: 8px;
}
.modal-title { font-size: var(--font-xl); font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.close-modal {
    background: none;
    border: none;
    font-size: var(--font-2xl);
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
    line-height: 1;
    padding: 0 8px;
}
.close-modal:hover { color: #212529; transform: scale(1.1); }
.modal-body { padding: 0 clamp(16px, 3vw, 30px) clamp(16px, 3vw, 30px); }

.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay.show {
    display: block !important;
    opacity: 1 !important;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1 !important;
}

.modal-overlay .modal {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

#contactoModal .modal-body { padding: 0 1.5rem 1.5rem 1.5rem; }

.talisman-promo {
    margin-top: 20px;
    padding: clamp(16px, 3vw, 24px);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--border-radius);
    text-align: center;
    border-left: 4px solid var(--secondary);
}
.talisman-promo h4 { margin-bottom: 8px; color: var(--primary-dark); font-size: var(--font-lg); }
.talisman-promo p { margin-bottom: 12px; color: var(--gray); font-size: var(--font-sm); }

#securityModal .modal-body input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-size: var(--font-base);
    margin-top: 8px;
}
#securityModal .modal-body input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42,107,143,0.1);
}
#secError { color: var(--error); font-size: var(--font-sm); margin-top: 10px; display: none; }

/* ============================================================ */
/* ✅ v10.2.0: ESTILOS DEL MODAL DE SEGURIDAD                    */
/* ============================================================ */
#securityModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 0;
    margin-bottom: 12px;
    gap: 10px;
    flex-wrap: nowrap;
}

#securityModal .modal-header .modal-title {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    margin: 0;
}

#securityModal .modal-header .close-modal {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

#securityModal .modal-header .close-modal:hover {
    color: var(--error);
    background: #FEE2E2;
    transform: scale(1.05);
}

.security-question-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.security-question-label {
    font-weight: 600;
    font-size: 1.05em;
    line-height: 1.5;
    color: #212529;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    display: block;
    margin-bottom: 0;
}

.btn-translate {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 32px;
    flex-shrink: 0;
}

.btn-translate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
}

.btn-translate:active {
    transform: translateY(0);
}

.btn-translate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-translate i {
    font-size: 0.85rem;
}

.btn-translate-manual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 400px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
    animation: pulseManualTranslation 2s infinite;
}

.btn-translate-manual:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, #D97706, #B45309);
}

.btn-translate-manual:active {
    transform: translateY(0);
}

.btn-translate-manual:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-translate-manual i {
    font-size: 0.9rem;
}

@keyframes pulseManualTranslation {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
    }
    50% {
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5);
    }
}

@media (max-width: 480px) {
    .btn-translate-manual {
        font-size: 0.75rem;
        padding: 10px 14px;
        gap: 6px;
    }
    .btn-translate-manual i {
        font-size: 0.8rem;
    }
}

.sec-translation-status {
    display: none;
    font-size: 0.75rem;
    color: var(--primary);
    margin-bottom: 8px;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border-radius: 6px;
    border-left: 3px solid var(--primary-light);
    animation: slideIn 0.3s ease;
}

.sec-translation-status.active {
    display: inline-flex;
}

.sec-translation-status i {
    font-size: 0.8rem;
    color: var(--primary);
}

.sec-question-original {
    display: none;
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 8px;
    padding-top: 8px;
    font-style: italic;
    border-top: 1px dashed #dee2e6;
    line-height: 1.4;
    word-break: break-word;
}

.sec-question-original.active {
    display: block;
}

.sec-question-original i {
    color: var(--gray);
    margin-right: 4px;
    font-size: 0.85em;
}

/* ============ FOOTER ============ */
.footer {
    text-align: center;
    padding: clamp(16px, 3vw, 40px) 0;
    color: var(--gray);
    border-top: 1px solid var(--gray-light);
    margin-top: clamp(16px, 3vw, 40px);
    font-size: var(--font-sm);
}
.footer p { margin-bottom: 6px; }
.privacy-link { color: var(--primary); text-decoration: none; transition: var(--transition); }
.privacy-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ============ LOADING ============ */
.loading-spinner {
    display: none;
    justify-content: center;
    align-items: center;
    padding: clamp(16px, 3vw, 40px);
    gap: 12px;
    flex-wrap: wrap;
}
.spinner {
    width: clamp(36px, 6vw, 50px);
    height: clamp(36px, 6vw, 50px);
    border: 5px solid rgba(42,107,143,0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    margin: 12px 0;
    overflow: hidden;
    display: none;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* ============================================================ */
/* ✅ v11.8.0: SPINNER DE CARGA DEL CHAT                        */
/* ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#chatLoadingOverlay {
    z-index: 99999 !important;
}

#chatLoadingOverlay button:hover {
    transform: translateY(-1px);
}

#chatLoadingOverlay button:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    #chatLoadingOverlay > div {
        padding: 24px 20px !important;
    }
    #chatLoadingOverlay h3 {
        font-size: 1rem !important;
    }
    #chatLoadingOverlay p {
        font-size: 0.85rem !important;
    }
}

/* ============ RADAR ============ */
.radar-alert {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left: 4px solid var(--secondary);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin: 10px 0;
    font-weight: 500;
    display: none;
}
.radar-alert i { color: var(--secondary); margin-right: 8px; font-size: 1.2rem; }

.radar-status {
    display: none;
    background: #e8f5e9;
    border-left: 4px solid var(--success);
    padding: 10px 14px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: var(--font-sm);
}
.radar-status i { color: var(--success); margin-right: 8px; }

.code-inactive-msg {
    background: #f8d7da;
    border-left: 4px solid var(--error);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin: 10px 0;
    color: #721c24;
    font-weight: 500;
    display: none;
}
.code-inactive-msg i { color: var(--error); margin-right: 8px; }

/* ============ LOGIN ============ */
.login-message {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    display: none;
    font-size: var(--font-sm);
}
.login-message.error { display: block; background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.login-message.success { display: block; background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.login-message.info { display: block; background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

.forgot-password-link {
    display: block;
    text-align: right;
    font-size: var(--font-sm);
    color: var(--primary);
    text-decoration: none;
    margin-top: -5px;
    margin-bottom: 10px;
    transition: var(--transition);
}
.forgot-password-link:hover { text-decoration: underline; color: var(--primary-dark); }

.plan-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
}
.plan-badge.free { color: #FFD700; border-color: #FFD700; }
.plan-badge.premium { background: #FFD700; color: #1A1A2E; border-color: #FFD700; }

#phoneNotice {
    display: none;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px 14px;
    border-radius: 6px;
    margin: 10px 0;
}
#phoneNotice i { color: #856404; margin-right: 6px; }

.no-contact-msg {
    padding: 10px;
    background: #f8d7da;
    border-radius: 8px;
    color: #721c24;
    width: 100%;
    text-align: center;
    font-size: var(--font-sm);
}

.plan-info-gratuito { display: none !important; }

/* ============ CHAT ============ */
.message-bubble {
    max-width: 80%;
    padding: 0.6rem 1rem;
    border-radius: 16px;
    margin-bottom: 0.4rem;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
    position: relative;
    clear: both;
}
.message-bubble.dueno { float: left; background: #e3f2fd; border-bottom-left-radius: 4px; }
.message-bubble.samaritano { float: right; background: #e8f5e9; border-bottom-right-radius: 4px; }
.message-bubble .autor-label { font-size: 0.6rem; font-weight: 600; color: #6c757d; margin-bottom: 2px; }
.message-bubble .mensaje-texto { font-size: 0.85rem; line-height: 1.4; }
.message-bubble .timestamp { font-size: 0.55rem; color: #6c757d; margin-top: 4px; display: block; clear: both; }
.message-bubble .leido { font-size: 0.5rem; color: #6c757d; margin-left: 4px; }
.message-bubble .leido.visto { color: var(--primary); }

.message-system {
    text-align: center;
    color: #6c757d;
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    background: #f1f3f5;
    border-radius: 12px;
    margin: 0.4rem auto;
    max-width: 80%;
    clear: both;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.4rem 0.8rem;
    background: #f1f3f5;
    border-radius: 16px;
    max-width: 60px;
    margin: 4px 0;
    clear: both;
    float: left;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-location-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 12px;
    margin: 6px 0;
    border: 1px solid #bae6fd;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
}

.location-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #0369a1;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.location-header i {
    font-size: 1.1rem;
    color: #0ea5e9;
}

.location-coords {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: #475569;
    margin-bottom: 6px;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.6);
    padding: 4px 8px;
    border-radius: 6px;
}

.location-distance {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #0ea5e9;
    font-weight: 600;
    margin-bottom: 10px;
    background: rgba(14, 165, 233, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}

.location-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-location-action {
    flex: 1;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-location-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-location-action:active {
    transform: translateY(0);
}

.btn-location-action i {
    font-size: 0.8rem;
}

.btn-location-action[onclick*="whatsapp"] {
    background: linear-gradient(135deg, #25D366, #128C7E);
}

.btn-location-action[onclick*="whatsapp"]:hover {
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}
.chat-input-area .chat-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.chat-input-area .chat-input-row input {
    flex: 1;
    min-height: 38px;
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    outline: none;
    transition: var(--transition);
}
.chat-input-area .chat-input-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.chat-input-area .chat-input-row .chat-buttons {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.chat-input-area .chat-input-row .chat-buttons .btn {
    padding: 0.3rem 0.8rem;
    min-height: 38px;
    font-size: 0.8rem;
    border-radius: var(--border-radius);
    white-space: nowrap;
}
.chat-input-area .btn-enviar-row {
    display: flex;
    justify-content: flex-end;
}
.chat-input-area .btn-enviar-row .btn {
    width: auto;
    padding: 0.4rem 1.5rem;
    min-height: 40px;
}

.chat-burbuja-flotante {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 10002;
    transition: all 0.3s ease;
}
.chat-burbuja-flotante:hover { transform: scale(1.1); }
.chat-burbuja-flotante .burbuja-icon { font-size: 1.5rem; }
.chat-burbuja-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse-badge 1s infinite;
}
@keyframes pulse-badge {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ============ QR DISPLAY ============ */
.qr-display-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    border: 2px solid #FF8C00;
    text-align: center;
}
.qr-display-container .qr-top-text {
    font-size: 12px;
    font-weight: 700;
    color: #1A4B6F;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.qr-display-container .qr-code-text {
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: #2A6B8F;
    word-break: break-all;
    background: white;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
    margin: 6px 0;
}
.qr-display-container .qr-bottom-text {
    font-size: 12px;
    font-weight: 700;
    color: #2A6B8F;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}
.qr-display-container .qr-link {
    font-size: 11px;
    font-weight: 600;
    color: #6C757D;
    margin-top: 4px;
}
.qr-display-container .qr-link a {
    color: #2A6B8F;
    text-decoration: none;
}
.qr-display-container canvas {
    max-width: 100%;
    height: auto;
    border: 3px solid #FF8C00;
    border-radius: 4px;
}
.qr-display-container .qr-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}
.qr-display-container .qr-actions .btn {
    min-height: 40px;
    padding: 8px 20px;
    font-size: 0.85rem;
}

/* ============ BANNERS ============ */
.banner {
    border-radius: var(--border-radius);
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.6rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.3rem;
    animation: slideDown 0.4s ease;
}
.banner.active { display: flex; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.banner-install {
    background: linear-gradient(135deg, #1E293B, #334155);
    color: white;
    box-shadow: 0 4px 20px rgba(30,41,59,0.3);
    border: 1px solid rgba(255,255,255,0.08);
}
.banner-text { display: flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; font-weight: 500; }
.banner-actions { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.btn-banner {
    padding: 0.15rem 0.6rem;
    border: none;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.btn-banner:hover { transform: scale(1.05); }
.btn-banner-install { background: white; color: #1E293B; }
.btn-banner-install:hover { background: #E2E8F0; }
.btn-banner-dismiss { background: rgba(0,0,0,0.08); color: inherit; }
.btn-banner-dismiss:hover { background: rgba(0,0,0,0.15); }

/* ============ RESPONSIVE EXTRA ============ */
@media (max-width: 480px) {
    .modal { padding: 0; }
    .modal-body { padding: 0 1rem 1rem 1rem; }
    .form-buttons .btn { width: 100%; }
    .btn { font-size: var(--font-sm); padding: 12px 16px; }
    .qr-display-container { padding: 12px; }
    .chat-input-area .chat-input-row { flex-wrap: wrap; }
    .chat-input-area .chat-input-row input { flex: 1 1 100%; order: 1; }
    .chat-input-area .chat-input-row .chat-buttons { order: 2; flex: 1 1 auto; justify-content: flex-start; }
    .chat-input-area .btn-enviar-row { justify-content: stretch; }
    .chat-input-area .btn-enviar-row .btn { width: 100%; }
    .stats-header-row { flex-direction: column; align-items: flex-start; }
    .btn-refresh-stats { width: 100%; justify-content: center; }
    .btn-translate { font-size: 0.7rem; padding: 5px 10px; min-height: 30px; }
    .btn-translate i { font-size: 0.75rem; }
    .sec-translation-status { font-size: 0.7rem; padding: 4px 8px; }
    .sec-question-original { font-size: 0.75em; }
    .security-question-row {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-translate {
        width: 100%;
        justify-content: center;
    }
    .btn-translate-manual {
        font-size: 0.72rem;
        padding: 10px 12px;
    }
}

.premium-only.hidden { display: none !important; }
.btn-chat-hidden { display: none !important; }
.hidden { display: none !important; }

/* ============ PLAN BADGE OWNER ============ */
.plan-badge-owner {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 6px;
}
.plan-badge-owner.free { background: #e9ecef; color: #6c757d; }
.plan-badge-owner.premium { background: #FFD700; color: #1A1A2E; }
.plan-badge-owner.pro { background: linear-gradient(135deg, #FF6B35, #FF4500); color: white; }

.owner-plan-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}
.owner-plan-indicator i { font-size: 0.7rem; }
.owner-plan-indicator.premium {
    background: #fff8e1;
    border-color: #FFD700;
    color: #1A1A2E;
}

/* ============================================================ */
/* ✅ v19.0.0: INDICADOR DE ROL EN EL SIDEBAR                    */
/* ============================================================ */
.sidebar-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}
.sidebar-role-badge.admin {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1A1A2E;
}
.sidebar-role-badge.distributor {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}
.sidebar-role-badge.user {
    background: #E9ECEF;
    color: #6C757D;
}

/* ============================================================ */
/* ✅ v24.0.2: ESTILOS DEL MENSAJE DE WHATSAPP PERSONALIZADO     */
/* ============================================================ */
#whatsappMessage {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    resize: vertical;
    transition: var(--transition);
}
#whatsappMessage:focus {
    outline: none;
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}
.whatsapp-counter {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 4px;
    text-align: right;
}
.whatsapp-counter.warning {
    color: #DC3545;
    font-weight: 600;
}
#shareLocationWhatsApp {
    width: 20px;
    height: 20px;
    accent-color: #25D366;
    cursor: pointer;
    flex-shrink: 0;
}
.checkbox-group-whatsapp {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px solid var(--gray-light);
    transition: var(--transition);
    cursor: pointer;
    margin: 8px 0;
}
.checkbox-group-whatsapp:hover {
    border-color: #25D366;
    background: #f0fdf4;
}

/* ==========================================================================
   NUEVO v28.0.0 - TIPO PERSONA (FASE 3)
   (@keyframes fadeIn ya existe arriba; no se duplica)
   ========================================================================== */
/* ============================================================ */
/* ✅ NUEVO v28.0.0: ESTILOS PARA BOTONES DE PERSONA             */
/* ============================================================ */
#personaActions {
    animation: fadeInPersona 0.4s ease;
}

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

.btn-emergency-contact,
.btn-medical-card,
.btn-help-instructions,
.btn-found-person,
.btn-call-emergency {
    transition: all 0.2s ease;
}

.btn-emergency-contact:hover,
.btn-medical-card:hover,
.btn-help-instructions:hover,
.btn-found-person:hover,
.btn-call-emergency:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-emergency-contact:active,
.btn-medical-card:active,
.btn-help-instructions:active,
.btn-found-person:active,
.btn-call-emergency:active {
    transform: translateY(0) scale(0.98);
}

/* Modal de ficha médica */
#medicalCardModal {
    animation: fadeIn 0.3s ease;
}

#medicalCardModal .modal {
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   ✅ v28.1.0: FIX VISIBILIDAD DE LA FICHA MÉDICA
   KeyFinderApp.js (window.verFichaMedica) abre #medicalCardModal solo con
   style.display = 'flex' (no añade la clase .active). Como .modal-overlay
   tiene opacity:0 por defecto, el modal quedaba invisible aunque ocupara
   la pantalla. Este selector por ID fuerza que se vea al abrirlo.
   ========================================================================== */
#medicalCardModal {
    opacity: 1;
    z-index: 10000;
}
/* ==========================================================================
   v9.24.0 - FIX @keyframes pulse-badge (usado por _renderBotonesPersona)
   ==========================================================================
   El modal de ficha médica y los botones de persona usan la animación
   pulse-badge en el banner "MODO PERDIDO". Antes estaba definida en el
   bloque CSS dinámico de KeyFinderApp.js (v9.23.0), que fue eliminado
   en v9.24.0 para evitar backticks huérfanos. Se mueve aquí.
   ========================================================================== */

@keyframes pulse-badge {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

/* ==========================================================================
   v9.24.0 - MEJORAS DE COMPATIBILIDAD
   ==========================================================================
   Estilos defensivos para cuando el navegador no soporta backdrop-filter
   (Safari < 9, Firefox < 103). No afecta a navegadores modernos.
   ========================================================================== */

@supports not (backdrop-filter: blur(4px)) {
    #medicalCardModal {
        background: rgba(15, 23, 42, 0.85) !important;
    }
}

/* ==========================================================================
   v9.24.0 - FIX RESPONSIVE DE LOS BOTONES DE PERSONA
   ==========================================================================
   En pantallas muy pequeñas (< 360px) los textos largos como
   "Llamar a María González (Mamá)" pueden desbordar. Se trunca con
   elipsis y se reduce el padding.
   ========================================================================== */

@media (max-width: 360px) {
    .btn-emergency-contact,
    .btn-medical-card,
    .btn-help-instructions,
    .btn-found-person,
    .btn-call-emergency {
        padding: 10px 8px !important;
        font-size: 0.82rem !important;
    }
    
    .btn-emergency-contact span,
    .btn-found-person span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
}

/* ==========================================================================
   v9.24.0 - MEJORA DE ACCESIBILIDAD
   ==========================================================================
   Foco visible en los botones de emergencia (tipo persona).
   Importante para navegación por teclado y lectores de pantalla.
   ========================================================================== */

.btn-emergency-contact:focus-visible,
.btn-medical-card:focus-visible,
.btn-help-instructions:focus-visible,
.btn-found-person:focus-visible,
.btn-call-emergency:focus-visible {
    outline: 3px solid #FFD700;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.25);
}

/* ==========================================================================
   v9.24.0 - MEJORA DEL BOTÓN "CERRAR" DEL MODAL DE FICHA MÉDICA
   ==========================================================================
   El botón × del modal médico usa estilos inline en el HTML generado.
   Este override añade una transición suave al hover/focus y un área
   táctil mínima de 44×44px (WCAG AAA) si el navegador lo permite.
   ========================================================================== */

#medicalCardModal button[onclick*="cerrarFichaMedica"]:hover {
    background: rgba(255, 255, 255, 0.35) !important;
    transform: scale(1.05);
}

#medicalCardModal button[onclick*="cerrarFichaMedica"]:active {
    transform: scale(0.95);
}

#medicalCardModal button[onclick*="cerrarFichaMedica"]:focus-visible {
    outline: 2px solid #FFD700;
    outline-offset: 2px;
}

/* ==========================================================================
   v9.24.0 - MEJORA DEL SCROLL DEL MODAL DE FICHA MÉDICA
   ==========================================================================
   El modal médico tiene `max-height: 90vh; overflow-y: auto`. Se mejora
   el scroll en iOS con `-webkit-overflow-scrolling: touch` y se estiliza
   la scrollbar en navegadores WebKit.
   ========================================================================== */

#medicalCardModal .modal {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #6366F1 #E0E7FF;
}

#medicalCardModal .modal::-webkit-scrollbar {
    width: 8px;
}

#medicalCardModal .modal::-webkit-scrollbar-track {
    background: #E0E7FF;
    border-radius: 4px;
}

#medicalCardModal .modal::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6366F1, #8B5CF6);
    border-radius: 4px;
    border: 2px solid #E0E7FF;
}

#medicalCardModal .modal::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4F46E5, #7C3AED);
}

/* ==========================================================================
   ✅ v28.2.0: OCULTAR BOTONES GENÉRICOS EN MODO PERSONA
   ==========================================================================
   Cuando el código consultado es de tipo "persona" (ficha médica), los
   botones genéricos del panel de contacto (WhatsApp, Llamar, Chat en
   tiempo real, formulario de WhatsApp, compartir ubicación por WhatsApp,
   y notificar al propietario) no tienen sentido y deben ocultarse.
   KeyFinderApp._renderBotonesPersona() añade la clase `is-persona-mode`
   al <body>, y este bloque se encarga de la ocultación visual sin
   necesidad de manipular el DOM desde JS. Se usa !important para
   ganar a cualquier estilo inline que el handler original pudiera
   haber aplicado con style.display = 'flex'.
   ========================================================================== */
body.is-persona-mode #btnWhatsappOwner,
body.is-persona-mode #btnCallOwner,
body.is-persona-mode #btnChatTiempoReal,
body.is-persona-mode #whatsappMessageGroup,
body.is-persona-mode #whatsappLocationGroup,
body.is-persona-mode #btnNotificarPropietario {
    display: none !important;
}