﻿
/* ???????????????????????????????????????????????????????????????
   20. ANALYTICS CHARTS
   ??????????????????????????????????????????????????????????????? */

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 24px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease),
                transform var(--duration) var(--ease-spring);
    animation: chartCardEnter 0.5s var(--ease) both;
}

.chart-card:nth-child(1) { animation-delay: 0.05s; }
.chart-card:nth-child(2) { animation-delay: 0.12s; }
.chart-card:nth-child(3) { animation-delay: 0.19s; }
.chart-card:nth-child(4) { animation-delay: 0.26s; }

@keyframes chartCardEnter {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chart-card:hover {
    border-color: var(--brand);
    box-shadow: 0 0 20px var(--brand-glow, rgba(99,102,241,0.15));
    transform: translateY(-2px);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-card-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card-header h3 i {
    color: var(--brand);
    font-size: 0.85rem;
    transition: transform var(--duration) var(--ease-spring);
}

.chart-card:hover .chart-card-header h3 i {
    transform: rotate(8deg) scale(1.1);
}

.chart-card-header .chart-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--brand-glow, rgba(99,102,241,0.15));
    color: var(--brand);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 240px;
}

.chart-canvas-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.chart-canvas-wrap.tall {
    height: 300px;
}

/* Gauge row */
.gauges-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 24px;
}

.gauge-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease),
                transform var(--duration) var(--ease-spring);
    animation: chartCardEnter 0.5s var(--ease) both;
}

.gauge-card:nth-child(1) { animation-delay: 0.33s; }
.gauge-card:nth-child(2) { animation-delay: 0.40s; }
.gauge-card:nth-child(3) { animation-delay: 0.47s; }

.gauge-card:hover {
    border-color: var(--brand);
    box-shadow: 0 0 20px var(--brand-glow, rgba(99,102,241,0.15));
    transform: translateY(-2px);
}

.gauge-canvas-wrap {
    width: 100%;
    height: 130px;
    position: relative;
}

.gauge-canvas-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Auto-refresh indicator */
.refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.12);
    transition: opacity var(--duration-fast) var(--ease);
}

.refresh-indicator .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success, #10b981);
    animation: pulseDot 2s ease infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.7); }
}

.refresh-indicator.refreshing {
    color: var(--brand);
}

.refresh-indicator.refreshing .pulse-dot {
    background: var(--brand);
    animation-duration: 0.5s;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .gauges-row {
        grid-template-columns: 1fr 1fr;
    }
    .forecast-summary-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .gauges-row {
        grid-template-columns: 1fr;
    }
    .chart-canvas-wrap {
        height: 200px;
    }
    .chart-canvas-wrap.tall {
        height: 240px;
    }
    .forecast-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ???????????????????????????????????????????????????????????????
   21. FORECAST / PREDICTIVE ANALYTICS
   ??????????????????????????????????????????????????????????????? */

.forecast-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
    position: relative;
}

.forecast-section::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), #a855f7, var(--brand));
    background-size: 200% 100%;
    animation: forecastShimmer 4s linear infinite;
    opacity: 0.5;
}

@keyframes forecastShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.forecast-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.forecast-section-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.forecast-section-header h2 i {
    color: #a855f7;
    font-size: 1rem;
}

.forecast-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.forecast-controls label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.forecast-controls select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease);
}

.forecast-controls select:focus {
    outline: none;
    border-color: var(--brand);
}

/* Summary cards */
.forecast-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.forecast-summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease),
                transform var(--duration) var(--ease-spring);
    animation: chartCardEnter 0.5s var(--ease) both;
}

.forecast-summary-card:nth-child(1) { animation-delay: 0.05s; }
.forecast-summary-card:nth-child(2) { animation-delay: 0.12s; }
.forecast-summary-card:nth-child(3) { animation-delay: 0.19s; }

.forecast-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.forecast-summary-card.fc-words { border-left: 3px solid #6366f1; }
.forecast-summary-card.fc-words:hover { border-color: #6366f1; box-shadow: 0 0 20px rgba(99,102,241,0.15); }
.forecast-summary-card.fc-sentences { border-left: 3px solid #10b981; }
.forecast-summary-card.fc-sentences:hover { border-color: #10b981; box-shadow: 0 0 20px rgba(16,185,129,0.15); }
.forecast-summary-card.fc-audio { border-left: 3px solid #06b6d4; }
.forecast-summary-card.fc-audio:hover { border-color: #06b6d4; box-shadow: 0 0 20px rgba(6,182,212,0.15); }

.forecast-summary-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.fc-words .forecast-summary-icon { background: rgba(99,102,241,0.12); color: #6366f1; }
.fc-sentences .forecast-summary-icon { background: rgba(16,185,129,0.12); color: #10b981; }
.fc-audio .forecast-summary-icon { background: rgba(6,182,212,0.12); color: #06b6d4; }

.forecast-summary-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.forecast-summary-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.forecast-summary-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.forecast-summary-delta {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--success, #10b981);
    display: flex;
    align-items: center;
    gap: 4px;
}

.forecast-summary-delta i.fa-arrow-down {
    color: var(--danger, #ef4444);
}

.chart-badge.forecast-badge {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

