/* [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﻿ */
/* ════════════════════════════════════════
   CRM 360° LAYOUT SYSTEM — MQN 2026
   LEY 1: Fragmentación Estructural
   ════════════════════════════════════════ */

:root {
    --bg-primary:    #f0f3f8; /* Gris azulado ultra-claro para fondo */
    --bg-card:       #ffffff; /* Blanco Puro */
    --bg-elevated:   #f8f9fc; /* Elevación suave */
    --accent:        #6c63ff; /* Restaurado: Violeta MQN */
    --accent-glow:   rgba(108, 99, 255, 0.25);
    --accent-2:      #00d4aa; /* Restaurado: Menta Vibrante */
    --gold:          #f5a623; /* Restaurado: Oro Industrial */
    --platinum:      #a8b2c8;
    --silver:        #8a9bb2;
    --bronze:        #cd7f32;
    --text-primary:  #1a202c; /* Texto oscuro legible */
    --text-secondary:#4a5568;
    --text-muted:    #a0aec0;
    --border:        rgba(0,0,0,0.05); /* Borde sutil */
    --danger:        #ff4757;
    --success:       #2ecc71;
    --warning:       #f39c12;
    --transition:    all 0.25s cubic-bezier(0.4,0,0.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* ────── CONTENEDOR PRINCIPAL ────── */
#crm360-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
}

/* ────── HEADER ────── */
#crm360-header {
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
}

.header-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #ffffff; box-shadow: 4px 4px 10px #d1d9e6, -4px -4px 10px #ffffff;, var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: 900;
    color: #718096;
    flex-shrink: 0;
}

.header-title {
    font-size: 0.85em;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 0.65em;
    color: var(--text-secondary);
    margin-top: 1px;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    transition: var(--transition);
}

.icon-btn:hover {
    background: #ffffff; box-shadow: 4px 4px 10px #d1d9e6, -4px -4px 10px #ffffff;
    color: #718096;
    border-color: #718096;
    transform: translateY(-1px);
}

/* ────── ESTADO VACÍO ────── */
#crm360-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0.4;
    padding: 30px;
    text-align: center;
}

#crm360-empty i { font-size: 2.5em; }
#crm360-empty p { font-size: 0.8em; font-weight: 600; }

/* ────── SCROLL CONTENT AREA ────── */
#crm360-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    display: none;
}

#crm360-content.visible { display: block; }

#crm360-content::-webkit-scrollbar { width: 4px; }
#crm360-content::-webkit-scrollbar-track { background: transparent; }
#crm360-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ────── CONTEXT SWITCHER ────── */
#crm360-context-switch {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
}

.ctx-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.7em;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
}

.ctx-btn.active {
    background: #ffffff; box-shadow: 4px 4px 10px #d1d9e6, -4px -4px 10px #ffffff;
    border-color: #718096;
    color: #718096;
    box-shadow: 0 0 12px var(--accent-glow);
}

.ctx-btn:not(.active):hover {
    border-color: #718096;
    color: #718096;
}

/* ────── TABS ────── */
.crm-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
}

.crm-tab {
    flex: 1;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.68em;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.crm-tab.active {
    background: var(--bg-elevated);
    border-color: #718096;
    color: #718096;
}

.crm-tab:not(.active):hover {
    border-color: var(--border);
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* ────── LOADING & TOAST ────── */
#crm360-loader {
    position: absolute;
    inset: 52px 0 0 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-primary);
    z-index: 10;
}

#crm360-loader.visible { display: flex; }

.loader-spinner {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border);
    border-top-color: #718096;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
    font-size: 0.72em;
    font-weight: 700;
    color: var(--text-muted);
}

#crm360-toast {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 0.72em;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

#crm360-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#crm360-toast.error   { border-color: var(--danger);  color: var(--danger); }

/* ── [V401] INYECCIÓN RESPONSIVA CRM ── */
@media screen and (max-width: 768px) {
    .crm-tabs {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .crm-tab {
        padding: 12px !important;
        font-size: 0.8em !important;
    }

    #crm360-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
        padding-bottom: 15px !important;
    }

    .header-actions {
        width: 100% !important;
        justify-content: flex-end !important;
    }
    
    /* Envolver tablas en un scroll horizontal suave */
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
}
