/* ============================================================
   ONSITE UI SYSTEM — VisionOS Deep Blue PRO
   Versión: 4.0.0 — App-Style (No-Zoom & Smooth Scroll)
   Optimizado para: 100% Mobile, SEO y Velocidad.
   ============================================================ */

/* ------------------------------------------------------------
   ROOT VARIABLES
------------------------------------------------------------ */
:root {
    --bg-primary: #020617;
    --bg-secondary: #030712;

    --glass-low:  rgba(15, 23, 42, 0.55);
    --glass-mid:  rgba(15, 23, 42, 0.72);
    --glass-high: rgba(15, 23, 42, 0.88);

    --glass-border-soft: rgba(148, 163, 184, 0.14);
    --glass-border-strong: rgba(248, 250, 252, 0.22);

    --text-main: #f3f4f6;
    --text-soft: #94a3b8;
    --text-muted: #64748b;

    --accent-1: #6da8ff;
    --accent-2: #8f6dff;
    --accent-3: #22d3ee;
    --accent-1-glow: rgba(109, 168, 255, 0.45);

    --shadow-soft: 0 20px 50px rgba(0, 0, 0, 0.55);
    --shadow-floating: 0 30px 70px rgba(0, 0, 0, 0.75);

    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
    --radius-pill: 999px;

    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;

    --container-xl: 1400px;
}

/* ------------------------------------------------------------
   GLOBAL RESET & APP BEHAVIOR (No Zoom, Full Scroll)
------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    height: 100%;
}

body {
    font-family: 'SF Pro Text', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 50% 120%, #020617 0%, #030712 100%);
    color: var(--text-main);
    min-height: 100%;
    width: 100%;
    
    /* El scroll debe ser libre en el body */
    overflow-y: auto;
    overflow-x: hidden;

    /* BLOQUEO DE ZOOM TÁCTIL (Mantiene el scroll pero quita el double-tap zoom) */
    touch-action: manipulation; 
    
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Fondo decorativo VisionOS */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 10%, rgba(109,168,255,0.18), transparent 55%),
        radial-gradient(circle at 80% 80%, rgba(143,109,255,0.16), transparent 55%);
    pointer-events: none;
    z-index: -1;
}

/* ------------------------------------------------------------
   GLOBAL CONTAINER (Tesla Style Unified)
------------------------------------------------------------ */
.main-container, .page-shell {
    width: 100%;
    max-width: var(--container-xl);
    margin: 0 auto;
    padding-left: 12px;
    padding-right: 12px;
    padding-top: var(--space-6);
    padding-bottom: calc(var(--space-7) * 2); /* Espacio para bottom-nav */
}

@media (min-width: 768px) {
    .main-container, .page-shell {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ------------------------------------------------------------
   GLASS SYSTEM
------------------------------------------------------------ */
.glass-base {
    position: relative;
    border-radius: var(--radius-lg);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--glass-border-soft);
    background: var(--glass-mid);
    overflow: hidden;
}

/* ------------------------------------------------------------
   FORMS (Bloqueo de Zoom Automático en iOS)
------------------------------------------------------------ */
input, select, textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    color: var(--text-main);
    /* 16px es el mínimo para que iOS no haga zoom al enfocar */
    font-size: 16px; 
    transition: all .25s ease;
}

input:focus, select:focus {
    border-color: var(--accent-1);
    outline: none;
    background: rgba(15, 23, 42, 0.85);
}

/* ------------------------------------------------------------
   TYPOGRAPHY
------------------------------------------------------------ */
.heading-xl { font-size: 2.2rem; font-weight: 800; }
.heading-lg { font-size: 1.6rem; font-weight: 700; }
.heading-md { font-size: 1.2rem; font-weight: 600; }

.text-muted-caps {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

/* ------------------------------------------------------------
   SCROLLBAR (Estilo App)
------------------------------------------------------------ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

/* ------------------------------------------------------------
   HELPERS
------------------------------------------------------------ */
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ------------------------------------------------------------
   ALERTS COMPONENT (VisionOS Extension)
------------------------------------------------------------ */
.alerts-wrapper {
    padding: var(--space-5);
}

.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.alerts-count {
    background: var(--accent-1);
    color: var(--bg-primary);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 800;
}

.alert-card-vision {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 6px);
    margin-bottom: var(--space-3);
    border: 1px solid var(--glass-border-soft);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.2s ease, background 0.2s ease;
}

.alert-card-vision:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.06);
}

.alert-content {
    flex: 1;
}

.alert-header { /* Meta info dentro de la tarjeta */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.alert-desc {
    color: var(--text-main);
    line-height: 1.4;
}

.alert-badge-count {
    background: var(--glass-border-strong);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    margin-left: var(--space-3);
}

.alerts-footer {
    text-align: center;
    margin-top: var(--space-5);
}

.btn-ghost-link {
    color: var(--accent-1);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-ghost-link:hover {
    opacity: 0.8;
}

/* Animación de entrada */
.alert-card-vision {
    opacity: 0;
    animation: alert-slide-in 0.4s ease forwards;
    animation-delay: calc(var(--anim-order) * 0.1s);
}

@keyframes alert-slide-in {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}
.activity-card { padding: var(--space-5); }

.module-header { margin-bottom: var(--space-6); }
.accent-dot { color: var(--accent-1); margin-right: 8px; }

.activity-row {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.activity-indicator {
    width: 3px;
    border-radius: 10px;
    flex-shrink: 0;
}
.activity-indicator.active { 
    background: var(--accent-3); 
    box-shadow: 0 0 10px var(--accent-3); 
}

.activity-content { flex: 1; min-width: 0; /* Vital para truncar texto */ }

.row-top { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.user-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time-stamp { font-size: 10px; color: var(--text-muted); }

.row-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.site-name {
    font-size: 12px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.status-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    font-weight: 800;
}

.view-all-btn {
    display: block;
    text-align: center;
    padding: 12px;
    font-size: 12px;
    color: var(--accent-1);
    text-decoration: none;
    border-top: 1px solid var(--glass-border-soft);
    margin-top: 10px;
}


/* --- ALERTS MODULE — VISIONOS DEEP BLUE PRO --- */

.alerts-wrapper {
    padding: var(--space-6);
    position: relative;
    overflow: hidden;
}

.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
}

.alerts-count {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    color: var(--text-soft);
}

/* Alert Card Base */
.alert-card-vision {
    display: flex;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    animation: alert-slide-in 0.6s forwards;
    animation-delay: calc(var(--anim-order) * 0.1s);
}

@keyframes alert-slide-in {
    to { opacity: 1; transform: translateY(0); }
}

.alert-card-vision:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    transform: scale(1.01) translateX(4px);
}

/* Severity Bars & Colors */
.alert-severity-bar {
    width: 4px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
    align-self: center;
}

/* High Severity (Critical) */
.alert-high {
    background: rgba(255, 59, 48, 0.05);
    border-left: 1px solid rgba(255, 59, 48, 0.2);
}
.alert-high .alert-severity-bar { 
    background: #ff3b30; 
    box-shadow: 0 0 12px rgba(255, 59, 48, 0.5); 
}
.alert-high .alert-severity-label { color: #ff453a; }

/* Medium Severity (Warning) */
.alert-medium .alert-severity-bar { 
    background: #ffcc00; 
    box-shadow: 0 0 12px rgba(255, 204, 0, 0.4); 
}
.alert-medium .alert-severity-label { color: #ffd60a; }

/* Low Severity (Info) */
.alert-low .alert-severity-bar { 
    background: var(--accent-1); 
    box-shadow: 0 0 12px var(--accent-1-glow); 
}

/* Typography & Content */
.alert-content {
    flex: 1;
    min-width: 0; /* Previene desbordamiento de texto */
}

.alert-type-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.alert-desc {
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Pro-touch: Trunca texto largo en móvil */
}

.alert-badge-count {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--accent-1);
    color: #000;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 6px;
    box-shadow: 0 0 10px var(--accent-1-glow);
}

.alerts-footer {
    text-align: center;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Responsividad Móvil Extrema */
@media (max-width: 480px) {
    .alert-card-vision {
        padding: 12px;
        gap: 12px;
    }
    .alert-severity-bar { height: 30px; }
    .alert-type-title { font-size: 13px; }
    .alert-desc { font-size: 12px; }
}

/* Insights Module Specifics */
.insights-container { padding: var(--space-6); }

.insights-grid-vision {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
}

.insight-sub-card {
    padding: var(--space-5);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
}

.insight-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.insight-row:last-child { border-bottom: none; }

/* Semantic Classes */
.color-accent-1 { color: var(--accent-1); }
.color-accent-2 { color: var(--accent-2); }
.color-accent-3 { color: var(--accent-3); }
.empty-state-text { font-size: 13px; margin-top: var(--space-2); }

/* Purple Badge Override */
.badge-purple {
    background: rgba(143, 109, 255, 0.1);
    color: var(--accent-2);
    border: 1px solid rgba(143, 109, 255, 0.2);
}

@media (max-width: 640px) {
    .insights-grid-vision { grid-template-columns: 1fr; }
    .insights-container { padding: var(--space-4); }
}
