/* AI 对话记录 — 锚定在历史按钮上方的弹出层 */
.ai-history-anchor {
    position: relative;
    display: flex;
    align-items: center;
}

.ai-icon-btn.is-history-open {
    background: #333;
    color: #ccc;
}

.ai-chat-history-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 120;
    width: min(340px, calc(100vw - 24px));
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.42));
}

.ai-chat-history-popover[hidden] {
    display: none !important;
}

.ai-chat-history-popover__panel {
    display: flex;
    flex-direction: column;
    max-height: min(420px, 52vh);
    overflow: hidden;
    background: #252526;
    border: 1px solid #454545;
    border-radius: 10px;
    color: #ccc;
    font-size: 12px;
}

.ai-chat-history-popover__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px 0;
}

.ai-chat-history-popover__title {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #e8e8e8;
    letter-spacing: 0.01em;
}

.ai-chat-history-popover__clear-all {
    flex-shrink: 0;
    border: none;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 10px;
    line-height: 1.4;
    background: transparent;
    color: #999;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.ai-chat-history-popover__clear-all:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.12);
    color: #f85149;
}

.ai-chat-history-popover__clear-all:disabled,
.ai-chat-history-popover__clear-all.is-disabled {
    opacity: 0.35;
    cursor: default;
}

.ai-chat-history-popover__hint {
    margin: 4px 0 0;
    padding: 0 14px 10px;
    font-size: 10px;
    line-height: 1.45;
    color: #777;
    border-bottom: 1px solid #3c3c3c;
}

.ai-chat-history-popover__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 6px 10px;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

.ai-chat-history-popover__body::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-history-popover__body::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.ai-chat-history-popover__arrow {
    position: absolute;
    right: 10px;
    bottom: -5px;
    width: 10px;
    height: 10px;
    background: #252526;
    border-right: 1px solid #454545;
    border-bottom: 1px solid #454545;
    transform: rotate(45deg);
    pointer-events: none;
}

.ai-chat-history-empty {
    padding: 28px 16px;
    text-align: center;
    color: #888;
    font-size: 12px;
    line-height: 1.5;
}

.ai-chat-history-group {
    margin-bottom: 2px;
}

.ai-chat-history-group__title {
    padding: 4px 8px 6px;
    font-size: 10px;
    font-weight: 600;
    color: #888;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    user-select: none;
}

.ai-chat-history-group__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-chat-history-group__divider {
    height: 1px;
    margin: 8px 8px 6px;
    background: #3c3c3c;
}

.ai-chat-history-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-radius: 7px;
    overflow: hidden;
    transition: background 0.12s ease;
}

.ai-chat-history-item:hover {
    background: #2d2d2d;
}

.ai-chat-history-item.is-active {
    background: rgba(14, 99, 156, 0.22);
}

.ai-chat-history-item.is-active:hover {
    background: rgba(14, 99, 156, 0.3);
}

.ai-chat-history-item__main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 8px 6px 8px 10px;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.ai-chat-history-item__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 500;
    color: #e0e0e0;
    line-height: 1.35;
}

.ai-chat-history-item.is-active .ai-chat-history-item__title {
    color: #fff;
}

.ai-chat-history-item__meta {
    flex-shrink: 0;
    font-size: 10px;
    color: #777;
    font-variant-numeric: tabular-nums;
}

.ai-chat-history-item.is-active .ai-chat-history-item__meta {
    color: #8ab4d9;
}

.ai-chat-history-item__delete {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    margin-right: 2px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #777;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.ai-chat-history-item:hover .ai-chat-history-item__delete,
.ai-chat-history-item.is-active .ai-chat-history-item__delete {
    opacity: 1;
}

.ai-chat-history-item__delete:hover {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
}
