/* ═══════════════════════════════════════════════════════════════════════
   AI HUB — Foundry-inspired shell, corporate palette, theme-aware
   ═══════════════════════════════════════════════════════════════════════ */
.aih-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: calc(100vh - 48px);
    background: var(--rz-body-background-color);
}

.aih-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: var(--rz-base-background-color);
    border-right: 1px solid var(--rz-base-200);
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

.aih-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 1rem;
    border-bottom: 1px solid var(--rz-base-200);
    margin-bottom: 0.5rem;
}

.aih-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.aih-brand-icon .rzi { font-size: 1.25rem; }

.aih-brand-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--rz-text-title-color);
    line-height: 1.1;
}

.aih-brand-sub {
    font-size: 0.7rem;
    color: var(--rz-text-tertiary-color);
    letter-spacing: 0.02em;
}

.aih-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.aih-nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--rz-text-primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    transition: background 0.12s ease, color 0.12s ease;
}

.aih-nav-item:hover { background: var(--rz-base-100); }
.aih-nav-item .rzi { font-size: 1.05rem; color: var(--rz-text-secondary-color); }

.aih-nav-item.active {
    background: color-mix(in srgb, var(--rz-primary) 10%, transparent);
    color: var(--rz-primary);
    font-weight: 600;
}

.aih-nav-item.active .rzi { color: var(--rz-primary); }

.aih-sidebar-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--rz-base-200);
}

.aih-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: var(--rz-text-tertiary-color);
    text-decoration: none;
    font-size: 0.78rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.aih-sidebar-link:hover { background: var(--rz-base-100); color: var(--rz-text-primary-color); }
.aih-sidebar-link .rzi { font-size: 0.95rem; }

.aih-main {
    padding: 1.5rem 2rem;
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   Shared layout primitives for every hub section. Defined on the shell so
   they are available while ANY sub-section is rendered. Blazor style
   blocks inside sub-components only apply while that component is mounted.
   ═══════════════════════════════════════════════════════════════════════ */

.aih-section { display: flex; flex-direction: column; gap: 1.25rem; }

.aih-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.aih-section-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: var(--rz-text-title-color);
    letter-spacing: -0.01em;
}

.aih-section-sub {
    font-size: 0.85rem;
    color: var(--rz-text-tertiary-color);
    margin: 0.25rem 0 0;
}

.aih-loading, .aih-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 240px;
    color: var(--rz-text-tertiary-color);
}
.aih-empty .rzi { font-size: 2rem; }

/* KPI grid used across Overview and Conversations */
.aih-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* KPI card base (KpiCard component reuses the same look). */
.aih-kpi {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    background: var(--rz-base-background-color);
    border: 1px solid var(--rz-base-200);
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-width: 0;
}

.aih-kpi:hover {
    border-color: var(--rz-base-300);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Charts grid for Overview */
.aih-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.aih-card {
    background: var(--rz-base-background-color);
    border: 1px solid var(--rz-base-200);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.aih-card-wide { grid-column: span 2; }

.aih-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--rz-base-200);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--rz-text-primary-color);
    background: var(--rz-base-50, var(--rz-base-100));
}

.aih-card-head .rzi { color: var(--rz-text-tertiary-color); font-size: 1rem; }

.aih-card-hint {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--rz-text-tertiary-color);
    font-weight: 400;
}

.aih-card-body { padding: 1rem; min-height: 150px; }

.aih-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    color: var(--rz-text-tertiary-color);
    font-size: 0.8rem;
}

.aih-top-list { display: flex; flex-direction: column; gap: 0.55rem; }

.aih-top-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.2fr) minmax(80px, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.78rem;
}

.aih-top-label { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow: hidden; }
.aih-top-name { font-weight: 500; color: var(--rz-text-primary-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aih-top-bar { height: 6px; background: var(--rz-base-100); border-radius: 99px; overflow: hidden; }
.aih-top-fill { height: 100%; background: linear-gradient(90deg, var(--rz-primary-lighter), var(--rz-primary)); }
.aih-top-value { font-variant-numeric: tabular-nums; color: var(--rz-text-tertiary-color); white-space: nowrap; }

/* ─── Shared table used by Conversations and Traces ─── */
.aih-trace-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    background: var(--rz-base-background-color);
    border: 1px solid var(--rz-base-200);
    border-radius: 10px;
}

.aih-trace-table-wrap {
    background: var(--rz-base-background-color);
    border: 1px solid var(--rz-base-200);
    border-radius: 10px;
    overflow: auto;
}

.aih-trace-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.aih-trace-table thead th {
    text-align: left;
    padding: 0.7rem 0.95rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--rz-text-tertiary-color);
    border-bottom: 1px solid var(--rz-base-200);
    background: var(--rz-base-50, var(--rz-base-100));
    white-space: nowrap;
}

.aih-trace-table tbody td {
    padding: 0.7rem 0.95rem;
    border-bottom: 1px solid var(--rz-base-100);
    color: var(--rz-text-primary-color);
    vertical-align: middle;
}

.aih-trace-table tbody tr:last-child td { border-bottom: none; }

.aih-trace-col-n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.aih-trace-time {
    font-variant-numeric: tabular-nums;
    color: var(--rz-text-tertiary-color);
    white-space: nowrap;
    font-size: 0.76rem;
}

.aih-trace-row { cursor: pointer; transition: background 0.1s ease; }
.aih-trace-row:hover td { background: var(--rz-base-50, var(--rz-base-100)); }

.aih-trace-feature {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    background: var(--rz-base-100);
    color: var(--rz-text-primary-color);
}

.aih-trace-model {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.76rem;
    white-space: nowrap;
}

.aih-trace-empty {
    text-align: center;
    padding: 2.5rem 1rem !important;
    color: var(--rz-text-tertiary-color);
}

.aih-trace-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.aih-trace-pager-info {
    font-size: 0.75rem;
    color: var(--rz-text-tertiary-color);
    margin-right: 0.5rem;
}

@media (max-width: 960px) {
    .aih-shell { grid-template-columns: 1fr; }
    .aih-sidebar {
        position: relative;
        max-height: unset;
        border-right: none;
        border-bottom: 1px solid var(--rz-base-200);
        flex-direction: row;
        gap: 0.5rem;
        overflow-x: auto;
        padding: 0.75rem 1rem;
    }
    .aih-sidebar-brand { display: none; }
    .aih-nav { flex-direction: row; flex: 1; }
    .aih-sidebar-footer { display: none; }
    .aih-main { padding: 1rem; }
    .aih-charts-grid { grid-template-columns: 1fr; }
    .aih-card-wide { grid-column: span 1; }
}
