/* INTENTOS code editor (CodeMirror) */
.code-editor-host {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.code-editor-host .CodeMirror {
    flex: 1;
    height: auto !important;
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace;
    font-size: var(--code-editor-font-size, 13px);
    line-height: 1.6;
}

.code-editor-host .CodeMirror-scroll {
    min-height: 100%;
}

.code-editor-toolbar-extras {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* Custom picker (replaces native select) — always dark (code panel is dark) */
.code-editor-picker {
    position: relative;
    flex-shrink: 0;
    --code-picker-bg: #18181b;
    --code-picker-border: rgba(255, 255, 255, 0.12);
    --code-picker-text: #e4e4e7;
    --code-picker-muted: #a1a1aa;
    --code-picker-hover: rgba(255, 255, 255, 0.08);
    --code-picker-active: color-mix(in srgb, #a3e635 16%, transparent);
    --code-picker-active-text: #a3e635;
}

.code-editor-picker-slot select,
.code-editor-select {
    display: none !important;
}

.code-editor-picker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    min-width: 4.75rem;
    max-width: 8.5rem;
    padding: 0.28rem 0.45rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font: 500 10px/1.2 ui-monospace, monospace;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.code-editor-picker-btn:hover {
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
}

.code-editor-picker-btn svg {
    flex-shrink: 0;
    opacity: 0.65;
    transition: transform 0.15s ease;
}

.code-editor-picker.open .code-editor-picker-btn svg {
    transform: rotate(180deg);
}

.code-editor-picker-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.code-editor-picker-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    min-width: 6.5rem;
    max-height: 15rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.75rem;
    border: 1px solid var(--code-picker-border);
    background: var(--code-picker-bg);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.48);
    padding: 0.3rem;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.code-editor-picker-menu.is-fixed {
    position: fixed;
    right: auto;
    top: auto;
}

.code-editor-picker.open .code-editor-picker-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.code-editor-picker-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.48rem 0.55rem;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--code-picker-text);
    font: 500 11px/1.25 ui-monospace, monospace;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.code-editor-picker-item:hover {
    background: var(--code-picker-hover);
    color: #fff;
}

.code-editor-picker-item.is-active {
    background: var(--code-picker-active);
    color: var(--code-picker-active-text);
    font-weight: 600;
}

.code-editor-swatch {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* legacy native selects — hidden when custom picker is used */

.code-editor-ai {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    width: min(22rem, calc(100% - 1.5rem));
    z-index: 12;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: color-mix(in srgb, var(--t-surface, #161616) 94%, transparent);
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.code-editor-ai.hidden { display: none; }

.code-editor-ai-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--t-accent);
}

.code-editor-ai-close {
    border: none;
    background: transparent;
    color: var(--t-text-muted, #9aa0aa);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 0.35rem;
}

.code-editor-ai-close:hover { color: var(--t-text); background: rgba(255,255,255,0.06); }

.code-editor-ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.5rem 0.65rem;
}

.code-editor-ai-actions button {
    padding: 0.3rem 0.55rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #c7ccd4;
    font: 500 10px/1 ui-monospace, monospace;
    cursor: pointer;
}

.code-editor-ai-actions button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }
.code-editor-ai-actions button:disabled { opacity: 0.4; cursor: wait; }
.code-editor-ai-actions button.is-active { border-color: var(--t-accent); color: var(--t-accent); }

.code-editor-ai-body {
    padding: 0 0.65rem 0.5rem;
    max-height: 10rem;
    overflow: auto;
    font: 11px/1.45 ui-monospace, monospace;
    color: var(--t-text-muted, #9aa0aa);
    white-space: pre-wrap;
    word-break: break-word;
}

.code-editor-ai-body.is-code { color: #7ee787; }

.code-editor-ai-foot {
    display: flex;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.code-editor-ai-foot button {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #c7ccd4;
    font: 500 10px/1 ui-monospace, monospace;
    cursor: pointer;
}

.code-editor-ai-foot button.is-primary {
    border-color: transparent;
    background: var(--t-accent);
    color: var(--t-accent-fg, #0a0a0a);
    font-weight: 600;
}

.code-editor-ai-foot button:hover:not(:disabled) { filter: brightness(1.05); }
.code-editor-ai-foot button:disabled { opacity: 0.35; cursor: not-allowed; }

.CodeMirror-hints {
    z-index: 100 !important;
    border-radius: 0.5rem !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    background: #1e1e1e !important;
    font-family: ui-monospace, monospace !important;
    font-size: 12px !important;
}

.CodeMirror-hint-active {
    background: color-mix(in srgb, var(--t-accent, #a3e635) 22%, #1e1e1e) !important;
    color: #fff !important;
}
