/* 策划 · 栏目规划：工作台内嵌，点「使用」展开外壳（独立样式） */

/* 栏目规划：外壳默认仅一行；--expanded 时框住「使用」行 + 表单 + 结果 */
.cehua-plan-series-shell {
    border-radius: 10px;
    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease,
        background 0.2s ease;
}

.cehua-plan-series-shell--expanded {
    border: 1px solid var(--border-color, #e5e6eb);
    background: var(--bg-primary, #fff);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
    margin-bottom: 10px;
}

.cehua-plan-series-shell--expanded .wb-fn-row {
    border-bottom: 1px solid var(--border-color, #e5e6eb);
}

/* 输入态 / 输出态严格互斥：输出时隐藏表单，保留功能栏 */
.cehua-plan-series-shell--result .cehua-plan-series-form-pane {
    display: none !important;
}

.cehua-plan-series-shell--form .cehua-plan-series-result-pane {
    display: none !important;
}

/* 展开/收起动画：max-height + opacity 过渡 */
.cehua-plan-series-embed {
    margin: 0;
    border: none;
    border-radius: 0;
    background: var(--bg-secondary, #fafafa);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding: 0 12px;
    transition:
        max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.cehua-plan-series-shell--expanded .cehua-plan-series-embed {
    max-height: 2000px;
    opacity: 1;
    padding: 10px 12px 12px;
}

.cehua-plan-series-embed .cehua-plan-series-field {
    margin-bottom: 8px;
}

.cehua-plan-series-embed .cehua-plan-series-field label {
    margin-bottom: 3px;
    font-size: 12px;
}

.cehua-plan-series-embed .cehua-plan-series-field input[type='text'],
.cehua-plan-series-embed .cehua-plan-series-field textarea {
    padding: 7px 10px;
    font-size: 13px;
}

.cehua-plan-series-embed .cehua-plan-series-field textarea {
    min-height: 52px;
    max-height: 120px;
}

.cehua-plan-series-embed .cehua-plan-series-actions {
    margin-top: 8px;
    padding-top: 0;
}

.cehua-plan-series-embed .cehua-plan-series-actions button {
    padding: 7px 14px;
    font-size: 13px;
}

/* 面板切换淡入 */
@keyframes cehua-pane-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 表单 / 结果：互斥面板；结果区白底独立「一页」 */
.cehua-plan-series-result-pane {
    animation: cehua-pane-fadein 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 320px;
    max-height: min(85vh, 900px);
    padding: 12px 14px 14px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid var(--border-color, #e5e6eb);
    border-radius: 10px;
    overflow: hidden;
}

/* 兜底：确保 hidden 属性始终生效（避免被 display:flex 覆盖） */
.cehua-plan-series-result-pane[hidden] {
    display: none !important;
}

.cehua-ps-result-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color, #e5e6eb);
}

.cehua-ps-back-btn {
    border: 1px solid var(--border-color, #e5e6eb);
    background: #fff;
    color: var(--text-primary, #1d2129);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
.cehua-ps-back-btn:hover {
    background: #f7f8fa;
    border-color: #c9cdd4;
}

.cehua-ps-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1d2129);
}

.cehua-ps-stop-btn {
    border: 1px solid #ffccc7;
    background: #fff2f0;
    color: #cf1322;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.cehua-ps-stop-btn:hover {
    background: #fff1f0;
    border-color: #ffa39e;
}

.cehua-ps-process-wrap {
    border: 1px solid var(--border-color, #e5e6eb);
    border-radius: 8px;
    background: #fafafa;
    flex-shrink: 0;
}

.cehua-ps-process-wrap--closed {
    display: none;
}

.cehua-ps-process-log {
    margin: 0;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #4e5969;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.cehua-ps-process-expand {
    align-self: center;
    border: 1px solid var(--border-color, #d9d9d9);
    background: #fff;
    color: #4e5969;
    border-radius: 999px;
    width: 28px;
    height: 24px;
    line-height: 20px;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.cehua-ps-process-expand:hover {
    background: #f7f8fa;
}

.cehua-plan-series-result-body {
    flex: 1;
    min-height: 120px;
    overflow: auto;
    background: #fff;
    color: #1d2129;
    font-size: 14px;
    line-height: 1.65;
    padding: 4px 2px 8px;
}

/* 流式阶段：白底，禁止沿用全局 .code-block 深色块 */
.cehua-ps-stream-plain {
    margin: 0;
    padding: 0;
    background: #fff !important;
    color: #1d2129 !important;
    border: none;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.65;
    max-height: min(58vh, 520px);
    overflow: auto;
}

.cehua-ps-stream-status {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary, #86909c);
    margin-bottom: 2px;
    min-height: 1.2em;
    flex-shrink: 0;
}

.cehua-ps-result-md {
    max-width: 100%;
}
.cehua-ps-result-md h1 {
    font-size: 1.25rem;
    margin: 1.1em 0 0.5em;
    font-weight: 700;
}
.cehua-ps-result-md h2 {
    font-size: 1.1rem;
    margin: 1em 0 0.45em;
    font-weight: 700;
}
.cehua-ps-result-md h3 {
    font-size: 1rem;
    margin: 0.9em 0 0.4em;
    font-weight: 600;
}
.cehua-ps-result-md p {
    margin: 0.5em 0;
}
.cehua-ps-result-md ul,
.cehua-ps-result-md ol {
    margin: 0.5em 0;
    padding-left: 1.4em;
}
.cehua-ps-result-md li {
    margin: 0.25em 0;
}
.cehua-ps-result-md strong {
    font-weight: 600;
}
.cehua-ps-result-md a {
    color: #165dff;
    text-decoration: none;
}
.cehua-ps-result-md a:hover {
    text-decoration: underline;
}
.cehua-ps-result-md code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: #f2f3f5;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.cehua-ps-result-md pre {
    background: #f7f8fa;
    color: #1d2129;
    padding: 12px 14px;
    border-radius: 8px;
    overflow: auto;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid #e5e6eb;
}
.cehua-ps-result-md pre code {
    background: transparent;
    padding: 0;
}
.cehua-ps-result-md blockquote {
    margin: 0.6em 0;
    padding: 0.4em 0 0.4em 12px;
    border-left: 3px solid #c9cdd4;
    color: #4e5969;
}
.cehua-ps-result-md table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
    font-size: 13px;
}
.cehua-ps-result-md th,
.cehua-ps-result-md td {
    border: 1px solid #e5e6eb;
    padding: 6px 10px;
    text-align: left;
}
.cehua-ps-result-md th {
    background: #f7f8fa;
    font-weight: 600;
}

.cehua-ps-result-md-plain {
    white-space: pre-wrap;
    word-break: break-word;
}

.cehua-plan-series-embed .cehua-ps-result-copy-hint {
    flex-shrink: 0;
    margin: 0;
    padding-top: 4px;
}

.cehua-ps-result-pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(65vh, 560px);
    overflow: auto;
    font-size: 13px;
    line-height: 1.55;
}

.cehua-ps-result-empty,
.cehua-ps-result-copy-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary, #86909c);
}

.cehua-ps-result-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    font-size: 14px;
    line-height: 1.6;
}

.cehua-ps-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary, #86909c);
}

.cehua-ps-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #165dff;
    animation: cehua-ps-pulse 1s ease-in-out infinite;
}

@keyframes cehua-ps-pulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.9);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.cehua-plan-series-overlay {
    position: fixed;
    inset: 0;
    z-index: 100050;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.cehua-plan-series-dialog {
    width: min(520px, 100%);
    max-height: min(90vh, 720px);
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    padding: 20px 22px 18px;
    box-sizing: border-box;
}

.cehua-plan-series-dialog h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    color: #1d2129;
}

.cehua-plan-series-dialog .sub {
    margin: 0 0 16px;
    font-size: 13px;
    color: #86909c;
    line-height: 1.5;
}

.cehua-plan-series-field {
    margin-bottom: 14px;
}

.cehua-plan-series-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #4e5969;
    margin-bottom: 6px;
}

.cehua-plan-series-field .req {
    color: #f53f3f;
    margin-left: 2px;
}

.cehua-plan-series-field input[type="text"],
.cehua-plan-series-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: #1d2129;
    background: #fafafa;
    outline: none;
}

.cehua-plan-series-field input[type="text"]:focus,
.cehua-plan-series-field textarea:focus {
    border-color: #165dff;
    background: #fff;
}

.cehua-plan-series-field textarea {
    min-height: 88px;
    resize: vertical;
}

.cehua-plan-series-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 4px;
}

.cehua-plan-series-actions button {
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

.cehua-plan-series-actions .btn-cancel {
    background: #f2f3f5;
    color: #4e5969;
}

.cehua-plan-series-actions .btn-cancel:hover {
    background: #e5e6eb;
}

.cehua-plan-series-actions .btn-submit {
    background: #165dff;
    color: #fff;
}

.cehua-plan-series-actions .btn-submit:hover {
    background: #0e42d2;
}

.cehua-plan-series-actions .btn-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cehua-plan-series-err {
    font-size: 12px;
    color: #f53f3f;
    margin-top: -6px;
    margin-bottom: 8px;
    min-height: 18px;
}

/* ── 历史记录按钮 ── */
.cehua-ps-history-btn {
    border: 1px solid var(--border-color, #d9d9d9);
    background: #fff;
    color: #4e5969;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
.cehua-ps-history-btn:hover {
    background: #f7f8fa;
    border-color: #c9cdd4;
}
.cehua-ps-history-btn--small {
    padding: 4px 10px;
    font-size: 12px;
    margin-left: auto;
}

.cehua-ps-history-clear-btn {
    margin-left: auto;
    border: 1px solid #ffccc7;
    background: #fff;
    color: #cf1322;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.cehua-ps-history-clear-btn:hover {
    background: #fff2f0;
}

/* ── 历史记录面板 ── */
.cehua-plan-series-history-pane {
    animation: cehua-pane-fadein 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: min(85vh, 900px);
    padding: 12px 14px 14px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid var(--border-color, #e5e6eb);
    border-radius: 10px;
    overflow: hidden;
}
.cehua-plan-series-history-pane[hidden] {
    display: none !important;
}

.cehua-ps-history-list {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cehua-ps-history-empty {
    padding: 24px 0;
    text-align: center;
    color: #86909c;
    font-size: 13px;
}

.cehua-ps-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.cehua-ps-history-item:hover {
    background: #f0f5ff;
    border-color: #adc6ff;
}

.cehua-ps-history-item-info {
    flex: 1;
    min-width: 0;
}
.cehua-ps-history-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1d2129;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cehua-ps-history-item-meta {
    font-size: 12px;
    color: #86909c;
    margin-top: 2px;
}

.cehua-ps-history-item-del {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: #86909c;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.cehua-ps-history-item-del:hover {
    background: #fff2f0;
    color: #cf1322;
}

/* ── 历史态隐藏表单和结果 ── */
.cehua-plan-series-shell--history .cehua-plan-series-form-pane,
.cehua-plan-series-shell--history .cehua-plan-series-result-pane {
    display: none !important;
}
.cehua-plan-series-shell--form .cehua-plan-series-history-pane,
.cehua-plan-series-shell--result .cehua-plan-series-history-pane {
    display: none !important;
}
