/* CodeMirror SQL editors */

.CodeMirror {
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    font-size: 14px;
    height: auto;
    min-height: 200px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: #272822;
    color: #f8f8f2;
}

.CodeMirror-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    z-index: 9999;
    border-radius: 0;
}

.CodeMirror-focused {
    border-color: var(--primary-400, #86b7fe);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(1, 74, 173, 0.2);
}

.CodeMirror-scroll {
    min-height: 200px;
    max-height: 600px;
}

#sourceQueryTextarea + .CodeMirror {
    min-height: 300px;
}

#targetInsertQueryTextarea + .CodeMirror {
    min-height: 200px;
}

.CodeMirror-linenumber {
    color: #6c757d;
    padding: 0 8px;
    min-width: 3em;
}

.CodeMirror-gutters {
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
}

.CodeMirror-cursor {
    border-left: 2px solid #212529;
}

.CodeMirror-selected {
    background: #49483e !important;
}

.CodeMirror-focused .CodeMirror-selected {
    background: #49483e !important;
}

.CodeMirror-activeline-background {
    background: rgba(0, 0, 0, 0.05);
}

.CodeMirror-hints {
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10000;
    color: #f8f8f2;
}

.CodeMirror-hint {
    padding: 6px 12px;
    cursor: pointer;
    color: #f8f8f2;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.CodeMirror-hint:hover {
    background: #2d2d2d;
    border-left-color: var(--primary-500, #014aad);
}

.CodeMirror-hint-active {
    background: var(--primary-500, #014aad) !important;
    color: white !important;
    border-left-color: var(--primary-600, #013f90);
}

.CodeMirror-foldgutter {
    width: 1.2em;
}

.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
    cursor: pointer;
    color: #888;
}

.CodeMirror-foldgutter-open:after {
    content: "\25BE";
}

.CodeMirror-foldgutter-folded:after {
    content: "\25B8";
}

.CodeMirror-scrollbar-filler {
    background: #272822;
}

.CodeMirror-trailingspace {
    background: rgba(255, 0, 0, 0.2);
    border-bottom: 1px dotted rgba(255, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .CodeMirror {
        font-size: 12px;
    }

    #sourceQueryTextarea + .CodeMirror {
        min-height: 250px;
    }

    #targetInsertQueryTextarea + .CodeMirror {
        min-height: 150px;
    }
}

/* ----- SQL overlay highlight (textarea + lớp trong suốt) ----- */
.sql-editor-container {
    position: relative;
    width: 100%;
}

.sql-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 0.375rem 0.75rem;
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    color: transparent;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    line-height: 1.5;
    tab-size: 4;
}

.sql-editor-container textarea {
    position: relative;
    z-index: 2;
    background: transparent !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    tab-size: 4;
    color: #333;
}

.sql-highlight .sql-keyword {
    color: #0078d4;
    font-weight: 600;
}

.sql-highlight .sql-string {
    color: #16825d;
    font-weight: 500;
}

.sql-highlight .sql-number {
    color: #d97706;
    font-weight: 500;
}

.sql-highlight .sql-operator {
    color: #dc2626;
    font-weight: 500;
}

.sql-highlight .sql-comment {
    color: #6b7280;
    font-style: italic;
}

.sql-editor-container textarea:focus {
    color: #000;
}

.sql-editor-container textarea:focus + .sql-highlight {
    border-color: #049ee0;
}
