/* CoT Settings Styles */

.cot-items-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cot-list-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    margin-bottom: 12px;
}

.cot-list-tools[hidden] {
    display: none;
}

.cot-list-tools input,
.cot-list-tools select {
    min-width: 0;
    min-height: 38px;
    padding: 6px 8px;
    border: 1px solid rgba(128, 128, 128, .28);
    border-radius: 8px;
    background: var(--panel-bg, #fff);
    color: var(--text-color, #333);
    font: inherit;
}

.cot-list-tools input {
    font-size: 16px;
}

.cot-list-tools p {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--text-color, #555);
    opacity: .8;
    font-size: 12px;
}

.cot-item-section > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(128, 128, 128, .28);
    border-radius: 8px;
    background: var(--panel-bg, #fff);
    color: var(--text-color, #333);
    overflow-wrap: anywhere;
    cursor: pointer;
}

.cot-item-section > summary::before {
    content: '▸';
}

.cot-item-section[open] > summary::before {
    content: '▾';
}

.cot-item-section > summary small {
    opacity: .75;
    white-space: nowrap;
}

.cot-item-section-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.cot-items-long .cot-item-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    background: var(--panel-bg, #fff);
    border-color: rgba(128, 128, 128, .28);
}

.cot-items-long .cot-item-content {
    grid-column: 1;
    grid-row: 1;
}

.cot-items-long .cot-item-name {
    display: flex;
    align-items: baseline;
    color: var(--text-color, #333);
    white-space: normal;
    overflow-wrap: anywhere;
}

.cot-items-long .cot-position-btn {
    flex-shrink: 0;
}

.cot-items-long .cot-btn-group {
    grid-column: 1 / -1;
    justify-self: end;
}

@media (max-width: 480px) {
    .cot-list-tools {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cot-list-tools input {
        grid-column: 1 / -1;
    }
}

.cot-item-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    position: relative;
}

.cot-item-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-color: #e0e0e0;
}

/* 拖拽状态样式 */
.cot-item-card.draggable {
    cursor: grab;
}
.cot-item-card.draggable:active {
    cursor: grabbing;
}
.cot-item-card.dragging {
    opacity: 0.5;
    border: 1px dashed var(--primary-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.cot-item-card.drag-over-top {
    border-top: 2px solid var(--primary-color);
}
.cot-item-card.drag-over-bottom {
    border-bottom: 2px solid var(--primary-color);
}

/* 锁定条目样式 */
.cot-item-card.locked {
    background: #fcfcfc;
    border-left: 3px solid var(--primary-color);
}

.cot-item-card.locked .cot-item-name {
    color: #333;
    font-weight: 600;
}

.cot-item-card.locked::after {
    content: "🔒";
    position: absolute;
    right: 10px;
    top: 5px;
    font-size: 10px;
    opacity: 0.3;
    pointer-events: none;
}

/* 拖拽把手 (虽然目前是点击排序，预留样式) */
.cot-drag-handle {
    color: #ccc;
    cursor: grab;
    font-size: 18px;
    line-height: 1;
}

/* 内容区域 */
.cot-item-content {
    flex: 1;
    min-width: 0; /* 防止文本溢出 */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cot-item-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cot-item-preview {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cot-config-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px 15px !important;
}

/* 带有开关的行在两行布局下，下行靠右展示或者整行撑开 */
.cot-config-row:has(.kkt-switch) {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.cot-config-row .kkt-item-label {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 14px;
    font-weight: 500;
}

.cot-config-row:has(.kkt-switch) .kkt-item-label {
    width: auto;
    flex: 1;
    min-width: 0;
}

.cot-config-row .kkt-item-label p {
    margin: 2px 0 0;
    color: #999;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
}

.cot-config-row .kkt-item-control {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.cot-config-row:has(.kkt-switch) .kkt-item-control {
    width: auto;
    flex-shrink: 0;
    justify-content: flex-end;
}

.cot-compact-select,
.cot-mini-input,
.cot-tiny-input,
.cot-mini-textarea {
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: var(--panel-bg, #fff);
    color: inherit;
    font: inherit;
}

.cot-config-row .cot-compact-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 38px;
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    background-color: #fafafa;
    transition: border-color 0.2s, background-color 0.2s;
}

.cot-config-row .cot-compact-select:focus {
    border-color: var(--primary-color, #2563eb);
    background-color: #ffffff;
    outline: none;
}

.cot-config-row .cot-mini-input,
.cot-config-row .cot-mini-textarea {
    width: 100%;
    max-width: 100%;
    padding: 7px 10px;
    font-size: 13px;
    border-radius: 8px;
}

.cot-compact-select { min-width: 132px; padding: 6px 24px 6px 8px; font-size: 12px; }
.cot-mini-input, .cot-mini-textarea { width: min(250px, 100%); padding: 6px 8px; font-size: 12px; }
.cot-tiny-input { width: 92px; padding: 6px; font-size: 11px; }
.cot-inline-controls { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; min-width: 0; }
.cot-inline-controls > * { flex: 1 1 120px; min-width: 0; }
.cot-advanced-toggle-wrap { display: flex; justify-content: flex-end; padding: 8px 12px; }
.cot-advanced-options { border-top: 1px solid #f0f0f0; }
.cot-save-policy-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 12px; }
#cot-policy-status { min-width: 0; color: #888; font-size: 11px; overflow-wrap: anywhere; }

.cot-item-editor-window {
    width: calc(100% - 28px);
    max-width: 480px;
    max-height: min(76dvh, 640px);
    padding: 0;
    overflow: hidden;
    background: var(--settings-surface);
    color: var(--settings-ink);
}
.cot-item-editor-window .settings-dialog-body { display: grid; gap: 12px; align-content: start; }
.cot-item-editor-window .form-group { margin: 0; }
.cot-item-editor-window .form-group label { margin: 0 0 5px; color: var(--settings-ink); font-size: calc(14px * var(--app-font-scale)); font-weight: 500; }
#cot-item-content { min-height: 96px; line-height: 1.65; }
.cot-editor-section { border: 1px solid var(--settings-line); border-radius: 10px; background: var(--settings-surface); }
.cot-editor-section > summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
    gap: 8px;
    padding: 10px;
    color: var(--settings-ink);
    font-size: calc(14px * var(--app-font-scale));
    font-weight: 500;
    cursor: pointer;
}
.cot-editor-section > summary::-webkit-details-marker { display: none; }
.cot-editor-section > summary::after { content: ''; width: 7px; height: 7px; flex: none; border: solid var(--settings-muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: 0 3px 3px 0; }
.cot-editor-section[open] > summary::after { transform: rotate(225deg); margin-bottom: -3px; }
.cot-editor-section[open] > summary { border-bottom: 1px solid var(--settings-line); }
.cot-editor-section > :not(summary) { margin: 10px; }
.cot-item-editor-window .settings-dialog-footer .btn { flex: 1; min-width: 0; }
.cot-item-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 10px; }
.cot-item-editor-window .form-group { min-width: 0; }
.cot-item-editor-window .form-group select,
.cot-item-editor-window .form-group input,
.cot-item-editor-window .form-group textarea {
    width: 100%; min-height: 38px; padding: 7px 10px;
    border-color: var(--settings-line); background-color: var(--settings-tint); color: var(--settings-ink);
    font: 400 calc(13px * var(--app-font-scale)) / 1.4 var(--font-family);
}
.cot-item-editor-window .form-group select { padding-inline-end: 25px; }

.cot-prompt-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.cot-prompt-field-header label { margin: 0; }
#cot-item-expand-btn { background: var(--settings-tint); border: 1px solid var(--settings-line); color: var(--settings-ink); }

.cot-prompt-dialog {
    box-sizing: border-box;
    width: min(760px, calc(100% - 24px));
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    max-height: 720px;
    padding: 16px;
    border: 0;
    border-radius: var(--border-radius);
    background: var(--panel-bg, #fff);
    color: var(--text-color, #333);
}

.cot-prompt-dialog[open] {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cot-prompt-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.cot-prompt-dialog h3 { margin: 0; }

.cot-prompt-dialog textarea {
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(128, 128, 128, .4);
    border-radius: 8px;
    background: inherit;
    color: inherit;
    font: 400 calc(16px * var(--app-font-scale)) / 1.65 var(--font-family);
    resize: none;
}

.cot-prompt-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cot-prompt-dialog-actions [hidden] { display: none; }

.cot-item-scope-fieldset {
    min-width: 0;
    margin: 10px 0;
    padding: 8px 10px;
    border: 1px solid var(--settings-line);
    border-radius: 8px;
    color: var(--settings-ink);
    font: 400 calc(13px * var(--app-font-scale)) / 1.5 var(--font-family);
}
.cot-item-scope-fieldset legend {
    max-width: 100%;
    padding: 0 5px;
    font-weight: 500;
    overflow-wrap: anywhere;
}
.cot-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; }
.cot-check-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    min-height: 26px;
    overflow-wrap: anywhere;
}
.cot-check-grid input {
    flex: none;
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--settings-selected);
}
.cot-node-empty {
    grid-column: 1 / -1;
    color: var(--settings-muted);
    font-size: calc(12px * var(--app-font-scale));
    overflow-wrap: anywhere;
}
.cot-editor-notice { margin: 9px 0; padding: 8px 10px; border-radius: 7px; background: #fff8e6; color: #8a6818; font-size: 11px; line-height: 1.45; }
.cot-choice-overlay { align-items: center; justify-content: center; z-index: 100000; }
.cot-choice-window { box-sizing: border-box; width: min(90%, 330px); padding: 16px; }
.cot-choice-window h3 { margin: 0 0 7px; color: #333; font-size: 15px; text-align: left; }
.cot-choice-window p { margin: 0 0 12px; color: #888; font-size: 11px; line-height: 1.45; }
.cot-choice-actions { display: flex; flex-direction: column; gap: 7px; }
.cot-choice-actions .btn { width: 100%; margin: 0; padding: 8px 10px; font-size: 12px; }

@media (max-width: 390px) {

    .cot-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cot-inline-controls > * { flex: 1 1 100%; min-width: 0; }
}

.cot-thinking-visible { margin: 5px 0; }
.cot-thinking-details { max-width: min(86%, 520px); margin-left: 44px; border: 1px solid rgba(0,0,0,.08); border-radius: 9px; background: rgba(255,255,255,.72); color: #777; font-size: 12px; }
.cot-thinking-details summary { cursor: pointer; padding: 7px 10px; list-style-position: inside; }
.cot-thinking-body { padding: 0 10px 9px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }

@media (max-width: 390px) {
    .cot-thinking-details { max-width: calc(100vw - 64px); margin-left: 34px; }
}

/* 按钮组 */
.cot-btn-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cot-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: #f5f5f5;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.cot-icon-btn:hover:not(:disabled) {
    background: #e0e0e0;
    color: #333;
}

.cot-icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cot-item-name .cot-position-btn {
    display: inline-flex;
    width: auto;
    min-width: 26px;
    height: 24px;
    margin-right: 6px;
    padding: 0 4px;
    vertical-align: middle;
}

.cot-icon-btn.danger:hover {
    background: #fee;
    color: #d32f2f;
}

.cot-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* 模态框只读样式 */
.cot-readonly-textarea {
    background-color: #f9f9f9;
    color: #666;
    cursor: default;
}

.cot-lock-notice {
    font-size: 12px;
    color: #d32f2f;
    background: #fff0f0;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 标题栏操作按钮样式 */
.cot-help-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    border: none;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cot-help-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* XML 说明内容样式 */
.xml-tag-item {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.xml-tag-item:last-child {
    border-bottom: none;
}

.xml-tag-item code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    color: #d63384;
    font-family: monospace;
    font-weight: bold;
    font-size: 14px;
}

.xml-tag-item p {
    margin: 5px 0 0 0;
    font-size: 13px;
    color: #555;
}
