﻿/* DataBricks-inspired table styling */
.bg-toolbar {
    background: #F5F7FA;
}

/* Allow horizontal scrolling for main layout content */
.horizontal-scroll {
    width: 100%;
    overflow-x: auto;
}

.workspace {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 0;
}

.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-height: 0;
}

.code-editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.run-row{
    padding: 0.45rem 0.4rem 0.45rem 2rem;
    background: white;
    z-index: 20;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.editor-textarea {
    flex: 1;
    width: 100%;
    border: none;
    padding: 16px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: #1a1a1a;
    color: #e0e0e0;
    overflow: auto;
}

    .editor-textarea::placeholder {
        color: #666;
    }

/* Splitter */
.splitter {
    height: 6px;
    background: white;
    cursor: ns-resize;
    position: relative;
    z-index: 10;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

    .splitter:hover,
    .splitter.resizing {
        background: rgba(128, 128, 128, 0.35);
    }

/* Results panel */
.results-container {
    background: #f8f9fa;
    border-top: 1px solid #dcdcdc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 150px;
    max-height: 600px;
    flex-shrink: 0;
}

.results-header {
    border-bottom: 1px solid #dcdcdc;
    color: black;
    flex-shrink: 0;
}

.results-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

/* Box wrapper for SSMS-style look */
.results-table-box {
    background-color: #ffffff; /* matches your table background */
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}
    

/* Table container */
.table-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    position: relative;
}

.table-header-wrapper {
    flex-shrink: 0;
    overflow: hidden;
    background: #ececec;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid #dcdcdc;
}

    .table-header-wrapper::-webkit-scrollbar {
        display: none;
    }

.table-body-wrapper {
    flex: 1;
    overflow: auto;
    min-height: 0;
    max-height: 100%;
    position: relative;
    scrollbar-gutter: stable;
    will-change: transform;
}

.table-header-wrapper table,
.table-body-wrapper table {
    width: fit-content;
}

/* Table styles */
.dark-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: #ffffff;
    margin: 0;
    table-layout: fixed;
    --column-width: 180px;
    --column-min-width: 120px;
    --column-max-width: 420px;
}

    .dark-table thead th {
        background: #ffffff;
        color: #212529;
        font-weight: 600;
        font-size: 12px;
        text-transform: none;
        letter-spacing: 0;
        padding: 12px 16px;
        white-space: nowrap;
        border-right: 1px solid #d6d6d6;
        border-bottom: 2px solid #d6d6d6;
        width: var(--column-width);
        min-width: var(--column-min-width);
        max-width: var(--column-max-width);
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: center;
        cursor: pointer;
        transition: background-color 0.12s ease;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }

        .dark-table thead th:hover {
            background: #f0f0f0;
        }

        .dark-table thead th:last-child {
            border-right: none;
        }

        .dark-table tbody td {
            color: #212529;
            font-size: 13px;
            padding-left: 5px;
            border-right: 1px solid #d6d6d6;
            border-bottom: 1px solid #d6d6d6;
            white-space: nowrap;
            width: var(--column-width);
            min-width: var(--column-min-width);
            max-width: var(--column-max-width);
            overflow: hidden;
            text-overflow: ellipsis;
            background: #ffffff;
            user-select: text;
            -webkit-user-select: text;
            -moz-user-select: text;
            -ms-user-select: text;
        }

        .dark-table tbody td:last-child {
            border-right: none;
        }

    .dark-table tbody tr:hover td {
        background: #eaf6ff;
    }

    .dark-table tbody tr:nth-child(even) td {
        background: #fbfbfb;
    }

    .dark-table tbody tr:nth-child(even):hover td {
        background: #eaf6ff;
    }

.cell-null {
    color: #6c757d;
    font-style: italic;
}

/* Scrollbar styling */
.table-body-wrapper::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

.table-body-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-body-wrapper::-webkit-scrollbar-thumb {
    background: #cfcfcf;
    border-radius: 5px;
}

    .table-body-wrapper::-webkit-scrollbar-thumb:hover {
        background: #bfbfbf;
    }

/* Badges */
.rows-badge {
    background: var(--bs-primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Prevent text selection during resize */
.noselect {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}


/* Make CodeMirror fill the editor wrapper */
/* Editor container (used by Monaco now, previously CodeMirror) */
.cm-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: white;
}

/* Make Monaco fill the container */
.cm-container .monaco-editor,
.cm-container .monaco-editor .overflow-guard {
    width: 100% !important;
    height: 100% !important;
}

/* Monaco line number gutter tweaks */
.cm-container .monaco-editor .margin {
    border-right: none !important; /* remove vertical border line */
    width: 38px !important;        /* narrower gutter */
}

.cm-container .monaco-editor .margin .margin-view-overlays {
    padding-left: 0.3rem !important; /* pull numbers closer to the code */
}

/* Monaco scrollbars to roughly match previous styling */
.monaco-scrollable-element > .scrollbar.vertical,
.monaco-scrollable-element > .scrollbar.horizontal {
    width: 10px !important;
}

.monaco-scrollable-element > .scrollbar > .slider {
    background: #c4c4c4;
    border-radius: 5px;
}

.monaco-scrollable-element > .scrollbar > .slider:hover {
    background: #b0b0b0;
}

/* Results box to mimic SSMS panel */
.results-table-box {
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.28);
    margin: 5px 6px;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Ensure the inner container can shrink and the body wrapper gets the available space */
.results-table-box .table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: transparent;
}

/* reduce header wrapper contrast inside box if needed */
.results-table-box .table-header-wrapper {
    background: transparent;
    border-bottom: none;
}

/* Custom styling for the Run button: smaller and more rounded */
.btn.run-btn {
    padding: 4px 8px;
    font-size: 0.80rem;
    border-radius: 8px;
    height: 27px;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.12s ease, transform 0.06s ease;
}

/* Slightly reduce icon size so it fits proportionally */
.btn.run-btn .bi {
    font-size: 0.88rem;
}

/* Keep disabled visuals reasonable */
.btn.run-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Optional hover feedback (subtle) */
.btn.run-btn:not(:disabled):active {
    transform: translateY(1px);
}

/* Custom styling for the Run button dropdown: smaller and more rounded */
.btn.run-btn-dropdown {
    padding: 4px 8px;
    font-size: 0.80rem;
    border-radius: 8px;
    height: 27px;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.12s ease, transform 0.06s ease;
    border-left: 1px solid white !important;
}

/* Slightly reduce icon size so it fits proportionally */
.btn.run-btn-dropdown .bi {
    font-size: 0.88rem;
}

/* Keep disabled visuals reasonable */
.btn.run-btn-dropdown:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Optional hover feedback (subtle) */
.btn.run-btn-dropdown:not(:disabled):active {
    transform: translateY(1px);
}

.btn-group.position-relative > .dropdown-menu {
    left: 0;
    transform: translate(0px, 30px) !important;
}

/* Custom styling for the Export button: smaller and more rounded */
.btn.export-btn {
    padding: 4px 8px;
    font-size: 0.80rem;
    line-height: 1;
    border-radius: 8px;
    height: 27px;
    min-width: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.12s ease, transform 0.06s ease;
}

    /* Slightly reduce icon size so it fits proportionally */
    .btn.export-btn .bi {
        font-size: 0.88rem;
    }

    /* Keep disabled visuals reasonable */
    .btn.export-btn:disabled {
        opacity: 0.8;
        cursor: not-allowed;
    }

    /* Optional hover feedback (subtle) */
    .btn.export-btn:not(:disabled):active {
        transform: translateY(1px);
    }

/* Disabled state */
.btn.save-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Custom styling for the Close button: smaller and more rounded */
.btn.close-btn {
    padding: 4px 8px;
    font-size: 0.80rem;
    line-height: 1;
    border-radius: 8px;
    height: 27px;
    min-width: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.12s ease, transform 0.06s ease;
}

    /* Slightly reduce icon size so it fits proportionally */
    .btn.close-btn .bi {
        font-size: 0.88rem;
    }

/* Custom CodeMirror hint styling (improved visuals) */
.CodeMirror-hints {
    max-height: 320px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid rgba(16,24,40,0.08);
    box-shadow: 0 12px 30px rgba(2,6,23,0.12);
    border-radius: 8px;
    padding: 6px 6px;
    font-size: 13px;
    color: #111827;
    z-index: 1200;
}

/* Individual hint item */
.CodeMirror-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 120ms ease, transform 60ms ease;
    background: transparent;
}

/* Hover / active */
.CodeMirror-hint-active {
    background: linear-gradient(90deg, rgba(13,110,253,0.10), rgba(2,6,23,0.03));
    transform: translateY(-1px);
}

/* Icon slot (left) */
.cm-hint-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(0,0,0,0.00);
}

/* default icon color (keeps previous styling) */
.cm-hint-icon {
    color: #0d6efd;
}

/* specific defaults (optional) - override per-type in render if needed */
/* e.g. columns you can keep green by default */
.CodeMirror-hints .CodeMirror-hint .cm-hint-icon svg {
    /* ensure svg respects currentColor */
    /* no styles required here if SVG uses currentColor */
}

/* when a hint item is active, make icon white while preserving no extra highlight around the icon */
.CodeMirror-hint-active .cm-hint-icon {
    color: #ffffff !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* main text becomes white on active (you already had this) */
.CodeMirror-hint-active .cm-hint-main {
    color: #ffffff !important;
}
.CodeMirror-hint-active .cm-hint-desc {
    color: rgba(255,255,255,0.85) !important;
}

/* Main text */
.cm-hint-main {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Fira Code", monospace;
    font-size: 13px;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Description / meta text on the right */
.cm-hint-desc {
    margin-left: auto;
    font-size: 12px;
    color: #6b7280;
    padding-left: 12px;
    white-space: nowrap;
}

/* Keep description readable when item active, but not overpowering */
li.CodeMirror-hint-active .cm-hint-desc {
    color: #ffffff !important;
}

/* small tweak for container placement if using document.body */
.CodeMirror-hints[style] {
    box-shadow: 0 14px 36px rgba(2,6,23,0.14);
}

/* ensure keyboard focus highlight is visible above layout */
.CodeMirror-hints {
    outline: none;
}

/* Add at the end of your existing CSS */

/* Line number column styling */
.line-number-header,
.line-number-cell {
    background: #ffffff !important;
    color: #666 !important;
    font-weight: 500;
    font-size: 11px;
    text-align: center !important;
    padding: 8px 6px !important;
    width: 45px !important;
    min-width: 45px !important;
    max-width: 45px !important;
    border-right: 2px solid #d0d0d0 !important;
    user-select: none;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    cursor: pointer;
    position: sticky;
    left: 0;
    z-index: 4;
}


/* Keep line numbers fixed even on row hover */
.dark-table tbody tr:hover .line-number-cell {
    background: #f0f0f0 !important;
}

.dark-table tbody tr:nth-child(even) .line-number-cell {
    background: #fbfbfb !important;
}

.dark-table tbody tr:nth-child(even):hover .line-number-cell {
    background: #f0f0f0 !important;
}

.dark-table thead th:not(:first-child) {
    position: relative !important;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: -2px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
}

.column-resizer:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Selection styles for table */
.selected-cell {
    background: #cce5ff !important;
    position: relative;
}

.selected-line {
    font-weight: 700 !important;
    color: #003d7a !important;
}

.selected-column {
    font-weight: 700 !important;
    color: #003d7a !important;
}

.selected-all {
    background: #99ccff !important;
    cursor: pointer;
}

/* Hover effects for clickable elements */
.line-number-header:hover {
    background: #e0e0e0 !important;
}

.line-number-cell:hover {
    background: #e8e8e8 !important;
}

[id^="results-table-"]:focus,
[id^="results-table-"]:focus-visible {
    outline: none;
    box-shadow: none; /* optional, removes Bootstrap’s focus halo */
}

/* Or if you have a specific container class */
.results-container:focus {
    outline: none;
}


