/* 13-03 / 13-09 — the AI portal's dashboard filter card, sections, metrics grid, chart rows and Top 6 tiles, shared by the voice and chat dashboards. */
.kb-dash-filter {
    padding: var(--space-5);
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.kb-dash-filter__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.kb-dash-filter__updated {
    margin-top: var(--space-3);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.kb-dash-section {
    margin-bottom: var(--space-7, 2rem);
}

.kb-dash-section__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-5);
    font-size: 1.25rem;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.kb-dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* The portal's .charts-row: side by side, stacked on narrow screens. */
.kb-charts-row {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    margin-top: 1.5rem;
}

.kb-charts-row--half > .kb-chart-card {
    flex: 0 0 calc(50% - 0.75rem);
    max-width: calc(50% - 0.75rem);
    margin-left: auto;
}

.kb-chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex: 1;
    min-height: 320px;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 768px) {
    .kb-charts-row {
        flex-direction: column;
    }

    .kb-charts-row--half > .kb-chart-card {
        flex: 1;
        max-width: none;
        margin-left: 0;
    }
}

.kb-dash-filter__subset {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--info-bg);
    color: var(--info-fg);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.kb-charts-row--spaced {
    margin-top: 2rem;
}

.kb-charts-row--half-left > .kb-chart-card {
    flex: 0 0 calc(50% - 0.75rem);
    max-width: calc(50% - 0.75rem);
}

.kb-dash-region {
    margin-top: 2rem;
}

.kb-dash-section__title--sub {
    font-size: 1.1rem;
    margin-bottom: var(--space-4);
}

.kb-dash-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.kb-dash-section__header .kb-dash-section__title {
    margin: 0;
}

/* The portal's Top 6 tiles (.agents-grid / .agent-card). */
.kb-top-venues {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.kb-top-venue {
    display: block;
    padding: var(--space-5);
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.kb-top-venue:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--info);
}

.kb-top-venue:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.kb-top-venue__header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.kb-top-venue__name {
    font-size: 1.25rem;
    font-weight: var(--weight-semibold);
    line-height: 1.3;
    color: var(--text-primary);
}

.kb-top-venue__metrics {
    display: flex;
    gap: 2rem;
}

.kb-top-venue__metric {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.kb-top-venue__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.kb-top-venue__label {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .kb-charts-row--half-left > .kb-chart-card {
        flex: 1;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kb-top-venue,
    .kb-top-venue:hover {
        transition: none;
        transform: none;
    }
}

/* Calls Over Time: venues listed beside the stacked bars, busiest first; below them on narrow cards. */
.kb-over-time {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-start;
}

@media (max-width: 768px) {
    .kb-over-time__legend {
        max-width: none;
    }
}

.kb-over-time__chart {
    flex: 1 1 240px;
    min-width: 0;
}

.kb-over-time__legend {
    flex: 1 0 200px;
    max-width: 240px;
    max-height: 400px;
    overflow-y: auto;
    margin: 0;
    padding: 0 var(--space-1) 0 0;
    list-style: none;
    font-size: 0.8125rem;
}

.kb-over-time__legend a {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.3rem var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
}

.kb-over-time__legend a:hover,
.kb-over-time__legend a:focus-visible {
    background: var(--hover-bg);
}

.kb-over-time__swatch {
    flex: 0 0 auto;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
}

.kb-over-time__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-over-time__count {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
