/* SQL page unified with the C/C++/Java/Python compiler interface. */
.sql-compiler-page .compiler-header {
    min-height: 94px;
}

.sql-compiler-page .compiler-header-actions {
    flex-wrap: nowrap;
}

.sql-compiler-page .sql-language-select { width: 185px; }
.sql-compiler-page .sql-database-select { width: 175px; }

.sql-compiler-page .compiler-workspace {
    grid-template-columns: minmax(0, 1.7fr) minmax(390px, .95fr);
}

.sql-compiler-page .compiler-tabs {
    align-items: end;
}

.sql-compiler-page .compiler-tab {
    min-width: 180px;
}

.sql-compiler-page .sql-icon-tool {
    width: 40px;
    padding: 0;
    justify-content: center;
}

.sql-compiler-page .compiler-stop-button {
    width: 44px;
    height: 50px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 44px;
    border: 1px solid var(--compiler-line);
    border-radius: 10px;
    color: var(--compiler-muted);
    background: var(--compiler-panel);
    cursor: pointer;
}
.sql-compiler-page .compiler-stop-button:hover { color: var(--compiler-red); border-color: #f1c6cb; background: var(--compiler-red-soft); }
.sql-compiler-page .compiler-stop-button:disabled { opacity: .45; cursor: default; }

.sql-compiler-page .sql-editor-host .CodeMirror {
    height: 100%;
    color: var(--compiler-text);
    background: var(--compiler-panel);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
}
.sql-compiler-page .sql-editor-host .CodeMirror-gutters {
    border-right: 1px solid var(--compiler-line);
    background: var(--compiler-panel-soft);
}
.sql-compiler-page .sql-editor-host .CodeMirror-linenumber { color: #8f9bb0; padding-right: 11px; }
.sql-compiler-page .sql-editor-host .CodeMirror-lines { padding: 14px 0; }
.sql-compiler-page .sql-editor-host .CodeMirror pre.CodeMirror-line,
.sql-compiler-page .sql-editor-host .CodeMirror pre.CodeMirror-line-like { padding: 0 14px; }
.sql-compiler-page .sql-editor-host .CodeMirror-cursor { border-left-color: var(--compiler-primary); }
.sql-compiler-page .sql-editor-host .CodeMirror-selected { background: rgba(6, 187, 204, .12); }

.sql-editor-footer {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding: 0 16px;
    border-top: 1px solid var(--compiler-line);
    color: var(--compiler-muted);
    background: var(--compiler-panel-soft);
    font-family: "JetBrains Mono", monospace;
    font-size: 9px;
}
.sql-editor-footer i { color: var(--compiler-primary); }

.sql-side-panel {
    display: block;
}

.sql-output-card {
    height: 100%;
}

.sql-output-header {
    flex: 0 0 auto;
}

.sql-result-tabs {
    min-height: 46px;
    display: flex;
    align-items: stretch;
    gap: 2px;
    padding: 0 10px;
    border-bottom: 1px solid var(--compiler-line);
    background: var(--compiler-panel);
}
.sql-result-tabs .result-tab {
    min-height: 45px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--compiler-muted);
    background: transparent;
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
}
.sql-result-tabs .result-tab.active {
    color: var(--compiler-primary-2);
    border-bottom-color: var(--compiler-primary);
}
.sql-result-tabs .result-tab b {
    min-width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--compiler-panel-soft);
    font-size: 8px;
}
.sql-result-fullscreen {
    width: 38px;
    margin-left: auto;
    padding: 0;
    justify-content: center;
}

.sql-result-meta {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--compiler-line);
    background: var(--compiler-panel-soft);
}
.sql-result-stats { display: flex; gap: 10px; color: var(--compiler-muted); font-size: 9px; }
.sql-result-actions { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.sql-result-search {
    width: 165px;
    height: 36px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid var(--compiler-line);
    border-radius: 8px;
    background: var(--compiler-panel);
}
.sql-result-search i { color: var(--compiler-muted); font-size: 9px; }
.sql-result-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--compiler-text);
    background: transparent;
    font-size: 9px;
}

.sql-tab-content {
    min-height: 0;
    flex: 1;
    display: none;
    overflow: auto;
}
.sql-tab-content.active { display: flex; flex-direction: column; }
.sql-compiler-page .compiler-output-card { display: flex; flex-direction: column; }
.sql-compiler-result {
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding: 14px;
    background: var(--compiler-panel);
}
.sql-compiler-result .compiler-empty-state { min-height: 100%; }
.sql-sample-button {
    margin-top: 14px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--compiler-line);
    border-radius: 8px;
    color: var(--compiler-text);
    background: var(--compiler-panel);
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
}
.sql-sample-button:hover { color: var(--compiler-primary-2); border-color: #9bddE4; background: #effcfd; }

.sql-compiler-page .compiler-result table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--compiler-line);
    border-radius: 10px;
    font-size: 10px;
}
.sql-compiler-page .compiler-result th,
.sql-compiler-page .compiler-result td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--compiler-line);
    border-right: 1px solid var(--compiler-line);
    color: var(--compiler-text);
    background: var(--compiler-panel);
}
.sql-compiler-page .compiler-result th { background: var(--compiler-panel-soft); font-weight: 800; }
.sql-compiler-page .compiler-result tr:last-child td { border-bottom: 0; }
.sql-compiler-page .compiler-result th:last-child,
.sql-compiler-page .compiler-result td:last-child { border-right: 0; }

.sql-compiler-page .messages-box { padding: 12px; }
.sql-compiler-page .message-entry {
    display: flex;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--compiler-line);
    border-radius: 9px;
    background: var(--compiler-panel-soft);
    font-size: 9px;
}
.sql-compiler-page .message-entry + .message-entry { margin-top: 8px; }
.sql-compiler-page .message-entry i { color: var(--compiler-primary); margin-top: 2px; }
.sql-compiler-page .message-entry b,
.sql-compiler-page .message-entry span { display: block; }
.sql-compiler-page .message-entry span { margin-top: 3px; color: var(--compiler-muted); }
.sql-compiler-page .message-entry.error i { color: var(--compiler-red); }

.sql-hidden-hooks { display: none !important; }

.sql-compiler-page .result-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
}
.sql-compiler-page .result-status.ready { color: #07855c; background: var(--compiler-green-soft); }
.sql-compiler-page .result-status.running { color: #6b5c10; background: #fff9df; }
.sql-compiler-page .result-status.error { color: #b23542; background: var(--compiler-red-soft); }

.sql-compiler-page .fullscreen-panel {
    position: fixed !important;
    inset: 14px !important;
    z-index: 2100 !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    border-radius: 14px !important;
    box-shadow: 0 24px 80px rgba(0,0,0,.25) !important;
}

@media (max-width: 1250px) {
    .sql-compiler-page .sql-database-select { display: none; }
    .sql-compiler-page .compiler-workspace { grid-template-columns: minmax(0, 1.55fr) minmax(340px, .95fr); }
    .sql-result-actions .compiler-tool span { display: none; }
}

@media (max-width: 980px) {
    .sql-compiler-page .compiler-header-actions #shortcutButton { display: none; }
    .sql-compiler-page .compiler-workspace { display: flex; flex-direction: column; height: auto; }
    .sql-compiler-page .compiler-editor-card { height: 650px; }
    .sql-compiler-page .sql-side-panel { height: 520px; }
    .sql-result-meta { align-items: flex-start; flex-direction: column; }
    .sql-result-actions { width: 100%; }
    .sql-result-search { flex: 1; width: auto; }
}

@media (max-width: 620px) {
    .sql-compiler-page .sql-language-select { width: 115px; }
    .sql-compiler-page .compiler-toolbar { flex-direction: column-reverse; align-items: stretch; }
    .sql-compiler-page .compiler-toolbar-left,
    .sql-compiler-page .compiler-toolbar-right { width: 100%; }
    .sql-compiler-page .compiler-run-button { width: 100%; min-width: 0; }
    .sql-result-tabs { overflow-x: auto; }
    .sql-result-tabs .result-tab { flex: 0 0 auto; }
    .sql-editor-footer { justify-content: flex-start; overflow-x: auto; white-space: nowrap; }
}


/* Force SQL query tabs to match the C/C++ compiler tabs exactly. */
.sql-compiler-page #queryTabs {
    min-height: 64px;
    padding-right: 8px;
}

.sql-compiler-page #queryTabs .compiler-tab {
    min-width: 180px !important;
    max-width: 180px;
    flex: 0 0 180px;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 -1px 8px;
    padding: 0 12px;
    border-radius: 11px 11px 0 0;
    font-size: 11px;
    font-weight: 600;
}

.sql-compiler-page #queryTabs .compiler-tab > span:nth-of-type(2) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
}

.sql-compiler-page #queryTabs .compiler-tab .language-chip {
    min-width: 25px;
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    font-size: 10px;
    font-weight: 800;
}

.sql-compiler-page #queryTabs .new-tab {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
}

/* Professional structured SQL result tables */
.sql-compiler-page .sql-results-stack {
    display: grid;
    gap: 14px;
    width: 100%;
}

.sql-compiler-page .sql-output-table {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--compiler-line);
    border-radius: 12px;
    background: var(--compiler-panel);
    box-shadow: 0 4px 14px rgba(20, 32, 57, .035);
}

.sql-compiler-page .sql-resultset-head {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--compiler-line);
    background: color-mix(in srgb, var(--compiler-panel-soft) 78%, #06bbcc 4%);
}

.sql-compiler-page .sql-resultset-head strong {
    color: var(--compiler-text);
    font-size: 10px;
    font-weight: 800;
}

.sql-compiler-page .sql-resultset-head span {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    color: #047f8c;
    background: #e9fbfd;
    font-size: 8px;
    font-weight: 800;
}

.sql-compiler-page .sql-output-table .table-responsive {
    width: 100%;
    overflow: auto;
    border: 0;
    border-radius: 0;
}

.sql-compiler-page .sql-output-table .sql-data-table {
    width: 100%;
    min-width: max-content;
    margin: 0 !important;
    border: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 10px;
}

.sql-compiler-page .sql-output-table .sql-data-table th,
.sql-compiler-page .sql-output-table .sql-data-table td {
    min-width: 105px;
    max-width: 360px;
    padding: 10px 12px;
    border-right: 1px solid var(--compiler-line);
    border-bottom: 1px solid var(--compiler-line);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.sql-compiler-page .sql-output-table .sql-data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #075f69;
    background: #edfcfd !important;
    font-family: Inter, "Segoe UI", sans-serif;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .015em;
}

.sql-compiler-page .sql-output-table .sql-data-table td {
    color: var(--compiler-text);
    background: var(--compiler-panel) !important;
}

.sql-compiler-page .sql-output-table .sql-data-table tbody tr:nth-child(even) td {
    background: color-mix(in srgb, var(--compiler-panel-soft) 68%, transparent) !important;
}

.sql-compiler-page .sql-output-table .sql-data-table tbody tr:hover td {
    background: #f1fcfd !important;
}

.sql-compiler-page .sql-output-table .sql-data-table th:last-child,
.sql-compiler-page .sql-output-table .sql-data-table td:last-child {
    border-right: 0;
}

.sql-compiler-page .sql-output-table .sql-data-table tbody tr:last-child td {
    border-bottom: 0;
}

.sql-compiler-page .sql-null {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 5px;
    color: var(--compiler-muted);
    background: var(--compiler-panel-soft);
    font-size: 8px;
    font-style: italic;
}

.sql-compiler-page .sql-no-rows td {
    padding: 22px !important;
    color: var(--compiler-muted) !important;
    text-align: center !important;
}

.sql-compiler-page .sql-empty-result {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 24px;
    color: #087e5d;
    text-align: left;
}

.sql-compiler-page .sql-empty-result > i {
    font-size: 24px;
}

.sql-compiler-page .sql-empty-result strong,
.sql-compiler-page .sql-empty-result span {
    display: block;
}

.sql-compiler-page .sql-empty-result strong {
    color: var(--compiler-text);
    font-size: 11px;
}

.sql-compiler-page .sql-empty-result span {
    margin-top: 3px;
    color: var(--compiler-muted);
    font-size: 9px;
}

.sql-compiler-page .sql-error-card {
    overflow: hidden;
    border: 1px solid #fecdd3;
    border-radius: 10px;
    background: #fff7f7;
}

.sql-compiler-page .sql-error-title {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 12px;
    color: #b42318;
    border-bottom: 1px solid #fecdd3;
    background: #fff0f1;
    font-size: 10px;
}

.sql-compiler-page .sql-error-card pre {
    margin: 0;
    padding: 12px;
    overflow: auto;
    color: #7f1d1d;
    background: transparent;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 9px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.sql-compiler-page .sql-error-card details {
    padding: 0 12px 12px;
    color: var(--compiler-muted);
    font-size: 9px;
}

.sql-compiler-page .sql-error-card code {
    display: block;
    margin-top: 7px;
    padding: 9px;
    overflow: auto;
    border-radius: 7px;
    color: var(--compiler-text);
    background: var(--compiler-panel);
    white-space: pre-wrap;
}

html[data-theme="dark"] .sql-compiler-page .sql-output-table .sql-data-table th {
    color: #8ee7ee;
    background: rgba(6, 187, 204, .10) !important;
}

html[data-theme="dark"] .sql-compiler-page .sql-output-table .sql-data-table tbody tr:hover td {
    background: rgba(6, 187, 204, .06) !important;
}

html[data-theme="dark"] .sql-compiler-page .sql-resultset-head span {
    color: #8ee7ee;
    background: rgba(6, 187, 204, .10);
}

/* SQL-specific mobile containment and touch scrolling. */
.sql-compiler-page .sql-side-panel,
.sql-compiler-page .sql-tab-content,
.sql-compiler-page .sql-compiler-result,
.sql-compiler-page .sql-results-stack,
.sql-compiler-page .sql-output-table,
.sql-compiler-page .sql-result-meta,
.sql-compiler-page .sql-result-actions {
    min-width: 0;
    max-width: 100%;
}

.sql-compiler-page .sql-output-table .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.sql-compiler-page .sql-error-card pre,
.sql-compiler-page .sql-error-card code { overflow-wrap: anywhere; }

@media (max-width: 900px) {
    .sql-compiler-page .compiler-workspace { height: auto; }
    .sql-compiler-page .compiler-editor-card { height: 650px; min-height: 650px; }
    .sql-compiler-page .sql-side-panel { height: auto; min-height: 420px; }
}

@media (max-width: 600px) {
    .sql-compiler-page .compiler-header-actions { grid-template-columns: minmax(0, 1fr) 44px; }
    .sql-compiler-page .runtime-badge { grid-column: 1 / -1; justify-self: start; }
    .sql-compiler-page .sql-language-select { width: 100%; }
    .sql-compiler-page .sql-database-select { display: none; }
    .sql-result-meta { align-items: stretch; flex-direction: column; }
    .sql-result-stats { flex-wrap: wrap; }
    .sql-result-actions { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, 44px); width: 100%; }
    .sql-result-search { width: 100%; height: 44px; }
    .sql-result-search input { font-size: 16px; }
    .sql-result-actions .compiler-tool { width: 44px; }
    .sql-result-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sql-result-tabs .result-tab { min-height: 44px; flex: 0 0 auto; }
    .sql-result-fullscreen { flex: 0 0 44px; position: sticky; right: 0; background: var(--compiler-panel); }
    .sql-compiler-page .sql-output-table .sql-data-table { width: max-content; min-width: 100%; }
    .sql-compiler-page .sql-output-table .sql-data-table th,
    .sql-compiler-page .sql-output-table .sql-data-table td { min-width: 120px; }
    .sql-compiler-page .fullscreen-panel { inset: 6px !important; }
}
