/**
 * Story-First AI Insights Display Styles
 * ========================================
 * Professional, engaging narrative-focused design
 */

/* Story Insights Container */
#story-insights-container {
    margin-bottom: 24px;
    animation: fadeInUp 0.5s ease;
}

.story-insights-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.story-insights-panel:hover {
    border-color: var(--brand);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

/* Headline Section (Story Starter) */
.story-headline {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-bottom: 2px solid var(--brand);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.impact-icon {
    font-size: 28px;
    min-width: 40px;
    text-align: center;
}

.story-headline h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 200px;
}

.confidence-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.confidence-badge.confidence-high {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.confidence-badge.confidence-medium {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.confidence-badge.confidence-low {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Narrative Section (The Story) */
.story-narrative {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.narrative-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 16px;
}

.narrative-text p {
    margin: 0 0 12px 0;
}

.narrative-text p:last-child {
    margin-bottom: 0;
}

.narrative-text strong {
    color: var(--brand);
    font-weight: 600;
}

.narrative-text em {
    font-style: italic;
    color: var(--muted);
}

/* Key Insight Box */
.key-insight-box {
    background: rgba(99, 102, 241, 0.05);
    border-left: 4px solid var(--brand);
    padding: 12px 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.key-insight-box i {
    color: var(--brand);
    font-size: 18px;
    flex-shrink: 0;
}

.key-insight-box span {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

/* Data Points Section */
.story-data-points {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.data-points-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    /* user-select: none; */
    transition: background 0.2s ease;
}

.data-points-header:hover {
    background: rgba(99, 102, 241, 0.05);
}

.data-points-header i {
    color: var(--brand);
    font-size: 16px;
}

.data-points-header span {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.toggle-data-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    transition: all 0.2s ease;
}

.toggle-data-btn:hover {
    color: var(--brand);
}

.toggle-data-btn.expanded {
    transform: rotate(180deg);
}

.data-points-content {
    padding: 0 24px 20px 24px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.data-point {
    background: var(--input-bg);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    text-align: center;
}

.data-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}

.data-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.data-change {
    font-size: 12px;
    font-weight: 600;
}

.data-change.positive {
    color: #4caf50;
}

.data-change.negative {
    color: #f44336;
}

/* Action Section */
.story-action {
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.05) 0%, rgba(33, 150, 243, 0.05) 100%);
    border-left: 4px solid #4caf50;
}

.action-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.action-header i {
    color: #4caf50;
    font-size: 16px;
}

.action-header span {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-content {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    margin-left: 26px;
}

/* Controls Section */
.story-controls {
    padding: 16px 24px;
    display: flex;
    gap: 8px;
    background: var(--input-bg);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.control-btn {
    padding: 8px 16px;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #5b5ecc;
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

/* Data-First Mode (Alternative View) */
.story-insights-panel.data-first-mode {
    .story-narrative {
        order: 2;
    }

    .story-data-points {
        order: 1;
        border-bottom: none;
    }

    .data-points-content {
        display: block !important;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .story-insights-panel {
        border-radius: 6px;
    }

    .story-headline {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 8px;
    }

    .story-headline h2 {
        font-size: 16px;
    }

    .confidence-badge {
        align-self: flex-start;
    }

    .story-narrative {
        padding: 16px;
    }

    .narrative-text {
        font-size: 13px;
    }

    .data-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .story-action {
        padding: 16px;
    }

    .story-controls {
        padding: 12px;
        gap: 6px;
    }

    .control-btn {
        padding: 6px 12px;
        font-size: 11px;
        flex: 1;
        justify-content: center;
    }
}

/* Dark mode optimization */
:root[data-theme="dark"] .story-insights-panel {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(71, 85, 105, 0.3);
}

:root[data-theme="dark"] .story-headline {
    background: rgba(99, 102, 241, 0.08);
}

:root[data-theme="dark"] .key-insight-box {
    background: rgba(99, 102, 241, 0.08);
}

:root[data-theme="dark"] .story-action {
    background: rgba(76, 175, 80, 0.08);
}

:root[data-theme="dark"] .data-point {
    background: rgba(51, 65, 85, 0.5);
    border-color: rgba(71, 85, 105, 0.2);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.story-insights-panel {
    animation: fadeInUp 0.5s ease-out;
}

/* Loading state */
.story-insights-panel.loading {
    opacity: 0.7;
    pointer-events: none;
}

.story-insights-panel.loading .story-narrative {
    animation: pulse 2s infinite;
}
