/* Session-history browser (/history). Ported from the standalone archive
   viewer; scoped under .history-root so nothing leaks into the dashboard.
   The transcript message bodies come entirely from the portal's own
   messages.css / tool styles. */

.history-root {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.history-root .history-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.history-root .history-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--text-bright, #c0caf5);
}

.history-root .history-nav {
    margin-bottom: 1rem;
}

.history-root .history-nav a,
.history-root .history-empty a {
    color: var(--accent, #7aa2f7);
    text-decoration: none;
}

.history-root .history-nav a:hover,
.history-root .history-empty a:hover {
    text-decoration: underline;
}

/* --- Stats strip --- */
.history-root .history-rollup {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.history-root .rollup-tile {
    display: flex;
    flex-direction: column;
    background: var(--bg-darker, #16161e);
    border: 1px solid var(--border, #292e42);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    min-width: 6rem;
}

.history-root .rollup-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-bright, #c0caf5);
}

.history-root .rollup-label {
    font-size: 0.75rem;
    color: var(--text-dim, #7f849c);
}

.history-root .rollup-user .rollup-value {
    color: var(--accent, #7aa2f7);
}

/* --- Filters --- */
.history-root .history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: flex-end;
}

.history-root .history-filters label {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    color: var(--text-dim, #7f849c);
    gap: 0.25rem;
}

.history-root .history-filters select,
.history-root .history-filters input {
    background: var(--bg-darker, #16161e);
    color: var(--text, #c0caf5);
    border: 1px solid var(--border, #292e42);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

.history-root .history-filter-search input {
    min-width: 12rem;
}

/* --- Session table --- */
.history-root .history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-root .history-table th,
.history-root .history-table td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border, #292e42);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22ch;
}

.history-root .history-table th {
    color: var(--text-dim, #7f849c);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: var(--bg-dark, #1a1b26);
}

.history-root .history-table th.num,
.history-root .history-table td.num {
    text-align: right;
}

.history-root .history-row {
    cursor: pointer;
}

.history-root .history-row:hover {
    background: var(--bg-highlight, #1f2335);
}

.history-root .cell-name a {
    color: var(--accent, #7aa2f7);
    text-decoration: none;
    font-weight: 600;
}

.history-root .cell-date {
    color: var(--text-dim, #7f849c);
}

.history-root .cell-models {
    color: var(--text-dim, #7f849c);
    font-size: 0.78rem;
}

/* --- Manifest header card --- */
.history-root .history-manifest-card {
    background: var(--bg-darker, #16161e);
    border: 1px solid var(--border, #292e42);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.history-root .history-manifest-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    color: var(--text-bright, #c0caf5);
}

.history-root .manifest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.4rem 1.5rem;
}

.history-root .manifest-field {
    display: flex;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.history-root .manifest-key {
    color: var(--text-dim, #7f849c);
    min-width: 6rem;
}

.history-root .manifest-val {
    color: var(--text, #c0caf5);
    word-break: break-word;
}

.history-root .manifest-provenance {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-root .provenance-chip {
    font-size: 0.72rem;
    color: var(--text-dim, #7f849c);
    background: var(--bg-dark, #1a1b26);
    border: 1px solid var(--border, #292e42);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
}

/* --- Loading / error / empty states --- */
.history-root .history-loading,
.history-root .history-empty {
    color: var(--text-dim, #7f849c);
    padding: 1.5rem 0;
    text-align: center;
}

.history-root .history-error {
    color: var(--error, #f7768e);
    background: rgba(247, 118, 142, 0.08);
    border: 1px solid var(--error, #f7768e);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
}
