/* [EXCALIBUR SEAL] - S﻿‍﻿O﻿‌﻿V﻿E﻿﻿R‌‍‌​E‌​​I​‌G‌﻿​N‍​‌ ​I‌N﻿﻿‍T​﻿​‌E﻿‌​L‍L​​E﻿‍C​‍​T‍‍U‌‍A﻿‌‍​L​ ‍‍﻿​P‌﻿‌​R﻿​﻿O﻿P﻿E﻿﻿‍‌R﻿‍‌‌T​​​‍Y‍‍:​‍ ‍​G﻿​﻿u‌‍i﻿‍‌l﻿﻿﻿l﻿e​‍​r‌​‍‍m‌‌o‌ ﻿‌‍﻿A​‍r‌﻿‌t​u‌r‌o﻿﻿ ‍‌L‌﻿‌‍e​ó​‍​‌n​‍​ ‍﻿H﻿e﻿‍﻿s​‌﻿s​​ ‌-​ ‌‌﻿‌M‌Q​‍​N‍‍‌ ﻿‌‍​2​0​﻿​2‌6‌‍ */
/* mqn-overrides.css [V9.5.4] - BLINDAJE DE CAPAS PARA CHAT */

#wa-chat-area-container {
    position: relative;
    z-index: 10;
    overflow-x: hidden;
    background: var(--bg-neumo, #f5f7fa);
}

#chat-msgs {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 12px;
    z-index: 11;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Forzar que los mensajes salientes no sean tapados por el sidebar lateral */
.msg-wrap.sal {
    justify-content: flex-end !important;
    padding-right: 10px;
    position: relative;
    z-index: 12;
}

.bubble.sal {
    background: var(--green-msg, #e1fdec) !important;
    box-shadow: var(--shadow-out, 4px 4px 8px #bebebe) !important;
    border-radius: 18px 18px 2px 18px !important;
    max-width: 85% !important;
}

/* Si el sidebar CRM estÃƒÂ¡ activo, el chat debe encogerse */
#wa-layout {
    display: flex;
    width: 100vw;
}

#wa-crm-sidebar-container {
    z-index: 100 !important;
    box-shadow: -5px 0 15px rgba(0,0,0,0.05);
}

/* BLOQUE DE LEGIBILIDAD DE CITAS [V12.2] */
.msg-quoted {
    font-size: 0.95em !important;
    line-height: 1.35 !important;
    margin-bottom: 6px !important;
    background: rgba(0,0,0,0.04) !important;
    border-left: 4px solid var(--primary-color, #007bff) !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
}

.msg-quoted-txt {
    font-size: 1em !important; /* Forzar 100% relativo al contenedor de cita */
    color: var(--text-muted, #555) !important;
    font-weight: 500 !important;
    display: block !important;
}

/* [V18.2] SIDEBAR RADAR - ICONOGRAFÃƒÂA DE ALTA FIDELIDAD */
.chat-meta {
    display: flex;
    align-items: center;
    gap: 6px; 
}

.pin-icon {
    color: #8696a0; 
    transform: rotate(45deg);
    flex-shrink: 0;
}

.chat-fijado {
    background-color: rgba(0,0,0,0.02) !important; /* Sombreado sutil MQN */
}

.cv.active.chat-fijado {
    background-color: var(--bg-active, #e9edef) !important;
}

/* ----------------------------------------------------------
   LUCIFER V81 - CRM 360 OMEGA (INYECCIÃ“N DE SOBERANÃA)
   ---------------------------------------------------------- */

/* TERMÃ“METRO DINÃMICO */
.potential-bar-fill.score-low  { background: linear-gradient(90deg, #ff4757, #ff6b81) !important; box-shadow: 0 0 10px rgba(255,71,87,0.4); }
.potential-bar-fill.score-med  { background: linear-gradient(90deg, #f5a623, #f7b733) !important; box-shadow: 0 0 10px rgba(245,166,35,0.4); }
.potential-bar-fill.score-high { background: linear-gradient(90deg, #2ecc71, #00d4aa) !important; box-shadow: 0 0 10px rgba(46,204,113,0.4); }

#crm360-potencial-label {
    font-size: 0.65em;
    font-weight: 1000;
    letter-spacing: 1px;
    margin-top: 4px;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

/* LÃNEA DE TIEMPO NEUMÃ“RFICA (SOLDADURA INDUSTRIAL) */
.crm-timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 15px;
}

.crm-timeline::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-node {
    position: relative;
    margin-bottom: 20px;
    padding-left: 15px;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 15px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px var(--bg-primary);
    z-index: 2;
}

.pedido-master-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.1), -2px -2px 8px rgba(255,255,255,0.02);
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.pedido-master-row:hover {
    transform: translateX(4px);
    border-color: #718096;
}

.node-status-pill {
    font-size: 0.6em;
    font-weight: 1000;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.pill-completed { background: rgba(46,204,113,0.15); color: #2ecc71; border: 1px solid rgba(46,204,113,0.3); }
.pill-pending   { background: rgba(245,166,35,0.15); color: #f5a623; border: 1px solid rgba(245,166,35,0.3); }
.pill-canceled  { background: rgba(255,71,87,0.15);  color: #ff4757; border: 1px solid rgba(255,71,87,0.3); }


/* --- [V104.7] MATRIZ DE AGENTES 4X3 --- */
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem !important;
    padding: 10px 5px !important;
}


/* -- FIN DE SOBREESCRITURAS INDUSTRIALES -- */

/* -- SATURACIÃ“N DE LIENZO: CENTRO DE MANDO FULLSCREEN -- */
#wa-admin-panels-container {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 100% !important;
    display: none; /* Se activa por JS */
    padding: 0 !important;
    margin: 0 !important;
    background: var(--bg-main) !important;
}

#wa-admin-panels-container.active {
    display: flex !important;
}

#panel-intel {
    justify-content: flex-start !important;
    align-items: stretch !important;
    width: 100% !important;
    padding: 0 !important;
}

#intel-sections-view {
    justify-content: flex-start !important;
    align-items: stretch !important;
    flex: 1 1 auto !important;
    height: auto !important;
    width: 100% !important;
    max-width: none !important;
}

#intel-sec-agentes {
    margin-top: 0 !important;
    padding: 20px !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    height: max-content !important;
    width: 100% !important;
    max-width: none !important;
}

 
    margin-top: 0 !important;
    padding-top: 0 !important;
    align-content: flex-start !important;
    align-items: flex-start !important;
}

    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

/* ── EXPANSIÓN MASIVA: MATRIZ DE AGENTES ── */
#intel-sec-agentes {
    overflow-x: auto !important;
    overflow-y: auto !important;
    padding: 20px !important;
    width: 100% !important;
}

#agentes-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 25px !important;
    width: 100% !important;
    min-width: 1300px !important;
    align-items: start !important;
    align-content: start !important;
}

#agentes-grid .agent-card,
#agentes-grid .role-card {
    width: 100% !important;
    min-width: 280px !important;
    height: max-content !important;
}

/* ── BLINDAJE DE CADENA FLEXBOX (SUTURA DE CONTENEDORES INYECTADOS) ── */
#wa-layout > div[id$="-container"] {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* El contenedor del Kárdex/Contactos debe tener un ancho fijo para no encimarse */
#wa-sidebar-container {
    width: 350px !important;
    flex: 0 0 350px !important;
    border-right: 1px solid var(--border);
}

/* El área de mensajes toma el espacio restante */
#wa-chat-area-container {
    flex: 1 1 0% !important;
    min-width: 0 !important;
}

/* Forzar a los hijos internos a llenar los contenedores dinámicos */
#wa-sidebar, #wa-main, #chat-area {
    flex: 1 1 0% !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* ── [LEY 9] SUTURA V279: NEUTRALIZACIÓN DE INPUTS NATIVOS (HORARIOS) ── */
.neumo-time-input, .neumo-select-input {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* Ocultar el ícono de reloj de Chrome/Edge en type="time" */
.neumo-time-input::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none;
}
.neumo-time-input::-webkit-inner-spin-button,
.neumo-time-input::-webkit-clear-button {
    display: none !important;
}

/* Ocultar flecha del select y añadir padding equilibrado */
.neumo-select-input {
    text-align: center;
    text-align-last: center; /* Centrar el texto seleccionado en Chrome */
}

/* Estilo para Scrollbars Neumórficos y no Nativos */
.neumo-scroll::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}
.neumo-scroll::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.02);
    border-radius: 10px;
}
.neumo-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.45);
    border-radius: 10px;
}
.neumo-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.45);
}

/* ── ESTADOS FOCUS NEUMÓRFICOS (ANTI-AESTHETIC-DEBT) ── */
.neumo-time-input:focus, .neumo-select-input:focus {
    outline: none !important;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.1), inset -2px -2px 5px rgba(255,255,255,0.8), 0 0 8px rgba(59,130,246,0.5) !important;
    background: rgba(255,255,255,0.5) !important;
}

/* ── [V401] INYECCIÓN RESPONSIVA: CELULARES Y TABLETS ── */
@media screen and (max-width: 768px) {
    /* Navegación Swipeable */
    #nav {
        padding: 5px 10px !important;
        min-height: 50px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    
    .nav-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        justify-content: flex-start !important;
        padding-bottom: 5px !important;
    }
    
    .nav-tabs::-webkit-scrollbar {
        height: 0px !important; /* Ocultar barra en móvil */
        display: none !important;
    }

    #nav-active-profile span {
        display: none !important; /* Ocultar texto de rol en móvil */
    }

    #nav > div {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Modales Fluidos */
    .modal-content, .neumo-card {
        width: 95% !important;
        max-width: none !important;
        height: auto !important;
        max-height: 95vh !important;
        overflow-y: auto !important;
        padding: 15px !important;
    }

    #agente-diag-modal .modal-content {
        width: 95% !important;
        padding: 15px !important;
    }

    #modal-mily-tutora .neumo-card {
        width: 95% !important;
    }

    /* Pila Neumórfica (Stacking) para Paneles Internos */
    #panels-container > .panel {
        flex-direction: column !important;
    }

    #wa-layout {
        flex-direction: column !important;
    }

    #wa-sidebar-container,
    #wa-crm-sidebar-container {
        width: 100% !important;
        max-width: none !important;
        flex: 1 1 auto !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
    }
    
    #panel-intel {
        flex-direction: column !important;
    }

    #intel-sec-agentes {
        overflow-x: hidden !important;
        padding: 10px !important;
    }

    #agentes-grid {
        grid-template-columns: 1fr !important;
        min-width: 0 !important;
    }
    
    .pedido-master-row {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    /* Fix Mando Dashboard Grid */
    .grid-mando {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .widget-card {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* ── [V104.75] INYECCIÓN DE RESPONSIVIDAD MÓVIL (Soberanía Celular) ── */
@media screen and (max-width: 768px) {
    /* 1. Navbar fluido - Scroll horizontal oculto para tabs */
    #nav {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        padding-bottom: 5px !important;
    }
    
    #nav::-webkit-scrollbar {
        height: 0px;
        background: transparent;
    }
    
    #nav .nav-tab {
        flex: 0 0 auto !important;
        min-width: max-content !important;
    }

    #nav-active-profile {
        display: none !important; /* Ocultar en móvil para ganar espacio */
    }

    /* 2. Paneles Principales a 100% */
    #main-layout, #panels-container {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    .panel {
        width: 100% !important;
        max-width: 100vw !important;
        flex-direction: column !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    /* 3. Grillas (Forzar 1 columna) */
    .grid-mando,
    [class*="grid-"],
    .stats-grid,
    .pos-grid {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* 4. Modales a ancho de pantalla */
    .modal-content {
        width: 95% !important;
        max-width: 95vw !important;
        margin: 10px auto !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* 5. Tablas Deslizables (Scroll horizontal nativo) */
    .table-container,
    .table-responsive,
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }

    /* 6. Text Inputs a 100% */
    .glass-input, 
    .neumo-input, 
    .neumo-inset,
    input[type="text"],
    input[type="number"],
    select {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Ocultar Testigo de Offline en posiciones intrusivas */
    #mqn-reconnect-witness {
        bottom: 20px !important;
        left: 10px !important;
        right: 10px !important;
        text-align: center !important;
        justify-content: center !important;
        font-size: 0.75em !important;
    }
}

/* SUTURA V522: BLOQUE DE CONTENCIÓN MÓVIL */
@media screen and (max-width: 768px) {
    .modal-content, .mqn-panel {
        width: 95% !important;
        margin: 5% auto !important;
        overflow-x: hidden !important;
    }
    .flex-row, .grid-columns {
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
    }
}
