:root {
    --primary-blue: #007bff;
    --primary-lilac: #8a2be2;
    --accent-blue: #6366f1;
    --accent-lilac: #a78bfa;
    --bg-main: #fcfdfe;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #f1f5f9;
    --accent: #6366f1;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline-color: var(--accent);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr 320px;
    height: 100vh;
}

/* Sidebar (Left) - Agent List */
aside {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-main);
    margin-bottom: 24px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--accent);
    border-radius: 2px;
}

.agent-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

nav#agentList {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background-color: #f3f4f6;
    color: var(--text-main);
}

.nav-item.active {
    background: #f3f4f6;
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 var(--accent);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* Main Content (Center) - Editor */
main.editor-pane {
    padding: 40px;
    overflow-y: auto;
    background: #ffffff;
}

.agent-header {
    margin-bottom: 32px;
}

.input-large {
    width: 100%;
    font-size: 2rem;
    font-weight: 700;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 0;
    color: var(--text-main);
}

.input-large:focus {
    border-bottom-color: var(--accent);
}

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* CodeMirror Customization */
.editor-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 32px;
    background: #ffffff;
}

.CodeMirror {
    height: 400px !important;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* Settings Sidebar (Right) */
.settings-pane {
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 24px;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.card-header {
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.card-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

.card-content {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    border-color: var(--accent);
    outline: none;
    background: rgba(79, 70, 229, 0.02);
}

.row {
    display: flex;
    gap: 12px;
}

.row .field {
    flex: 1;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius);
    transition: all 0.2s;
}

#saveBtn {
    width: 100%;
    padding: 12px;
    background: var(--text-main);
    color: white;
    border: none;
    font-size: 0.875rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#saveBtn:hover {
    background: #000;
}

.btn-secondary {
    padding: 8px 16px;
    background: #f3f4f6;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-danger {
    width: 100%;
    padding: 12px;
    background: #fff;
    color: #ef4444;
    border: 1px solid #fee2e2;
    margin-top: 8px;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--bg-main);
    color: var(--accent);
    border-color: var(--accent);
}

/* Utils */
.hidden {
    display: none !important;
}

.empty-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.url-copy-wrapper {
    display: flex;
    gap: 8px;
}

.status {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    margin-top: 12px;
    min-height: 1.25rem;
}

.status.success {
    color: #10b981;
}

.status.error {
    color: #ef4444;
}

/* Accordion Helpers */
.accordion-content {
    display: none;
}

.accordion-content.active {
    display: block;
}

.chevron {
    transition: transform 0.3s;
}

.chevron.rotated {
    transform: rotate(180deg);
}

/* RAG Help Modal & Info Trigger */
.info-trigger {
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.info-trigger:hover {
    color: var(--accent);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.step-guide {
    margin: 20px 0;
}

.step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.step-num {
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.arrow {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.code-block-header {
    background: #0f172a;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.sql-preview {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 0 0 8px 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 250px;
    border-left: 2px solid var(--accent);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.7rem;
}