/* ZNT88 客服副驾 · 历史沟通回顾 MVP
 * 作用域：仅历史回顾工具区与模态窗口；颜色使用 PROJECT_RULES §8 品牌 token。
 */

html body #agent-page[data-kefu-fujia-root] .kf-history-tool {
    border-top: 1px solid #EBEBEB;
    padding-top: 14px;
    margin-top: 14px;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-tool-title {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: #111111;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-tool-desc {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.6;
    color: #555555;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #FF5A5F;
    color: #FFFFFF;
    border: 1px solid #FF5A5F;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-primary:hover:not(:disabled) {
    background: #CC3A3F;
    border-color: #CC3A3F;
    transform: translateY(-1px);
}

html body #agent-page[data-kefu-fujia-root] .kf-history-primary:disabled {
    opacity: 0.55;
    cursor: default;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest {
    margin-top: 10px;
    padding: 10px 12px;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.7;
    color: #555555;
    white-space: pre-wrap;
    /* 只读总结：固定可调高度，内容纵向滚动，右下角拖动手柄调整高度（120–560px）。
       右栏 R1 起默认高度 220→180，给“主要客情 + 画像”腾出首屏空间；min/max 与拖拽不变。 */
    height: 180px;
    min-height: 120px;
    max-height: 560px;
    overflow-y: auto;
    overflow-x: hidden;
    resize: vertical;
    word-break: break-word;
    box-sizing: border-box;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest.is-empty {
    color: #999999;
    height: auto;
    min-height: 0;
    overflow: visible;
    resize: none;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-meta {
    margin: 0 0 6px;
    font-size: 11px;
    color: #999999;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-text,
html body #agent-page[data-kefu-fujia-root] .kf-history-latest-warning {
    margin: 0 0 6px;
    white-space: pre-wrap;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-warning {
    color: #FF5A5F;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-list {
    margin: 0 0 6px;
    padding-left: 18px;
    list-style: disc;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-list li {
    margin: 0 0 3px;
}

html body #agent-page[data-kefu-fujia-root] .kf-history-latest-title {
    display: block;
    margin-bottom: 4px;
    color: #111111;
    font-weight: 600;
}

/* 阻断式模态：挂载在 body，页面主体 pointer-events 关闭。 */
body.kf-history-modal-open {
    overflow: hidden;
}

body.kf-history-modal-open #agent-page {
    pointer-events: none;
    user-select: none;
}

.kf-history-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2147483600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(17, 17, 17, 0.32);
    pointer-events: auto;
}

.kf-history-modal {
    width: min(560px, calc(100vw - 32px));
    max-height: 86vh;
    overflow: auto;
    background: #FFFFFF;
    color: #111111;
    border: 1px solid #EBEBEB;
    border-radius: 16px;
    padding: 22px 24px;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font: 14px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.kf-history-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.kf-history-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111111;
}

.kf-history-modal-close {
    border: 1px solid #D0D0D0;
    background: #FFFFFF;
    color: #111111;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
}

.kf-history-reminder {
    margin: 0 0 14px;
    padding: 10px 12px;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-left: 3px solid #FF5A5F;
    border-radius: 8px;
    color: #555555;
    font-size: 12px;
    line-height: 1.7;
}

/* 统一分析弹窗：快速/深度/历史回顾共用同一句主文案与同一视觉风格（品牌色只用于强调，文字本身说明状态）。 */
.kf-analysis-overlay-lead {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-left: 4px solid #FF5A5F;
    border-radius: 8px;
    color: #111111;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.6;
}

.kf-analysis-overlay-modal {
    width: min(560px, calc(100vw - 32px));
}

.kf-analysis-overlay-detail {
    margin: 0 0 14px;
    color: #555555;
    font-size: 12px;
    line-height: 1.7;
}

.kf-analysis-overlay .kf-history-actions {
    justify-content: flex-end;
}

body.kf-analysis-overlay-open {
    overflow: hidden;
}

body.kf-analysis-overlay-open #agent-page {
    pointer-events: none;
    user-select: none;
}

.kf-history-stats {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #111111;
}

.kf-history-progress {
    width: 100%;
    height: 6px;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}

.kf-history-progress > span {
    display: block;
    width: 0;
    height: 100%;
    background: #FF5A5F;
    transition: width 0.3s;
}

.kf-history-status {
    margin: 0 0 14px;
    color: #555555;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.kf-history-status.is-strong {
    color: #111111;
    font-weight: 600;
}

.kf-history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.kf-history-secondary {
    background: #FFFFFF;
    color: #111111;
    border: 1px solid #D0D0D0;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.kf-history-secondary:hover:not(:disabled) {
    border-color: #FF5A5F;
    color: #FF5A5F;
}

.kf-history-secondary:disabled {
    opacity: 0.55;
    cursor: default;
}

.kf-history-result {
    margin-top: 4px;
    border-top: 1px solid #EBEBEB;
    padding-top: 14px;
}

.kf-history-result h4 {
    margin: 14px 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: #111111;
}

.kf-history-result p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.7;
    color: #555555;
    white-space: pre-wrap;
}

.kf-history-result ul {
    margin: 0 0 8px;
    padding-left: 20px;
    color: #555555;
    font-size: 13px;
    line-height: 1.7;
}

.kf-history-result li {
    margin: 3px 0;
}

.kf-history-result .kf-history-fact {
    color: #111111;
}

.kf-history-result .kf-history-inference {
    color: #555555;
}

.kf-history-result .kf-history-warning {
    color: #555555;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-radius: 8px;
    padding: 8px 10px;
    margin: 8px 0 0;
}

@media (max-width: 600px) {
    .kf-history-modal-backdrop {
        padding: 10px;
        align-items: flex-end;
    }
    .kf-history-modal {
        width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        padding: 18px;
    }
}
