/* ==========================================================================
   ESTILOS: PREDICTOR A CIERRE DE PERIODOS & DIAGNÓSTICO IA GEMINI 3.8 FLASH
   Diseño de Alta Densidad Ejecutiva y Confiabilidad Minera
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BANNER DE PREDICCIONES A CIERRE (SEMANA & MES)
   -------------------------------------------------------------------------- */
.cp-predictions-bar {
    margin: 10px 16px 6px 16px;
    position: relative;
    z-index: 10;
}

.cp-pred-container {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: stretch;
}

/* Tarjeta de Predicción */
.cp-pred-card {
    background: linear-gradient(135deg, rgba(26, 32, 44, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.cp-pred-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.cp-pred-card.red {
    border-left: 4px solid #ef4444;
}

.cp-pred-card.yellow {
    border-left: 4px solid #f59e0b;
}

.cp-pred-card.green {
    border-left: 4px solid #10b981;
}

/* Cabecera de Tarjeta */
.cp-pred-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.cp-pred-badge-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cp-pred-icon {
    font-size: 15px;
}

.cp-pred-pill {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #e2e8f0;
}

.cp-pred-source-tag {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-weight: 600;
}

.cp-pred-timeframe {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

/* Fila de Métricas (Math Flow) */
.cp-pred-metrics-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.cp-pred-metric-box {
    display: flex;
    flex-direction: column;
}

.cp-pred-metric-title {
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.cp-pred-value {
    font-size: 18px;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.cp-pred-value small {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 2px;
}

.cp-pred-value.text-muted {
    color: #cbd5e1;
}

.cp-pred-value.text-deficit {
    color: #f87171;
}

.cp-pred-subinfo {
    font-size: 10px;
    color: #64748b;
    margin-top: 2px;
}

.cp-pred-subinfo strong {
    color: #94a3b8;
}

.cp-pred-sep {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    padding: 0 4px;
}

.cp-pred-badge-var {
    font-size: 10px;
    font-weight: 700;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
    margin-top: 3px;
}

/* Atribución Causal: KPI Culpable */
.cp-pred-culprit-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.cp-pred-culprit-label {
    font-size: 10px;
    font-weight: 700;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: block;
    margin-bottom: 4px;
}

.cp-pred-culprit-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    color: #fbbf24;
}

.cp-pred-culprit-badge strong {
    color: #fef08a;
}

.cp-pred-culprit-impact {
    font-size: 10px;
    color: #fca5a5;
    font-weight: 700;
}

.cp-pred-culprit-desc {
    font-size: 10.5px;
    color: #94a3b8;
    margin: 4px 0 0 0;
    line-height: 1.35;
}

/* Barra Lateral de Acciones */
.cp-pred-actions-aside {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.cp-btn-ai-diagnostic {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
    transition: all 0.2s ease;
    text-align: left;
}

.cp-btn-ai-diagnostic:hover {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.5);
}

.ai-sparkle {
    font-size: 20px;
}

.ai-btn-text {
    display: flex;
    flex-direction: column;
}

.ai-btn-text strong {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ai-btn-text small {
    font-size: 10px;
    color: #ddd6fe;
    font-weight: 500;
}

.cp-btn-refresh-pred {
    background: rgba(30, 41, 59, 0.85);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.cp-btn-refresh-pred:hover {
    background: rgba(51, 65, 85, 0.95);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.25);
}

/* --------------------------------------------------------------------------
   2. MODAL DE DIAGNÓSTICO IA (GEMINI 3.8 FLASH)
   -------------------------------------------------------------------------- */
.cp-ai-diag-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 29, 0.82);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.cp-ai-diag-modal {
    background: #0f172a;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 14px;
    width: 900px;
    max-width: 95vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(124, 58, 237, 0.2);
    overflow: hidden;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cp-ai-diag-header {
    background: linear-gradient(90deg, #1e1b4b, #0f172a);
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cp-ai-diag-badge-ia {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #c4b5fd;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ai-sparkle-dot {
    width: 6px;
    height: 6px;
    background: #a855f7;
    border-radius: 50%;
    box-shadow: 0 0 8px #a855f7;
}

.cp-ai-diag-title {
    font-size: 17px;
    font-weight: 800;
    color: #f8fafc;
    margin: 0;
    letter-spacing: 0.2px;
}

.cp-ai-diag-subtitle {
    font-size: 11.5px;
    color: #94a3b8;
    margin: 4px 0 0 0;
}

.cp-ai-diag-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cp-ai-diag-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

/* Barra de Controles de Consulta */
.cp-ai-diag-controls-bar {
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.cp-ai-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-ai-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #cbd5e1;
}

.cp-ai-select {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.cp-ai-select:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.cp-btn-run-diagnosis {
    margin-left: auto;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35);
    transition: all 0.2s ease;
}

.cp-btn-run-diagnosis:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(99, 102, 241, 0.5);
}

/* Área de Contenido Principal */
.cp-ai-diag-content-area {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 380px;
    background: #090d16;
}

/* Estado Vacío */
.cp-ai-empty-state {
    text-align: center;
    padding: 40px 20px;
    max-width: 550px;
    margin: 0 auto;
}

.cp-ai-empty-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.cp-ai-empty-state h3 {
    font-size: 16px;
    color: #f1f5f9;
    margin-bottom: 8px;
}

.cp-ai-empty-state p {
    font-size: 12.5px;
    color: #94a3b8;
    line-height: 1.5;
}

.cp-ai-features-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

.cp-ai-features-pills span {
    font-size: 11px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
}

/* Estado Cargando */
.cp-ai-loading-state {
    text-align: center;
    padding: 60px 20px;
}

.cp-ai-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #a855f7;
    border-radius: 50%;
    margin: 0 auto 16px auto;
    animation: spin 0.8s linear infinite;
}

.cp-ai-loading-state h4 {
    font-size: 15px;
    color: #f8fafc;
    margin-bottom: 6px;
}

.cp-ai-loading-state p {
    font-size: 12px;
    color: #94a3b8;
}

/* Resultados Markdown */
.cp-ai-results-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 11.5px;
    color: #94a3b8;
}

.cp-ai-results-meta strong {
    color: #f8fafc;
}

.cp-ai-markdown-body {
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.6;
}

.cp-ai-markdown-body h1,
.cp-ai-markdown-body h2,
.cp-ai-markdown-body h3 {
    color: #f8fafc;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
}

.cp-ai-markdown-body h3 {
    font-size: 14.5px;
    color: #c4b5fd;
}

.cp-ai-markdown-body ul,
.cp-ai-markdown-body ol {
    margin: 8px 0 12px 20px;
    padding-left: 0;
}

.cp-ai-markdown-body li {
    margin-bottom: 6px;
}

.cp-ai-markdown-body strong {
    color: #ffffff;
    font-weight: 600;
}

.cp-ai-markdown-body hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 16px 0;
}

/* Pie de Modal */
.cp-ai-diag-footer {
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cp-ai-footer-note {
    font-size: 11px;
    color: #64748b;
}

.cp-ai-footer-note strong {
    color: #94a3b8;
}

.cp-ai-footer-actions {
    display: flex;
    gap: 8px;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* Responsive */
@media (max-width: 1024px) {
    .cp-pred-container {
        grid-template-columns: 1fr;
    }
    .cp-pred-actions-aside {
        flex-direction: row;
    }
}
