﻿.history-summary-menu
{
    position: relative;
}

.history-summary-btn
{
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-dim);
    background: transparent;
    cursor: pointer;
}

.history-summary-btn[hidden]
{
    display: none;
}

.history-summary-btn:hover,
.history-summary-btn:focus,
.history-summary-btn[aria-expanded="true"]
{
    border-color: #8bcfc6;
    color: var(--accent-hover);
    background: #eef8f6;
    outline: none;
}

.history-summary-btn:disabled
{
    cursor: not-allowed;
    opacity: 0.55;
}

.history-summary-btn svg
{
    position: relative;
    z-index: 1;
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.history-summary-progress
{
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background:
        conic-gradient(#8bcfc6 var(--summary-progress, 0%), #e6edf3 0);
    opacity: 0.95;
}

.history-summary-progress::after
{
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--panel);
}

.history-summary-btn:hover .history-summary-progress::after,
.history-summary-btn:focus .history-summary-progress::after,
.history-summary-btn[aria-expanded="true"] .history-summary-progress::after
{
    background: #eef8f6;
}

.history-summary-btn.summarizing .history-summary-progress
{
    animation: summary-spin 900ms linear infinite;
}

.history-summary-busy-overlay
{
    position: fixed;
    z-index: 80;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.26);
    backdrop-filter: blur(1px);
}

.history-summary-busy-overlay[hidden]
{
    display: none;
}

.history-summary-busy-card
{
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 300px;
    max-width: calc(100vw - 48px);
    border: 1px solid rgba(139, 207, 198, 0.7);
    border-radius: 14px;
    padding: 18px 20px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
}

.history-summary-busy-card strong
{
    display: block;
    font-size: 14px;
}

.history-summary-busy-card p
{
    margin: 4px 0 0;
    color: var(--text-dim);
    font-size: 12px;
}

.history-summary-busy-spinner
{
    width: 26px;
    height: 26px;
    border: 3px solid #d8f1ee;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: summary-spin 780ms linear infinite;
}

.history-summary-backdrop
{
    position: fixed;
    z-index: 70;
    inset: 0;
    background: rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(1px);
    animation: summary-backdrop-fade 140ms ease;
}

.history-summary-backdrop[hidden]
{
    display: none;
}

.history-summary-panel
{
    position: fixed;
    z-index: 75;
    top: 50%;
    left: 50%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: min(760px, calc(100vw - 48px));
    max-height: min(820px, calc(100vh - 48px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--panel);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
    transform: translate(-50%, -50%);
    animation: summary-modal-pop 140ms ease;
}

.history-summary-panel[hidden]
{
    display: none;
}

.history-summary-panel-head
{
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.history-summary-panel-title
{
    font-size: 13px;
    font-weight: 800;
}

.history-summary-panel-actions
{
    display: flex;
    gap: 4px;
    align-items: center;
}

.history-summary-action
{
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-dim);
    background: transparent;
    cursor: pointer;
}

.history-summary-action:hover,
.history-summary-action:focus
{
    border-color: #8bcfc6;
    color: var(--accent-hover);
    background: #eef8f6;
    outline: none;
}

.history-summary-action:disabled
{
    cursor: not-allowed;
    opacity: 0.45;
}

.history-summary-action svg
{
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

.history-summary-panel-meta
{
    grid-column: 1 / -1;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-dim);
}

.history-summary-text
{
    grid-column: 1 / -1;
    min-height: 0;
    max-height: none;
    overflow: auto;
    margin: 10px 0 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text);
    background: var(--panel-soft);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.history-summary-text.editing
{
    background: #ffffff;
    border-color: #8bcfc6;
    box-shadow: 0 0 0 3px #d7f3ec;
    outline: none;
}

.history-summary-stats
{
    display: flex;
    flex-wrap: wrap;
    grid-column: 2;
    grid-row: 4;
    justify-content: flex-end;
    gap: 6px 12px;
    align-items: center;
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 12px;
}

.history-summary-edit-actions
{
    display: flex;
    grid-column: 1;
    grid-row: 4;
    justify-content: flex-start;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.history-summary-edit-actions[hidden]
{
    display: none;
}

.history-summary-save-btn,
.history-summary-cancel-btn
{
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid #8bcfc6;
    border-radius: 8px;
    color: var(--accent-hover);
    background: transparent;
    cursor: pointer;
}

.history-summary-save-btn:hover,
.history-summary-save-btn:focus,
.history-summary-cancel-btn:hover,
.history-summary-cancel-btn:focus
{
    border-color: var(--accent);
    background: #dff7f1;
    outline: none;
}

.history-summary-save-btn svg,
.history-summary-cancel-btn svg
{
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

.history-summary-stats[hidden]
{
    display: none;
}

.history-summary-stats-prefix
{
    color: #7a8797;
    font-size: 12px;
}

.history-summary-stats-item
{
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.history-summary-stats-label
{
    color: #8a96a6;
    font-size: 11px;
}

.history-summary-stats-value
{
    color: #465466;
    font-size: 12px;
    line-height: 1.2;
}

.history-summary-stats-cost
{
    color: #23766d;
    font-size: 11px;
    line-height: 1.2;
}

.history-summary-stats-cost.with-separator::before
{
    content: "· ";
    color: #a0aec0;
}


.chat-conversation-status .history-summary-panel,
.stage-conversation-status .history-summary-panel
{
}

@keyframes summary-spin
{
    from
    {
        transform: rotate(0deg);
    }
    to
    {
        transform: rotate(360deg);
    }
}

@keyframes summary-backdrop-fade
{
    from
    {
        opacity: 0;
    }
    to
    {
        opacity: 1;
    }
}

@keyframes summary-modal-pop
{
    from
    {
        opacity: 0;
        transform: translate(-50%, calc(-50% - 4px)) scale(0.98);
    }
    to
    {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}
