/* ==============================================================================
   CESIA CORE OS v7.0 - ESTILOS EJECUTIVOS NEURONALES (DISEÑO JARVIS CORE)
   Inspirado en la arquitectura visual de Salazar & Asociados / Neurobita OS
   ============================================================================== */

:root {
    --cesia-cyan: #38bdf8;
    --cesia-blue: #0284c7;
    --cesia-purple: #c084fc;
    --cesia-pink: #ec4899;
    --cesia-emerald: #10b981;
    --cesia-amber: #f59e0b;
    --cesia-rose: #f43f5e;
    --cesia-dark: #020813;
    --cesia-space: radial-gradient(circle at 50% 25%, #06172e 0%, #020813 100%);
    --cesia-card: rgba(15, 23, 42, 0.88);
    --cesia-border: rgba(168, 85, 247, 0.3);
}

* {
    box-sizing: border-box;
}

body.cesia-body {
    background: #020813 !important;
    background-image: var(--cesia-space) !important;
    background-attachment: fixed !important;
    color: #e0f2fe;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Wrapper principal Cesia */
.cesia-standalone-wrapper {
    max-width: 1560px;
    margin: 0 auto;
    padding: 16px 14px;
}

/* Barra superior de navegación */
.cesia-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 16px;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.45);
}

.cesia-top-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
}

.cesia-top-brand h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2.5px;
    background: linear-gradient(135deg, #c084fc 0%, #f472b6 50%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.cesia-badge-plan {
    font-size: 9.5px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cesia-badge-free {
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #cbd5e1;
}

.cesia-badge-premium {
    background: rgba(236, 72, 153, 0.2);
    border: 1px solid rgba(236, 72, 153, 0.4);
    color: #f472b6;
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.35);
}

/* Botón Interruptor para regresar al Panel Visual */
.cesia-switch-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cesia-switch-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: #a855f7;
    color: #e9d5ff;
    transform: translateY(-1px);
}

/* Contenedor central Cesia */
.cesia-container {
    background: radial-gradient(circle at 50% 25%, #06172e 0%, #020813 100%);
    border-radius: 20px;
    padding: 22px;
    color: #e0f2fe;
    box-shadow: 0 10px 45px rgba(168, 85, 247, 0.15), inset 0 0 25px rgba(56, 189, 248, 0.05);
    position: relative;
    border: 1px solid rgba(168, 85, 247, 0.28);
    width: 100%;
}

/* Header */
.cesia-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(168, 85, 247, 0.2);
    padding-bottom: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.cesia-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 3px;
    color: #c084fc;
    text-shadow: 0 0 15px rgba(192, 132, 252, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cesia-badge {
    background: rgba(168, 85, 247, 0.18);
    border: 1px solid #c084fc;
    color: #e9d5ff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.35);
    white-space: nowrap;
}

/* Indicador de pulso verde JARVIS */
.pulse-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulseGlow 1.5s infinite;
}

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

/* Selector de Modo Consulta vs Autónomo (estilo JARVIS) */
.mode-switch-wrapper {
    display: flex;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 30px;
    padding: 3px;
    gap: 4px;
}

.mode-btn {
    padding: 8px 16px;
    border-radius: 25px;
    border: none;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mode-btn.active-consulta {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(2, 132, 199, 0.6);
}

.mode-btn.active-autonomo {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.6);
}

/* ==============================================================================
   COLUMNA IZQUIERDA: CEREBRO 3D JARVIS
   ============================================================================== */
.brain-viewport {
    position: relative;
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: radial-gradient(circle at center, rgba(30, 20, 55, 0.6) 0%, rgba(2, 8, 19, 0.98) 75%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: inset 0 0 30px rgba(168, 85, 247, 0.15);
}

#canvasBrain {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#canvasBrain:active {
    cursor: grabbing;
}

.brain-overlay-top {
    position: absolute;
    top: 14px;
    left: 16px;
    pointer-events: none;
    z-index: 10;
}

.brain-overlay-bottom {
    position: absolute;
    bottom: 14px;
    right: 16px;
    pointer-events: none;
    z-index: 10;
}

.brain-interactive-hint {
    position: absolute;
    bottom: 14px;
    left: 16px;
    font-size: 10.5px;
    color: #64748b;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10;
}

/* ==============================================================================
   CARDS HUD DE SUB-NEURONAS Y SUB-PROCESOS (ESTILO REQSALAZAR / JARVIS)
   ============================================================================== */
.hud-card {
    background: rgba(10, 25, 47, 0.75);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 14px;
    padding: 16px;
    backdrop-filter: blur(8px);
    margin-bottom: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.hud-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #c084fc;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(168, 85, 247, 0.18);
    padding-bottom: 6px;
}

/* Subprocesos atómicos desglosados en el HUD */
.sub-process-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sub-process-card:hover {
    border-color: #c084fc;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.2);
}

.sub-process-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-process-step:last-child {
    border-bottom: none;
}

/* ==============================================================================
   COLUMNA DERECHA: CONSOLA DE VOZ, CHAT Y TERMINAL
   ============================================================================== */
.voice-command-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 16px;
    padding: 16px;
    margin-top: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.mic-action-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid #ec4899;
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.35);
    flex-shrink: 0;
}

.mic-action-btn:hover {
    background: rgba(236, 72, 153, 0.3);
    color: #ffffff;
    transform: scale(1.05);
}

.mic-action-btn.listening {
    background: linear-gradient(135deg, #ec4899, #be185d);
    border-color: #f472b6;
    color: #ffffff;
    box-shadow: 0 0 25px rgba(236, 72, 153, 0.85);
    animation: micPulse 1.2s infinite alternate;
}

@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(236, 72, 153, 0.5); }
    100% { transform: scale(1.1); box-shadow: 0 0 25px rgba(236, 72, 153, 0.9); }
}

/* Switch Manos Libres */
.hands-free-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 11.5px;
    color: #94a3b8;
    user-select: none;
}

.hands-free-toggle input {
    display: none;
}

.toggle-switch-slider {
    width: 36px;
    height: 20px;
    background: #334155;
    border-radius: 20px;
    position: relative;
    transition: background 0.25s;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.toggle-switch-slider:before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    left: 2px;
    top: 2px;
    background: #cbd5e1;
    transition: transform 0.25s;
}

.hands-free-toggle input:checked + .toggle-switch-slider {
    background: #ec4899;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.6);
}

.hands-free-toggle input:checked + .toggle-switch-slider:before {
    transform: translateX(16px);
    background: #ffffff;
}

/* Terminal de Actividad y Chat con efecto Scanline */
.feed-terminal {
    background: rgba(2, 6, 23, 0.94);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 14px;
    padding: 14px;
    font-family: 'JetBrains Mono', -apple-system, monospace;
    font-size: 11.5px;
    height: 380px;
    overflow-y: auto;
    color: #cbd5e1;
}

/* Scanline efecto JARVIS */
.jarvis-scanline {
    position: relative;
}

.jarvis-scanline::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(236, 72, 153, 0.02), rgba(56, 189, 248, 0.01), rgba(168, 85, 247, 0.02));
    z-index: 2;
    background-size: 100% 3px, 6px 100%;
    pointer-events: none;
    opacity: 0.6;
}

/* Burbujas del Chat dentro de la terminal */
.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.55;
    font-size: 12px;
    margin-bottom: 12px;
    animation: fadeInMsg 0.2s ease;
}

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

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-bubble {
    flex: 1;
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 95%;
}

.chat-msg-user .chat-avatar {
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.chat-msg-user .chat-bubble {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #f8fafc;
}

.chat-msg-cesia .chat-avatar {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    box-shadow: 0 2px 10px rgba(236, 72, 153, 0.35);
    border: 1px solid rgba(236, 72, 153, 0.5);
}
.chat-msg-cesia .chat-bubble {
    background: rgba(24, 17, 45, 0.75);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #e2e8f0;
}

.chat-msg-system .chat-bubble {
    background: rgba(15, 23, 42, 0.6);
    border: 1px dashed rgba(168, 85, 247, 0.3);
    color: #94a3b8;
    font-size: 11px;
}

/* Custom scrollbar */
.feed-terminal::-webkit-scrollbar {
    width: 5px;
}
.feed-terminal::-webkit-scrollbar-track {
    background: rgba(5, 7, 17, 0.5);
}
.feed-terminal::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.4);
    border-radius: 10px;
}

/* ==============================================================================
   SECCIÓN INFERIOR: ACCIONES RÁPIDAS (WAKE CHIPS)
   ============================================================================== */
.wake-keys-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
}

.wake-chip {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 16px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wake-chip:hover, .wake-chip:active {
    background: rgba(168, 85, 247, 0.25);
    border-color: #c084fc;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
    transform: translateY(-1px);
}

/* ==============================================================================
   METODOLOGÍA CESIA: AGENTE DOM & RESALTADO VISUAL (PILAR 6)
   ============================================================================== */
.cesia-dom-highlight {
    outline: 2px solid #ec4899 !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.6) !important;
    transition: all 0.3s ease-in-out !important;
    animation: cesiaPulseOutline 1.5s infinite alternate ease-in-out !important;
}

@keyframes cesiaPulseOutline {
    0% {
        outline-color: #ec4899;
        box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
    }
    100% {
        outline-color: #c084fc;
        box-shadow: 0 0 25px rgba(192, 132, 252, 0.8);
    }
}

/* ==============================================================================
   PILAR 7: UX RESPONSIVE & OPTIMIZACIÓN DE ESPACIO EN MÓVILES (< 768px)
   ============================================================================== */
@media (max-width: 767px) {
    /* Ocultar etiquetas no esenciales para no saturar barras de herramientas */
    .cesia-mobile-hide-label,
    .cesia-status-badge-secondary {
        display: none !important;
    }

    /* Espacio prioritario para selectores operativos (sucursal, fecha, ejercicio) */
    .cesia-mobile-priority-bar {
        width: 100% !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        padding-bottom: 4px !important;
    }

    /* Top bar simplificada */
    .cesia-top-bar {
        padding: 8px 12px;
    }
    .cesia-top-brand h4 {
        font-size: 13px;
        letter-spacing: 1px;
    }
    .cesia-switch-btn {
        padding: 5px 9px;
        font-size: 10px;
    }
}

