/* ===========================================
   Charts & Gauges
   =========================================== */

/* Chart Container */
.chart-container {
    position: relative;
    height: 250px;
}

/* Overview Sentiment Breakdown canvas — shorter to fit the overview card */
.sentiment-chart-canvas {
    height: 190px;
    margin-bottom: 0.5rem;
}

/* Chart Section */
.chart-section {
    background: var(--c-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart-header h3,
.chart-header h4 {
    margin: 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Charts Grid */
.charts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* Sentiment/Usage Grids */
.sentiment-grid,
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.sentiment-card,
.usage-card {
    background: var(--c-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
}

.sentiment-card h4,
.usage-card h4 {
    margin: 0 0 1rem 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Gauge */
.gauge-container {
    margin: 0.75rem 0;
}

.gauge-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.gauge-label span:first-child {
    color: var(--text-secondary);
}

.gauge-label span:last-child {
    font-weight: 600;
}

.gauge-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.gauge-fill.low { background: var(--c-success); }
.gauge-fill.medium { background: var(--c-primary); }
.gauge-fill.high { background: var(--c-secondary); }

/* Rate Limit Bars */
.rate-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rate-bar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rate-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.rate-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rate-progress {
    height: 8px;
    background: var(--surface-progress);
    border-radius: 4px;
    overflow: hidden;
}

.rate-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.rate-fill.low { background: var(--c-success); }
.rate-fill.medium { background: var(--c-primary); }
.rate-fill.high { background: var(--c-secondary); }

/* Sentiment Bar */
.sentiment-bar-container {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.sentiment-segment {
    height: 100%;
    transition: width 0.3s;
}

.sentiment-segment.positive { background: var(--c-success); }
.sentiment-segment.neutral { background: var(--c-muted); }
.sentiment-segment.negative { background: var(--c-danger); }

/* Overview Sentiment Chart */
.sentiment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sentiment-header h4 {
    margin: 0;
}

.sentiment-header .view-btn {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.sentiment-header .view-btn:hover {
    background: var(--surface);
}

.sentiment-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.timeframe-select {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--c-bg);
    cursor: pointer;
}

.mode-toggle,
.toggle-mode-btn {
    padding: 0.2rem 0.35rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--c-bg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: fit-content;
}

.mode-icon {
    color: var(--text-primary);
}
.mode-toggle:hover,
.toggle-mode-btn:hover {
    background: var(--surface);
}

.sentiment-chart {
    display: flex;
    gap: 4px;
    height: 100px;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.sentiment-bar-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.bar-stack {
    width: 100%;
    height: 85px;
    display: flex;
    flex-direction: column-reverse;
    border-radius: 3px 3px 0 0;
    overflow: hidden;
    min-height: 4px;
}

.bar-segment {
    width: 100%;
    transition: height 0.3s ease;
}

.bar-segment.positive { background: var(--c-success); }
.bar-segment.neutral { background: var(--c-muted); }
.bar-segment.negative { background: var(--c-danger); }

.bar-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.bar-label-weekday {
    font-weight: 600;
}

.bar-label-date {
    font-size: 0.55rem;
    opacity: 0.75;
}

.sentiment-legend {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.sentiment-legend-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sentiment-legend-row.sentiment-legend-total {
    margin-top: 0.2rem;
    color: var(--text-secondary);
}

.sentiment-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.sentiment-legend .dot.positive { background: var(--c-success); }
.sentiment-legend .dot.neutral { background: var(--c-muted); }
.sentiment-legend .dot.negative { background: var(--c-danger); }

/* Type Filters */
.type-filters {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.type-filter {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.type-filter:hover { opacity: 0.85; }

.type-filter.active {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: var(--c-text-on-bright);
}

/* Type Filter Colors */
.type-filter.questions { background: var(--c-info-soft); border-color: color-mix(in srgb, var(--c-info), transparent 70%); color: var(--c-info-dim); }
.type-filter.technical { background: var(--c-muted-soft); border-color: color-mix(in srgb, var(--c-muted), transparent 70%); color: var(--c-muted-dim); }
.type-filter.helpful { background: var(--c-success-soft); border-color: color-mix(in srgb, var(--c-success), transparent 70%); color: var(--c-success-dim); }
.type-filter.social { background: color-mix(in srgb, var(--c-info), var(--c-bg) 90%); border-color: color-mix(in srgb, var(--c-info), transparent 80%); color: var(--c-info-dim); }
.type-filter.memes { background: var(--c-primary-soft); border-color: color-mix(in srgb, var(--c-primary), transparent 70%); color: var(--c-primary-dim); }
.type-filter.sarcastic { background: var(--c-special-soft); border-color: color-mix(in srgb, var(--c-special), transparent 70%); color: var(--c-special-dim); }
.type-filter.swearing { background: var(--c-secondary-soft); border-color: color-mix(in srgb, var(--c-secondary), transparent 70%); color: var(--c-secondary-dim); }

.type-filter.questions.active { background: var(--c-info); border-color: var(--c-info); color: var(--c-text-on-dark); }
.type-filter.technical.active { background: var(--c-muted); border-color: var(--c-muted); color: var(--c-text-on-dark); }
.type-filter.helpful.active { background: var(--c-success); border-color: var(--c-success); color: var(--c-text-on-dark); }
.type-filter.social.active { background: color-mix(in srgb, var(--c-info), var(--c-muted) 50%); border-color: color-mix(in srgb, var(--c-info), var(--c-muted) 50%); color: var(--c-text-on-dark); }
.type-filter.memes.active { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-text-on-bright); }
.type-filter.sarcastic.active { background: var(--c-special); border-color: var(--c-special); color: var(--c-text-on-dark); }
.type-filter.swearing.active { background: var(--c-secondary); border-color: var(--c-secondary); color: var(--c-text-on-dark); }

/* Type Breakdown */
.type-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.type-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0;
    border-radius: 4px;
    transition: background 0.15s;
}

.type-item:hover { background: var(--surface); }

.type-item .type-label {
    font-size: 0.8rem;
    color: var(--text-body);
    min-width: 80px;
}

.type-item .type-bar-container {
    flex: 1;
    height: 10px;
    background: var(--surface-hover);
    border-radius: 5px;
    overflow: hidden;
}

.type-item .type-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.type-bar.questions { background: var(--c-info); }
.type-bar.technical { background: var(--c-muted); }
.type-bar.helpful { background: var(--c-success); }
.type-bar.social { background: color-mix(in srgb, var(--c-info), var(--c-muted) 50%); }
.type-bar.memes { background: var(--c-primary); }
.type-bar.sarcastic { background: var(--c-special); }
.type-bar.swearing { background: var(--c-secondary); }
.type-bar.shilling { background: var(--c-secondary); }
.type-bar.fud { background: var(--c-danger); }

.type-item .type-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 35px;
    text-align: right;
    font-weight: 600;
}

/* Impact Breakdown */
.impact-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.impact-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.impact-row .impact-label {
    color: var(--text-secondary);
    min-width: 100px;
}

.impact-row .impact-bar-container {
    flex: 1;
    height: 8px;
    background: var(--surface-hover);
    border-radius: 4px;
    overflow: hidden;
}

.impact-row .impact-bar {
    height: 100%;
    border-radius: 4px;
}

.impact-bar.positive { background: var(--c-success); }
.impact-bar.negative { background: var(--c-danger); }

.impact-row .impact-value {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    font-size: 0.75rem;
}

/* Stats Row */
.stats-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border-radius: 8px;
    min-width: 90px;
}

.stat-item .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-item .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-item.positive .value { color: var(--c-success); }
.stat-item.negative .value { color: var(--c-danger); }
.stat-item.dim { opacity: 0.45; }
.sentiment-badge.dim { opacity: 0.4; }
