/* AI Task Editor — standalone styles */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.ai-task-editor-body {
    height: 100vh;
    overflow: hidden;
    padding-top: 0 !important;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
}

/* === Theme variables (dark) === */
.ai-task-editor {
    --bg-primary: #1e1e2e;
    --bg-secondary: #181825;
    --bg-surface: #252538;
    --bg-hover: #2a2a3d;
    --bg-active: #333350;
    --border: #3b3b55;
    --text-primary: #cdd6f4;
    --text-secondary: #9399b2;
    --text-muted: #6c7086;
    --accent: #89b4fa;
    --accent-hover: #74c7ec;
    --green: #a6e3a1;
    --red: #f38ba8;
    --yellow: #f9e2af;
    --peach: #fab387;
    --mauve: #cba6f7;
    --radius: 5px;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* === Header === */
.ai-te-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ai-te-header h1 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.ai-te-header-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* === Main layout === */
.ai-te-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === Sidebar === */
.ai-te-sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-te-sidebar-toolbar {
    display: flex;
    gap: 3px;
    padding: 6px;
    border-bottom: 1px solid var(--border);
}

.ai-te-sidebar-filter {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
}

.ai-te-sidebar-filter select,
.ai-te-sidebar-filter input {
    width: 100%;
    margin-bottom: 3px;
}

.ai-te-task-list {
    flex: 1;
    overflow-y: auto;
    padding: 3px;
}

.ai-te-task-item {
    padding: 6px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 1px;
    transition: all 0.15s;
}

.ai-te-task-item:hover { background: var(--bg-hover); }
.ai-te-task-item.active { background: var(--bg-active); border-color: var(--accent); }

.ai-te-task-item .task-id { font-weight: 600; font-size: 11px; color: var(--text-primary); word-break: break-all; }
.ai-te-task-item .task-meta { display: flex; gap: 4px; margin-top: 2px; }
.ai-te-task-item .task-description {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Badges === */
.ai-te-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #313244;
}

.ai-te-badge-chat { color: var(--green); }
.ai-te-badge-toolSession { color: var(--mauve); }
.ai-te-badge-embedding { color: var(--yellow); }
.ai-te-badge-tts { color: var(--peach); }
.ai-te-badge-transcribe { color: var(--accent); }
.ai-te-badge-improveText { color: #94e2d5; }
.ai-te-badge-openai { background: #1a3a2a; color: var(--green); }
.ai-te-badge-claude { background: #2a1a3a; color: var(--mauve); }

/* === Center panel === */
.ai-te-center {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-width: 0;
}

.ai-te-center-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 200px;
}

.ai-te-pane-header {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    user-select: none;
}

.ai-te-pane-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* === Splitter === */
.ai-te-splitter {
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}

.ai-te-splitter:hover,
.ai-te-splitter.dragging { background: var(--accent); }

/* === Form sections (edit pane) === */
.ai-te-form-section {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.ai-te-form-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-te-form-section-title .hint {
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-weight: 400;
    opacity: 0.6;
}

/* === Ace containers === */
.ai-te-ace { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; }
.ai-te-ace-sm { height: 100px; }
.ai-te-ace-md { height: 180px; }
.ai-te-ace-lg { height: 280px; }
.ai-te-ace-xl { height: 350px; }

/* === Inputs === */
.ai-te-input,
.ai-task-editor input[type="text"],
.ai-task-editor input[type="number"],
.ai-task-editor select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 4px 6px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

.ai-task-editor input:focus,
.ai-task-editor select:focus { border-color: var(--accent); }

.ai-task-editor input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent); }

/* === Buttons === */
.ai-te-btn {
    padding: 4px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.ai-te-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.ai-te-btn-primary { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.ai-te-btn-primary:hover { background: var(--accent-hover); }
.ai-te-btn-danger { color: var(--red); border-color: transparent; }
.ai-te-btn-danger:hover { background: rgba(243, 139, 168, 0.1); border-color: var(--red); }
.ai-te-btn-sm { padding: 3px 7px; font-size: 10px; }
.ai-te-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Right panel === */
.ai-te-right-panel {
    width: 340px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-te-right-scroll {
    overflow-y: auto;
    padding: 4px 6px;
    flex-shrink: 0;
    max-height: 55%;
}

/* === Right panel compact form === */
.ai-te-rp-section {
    border-bottom: 1px solid var(--border);
    padding: 5px 0;
}

.ai-te-rp-section:last-child { border-bottom: none; }

.ai-te-rp-row {
    display: flex;
    gap: 5px;
    margin-bottom: 3px;
}

.ai-te-rp-row:last-child { margin-bottom: 0; }

.ai-te-rp-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.ai-te-rp-field label {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.ai-te-rp-field input,
.ai-te-rp-field select { padding: 3px 5px; font-size: 11px; }

.ai-te-rp-grow { flex: 1; }

.ai-te-rp-check {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    padding-top: 12px;
}

.ai-te-rp-check label {
    text-transform: none;
    font-size: 10px;
    color: var(--text-secondary);
}

/* === JSON Preview === */
.ai-te-json-preview-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    min-height: 0;
}

.ai-te-preview-header {
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-te-preview-header span {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Test pane === */
.ai-te-test-section { margin-bottom: 10px; }

.ai-te-test-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-te-test-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 8px 0;
}

.ai-te-test-result {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.ai-te-test-result-header {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 24px;
}

.ai-te-test-meta { display: flex; gap: 12px; font-size: 10px; color: var(--text-muted); }
.ai-te-test-meta .value { color: var(--text-primary); font-weight: 500; }

.ai-te-status { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; }
.ai-te-status-success { color: var(--green); }
.ai-te-status-error { color: var(--red); }
.ai-te-status-loading { color: var(--yellow); }

/* === Tool calls === */
.ai-te-tool-call {
    margin: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    overflow: hidden;
}

.ai-te-tool-call-header {
    padding: 4px 8px;
    background: rgba(203, 166, 247, 0.1);
    font-size: 10px;
    font-weight: 600;
    color: var(--mauve);
}

.ai-te-tool-call-body {
    padding: 6px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

/* === Tools multi-select === */
.ai-te-multi-select {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 30px;
}

.ai-te-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    background: var(--bg-active);
    border-radius: 12px;
    font-size: 11px;
    color: var(--accent);
}

.ai-te-chip .remove { cursor: pointer; color: var(--text-muted); font-size: 14px; line-height: 1; }
.ai-te-chip .remove:hover { color: var(--red); }

.ai-te-tool-dropdown { position: relative; }
.ai-te-tool-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 100;
    max-height: 150px;
    overflow-y: auto;
    display: none;
}

.ai-te-tool-dropdown-menu.open { display: block; }
.ai-te-tool-dropdown-item { padding: 5px 8px; cursor: pointer; font-size: 11px; }
.ai-te-tool-dropdown-item:hover { background: var(--bg-hover); }
.ai-te-tool-dropdown-item.selected { color: var(--accent); }

/* === File upload === */
.ai-te-file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary);
    margin-bottom: 6px;
}

.ai-te-file-upload:hover,
.ai-te-file-upload.dragover { border-color: var(--accent); background: rgba(137, 180, 250, 0.05); }

.ai-te-file-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 11px;
    margin-bottom: 6px;
}

.ai-te-file-info .file-name { flex: 1; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-te-file-info .file-remove { cursor: pointer; color: var(--text-muted); font-size: 14px; }
.ai-te-file-info .file-remove:hover { color: var(--red); }

/* === Collapsible log === */
.ai-te-collapsible {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
    overflow: hidden;
}

.ai-te-collapsible-header {
    padding: 6px 10px;
    background: var(--bg-surface);
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.ai-te-collapsible-header:hover { color: var(--text-secondary); }
.ai-te-collapsible-header .arrow { transition: transform 0.2s; font-size: 10px; }
.ai-te-collapsible-header.open .arrow { transform: rotate(90deg); }
.ai-te-collapsible-body { display: none; max-height: 350px; overflow: auto; }
.ai-te-collapsible-body.open { display: block; }

/* === Utility classes === */
.ai-te-mt-4 { margin-top: 4px; }
.ai-te-otp-input { width: 200px; }
.ai-te-upload-icon { font-size: 20px; }
.ai-te-upload-text { font-size: 11px; color: var(--text-muted); }
.ai-te-upload-hint { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.ai-te-justify-end { justify-content: flex-end; }
.ai-te-model-label { color: var(--text-secondary); margin-left: 4px; }
.ai-te-color-success { color: var(--green); }
.ai-te-color-warning { color: var(--yellow); }
.ai-te-tool-desc { color: var(--text-muted); font-size: 9px; margin-left: 6px; }
.ai-te-file-size { color: var(--text-muted); font-size: 10px; }

/* === Toast === */
.ai-te-toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 500;
    z-index: 2000;
    animation: ai-te-slideIn 0.3s ease;
    max-width: 320px;
}

.ai-te-toast-success { background: #2d4a3e; color: var(--green); border: 1px solid #3a6b52; }
.ai-te-toast-error { background: #4a2d3e; color: var(--red); border: 1px solid #6b3a52; }
.ai-te-toast-info { background: #2d3a4a; color: var(--accent); border: 1px solid #3a526b; }

@keyframes ai-te-slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Spinner === */
.ai-te-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ai-te-spin 0.6s linear infinite;
}

@keyframes ai-te-spin { to { transform: rotate(360deg); } }

/* === Scrollbar === */
.ai-task-editor ::-webkit-scrollbar { width: 5px; height: 5px; }
.ai-task-editor ::-webkit-scrollbar-track { background: transparent; }
.ai-task-editor ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.ai-task-editor ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Prepare section === */
.ai-te-prepare-section {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.ai-te-prepare-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    margin-bottom: 6px;
}

.ai-te-prepare-row:last-child { margin-bottom: 0; }

.ai-te-prepared-badge {
    font-size: 10px;
    color: var(--green);
    font-weight: 600;
}
