/* ============================================================
   预测历史抽屉 / 侧栏（prediction-history.js 专用样式）

   视觉参照 /ReportIntelligentSearch 左侧会话列表（DeepSeek 风格）：
     底色 #f9fafb、右边框 #e7e9ec、条目 hover #f1f3f5、选中 #e4edfd + 文字 #3964fe、
     条目圆角 12px、分组标题 12px/500 粘性吸顶、hover 才出现右侧图标动作。
   两种宿主形态：
     .ph-host  → 内嵌（弹窗左侧栏，/Event 本地预测）
     .ph-drawer→ 浮动（屏幕右侧抽屉，/Wiki/EventPrediction）
   样式全部自带 ph- 前缀，不与页面既有样式冲突。
   ============================================================ */

/* 主题令牌（与 /ReportIntelligentSearch .ris-sidebar 同一套静态值） */
.ph-host,
.ph-panel,
.ph-drawer {
    --ph-fill: #f9fafb;      /* 侧栏底色 */
    --ph-hover: #f1f3f5;     /* hover */
    --ph-active: #e4edfd;    /* 选中 */
    --ph-text: #0f1115;
    --ph-text-2: #81858c;    /* 次级文字 */
    --ph-text-3: #adb2b8;    /* 说明文字 */
    --ph-brand: #3964fe;
    --ph-border: #e7e9ec;
}

/* ============================================================
   浮动模式（屏幕右侧抽屉）
   ============================================================ */
.ph-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    max-width: 92vw;
    background: var(--ph-fill);
    border-left: 1px solid var(--ph-border);
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.14);
    display: flex;
    flex-direction: column;
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 12050;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
}
.ph-drawer.ph-open { transform: translateX(0); }

/* ============================================================
   内嵌模式（弹窗左侧栏）：不浮动、不遮挡，是弹窗布局的一部分
   ============================================================ */
.ph-host {
    display: none;
    width: 280px;
    flex-shrink: 0;
    min-height: 0;
    background: var(--ph-fill);
    border-right: 1px solid var(--ph-border);
}
.ph-host.ph-host-open { display: flex; }

/* 页面级左侧栏（/Wiki/EventPrediction）：独立卡片，与页面面板同一视觉语言，
   高 100% 撑满工作区，不浮动、不遮挡右侧大盘。 */
.ph-host.ph-host-page {
    height: 100%;
    width: 272px;
    border: 1px solid var(--ph-border);
    border-radius: 14px;
    overflow: hidden;
}

.ph-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
}

/* ============================================================
   顶行：标题 + 图标按钮（对照 .ris-sidebar-top）
   ============================================================ */
.ph-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 15px 4px 10px 4px;
    margin: 0 12px 8px;
}
.ph-head-title {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ph-text);
}
.ph-head-title svg { color: var(--ph-brand); flex-shrink: 0; }
.ph-head-count { font-size: 11px; font-weight: 500; color: var(--ph-text-3); }
.ph-head-actions { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }

.ph-iconbtn {
    width: 22px;
    height: 22px;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ph-text-2);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.ph-iconbtn:hover { color: var(--ph-text); background: var(--ph-hover); }
.ph-iconbtn.ph-on { color: var(--ph-brand); background: var(--ph-active); }

/* 搜索：默认收起，点放大镜展开（同 .ris-sidebar-search） */
.ph-search-wrap { flex-shrink: 0; display: none; padding: 0 12px 8px; }
.ph-search-wrap.open { display: block; }
.ph-search {
    width: 100%;
    box-sizing: border-box;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    background: #fff;
    color: var(--ph-text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.ph-search::placeholder { color: var(--ph-text-3); }
.ph-search:focus { border-color: var(--ph-brand); }

/* 回放中的提示条 */
.ph-replay-bar {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0 12px 8px;
    padding: 7px 10px;
    border-radius: 10px;
    background: var(--ph-active);
    color: var(--ph-brand);
    font-size: 11.5px;
    line-height: 1.5;
    flex-shrink: 0;
}
.ph-replay-bar.ph-show { display: flex; }
.ph-replay-bar span { flex: 1; min-width: 0; }
.ph-replay-bar button {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--ph-brand);
    padding: 3px 8px;
    cursor: pointer;
}
.ph-replay-bar button:hover { background: #fff; }

/* ============================================================
   列表滚动区
   ============================================================ */
.ph-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 14px;
}
.ph-empty {
    padding: 28px 12px;
    text-align: center;
    font-size: 13px;
    line-height: 1.9;
    color: var(--ph-text-3);
}
.ph-empty small { font-size: 11px; color: var(--ph-text-3); }
.ph-loading { padding: 20px 12px; text-align: center; font-size: 12px; color: var(--ph-text-2); }

/* 日期分组：粘性标题（今天 / 昨天 / 7 天内 …） */
.ph-group { margin-top: 14px; }
.ph-group:first-child { margin-top: 0; }
.ph-group-label {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    color: var(--ph-text-2);
    background: var(--ph-fill);
    box-shadow: 4px 0 0 var(--ph-fill);
    user-select: none;
}

/* 条目：圆角 12px、hover 变底色（同 .ris-conv-item） */
.ph-item {
    --ph-mask: 241, 243, 245;
    position: relative;
    box-sizing: border-box;
    padding: 7px 6px 7px 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.12s;
}
.ph-item:hover { background: var(--ph-hover); }
.ph-item.ph-active {
    --ph-mask: 228, 237, 253;
    background: var(--ph-active);
}
.ph-item.ph-active .ph-title { color: var(--ph-brand); }

/* 对比勾选：圆形勾（同 .ris-conv-check），默认隐藏，hover/已选时出现 */
.ph-check {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(148, 163, 184, 0.7);
    border-radius: 50%;
    background: #fff;
    color: #fff;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.ph-check svg { opacity: 0; }
.ph-item:hover .ph-check,
.ph-item.ph-checked .ph-check { display: inline-flex; }
.ph-item.ph-checked { background: var(--ph-active); }
.ph-item.ph-checked .ph-check { background: var(--ph-brand); border-color: var(--ph-brand); }
.ph-item.ph-checked .ph-check svg { opacity: 1; }
.ph-item.ph-checked .ph-title { color: var(--ph-brand); }

.ph-item-main { flex: 1; min-width: 0; }
.ph-title {
    font-size: 13.5px;
    line-height: 20px;
    color: var(--ph-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ph-sub {
    font-size: 11px;
    line-height: 16px;
    color: var(--ph-text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ph-sub .ph-risk-high { color: #e11d48; }
.ph-sub .ph-risk-mid { color: #d97706; }

/* hover 才出现的右侧渐变遮罩 + 图标动作（同 .ris-conv-actions） */
.ph-item-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 62px;
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    padding-right: 4px;
    box-sizing: border-box;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    background: linear-gradient(90deg,
        rgba(var(--ph-mask), 0) 0%,
        rgba(var(--ph-mask), 0.5) 20%,
        rgb(var(--ph-mask)) 41%);
}
.ph-item:hover .ph-item-actions,
.ph-item.ph-active .ph-item-actions,
.ph-item:focus-within .ph-item-actions { display: flex; }
.ph-item-actions .ph-iconbtn { color: var(--ph-text-2); }
.ph-item-actions .ph-iconbtn:hover { background: rgba(0, 0, 0, 0.06); color: var(--ph-text); }
.ph-item-actions .ph-iconbtn.ph-del:hover { background: rgba(225, 29, 72, 0.1); color: #e11d48; }

/* ============================================================
   对比面板
   ============================================================ */
.ph-compare {
    flex-shrink: 0;
    max-height: 46vh;
    overflow-y: auto;
    margin: 0 12px 12px;
    padding: 10px 12px 12px;
    border: 1px solid var(--ph-border);
    border-radius: 12px;
    background: #fff;
}
.ph-compare-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ph-text);
    margin-bottom: 6px;
}
.ph-compare-title .ph-spacer { flex: 1; }
.ph-compare-sub { font-size: 11px; line-height: 1.7; color: var(--ph-text-2); margin-bottom: 8px; }
.ph-cmp-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.ph-cmp-table th {
    text-align: right;
    font-weight: 500;
    color: var(--ph-text-2);
    padding: 4px 5px;
    border-bottom: 1px solid var(--ph-border);
    white-space: nowrap;
}
.ph-cmp-table th:first-child { text-align: left; }
.ph-cmp-table td { text-align: right; padding: 3px 5px; border-bottom: 1px solid #f3f4f6; color: var(--ph-text); }
.ph-cmp-table td:first-child { text-align: left; color: var(--ph-text-2); }
.ph-cmp-up { color: #e11d48; }
.ph-cmp-down { color: #059669; }
.ph-cmp-na { color: var(--ph-text-3); }
.ph-legend-a { color: var(--ph-brand); font-weight: 600; }
.ph-legend-b { color: #0ea5e9; font-weight: 600; }

/* 按钮（对比面板用） */
.ph-btn {
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--ph-border);
    background: #fff;
    color: var(--ph-text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
}
.ph-btn:hover { background: var(--ph-hover); }
.ph-btn.ph-btn-primary {
    background: var(--ph-brand);
    border-color: var(--ph-brand);
    color: #fff;
}
.ph-btn.ph-btn-primary:hover { background: #2f55e6; }

/* 底部浮动提示（两种模式共用） */
.ph-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    z-index: 12100;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.ph-toast.ph-show { opacity: 1; }

/* 「下载报告」按钮：放在「结合趋势、风险和路径，生成审阅快报。」右侧 */
.ph-brief-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    height: 28px;
    padding: 0 11px;
    box-sizing: border-box;
    border: none;
    border-radius: 9px;
    background: linear-gradient(90deg, #4f46e5, #6366f1);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.22);
    transition: filter 0.15s, box-shadow 0.15s, opacity 0.15s;
    white-space: nowrap;
}
.ph-brief-btn:hover:not(:disabled) {
    filter: brightness(1.06);
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
}
.ph-brief-btn:disabled {
    cursor: not-allowed;
    background: #e2e8f0;
    color: #94a3b8;
    box-shadow: none;
}
.ph-brief-btn svg { flex-shrink: 0; }

/* 简报撰写中的转圈（与知识库「下载 Word」同一观感）：
   用 currentColor 描边，深浅底色的按钮上都能看清 */
.ph-spin {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    display: inline-block;
    box-sizing: border-box;
    border: 2px solid rgba(148, 163, 184, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ph-spin 0.7s linear infinite;
}
@keyframes ph-spin { to { transform: rotate(360deg); } }
/* 忙碌态：禁用外观由 .ph-brief-btn:disabled 提供，这里只保证指针与转圈位置正常 */
.ph-brief-btn.ph-busy { cursor: wait; }
.ph-iconbtn.ph-busy { cursor: wait; }

/* 页面/控制栏的历史入口按钮：白色胶囊 + 柔和投影（同 .ris-sidebar-new）。
   /Wiki/EventPrediction 用它展开默认隐藏的左侧历史列表；/Event 弹窗的列表常驻，不用它。 */
.ph-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid var(--ph-border, #e7e9ec);
    border-radius: 100px;
    background: #fff;
    color: #0f1115;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 -2px 2px rgba(72, 104, 178, 0.04), 0 2px 2px rgba(106, 111, 117, 0.09), 0 1px 2px rgba(72, 104, 178, 0.08);
    transition: box-shadow 0.3s, border-color 0.15s;
}
.ph-open-btn:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 4px rgba(72, 104, 178, 0.04), 0 6px 6px rgba(106, 111, 117, 0.1);
}
.ph-open-btn svg { flex-shrink: 0; color: #3964fe; }
