/* ============================================================
   History — Tabs, notes view, commits, pagination
   ============================================================ */

/* ── History Title Row ─────────────────────────────────────── */

.history-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.history-title-row h2 {
    font-size: 1rem;
    font-weight: 600;
}

.history-title-row .btn-small {
    margin: 0;
}

/* ── History Tabs ──────────────────────────────────────────── */

.history-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    padding: 0 20px;
    flex-shrink: 0;
}

.history-tab-btn {
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.history-tab-btn:hover {
    color: var(--text-primary);
}

.history-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
[data-theme="light"] .history-tab-btn.active { color: var(--accent-dim); } /* 4.4:1 with --accent on the light panel, 5.5:1 with this (#4851) */

.history-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
    min-height: 0;
}

.history-tab-content.active {
    display: flex;
}

#history-tab-activity,
#history-tab-tasks,
#history-tab-agent-notes,
#history-tab-commits,
#history-tab-changes,
#history-tab-chat,
#history-tab-notes {
    min-height: 0;
}

/* ── Persisted Changes View ───────────────────────────────── */

.history-changes-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.history-changes-content {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 16px 20px;
    overflow: auto;
    white-space: pre;
    tab-size: 4;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* ── Notes View ────────────────────────────────────────────── */

.notes-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.notes-header {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.notes-header .btn-small {
    margin: 0;
}

.notes-rendered {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.notes-rendered h1,
.notes-rendered h2,
.notes-rendered h3 {
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.notes-rendered h1 { font-size: 1.25rem; }
.notes-rendered h2 { font-size: 1.0625rem; }
.notes-rendered h3 { font-size: 0.9375rem; }

.notes-rendered p {
    margin: 8px 0;
}

.notes-rendered ul,
.notes-rendered ol {
    margin: 8px 0;
    padding-left: 24px;
}

.notes-rendered li {
    margin: 4px 0;
}

.notes-rendered code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.notes-rendered pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 8px 0;
}

.notes-rendered pre code {
    background: none;
    padding: 0;
}

.notes-rendered blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.notes-rendered .empty-notes {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

#notes-edit-area {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.notes-textarea {
    flex: 1;
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.notes-edit-actions {
    display: flex;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.notes-edit-actions .btn-small {
    margin: 0;
}

.notes-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.notes-spinner span {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ── Commits View ──────────────────────────────────────────── */

.commits-view {
    overflow-y: auto;
    padding: 12px 20px;
}

.commit-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.commit-row:last-child {
    border-bottom: none;
}

.commit-row:hover {
    background: var(--bg-hover);
}

.commit-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.commit-hash {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.commit-subject {
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.commit-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    font-size: var(--fs-base);
    color: var(--text-secondary);
}

.commit-branch {
    color: var(--accent);
    font-size: var(--fs-base);
}

.commit-agent {
    color: var(--text-secondary);
    font-size: var(--fs-base);
}

.commit-time {
    white-space: nowrap;
    font-size: var(--fs-base);
}
.chat-search-results { padding: 6px 8px; }
.chat-search-result { margin: 0 0 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.chat-search-result-header { display:flex; justify-content:space-between; gap:8px; color:var(--text-secondary); font-size: var(--fs-base); padding:4px 2px; }
.chat-search-result-header strong { color:var(--text-primary); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-search-hit { display:block; width:100%; text-align:left; border:0; border-radius:5px; padding:7px 8px; color:var(--text-primary); background:transparent; cursor:pointer; }
.chat-search-hit:hover, .chat-search-hit:focus-visible { background:var(--bg-hover); outline:2px solid var(--accent-secondary); outline-offset:-2px; }
.chat-search-hit-meta { display:block; color:var(--text-secondary); font-size: var(--fs-base); margin-bottom:3px; }
.chat-search-hit-excerpt { font-size:0.75rem; line-height:1.35; overflow:hidden; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; }
.chat-search-hit mark { background:color-mix(in srgb, var(--accent-secondary) 45%, transparent); color:var(--text-primary); font-weight:700; border-radius:2px; padding:0 2px; }
.chat-search-status { padding:10px; color:var(--text-secondary); font-size: var(--fs-base); }
.chat-search-target { outline:2px solid var(--accent-secondary); outline-offset:3px; }
