/* ============================================
   NODE DRAWER - Unified View/Edit Panel
   Replaces node-config-modal.css
   ============================================ */

.node-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    background: #1F2937;
    border-left: 1px solid #374151;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.node-drawer.hidden {
    transform: translateX(100%);
}

/* Edit mode - expanded width */
.node-drawer.edit-mode {
    width: 500px;
}

/* ---- Header ---- */
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}

.drawer-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.drawer-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #374151;
    border-radius: 8px;
    flex-shrink: 0;
}

.drawer-title-group {
    overflow: hidden;
}

.drawer-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-subtitle {
    font-size: 12px;
    color: #9CA3AF;
    font-family: monospace;
}

.drawer-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.drawer-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #374151;
}

.drawer-status.connected {
    color: #10B981;
}

.drawer-status.disconnected {
    color: #F59E0B;
}

.drawer-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.drawer-close {
    background: transparent;
    border: none;
    color: #9CA3AF;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.drawer-close:hover {
    background: #374151;
    color: white;
}

/* ---- View Mode Content ---- */
.drawer-view-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.drawer-section {
    padding: 16px;
    border-bottom: 1px solid #374151;
}

/* Node title displayed prominently above Action */
.drawer-title-section {
    padding: 16px 16px 12px;
}

.drawer-node-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #F9FAFB;
    line-height: 1.4;
    overflow-wrap: break-word;
}

.drawer-section label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.drawer-value {
    margin: 0;
    color: white;
    font-size: 14px;
}

.drawer-params {
    background: #111827;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #9CA3AF;
    margin: 0;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.drawer-actions {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* ---- Edit Mode Content ---- */
.drawer-edit-content {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* When in edit mode, show edit content and hide view content */
.node-drawer.edit-mode .drawer-view-content {
    display: none;
}

.node-drawer.edit-mode .drawer-edit-content {
    display: flex;
}

/* ---- Tabs ---- */
.drawer-tabs {
    display: flex;
    gap: 2px;
    padding: 12px 16px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
    overflow-x: auto;
}

.drawer-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9CA3AF;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.drawer-tab:hover:not(.disabled) {
    background: #374151;
    color: white;
}

.drawer-tab.active {
    background: #3B82F6;
    color: white;
}

.drawer-tab.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.drawer-tab span {
    font-size: 14px;
}

/* ---- Tab Content ---- */
.drawer-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Variable Hint Box */
.variable-hint {
    background: #1E3A5F;
    border: 1px solid #3B82F6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.variable-hint strong {
    display: block;
    color: #60A5FA;
    font-size: 13px;
    margin-bottom: 4px;
}

.variable-hint p {
    margin: 0;
    font-size: 12px;
    color: #93C5FD;
}

.variable-hint code {
    background: #111827;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* Config Form */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 13px;
    font-weight: 500;
    color: #E5E7EB;
}

.form-field .required {
    color: #EF4444;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 10px 12px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #3B82F6;
}

.form-field textarea {
    min-height: 100px;
    resize: vertical;
    font-family: Monaco, Menlo, monospace;
}

.form-field .field-hint {
    font-size: 11px;
    color: #6B7280;
}

/* Coming Soon Placeholder */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #6B7280;
}

.coming-soon-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.coming-soon h4 {
    margin: 0 0 8px 0;
    color: #9CA3AF;
    font-size: 16px;
}

.coming-soon p {
    margin: 0 0 12px 0;
    font-size: 13px;
}

.coming-soon .badge {
    background: #374151;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
}

/* ---- Footer ---- */
.drawer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-top: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}

.drawer-footer-right {
    display: flex;
    gap: 10px;
}

/* ---- Buttons ---- */
.drawer-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.drawer-btn.primary {
    background: #3B82F6;
    color: white;
}

.drawer-btn.primary:hover {
    background: #2563EB;
}

.drawer-btn.secondary {
    background: #374151;
    color: white;
}

.drawer-btn.secondary:hover {
    background: #4B5563;
}

.drawer-btn.danger {
    background: #DC2626;
    color: white;
}

.drawer-btn.danger:hover {
    background: #B91C1C;
}

.drawer-btn.danger-outline {
    background: transparent;
    color: #EF4444;
    border: 1px solid #EF4444;
}

.drawer-btn.danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
    .node-drawer {
        width: 100%;
        max-height: 70vh;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-top: 1px solid #374151;
    }

    .node-drawer.hidden {
        transform: translateY(100%);
    }

    .node-drawer.edit-mode {
        width: 100%;
        max-height: 85vh;
    }

    .drawer-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .drawer-actions,
    .drawer-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .drawer-footer {
        flex-direction: column;
        gap: 10px;
    }

    .drawer-footer-right {
        width: 100%;
    }

    .drawer-footer-right .drawer-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================
   TOOLBAR - Move to bottom-center
   ============================================ */

/* Override the toolbar position from agent_builder.html inline styles */
.workflow-toolbar {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: auto !important;
    right: auto !important;
    z-index: 60;
    display: flex;
    gap: 4px;
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 6px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: calc(100% - 24px);
    box-sizing: border-box;
}

/* Mobile toolbar - stay centered at bottom, compact layout */
@media (max-width: 768px) {
    .workflow-toolbar {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        padding: 4px 8px;
        gap: 3px;
    }
}

@media (max-width: 480px) {
    .workflow-toolbar {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding: 4px 6px;
        gap: 2px;
        /* Single row, always: the slimmed button set fits 320px-wide
           phones, and wrapping would grow the bar over the canvas */
        flex-wrap: nowrap;
        justify-content: center;
        max-width: calc(100% - 16px);
    }
}

/* Dim toolbar when drawer is in edit mode */
body.drawer-edit-mode .workflow-toolbar {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* ============================================
   PHASE 2: Navigation Buttons
   ============================================ */

.nav-btn {
    background: transparent;
    border: 1px solid #374151;
    color: #9CA3AF;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 12px;
}

.nav-btn:hover:not(:disabled) {
    background: #374151;
    color: white;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.drawer-header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    min-width: 0;
    overflow: hidden;
}

.editing-badge {
    color: #F59E0B;
    font-weight: 500;
}

/* ============================================
   PHASE 2: Prompt Tab Styles
   ============================================ */

.prompt-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.prompt-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}

.prompt-textarea:focus {
    outline: none;
    border-color: #3B82F6;
}

.prompt-hint {
    background: #1E3A5F;
    border: 1px solid #3B82F6;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    color: #93C5FD;
}

.regenerate-btn {
    align-self: flex-start;
}

.regenerate-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.regenerate-btn.loading::after {
    content: ' ⏳';
}

.context-variables {
    margin-top: 8px;
}

.context-variables .field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #E5E7EB;
    margin-bottom: 8px;
}

.context-variables ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.context-variables li {
    padding: 6px 10px;
    background: #111827;
    border-radius: 4px;
    margin-bottom: 4px;
    font-family: Monaco, Menlo, monospace;
    font-size: 12px;
    color: #9CA3AF;
}

.context-variables li:hover {
    background: #1F2937;
    color: #E5E7EB;
}

/* ============================================
   PHASE 2: Chat Tab Styles
   ============================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 300px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 12px;
    max-height: 400px;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.user .message-avatar {
    background: #3B82F6;
}

.message-content {
    background: #374151;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    overflow-wrap: break-word;
}

.chat-message.user .message-content {
    background: #3B82F6;
}

.message-content pre {
    background: #111827;
    padding: 8px;
    border-radius: 6px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 12px;
    white-space: pre-wrap;
}

.message-content code {
    background: #111827;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: Monaco, Menlo, monospace;
}

.suggestion-apply-btn {
    margin-top: 8px;
    padding: 8px 16px;
    background: #10B981;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-block;
    transition: background 0.15s;
}

.suggestion-apply-btn:hover {
    background: #059669;
}

.suggestion-apply-btn:disabled {
    background: #6B7280;
    cursor: default;
    opacity: 0.7;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #374151;
    margin-top: auto;
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    resize: none;
    font-family: inherit;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #3B82F6;
}

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chat-send-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-send-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #6b7280;
    cursor: not-allowed;
}

.chat-send-btn .btn-icon {
    font-size: 14px;
}

.chat-send-btn .kbd-hint {
    font-size: 11px;
    opacity: 0.5;
    margin-left: 2px;
}

/* Typing indicator */
.chat-message.typing .message-content::after {
    content: '...';
    animation: typing 1s infinite;
}

@keyframes typing {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ============================================
   PHASE 2: Preview Modal Styles
   ============================================ */

.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.preview-modal.hidden {
    display: none;
}

.preview-container {
    width: min(500px, 90vw);
    max-height: 80vh;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 16px;
    border-bottom: 1px solid #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111827;
}

.preview-header h3 {
    margin: 0;
    font-size: 16px;
    color: white;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.preview-content > p {
    color: #9CA3AF;
    margin: 0 0 12px 0;
    font-size: 14px;
}

.preview-diff {
    background: #111827;
    border-radius: 8px;
    padding: 12px;
    font-family: Monaco, Menlo, monospace;
    font-size: 13px;
}

.diff-field {
    margin-bottom: 16px;
}

.diff-field:last-child {
    margin-bottom: 0;
}

.diff-field-name {
    color: #60A5FA;
    font-weight: 500;
    margin-bottom: 6px;
}

.diff-removed {
    color: #EF4444;
    text-decoration: line-through;
    display: block;
    padding: 4px 0;
}

.diff-added {
    color: #10B981;
    display: block;
    padding: 4px 0;
}

.diff-unchanged {
    color: #6B7280;
    display: block;
    padding: 4px 0;
}

.preview-footer {
    padding: 16px;
    border-top: 1px solid #374151;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #111827;
}

/* ============================================
   PHASE 2: Mobile Responsive Updates
   ============================================ */

@media (max-width: 768px) {
    .nav-btn {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    .drawer-header-center {
        padding: 0 8px;
    }

    .chat-messages {
        max-height: 250px;
    }

    .preview-container {
        width: 95vw;
        max-height: 90vh;
    }
}

/* ============================================
   PHASE 3: JSON Editor & Code Editor
   ============================================ */

.json-editor-container,
.code-editor-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-action-btn {
    padding: 6px 12px;
    background: #374151;
    border: 1px solid #4B5563;
    border-radius: 6px;
    color: #E5E7EB;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.editor-action-btn:hover {
    background: #4B5563;
}

.editor-action-btn.primary {
    background: #3B82F6;
    border-color: #3B82F6;
    color: white;
}

.editor-action-btn.primary:hover {
    background: #2563EB;
}

.editor-wrapper {
    display: flex;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden;
    flex: 1;
    min-height: 200px;
}

.line-numbers {
    padding: 12px 8px;
    background: #0D1117;
    color: #6B7280;
    font-family: Monaco, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    border-right: 1px solid #374151;
    min-width: 40px;
    overflow: hidden;
}

.json-editor,
.code-editor {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: #E5E7EB;
    font-family: Monaco, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    tab-size: 2;
}

.json-editor:focus,
.code-editor:focus {
    outline: none;
}

/* Validation Status */
.validation-status {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.validation-status.valid {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.validation-status.invalid {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.validation-status.neutral {
    background: #1F2937;
    color: #9CA3AF;
    border: 1px solid #374151;
}

/* Editor Actions */
.editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   PHASE 3: Code Editor Specific
   ============================================ */

.code-variables {
    margin-top: 8px;
}

.variable-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.variable-chip {
    padding: 4px 10px;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    color: #9CA3AF;
    cursor: pointer;
    transition: all 0.2s;
}

.variable-chip:hover {
    background: #374151;
    color: #E5E7EB;
    border-color: #4B5563;
}

.code-templates {
    margin-top: 8px;
}

.code-templates select {
    width: 100%;
    padding: 8px 12px;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #E5E7EB;
    font-size: 13px;
    cursor: pointer;
}

.code-templates select:focus {
    outline: none;
    border-color: #3B82F6;
}

/* Test Output */
.test-output {
    margin-top: 12px;
}

.test-result {
    padding: 12px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    min-height: 60px;
    max-height: 150px;
    overflow-y: auto;
}

.test-result.success {
    border-color: #10B981;
}

.test-result.error {
    border-color: #EF4444;
    color: #EF4444;
}

.test-placeholder {
    color: #6B7280;
    font-style: italic;
}

.test-result .result-value {
    color: #10B981;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.test-result .result-error {
    color: #EF4444;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.test-result .result-time {
    color: #6B7280;
    font-size: 11px;
    margin-top: 8px;
}

/* Loading state for Test button */
.editor-action-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.editor-action-btn.loading::after {
    content: '...';
    animation: dots 1s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ============================================
   PHASE 3: Mobile Responsive Updates
   ============================================ */

@media (max-width: 768px) {
    .editor-wrapper {
        min-height: 150px;
    }

    .line-numbers {
        min-width: 32px;
        padding: 8px 4px;
        font-size: 11px;
    }

    .json-editor,
    .code-editor {
        padding: 8px;
        font-size: 12px;
    }

    .editor-actions {
        flex-direction: column;
    }

    .editor-action-btn {
        width: 100%;
        text-align: center;
    }

    .variable-chips {
        max-height: 80px;
        overflow-y: auto;
    }

    .test-result {
        max-height: 100px;
    }
}

/* ============================================
   ADVANCED TAB: Accordion Sections
   ============================================ */

.advanced-sections {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.advanced-section {
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden;
    background: #1F2937;
}

.advanced-section + .advanced-section {
    margin-top: 4px;
}

.section-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #111827;
    border: none;
    color: #E5E7EB;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.section-header:hover {
    background: #1a2332;
}

.section-title {
    flex: 1;
}

.section-desc {
    font-size: 12px;
    color: #6B7280;
    font-weight: 400;
}

.section-chevron {
    color: #6B7280;
    font-size: 12px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.section-body {
    display: none;
    padding: 16px;
}

.advanced-section.expanded .section-body {
    display: block;
}

/* Reduce spacing within accordion section bodies */
.section-body .prompt-editor {
    gap: 12px;
}

.section-body .editor-wrapper {
    min-height: 160px;
}

/* Editor header with multiple action buttons */
.editor-header-actions {
    display: flex;
    gap: 6px;
}

@media (max-width: 768px) {
    .section-header {
        padding: 10px 12px;
        font-size: 13px;
    }

    .section-body {
        padding: 12px;
    }

    .section-desc {
        display: none;
    }
}

/* ---- Agent Step Config Tabs ---- */
.agent-config-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: #1F2937;
    border-radius: 8px;
}

.agent-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #9CA3AF;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.agent-tab:hover {
    background: #374151;
    color: #F9FAFB;
}

.agent-tab.active {
    background: #7c3aed;
    color: white;
}

.agent-tab-content {
    display: none;
}

.agent-tab-content.active {
    display: block;
}

/* Agent step node styling */
[data-step-type="agent"] {
    --node-color: #7c3aed;
}

/* Budget badge styling for agent nodes */
.agent-budget-badge {
    background: #7c3aed;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* ============================================
   MODEL SELECTOR - Per-node model override
   ============================================ */

.model-selector-field {
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 12px;
    background: #111827;
}

.model-selector-field > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: #E5E7EB;
}

.model-selector-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: #1F2937;
    border-radius: 6px;
    padding: 2px;
}

.model-tab {
    flex: 1;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #9CA3AF;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.model-tab.active {
    background: #374151;
    color: #F9FAFB;
}

.model-tab:hover:not(.active) {
    color: #D1D5DB;
}

.model-tab-content {
    display: none;
}

.model-tab-content.active {
    display: block;
}

.model-search-input {
    width: 100%;
    padding: 8px 10px;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #F9FAFB;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
    box-sizing: border-box;
}

.model-search-input:focus {
    border-color: #6366F1;
}

.model-search-input::placeholder {
    color: #6B7280;
}

.model-list {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-list.scrollable {
    max-height: 200px;
}

.model-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s ease;
    border: 1px solid transparent;
}

.model-item:hover {
    background: #1F2937;
}

.model-item.selected {
    background: rgba(99, 102, 241, 0.15);
    border-color: #6366F1;
}

.model-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-item-name {
    font-size: 13px;
    font-weight: 500;
    color: #E5E7EB;
}

.model-check {
    color: #6366F1;
    font-weight: bold;
    font-size: 14px;
}

.model-item-meta {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.model-price {
    font-size: 11px;
    color: #9CA3AF;
}

.model-context {
    font-size: 11px;
    color: #6B7280;
}

.model-current {
    margin-top: 10px;
    padding: 8px 10px;
    background: #1F2937;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-selected-label {
    font-size: 12px;
    color: #A5B4FC;
    font-weight: 500;
}

.model-default-label {
    font-size: 12px;
    color: #6B7280;
    font-style: italic;
}

.model-clear-btn {
    background: transparent;
    border: 1px solid #4B5563;
    border-radius: 4px;
    color: #9CA3AF;
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.model-clear-btn:hover {
    border-color: #EF4444;
    color: #EF4444;
}

.model-pricing-note {
    font-size: 11px;
    color: #6B7280;
    font-style: italic;
    margin-top: 6px;
    text-align: center;
}

.model-loading,
.model-error,
.model-empty {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: #6B7280;
}

.model-error {
    color: #EF4444;
}

/* Scrollbar styling for model list */
.model-list::-webkit-scrollbar {
    width: 4px;
}

.model-list::-webkit-scrollbar-track {
    background: transparent;
}

.model-list::-webkit-scrollbar-thumb {
    background: #4B5563;
    border-radius: 2px;
}

/* Static hint for palette model-select field */
.field-hint-static {
    font-size: 12px;
    color: #6B7280;
    font-style: italic;
    padding: 6px 0;
}

/* ============================================
   VIEW MODE: Summary + Quick-Edit Fields
   ============================================ */

.drawer-summary-section {
    padding: 16px;
    border-bottom: 1px solid #374151;
}

.drawer-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    background: var(--badge-color, #6B7280);
    margin-bottom: 8px;
}

.drawer-summary {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: #F9FAFB;
    line-height: 1.5;
    overflow-wrap: break-word;
}

/* ---- AI Summary Section ---- */
.drawer-ai-summary {
    padding: 12px 16px;
    border-bottom: 1px solid #374151;
}

.ai-summary-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.ai-summary-label {
    font-size: 11px;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-summary-text {
    margin: 0;
    font-size: 14px;
    color: #D1D5DB;
    line-height: 1.5;
}

.ai-summary-btn {
    width: 100%;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed #3B82F6;
    border-radius: 8px;
    color: #60A5FA;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: all 0.2s;
}

.ai-summary-btn:hover {
    background: rgba(59, 130, 246, 0.2);
}

.ai-summary-error {
    font-size: 13px;
    color: #F87171;
}

.ai-summary-error a {
    color: #60A5FA;
    text-decoration: underline;
}

/* ---- Field Rows ---- */
.drawer-fields {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.drawer-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #2D3748;
    gap: 12px;
}

.drawer-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 70px;
    margin-bottom: 0;
}

.drawer-field .drawer-value {
    margin: 0;
    font-size: 13px;
    color: #E5E7EB;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.drawer-field .drawer-value.code {
    font-family: Monaco, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #9CA3AF;
    white-space: pre-wrap;
    text-align: left;
}

/* ---- Quick-Edit Dropdowns ---- */
.drawer-quick-select {
    padding: 5px 10px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #E5E7EB;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
    max-width: 170px;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.drawer-quick-select:hover {
    border-color: #4B5563;
}

.drawer-quick-select:focus {
    outline: none;
    border-color: #3B82F6;
}

/* ---- Toggle Switch ---- */
.drawer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 0;
    position: relative;
}

.drawer-toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.drawer-toggle input[type="checkbox"]:focus + .toggle-slider {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: #374151;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #9CA3AF;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.drawer-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: #3B82F6;
}

.drawer-toggle input[type="checkbox"]:checked + .toggle-slider::after {
    transform: translateX(16px);
    background: white;
}

/* ---- Data Flow Section ---- */
.drawer-dataflow {
    padding: 10px 16px;
    border-bottom: 1px solid #374151;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dataflow-item {
    font-size: 12px;
    color: #6B7280;
    display: block;
}

.dataflow-item::before {
    margin-right: 6px;
}

/* ---- Advanced Tab: Info Panel ---- */
#drawer-info-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #2D3748;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.info-value {
    font-size: 13px;
    color: #D1D5DB;
    font-family: Monaco, Menlo, Consolas, monospace;
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.info-json {
    background: #111827;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #9CA3AF;
    font-family: Monaco, Menlo, Consolas, monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-top: 4px;
}

/* ---- Mobile for new view mode elements ---- */
@media (max-width: 768px) {
    .drawer-field {
        padding: 8px 12px;
    }

    .drawer-quick-select {
        max-width: 140px;
        font-size: 12px;
    }

    .drawer-summary {
        font-size: 14px;
    }
}
