/* CodeEditor component - CodeMirror 6 integration */

.code-editor {
    height: 100%;
    overflow: hidden;
}

.code-editor .cm-editor {
    height: 100%;
    outline: none;
}

.code-editor .cm-scroller {
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* Text and cursor colors from syntax variables */
.code-editor .cm-editor {
    color: var(--syntax-text);
}

.code-editor .cm-content {
    caret-color: var(--syntax-key);
}

.code-editor .cm-cursor {
    border-left-color: var(--syntax-key);
}

/* Remove default focus outline - we handle it via the container */
.code-editor .cm-editor.cm-focused {
    outline: none;
}

/* Search panel */
.code-editor .cm-panel {
    font-size: 0.8125rem;
}

.code-editor .cm-panel input,
.code-editor .cm-panel button {
    font-size: 0.8125rem;
}

/* DiffEditor component - CodeMirror MergeView */

.diff-editor {
    height: 100%;
    overflow: hidden;
}

.diff-editor .cm-mergeView {
    height: 100%;
}

.diff-editor .cm-mergeView > div {
    height: 100%;
}

.diff-editor .cm-editor {
    height: 100%;
    outline: none;
    color: var(--syntax-text);
}

.diff-editor .cm-editor.cm-focused {
    outline: none;
}

.diff-editor .cm-scroller {
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

.diff-editor .cm-content {
    caret-color: var(--syntax-key);
}

/* Change highlighting */
.diff-editor .cm-changedLine {
    background-color: rgba(234, 179, 8, 0.06);
}

.diff-editor .cm-deletedChunk,
.diff-editor .cm-changedText.del {
    background-color: rgba(239, 68, 68, 0.15);
}

.diff-editor .cm-insertedLine,
.diff-editor .cm-changedText.ins {
    background-color: rgba(34, 197, 94, 0.15);
}

/* Collapsed unchanged regions */
.diff-editor .cm-collapsedLines {
    color: var(--color-text-muted);
    font-size: 0.6875rem;
    padding: 2px 12px;
    cursor: pointer;
}

/* Gap between panels */
.diff-editor .cm-mergeViewGutter {
    background: var(--color-border-default);
    width: 1px;
}

/* Custom unified word-level diff (jsdiff-based) */

.diff-editor.diff-view {
    height: 100%;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-surface);
    padding: 4px 0;
}

.diff-editor.diff-view .diff-line {
    display: flex;
    white-space: pre-wrap;
    padding: 0 12px 0 0;
}

.diff-editor.diff-view .diff-marker {
    display: inline-block;
    width: 1.5rem;
    flex-shrink: 0;
    text-align: center;
    color: var(--color-text-muted);
    user-select: none;
    opacity: 0.6;
}

.diff-editor.diff-view .diff-content {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.diff-editor.diff-view .diff-line-removed {
    background-color: rgba(239, 68, 68, 0.10);
}

.diff-editor.diff-view .diff-line-added {
    background-color: rgba(34, 197, 94, 0.10);
}

.diff-editor.diff-view .diff-line-removed .diff-marker {
    color: rgb(220, 38, 38);
}

.diff-editor.diff-view .diff-line-added .diff-marker {
    color: rgb(22, 163, 74);
}

.diff-editor.diff-view .diff-word-removed {
    background-color: rgba(239, 68, 68, 0.35);
}

.diff-editor.diff-view .diff-word-added {
    background-color: rgba(34, 197, 94, 0.35);
}
