/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--tg-theme-bg-color: #ffffff;--tg-theme-text-color: #000000;--tg-theme-hint-color: #999999;--tg-theme-link-color: #2481cc;--tg-theme-button-color: #2481cc;--tg-theme-button-text-color: #ffffff;--tg-theme-secondary-bg-color: #f0f0f0}*{box-sizing:border-box;margin:0;padding:0}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;background:var(--tg-theme-bg-color);color:var(--tg-theme-text-color);font-size:14px;line-height:1.4}.app{min-height:100vh;padding:16px;max-width:100%;overflow-x:hidden}.header{display:flex;align-items:center;gap:12px;margin-bottom:16px}.header h2{flex:1;font-size:18px;font-weight:600}button{cursor:pointer;border:none;border-radius:8px;font-size:14px;padding:10px 16px;transition:opacity .2s}button:disabled{opacity:.5;cursor:not-allowed}.btn-primary{background:var(--tg-theme-button-color);color:var(--tg-theme-button-text-color)}.btn-secondary{background:var(--tg-theme-secondary-bg-color);color:var(--tg-theme-text-color)}.btn-back{background:none;color:var(--tg-theme-link-color);padding:0}.btn-delete{background:none;color:#ff3b30;padding:4px 8px;font-size:18px}.btn-icon{background:none;padding:8px;font-size:18px}.connection-list .list{display:flex;flex-direction:column;gap:8px}.connection-item{display:flex;align-items:center;padding:12px;background:var(--tg-theme-secondary-bg-color);border-radius:12px;cursor:pointer}.connection-item:active{opacity:.7}.conn-info{flex:1}.conn-name{font-weight:500;margin-bottom:2px}.conn-details{font-size:12px;color:var(--tg-theme-hint-color)}.empty{text-align:center;color:var(--tg-theme-hint-color);padding:32px 16px}.loading{text-align:center;padding:32px;color:var(--tg-theme-hint-color)}.connection-form form{display:flex;flex-direction:column;gap:16px}.form-group{display:flex;flex-direction:column;gap:6px}.form-group label{font-size:12px;color:var(--tg-theme-hint-color);text-transform:uppercase}.form-row{display:flex;gap:12px}.form-row .form-group{flex:1}input,select,textarea{width:100%;padding:12px;border:1px solid var(--tg-theme-secondary-bg-color);border-radius:8px;font-size:16px;background:var(--tg-theme-bg-color);color:var(--tg-theme-text-color)}input:focus,select:focus,textarea:focus{outline:none;border-color:var(--tg-theme-button-color)}.form-actions{display:flex;gap:12px;margin-top:8px}.form-actions button{flex:1}.error-message{background:#ffebee;color:#c62828;padding:12px;border-radius:8px;font-size:13px}.success-message{background:#e8f5e9;color:#2e7d32;padding:12px;border-radius:8px;font-size:13px}.query-editor{display:flex;flex-direction:column;height:calc(100vh - 32px)}.editor-area{flex:0 0 auto;margin-bottom:12px}.editor-area textarea{width:100%;height:120px;font-family:SF Mono,Monaco,Courier New,monospace;font-size:14px;resize:vertical}.editor-hint{font-size:11px;color:var(--tg-theme-hint-color);margin-top:4px;text-align:right}.editor-actions{display:flex;gap:12px;margin-bottom:16px}.editor-actions button{flex:1}.result-area{flex:1;overflow:hidden;display:flex;flex-direction:column}.result-meta{font-size:12px;color:var(--tg-theme-hint-color);margin-bottom:8px}.result-table-wrapper{flex:1;overflow:auto;border:1px solid var(--tg-theme-secondary-bg-color);border-radius:8px}.result-table{width:100%;border-collapse:collapse;font-size:13px}.result-table th,.result-table td{padding:8px 12px;text-align:left;border-bottom:1px solid var(--tg-theme-secondary-bg-color);white-space:nowrap;max-width:300px;overflow:hidden;text-overflow:ellipsis}.result-table th{background:var(--tg-theme-secondary-bg-color);font-weight:600;position:sticky;top:0}.result-table tr:hover td{background:var(--tg-theme-secondary-bg-color)}.null-value{color:var(--tg-theme-hint-color);font-style:italic}.no-results{padding:24px;text-align:center;color:var(--tg-theme-hint-color)}.saved-queries-panel{background:var(--tg-theme-secondary-bg-color);border-radius:12px;padding:12px;margin-bottom:16px}.saved-queries-panel h3{font-size:14px;margin-bottom:8px}.saved-list{display:flex;flex-direction:column;gap:4px}.saved-item{display:flex;align-items:center;padding:8px;background:var(--tg-theme-bg-color);border-radius:8px;cursor:pointer}.saved-item:active{opacity:.7}.saved-name{flex:1;font-size:13px}.dialog-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#00000080;display:flex;align-items:center;justify-content:center;padding:16px;z-index:100}.dialog{background:var(--tg-theme-bg-color);border-radius:16px;padding:20px;width:100%;max-width:320px}.dialog h3,.dialog input{margin-bottom:16px}.dialog-actions{display:flex;gap:12px}.dialog-actions button{flex:1}.header-actions{display:flex;gap:4px}.btn-icon.active{background:var(--tg-theme-secondary-bg-color);border-radius:8px}.schema-browser{background:var(--tg-theme-secondary-bg-color);border-radius:12px;padding:12px;margin-bottom:16px;max-height:300px;overflow-y:auto}.schema-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.schema-header h3{font-size:14px;font-weight:600}.btn-close{background:none;padding:4px 8px;font-size:18px;color:var(--tg-theme-hint-color)}.schema-tables{display:flex;flex-direction:column;gap:4px}.schema-table{background:var(--tg-theme-bg-color);border-radius:8px;overflow:hidden}.table-header{display:flex;align-items:center;padding:10px 12px;cursor:pointer;gap:8px}.table-header:hover{background:#00000008}.table-icon{font-size:10px;color:var(--tg-theme-hint-color);width:12px}.table-name{flex:1;font-weight:500;font-size:13px}.btn-select{background:var(--tg-theme-button-color);color:var(--tg-theme-button-text-color);padding:4px 8px;font-size:10px;font-weight:600;border-radius:4px}.table-columns{border-top:1px solid var(--tg-theme-secondary-bg-color);padding:8px 12px 8px 32px}.column-row{display:flex;align-items:center;gap:8px;padding:4px 0;font-size:12px}.column-key{width:16px;font-size:10px}.column-name{flex:1;font-family:SF Mono,Monaco,Courier New,monospace}.column-type{font-family:SF Mono,Monaco,Courier New,monospace;font-size:11px}.column-nullable{font-size:10px;color:var(--tg-theme-hint-color);background:var(--tg-theme-secondary-bg-color);padding:2px 4px;border-radius:3px}.result-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;flex-wrap:wrap;gap:8px}.pagination{display:flex;align-items:center;gap:8px}.btn-page{background:var(--tg-theme-secondary-bg-color);color:var(--tg-theme-text-color);padding:6px 12px;font-size:12px}.btn-page:disabled{opacity:.3}.page-info{font-size:12px;color:var(--tg-theme-hint-color);min-width:60px;text-align:center}.password-input{display:flex;gap:8px}.password-input input{flex:1}.btn-toggle-password{background:var(--tg-theme-secondary-bg-color);padding:8px 12px;font-size:16px}.conn-actions{display:flex;gap:4px}.btn-edit{background:none;padding:4px 8px;font-size:16px}.hint{font-weight:400;font-size:11px;color:var(--tg-theme-hint-color)}.tabs{display:flex;gap:4px;margin-bottom:16px;background:var(--tg-theme-secondary-bg-color);border-radius:12px;padding:4px}.tab{flex:1;background:transparent;color:var(--tg-theme-hint-color);padding:10px 16px;border-radius:8px;font-weight:500}.tab.active{background:var(--tg-theme-bg-color);color:var(--tg-theme-text-color);box-shadow:0 1px 3px #0000001a}.terminal-container{display:flex;flex-direction:column;height:calc(100vh - 32px);background:#1e1e1e;border-radius:12px;overflow:hidden}.terminal-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:#2d2d2d;color:#d4d4d4}.terminal-header span{font-weight:500}.terminal-header .btn-close{background:none;color:#d4d4d4;font-size:20px;padding:4px 8px}.terminal-body{flex:1;padding:8px}.terminal-body .xterm{height:100%}.terminal-body .xterm-viewport{overflow-y:auto!important}
