/* ═══════════════════════════════════════════════════════════════════
 * Smart Insights + Tooltips
 * Adds explanations and context-aware insights to the analysis tab
 * ═══════════════════════════════════════════════════════════════════ */


/* ─── Smart Insights Section ─── */

.smart-insights-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    padding: 14px;
    grid-column: 1 / -1; /* span full width in grid */
}

.smart-insights-section h3 {
    color: #a78bfa;
    margin-bottom: 12px;
}


/* ─── Insight Card ─── */

.insight-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.insight-card:hover {
    background: rgba(15, 23, 42, 0.75);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateX(-2px);
}

.insight-card:last-child {
    margin-bottom: 0;
}

.insight-card.insight-alert {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(239, 68, 68, 0.05));
    border-color: rgba(251, 191, 36, 0.4);
}


/* ─── Insight Icon ─── */

.insight-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
}


/* ─── Insight Content ─── */

.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #c4b5fd;
    margin-bottom: 4px;
}

.insight-body {
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.95);
    line-height: 1.5;
}

.insight-body > div {
    margin-bottom: 4px;
}

.insight-body > div:last-child {
    margin-bottom: 0;
}

.insight-body strong {
    color: #fbbf24;
    font-weight: 700;
}


/* ─── Tooltip System ─── */

.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.4);
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: normal;
    width: max-content;
    max-width: 280px;
    text-align: right;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.has-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before {
    opacity: 1;
}

.has-tooltip:hover::after {
    transform: translateX(-50%) translateY(0);
}


/* ─── Distance label inside SMC items ─── */

.smc-dist {
    font-size: 0.7rem;
    color: rgba(203, 213, 225, 0.6);
    margin-right: 4px;
    font-weight: 500;
}


/* ─── Mobile responsive ─── */

@media (max-width: 768px) {
    .smart-insights-section {
        padding: 10px;
    }
    
    .insight-card {
        padding: 8px 10px;
        gap: 8px;
    }
    
    .insight-icon {
        font-size: 1.25rem;
    }
    
    .insight-title {
        font-size: 0.8rem;
    }
    
    .insight-body {
        font-size: 0.78rem;
    }
    
    /* Mobile tooltips: bottom instead of top */
    .has-tooltip::after {
        max-width: 240px;
        font-size: 0.72rem;
    }
}


/* ─── Hide tooltips on touch devices when not focused ─── */

@media (hover: none) {
    .has-tooltip::after,
    .has-tooltip::before {
        display: none;
    }
}


/* ─── Refresh button + spin animation ─── */

@keyframes spin-refresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#refresh-analysis-icon.spin {
    display: inline-block;
    animation: spin-refresh 1s linear infinite;
}

#refresh-analysis-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#refresh-analysis-btn:hover:not(:disabled) {
    transform: rotate(-15deg);
    transition: transform 0.2s ease;
}


/* ─── Refresh overlay (subtle loading inside tab body) ─── */

.refresh-overlay {
    color: #c4b5fd;
    font-size: 0.9rem;
}

.refresh-overlay .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(196, 181, 253, 0.3);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin-refresh 0.8s linear infinite;
}


/* ─── Sessions & Narrator insights ─── */

.sessions-insights,
.narrator-insights {
    margin-bottom: 16px;
}

.sessions-insights h3 {
    color: #a78bfa;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.narrator-insights h3 {
    color: #a78bfa;
    font-size: 0.95rem;
    margin-bottom: 10px;
}
