/* ==========================================================================
   SOVEREIGN RAG 2026 — COMPONENTE DE VISUALIZACIÓN ANALÍTICA (ECHARTS & BENTO)
   Estética: Luxury Dark Glassmorphism con Acentos Esmeralda, Cian y Violeta
   ========================================================================== */

.rag-chart-card {
    margin: 16px 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.rag-chart-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 16px 40px -4px rgba(0, 0, 0, 0.6), 0 0 24px rgba(6, 182, 212, 0.12);
}

/* Encabezado de la Tarjeta del Gráfico */
.rag-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
    gap: 10px;
}

.rag-chart-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.rag-chart-title-icon {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--emerald-400, #34d399);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.rag-chart-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary, #f8fafc);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barra de Herramientas Superior (Morpher Pills + Acciones) */
.rag-chart-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rag-chart-pill-group {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.rag-chart-type-pill {
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.rag-chart-type-pill:hover {
    color: var(--text-primary, #f8fafc);
    background: rgba(255, 255, 255, 0.06);
}

.rag-chart-type-pill.active {
    color: #0b0f19;
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* Botones de Acción (Exportar HD / Pantalla Completa) */
.rag-chart-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary, #94a3b8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rag-chart-action-btn:hover {
    color: var(--emerald-400, #34d399);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

/* Contenedor del Lienzo Canvas ECharts */
.rag-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 320px;
    padding: 10px;
    background: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.02) 0%, transparent 80%);
}

.rag-chart-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Vista Alternativa: Tabla Bento Embebida */
.rag-chart-table-view {
    display: none;
    padding: 12px;
    max-height: 340px;
    overflow-y: auto;
}

.rag-chart-table-view.active {
    display: block;
}

/* ==========================================================================
   TABLAS BENTO COMPARATIVAS MODERNAS EN EL CHAT
   ========================================================================== */

.rag-bento-table-wrap {
    margin: 16px 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
}

/* Header Bar Bento 2026 */
.rag-bento-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .rag-bento-table-header {
    background: linear-gradient(180deg, #F1ECE1, #E8E0D0);
    border-bottom: 1px solid rgba(22, 34, 56, 0.1);
}

.rag-bento-title-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rag-bento-icon {
    font-size: 13px;
}

.rag-bento-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rag-bento-badge-count {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

[data-theme="light"] .rag-bento-badge-count {
    background: rgba(22, 34, 56, 0.08);
}

.rag-bento-copy-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm, 6px);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rag-bento-copy-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--emerald-400);
}

[data-theme="light"] .rag-bento-copy-btn {
    background: rgba(22, 34, 56, 0.04);
    border-color: rgba(22, 34, 56, 0.15);
}

.rag-bento-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar sutil para tablas */
.rag-bento-table-scroll::-webkit-scrollbar {
    height: 6px;
}
.rag-bento-table-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.rag-bento-table-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.rag-bento-table-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 0.5);
}

.rag-bento-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    text-align: left;
    white-space: nowrap;
}

.rag-bento-table th {
    background: rgba(30, 41, 59, 0.85);
    color: var(--text-primary, #f8fafc);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 2;
}

.rag-bento-table td {
    padding: 10px 14px;
    color: var(--text-secondary, #cbd5e1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s ease;
}

.rag-bento-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.rag-bento-table tr:hover td {
    background: rgba(56, 189, 248, 0.06);
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--emerald-400);
}

/* Badges Inteligentes de Celdas */
.bento-badge {
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.bento-badge.emerald {
    background: rgba(16, 185, 129, 0.16);
    color: var(--emerald-400);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.bento-badge.amber {
    background: rgba(245, 158, 11, 0.16);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.bento-badge.rose {
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.bento-badge.sky {
    background: rgba(56, 189, 248, 0.16);
    color: var(--sky-400);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.bento-mono-num {
    font-family: var(--font-mono, "Consolas", monospace);
    font-weight: 600;
    color: var(--text-primary);
}

/* Pie de Tabla con Metadatos */
.rag-bento-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-size: 11px;
    color: var(--text-muted, #64748b);
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ==========================================================================
   TRANSICIÓN CINEMATOGRÁFICA AUTO-FOCUS MODE EN ESCRITORIO
   ========================================================================== */

.app-container {
    transition: grid-template-columns 0.45s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Indicador flotante cuando el panel se contrae automáticamente */
.rag-focus-mode-badge {
    position: absolute;
    top: 14px;
    left: 18px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald-400, #34d399);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeInDown 0.35s ease;
}

/* ==========================================================================
   RESPONSIVIDAD MÓVIL (1 Y 2 PANTALLAS / PLEGABLES)
   ========================================================================== */

@media (max-width: 768px) {
    .rag-chart-card {
        margin: 12px 0;
        border-radius: 10px;
    }

    .rag-chart-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .rag-chart-toolbar {
        width: 100%;
        justify-content: space-between;
    }

    .rag-chart-pill-group {
        flex: 1;
        justify-content: space-between;
    }

    .rag-chart-type-pill {
        padding: 3px 7px;
        font-size: 10px;
    }

    .rag-chart-canvas-wrap {
        height: 260px;
        padding: 6px;
    }

    .rag-bento-table {
        font-size: 11.5px;
    }

    .rag-bento-table th, 
    .rag-bento-table td {
        padding: 8px 10px;
    }
}

/* Móviles de pantalla muy estrecha (< 400px) */
@media (max-width: 400px) {
    .rag-chart-canvas-wrap {
        height: 230px;
    }

    .rag-chart-type-pill span {
        display: none; /* Dejar solo iconos si no hay espacio */
    }
}

/* ==========================================================================
   ESTILOS ESPECÍFICOS MODO CLARO RETRO-TECH (ECHARTS & BENTO)
   ========================================================================== */
[data-theme="light"] .rag-chart-card {
    background: #FFFFFF !important;
    border-color: rgba(22, 34, 56, 0.09) !important;
    box-shadow: 0 4px 20px rgba(22, 34, 56, 0.06) !important;
}
[data-theme="light"] .rag-chart-header {
    background: #FAF7F2 !important;
    border-bottom: 1px solid rgba(22, 34, 56, 0.07) !important;
}
[data-theme="light"] .rag-chart-title {
    color: #162238 !important;
}
[data-theme="light"] .rag-chart-title-icon {
    background: linear-gradient(135deg, rgba(255, 107, 74, 0.15), rgba(16, 185, 129, 0.15)) !important;
    border-color: #FFB39F !important;
    color: #EA580C !important;
}
[data-theme="light"] .rag-chart-type-pill {
    background: #FFFFFF !important;
    border-color: #CBD5E1 !important;
    color: #475569 !important;
}
[data-theme="light"] .rag-chart-type-pill:hover {
    border-color: #FF6B4A !important;
    color: #EA580C !important;
    background: #FFEAE3 !important;
}
[data-theme="light"] .rag-chart-type-pill.active {
    background: #FFEAE3 !important;
    border-color: #FF6B4A !important;
    color: #EA580C !important;
    box-shadow: 0 0 10px rgba(255, 107, 74, 0.25) !important;
}
[data-theme="light"] .rag-bento-table-wrap {
    background: #FFFFFF !important;
    border: 1px solid rgba(22, 34, 56, 0.09) !important;
    box-shadow: 0 4px 20px rgba(22, 34, 56, 0.06) !important;
}
[data-theme="light"] .rag-bento-table-scroll::-webkit-scrollbar-track {
    background: rgba(22, 34, 56, 0.04);
}
[data-theme="light"] .rag-bento-table-scroll::-webkit-scrollbar-thumb {
    background: rgba(22, 34, 56, 0.18);
}
[data-theme="light"] .rag-bento-table {
    background: #FFFFFF !important;
}
[data-theme="light"] .rag-bento-table th {
    background: #FAF7F2 !important;
    color: #162238 !important;
    border-bottom: 1px solid rgba(22, 34, 56, 0.09) !important;
}
[data-theme="light"] .rag-bento-table td {
    color: #162238 !important;
    border-bottom: 1px solid rgba(22, 34, 56, 0.06) !important;
}
[data-theme="light"] .rag-bento-table tr:nth-child(even) td {
    background: #FAF7F2 !important;
}
[data-theme="light"] .rag-bento-table tr:hover td {
    background: #FFEAE3 !important;
    color: #162238 !important;
}
[data-theme="light"] .rag-bento-table a {
    color: #EA580C !important;
    font-weight: 600;
}
[data-theme="light"] .rag-bento-table-footer {
    background: #FAF7F2 !important;
    color: #64748B !important;
    border-top: 1px solid rgba(22, 34, 56, 0.06) !important;
}
