/**
 * VIVA DASHBOARD STYLES v55.0
 * Migrado de inline a externo para mejor rendimiento y limpieza.
 */

:root {
    --primary: #4db6ac; /* TURQUESA LOGO */
    --primary-glow: rgba(77, 182, 172, 0.4);
    --secondary: #1b3a61; /* AZUL MARINO LOGO */
    --bg-color: #0f172a;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
}

body.light-mode {
    --bg-color: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border-glass: rgba(27, 58, 97, 0.1);
    --text-primary: #1b3a61;
    --text-muted: #475569;
    --primary-glow: rgba(77, 182, 172, 0.2);
}

/* --- THEME SWITCH PREMIUM v57 --- */
.theme-switch {
    width: 65px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary);
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    margin-left: 10px;
    box-shadow: 0 0 10px var(--primary-glow);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    flex-shrink: 0;
}

.switch-thumb {
    position: absolute;
    top: 3px;
    left: 4px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    font-size: 0.9rem;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 2;
}

.theme-switch .light-icon { opacity: 0; position: absolute; transform: scale(0); transition: 0.3s; }
.theme-switch .dark-icon { opacity: 1; position: absolute; transform: scale(1); transition: 0.3s; }

body.light-mode .theme-switch {
    background: rgba(27, 58, 97, 0.1);
}

body.light-mode .switch-thumb {
    left: calc(100% - 28px);
    background: var(--secondary);
    color: white;
}

body.light-mode .light-icon { opacity: 1; transform: scale(1); }
body.light-mode .dark-icon { opacity: 0; transform: scale(0); }

/* --- REUSABLE TOGGLE v61 --- */
.viva-toggle {
    width: 55px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary);
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    transition: 0.3s;
}

.viva-toggle .toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.viva-toggle.active {
    background: var(--primary-glow);
    border-color: var(--primary);
}

.viva-toggle.active .toggle-thumb {
    left: calc(100% - 24px);
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.space-between { justify-content: space-between; }
.w-100 { width: 100%; }
.mr-10 { margin-right: 10px; }
.ml-10 { margin-left: 10px; }

/* --- CONTROL CENTRAL CHAT v61.2 --- */
.chat-section-top {
    padding: 10px 15px 25px 15px;
    background: linear-gradient(to bottom, var(--bg-glass), transparent);
    margin-bottom: 10px;
}

.section-label-premium {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.chat-input-box-v2 {
    display: flex;
    gap: 12px;
    background: var(--bg-glass);
    padding: 8px;
    border-radius: 20px;
    border: 2px solid var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.chat-input-premium {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 15px;
    font-size: 1.05rem;
    outline: none;
    font-weight: 500;
}

.btn-send-chat-premium {
    background: var(--primary);
    color: var(--secondary);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.btn-send-chat-premium:hover {
    transform: scale(1.1) rotate(-10deg);
    filter: brightness(1.2);
}

.chat-input-premium::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}


* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0; font-family: 'Inter', sans-serif;
    background-color: var(--bg-color); color: var(--text-primary);
    overflow-x: hidden; padding-bottom: 90px;
    -webkit-user-select: none; user-select: none;
}

button, .nav-item, .caretaker-bubble, .mgmt-clickable, .card-clickable {
    cursor: pointer !important;
}

button * {
    pointer-events: none;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

button:active {
    transform: scale(0.95);
    opacity: 0.8;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.2);
}

.header {
    padding: 10px 20px; display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-glass); position: sticky; top: 0; z-index: 100;
}


.logo h1 { 
    margin: 0; font-size: 24px; font-weight: 900; letter-spacing: -1px; 
    background: linear-gradient(to right, #4f46e5, #9333ea); 
    -webkit-background-clip: text; background-clip: text; 
    -webkit-text-fill-color: transparent; 
}

.logo span { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); font-weight: 800; }

.status-badge {
    background: rgba(16, 185, 129, 0.1); color: var(--success);
    padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; gap: 6px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge i { font-size: 8px; animation: pulse 2s infinite; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

.tab-content { display: none; padding: 10px 20px; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card {
    background: var(--bg-glass); border: 1px solid var(--border-glass);
    border-radius: 24px; padding: 20px; margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.card-title {
    margin: 0 0 15px 0; font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
    display: flex; align-items: center; gap: 10px;
}

.card-title i { color: var(--primary); }

.device-selector {
    display: flex; background: rgba(0,0,0,0.2); padding: 4px; border-radius: 12px; margin-bottom: 20px;
}

.device-option {
    flex: 1; padding: 5px; text-align: center; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.3s;
    display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-muted);
}

.device-option.active { background: var(--primary); color: white; box-shadow: 0 4px 12px var(--primary-glow); }

.metric { font-size: 1.8rem !important; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.metric-unit { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.heart-rate { color: #f43f5e; text-shadow: 0 0 20px rgba(244, 63, 94, 0.3); }
.heart-beat i { font-size: 1.5rem; animation: pulseHeart 0.8s infinite alternate cubic-bezier(0.4, 0, 0.2, 1); }

@keyframes pulseHeart { from { transform: scale(1); } to { transform: scale(1.2); } }

.mgmt-item {
    background: rgba(255,255,255,0.03); border-radius: 16px; padding: 15px; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center; border: 1px solid rgba(255,255,255,0.05);
}

.mgmt-info b { display: block; font-size: 16px; margin-bottom: 2px; }
.mgmt-info span { font-size: 13px; color: var(--text-muted); }

.btn-delete { 
    background: rgba(239, 68, 68, 0.1); color: var(--danger); border: none; 
    width: 36px; height: 36px; border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; cursor: pointer; 
}

.btn-add-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; border: none; border-radius: 15px; padding: 15px; width: 100%; 
    font-weight: 700; font-size: 15px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: 0.3s;
}

.btn-add-primary i {
    font-size: 18px;
}

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 80px;
    background: var(--bg-glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-glass); display: flex; justify-content: space-around; align-items: center;
    padding: 0 10px 20px 10px; z-index: 1000;
}

.nav-item {
    background: none; border: none; color: var(--text-muted); 
    display: flex; flex-direction: column; align-items: center; gap: 4px; 
    font-size: 10px; font-weight: 700; transition: 0.3s;
}

.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--primary); }

.nav-item.nav-call-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; width: 50px; height: 50px; border-radius: 14px;
    margin-top: 0; box-shadow: 0 4px 12px var(--primary-glow);
    justify-content: center;
}

.nav-item.nav-call-btn i { font-size: 24px; margin: 0; }

.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.input-group input, .input-group select {
    width: 100%; background: rgba(0,0,0,0.1); border: 1px solid var(--border-glass);
    border-radius: 12px; padding: 12px; color: var(--text-primary); font-family: inherit; font-size: 14px;
}

.caretaker-bar { display: flex; gap: 15px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 20px; }
.caretaker-bubble { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 60px; }
.bubble-circle { width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--border-glass); display: flex; align-items: center; justify-content: center; font-size: 20px; background: rgba(255,255,255,0.05); }
.caretaker-bubble.active .bubble-circle { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 0 15px var(--primary-glow); }
.bubble-name { font-size: 9px !important; font-weight: 700; color: var(--text-muted); }

.profile-section { text-align: center; margin-bottom: 30px; }
.profile-photo-container { position: relative; width: 100px; height: 100px; border-radius: 50%; border: 3px solid var(--primary); margin: 0 auto; padding: 3px; }
.profile-photo-container img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-name { margin: 15px 0 5px 0; font-size: 20px; font-weight: 800; }
.profile-hint { color: var(--text-muted); font-size: 11px; }

.modal-container { 
    display:none; position:fixed; top:0; left:0; right:0; bottom:0; 
    background:rgba(0,0,0,0.9); z-index:2000; padding:20px; 
    align-items: center; justify-content: center;
    overflow-y: auto; /* v83: Permitir scroll si el modal es muy alto */
}

.modal-content { 
    background: var(--bg-color); border: 1px solid var(--primary); 
    border-radius: 24px; padding: 25px; width: 100%; max-width: 450px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-height: 90vh; /* v83: No dejar que mida mÃ¡s del 90% del alto de pantalla */
    overflow-y: auto; /* v83: Scroll interno si hay mucho contenido */
    margin: auto;
}

.flex-gap-10 { display:flex; gap:10px; margin-top:20px; }
.btn-cancel { background:rgba(255,255,255,0.1); color:white; border:none; padding:15px; border-radius:15px; font-weight:700; width:100%; cursor:pointer; }

.modal-title { margin-top: 0; color: var(--primary); }

/* v55: Call Alert Styles */
.call-alert-box {
    text-align: center;
    border: 2px solid var(--success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}
.call-alert-icon {
    font-size: 50px;
    margin-bottom: 15px;
    animation: shake 0.5s infinite;
}
@keyframes shake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}

#reminder-popup { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.95); z-index: 100000; display: none; align-items: center; justify-content: center; }
.reminder-card { background: #1e293b; border: 2px solid var(--primary); border-radius: 30px; padding: 30px; width: 100%; max-width: 350px; text-align: center; }
.rem-popup-icon { font-size: 50px; margin-bottom: 20px; }
.rem-popup-title { color: var(--primary); margin-bottom: 10px; }
.rem-popup-desc { font-size: 18px; margin-bottom: 20px; font-weight: 600; }
.rem-popup-time { color: var(--text-muted); margin-bottom: 30px; }

.flex-center { display: flex; align-items: center; }
.lang-select { 
    background: var(--bg-color); color: var(--text-primary); 
    border: 2px solid var(--primary); border-radius: 8px; 
    padding: 6px 30px 6px 10px; font-size: 14px; margin-right: 10px; 
    cursor: pointer; font-weight: 800; outline: none;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}

.privacy-alert { background: rgba(239, 68, 68, 0.1); color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }
.card-bordered { border: 1px solid var(--primary); }
.text-small-muted { font-size: 11px; color: var(--text-muted); margin-bottom: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 15px; }
.textarea-dark { width:100%; height:60px; background:rgba(0,0,0,0.3); color:white; border-radius:10px; border:1px solid var(--border-glass); }
.mt-15 { margin-top: 15px; }
.label-small { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 5px; }
.select-dark { background:rgba(0,0,0,0.3); color:white; border-radius:8px; padding:8px; border:1px solid var(--border-glass); }

.btn-back-tv { background:rgba(255,255,255,0.1); color:white; border:1px solid rgba(255,255,255,0.2); cursor:pointer; margin-left: 10px; }

.modal-media-overlay { background: rgba(0, 0, 0, 0.95) !important; }
.modal-media-content { max-width: 95% !important; background: transparent !important; border: none !important; box-shadow: none !important; }
.media-viewer-container { text-align: center; }
.media-element { max-width: 100%; max-height: 70vh; border-radius: 15px; box-shadow: 0 0 30px rgba(0, 0, 0, 0.5); }
.video-play-icon { margin-right: 15px; color: var(--primary); }

.btn-full { width: 100%; }
.mt-20 { margin-top: 20px; }

.hidden { display: none !important; }

/* v68.0: Geofencing Styles */
.gps-map-container {
    height: 300px !important; min-height: 300px !important; background: rgba(255,255,255,0.05) !important;
    border-radius: 20px;
    margin-top: 15px;
    border: 2px solid var(--border-glass);
    overflow: hidden;
    background: rgba(255,255,255,0.05);
}

.geofencing-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.radius-control-box {
    flex: 1;
    min-width: 140px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.radius-input {
    width: 60px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 800;
    text-align: right;
    font-size: 14px;
    outline: none;
}

.radius-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

/* v65.2: SmartHub Mobile Optimization */
@media screen and (max-width: 600px) {
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 15px;
        justify-content: space-between;
        gap: 8px;
    }
    .logo {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
        border-bottom: 1px solid var(--border-glass);
        padding-bottom: 5px;
    }
    .btn-back-tv {
        margin: 0;
        padding: 6px 10px;
        font-size: 11px;
        flex: 1;
        justify-content: center;
    }
    .header-right {
        margin: 0;
        flex: 1;
        justify-content: flex-end;
        gap: 5px;
        min-width: 120px; /* v66.2: Asegurar espacio para idioma y tema */
    }
    .lang-select {
        margin-right: 0;
        padding: 4px 15px 4px 5px;
        font-size: 11px;
        max-width: 65px;
    }
    .theme-switch {
        width: 50px;
        height: 26px;
        margin-left: 5px;
        flex-shrink: 0; /* v66.2: No dejar que se comprima */
    }
    .theme-switch .switch-thumb {
        width: 20px;
        height: 20px;
        top: 2px;
    }
    body.light-mode .switch-thumb {
        left: calc(100% - 22px);
    }
    #viva-online-status {
        display: none; /* Ahorrar espacio en mÃ³vil */
    }
}


/* --- AJUSTES DE ORDEN Y CENTRADO HUB TV v69.0 --- */
.centered-header {
    justify-content: center !important;
    padding: 20px 30px !important;
    min-height: 80px;
}

.centered-navigation {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 40px !important;
    width: 100% !important;
}

.centered-navigation .status-badge, 
.centered-navigation .dash-lang-container,
.centered-navigation .theme-switch,
.centered-navigation .back-tv-btn,
.centered-navigation .nav-item-btn {
    margin: 0 !important;
    white-space: nowrap !important;
}

/* Evitar que el media query de móvil rompa el centrado en el Hub de TV */
@media screen and (max-width: 900px) {
    .centered-header {
        flex-wrap: nowrap !important;
    }
    .centered-navigation {
        justify-content: center !important;
        gap: 20px !important;
    }
}


/* --- NAVEGACIÓN FLOTANTE PREMIUM v70 --- */
.bottom-nav {
    bottom: 20px !important;
    left: 20px !important;
    right: 20px !important;
    width: auto !important;
    height: 75px !important;
    border-radius: 25px !important;
    padding: 0 15px !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6) !important;
    border: 1px solid var(--primary) !important;
}

.nav-item {
    gap: 2px !important;
}

.nav-item i {
    font-size: 1.6rem !important;
}

.nav-call-btn {
    transform: translateY(-5px) !important;
    width: 60px !important;
    height: 60px !important;
}

/* Asegurar que el contenido no quede debajo de la nav flotante */
body {
    padding-bottom: 120px !important;
}


/* --- AUTO-AJUSTE UNIVERSAL DASHBOARD v74.0 --- */
.header {
    height: clamp(70px, 10vh, 100px) !important;
}

.logo h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem) !important;
}

.status-badge {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem) !important;
}

.bottom-nav {
    height: clamp(65px, 9vh, 85px) !important;
    gap: clamp(10px, 5vw, 40px) !important;
}

.nav-item i {
    font-size: clamp(1.4rem, 4vw, 2rem) !important;
}

.nav-item span {
    font-size: clamp(0.7rem, 1.2vw, 1rem) !important;
}

.card {
    padding: clamp(15px, 4vw, 30px) !important;
    border-radius: clamp(15px, 3vw, 30px) !important;
}

.card-title {
    font-size: clamp(1.1rem, 2.5vw, 1.6rem) !important;
}


/* --- CORRECCIÓN LINTS Y LIMPIEZA v74.1 --- */
.logo-hidden {
    display: none !important;
}

.btn-contact-call {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    transition: 0.3s !important;
}


/* Dashboard Side by Side Layout */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Linter Fixes and Layout Utilities */
.grid-2-cols { grid-template-columns: repeat(2, 1fr) !important; }
.grid-full-width { grid-column: 1 / -1 !important; }
