/* SQL Tool Variables */
:root {
    /* Monokai Theme Colors */
    --monokai-bg: #272822;
    --monokai-fg: #f8f8f2;
    --monokai-comment: #75715e;
    --monokai-yellow: #e6db74;
    --monokai-purple: #ae81ff;
    --monokai-red: #f92672;
    --monokai-blue: #66d9ef;
    --monokai-green: #a6e22e;
    --monokai-orange: #fd971f;

    /* Glass Variables */
    --glass-bg: rgba(30, 30, 30, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --glass-blur: blur(12px) saturate(150%);
}

/* Hide Global Navigation for this tool */
header.navbar-fixed,
#headNav,
#aplayer,
.aplayer {
    display: none !important;
}

/* Base Layout */
body {
    margin: 0;
    padding: 0;
    background-image: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: var(--monokai-fg);
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    overflow: hidden;
    height: 100vh;
}

.sql-tool-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
    background: var(--monokai-bg);
}

/* Toolbar Styles */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    height: 44px;
    box-sizing: border-box;
    
    /* Liquid Glass Effect */
    background: rgba(39, 40, 34, 0.7);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tool-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--monokai-fg);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.back-btn {
    color: var(--monokai-fg);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-3px);
}

/* Button & Button Groups */
.btn-group {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: rgba(248, 248, 242, 0.7);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.toolbar-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--monokai-fg);
}

.toolbar-btn:active {
    transform: translateY(1px);
}

/* Editor Area */
.editor-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    overflow: hidden;
    display: flex;
    background: var(--monokai-bg);
    box-sizing: border-box;
}

.editor-view {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
}

.text-view {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.line-numbers {
    width: 50px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--monokai-comment);
    text-align: right;
    padding: 54px 5px 40px 5px; /* Top: 44px + 10px; Bottom: 30px + 10px */
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    user-select: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
    height: 100%;
}

.line-numbers::-webkit-scrollbar {
    display: none;
}

.line-number {
    display: block;
    line-height: 21px; /* 14px * 1.5 */
    height: 21px;
    padding-right: 5px;
    color: var(--monokai-comment);
}

.syntax-highlight {
    position: absolute;
    left: 50px;
    top: 0;
    right: 0;
    bottom: 0;
    margin: 0 !important;
    padding: 54px 10px 40px 10px !important;
    overflow: auto;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 21px;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    tab-size: 2;
    -moz-tab-size: 2;
    pointer-events: none;
    color: transparent;
    border-radius: 0 !important;
    background: transparent !important;
    z-index: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-sizing: border-box;
    height: 100%;
}

.syntax-highlight::-webkit-scrollbar {
    display: none;
}

.syntax-highlight code {
    display: block;
    font-family: inherit;
    font-size: inherit;
    margin: 0;
    padding: 0;
    line-height: inherit;
    white-space: inherit;
    word-break: inherit;
    overflow-wrap: inherit;
}

.syntax-highlight .hl-keyword { color: var(--monokai-red); font-weight: bold; }
.syntax-highlight .hl-string { color: var(--monokai-yellow); }
.syntax-highlight .hl-number { color: var(--monokai-purple); }
.syntax-highlight .hl-function { color: var(--monokai-green); }
.syntax-highlight .hl-operator { color: var(--monokai-red); }
.syntax-highlight .hl-comment { color: var(--monokai-comment); font-style: italic; }
.syntax-highlight .hl-punctuation { color: var(--monokai-fg); }

#sqlInput {
    position: absolute;
    left: 50px;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    width: calc(100% - 50px);
    box-sizing: border-box;
    background: transparent;
    border: none;
    color: var(--monokai-fg);
    -webkit-text-fill-color: transparent; /* Text is active but transparent so highlight shows */
    padding: 54px 10px 40px 10px;
    resize: none;
    outline: none;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    overflow: auto;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 21px;
    tab-size: 2;
    caret-color: var(--monokai-fg);
    z-index: 2;
}

#sqlInput::placeholder {
    -webkit-text-fill-color: var(--monokai-comment);
    opacity: 1;
}

#sqlInput::selection {
    background: rgba(102, 217, 239, 0.3);
    -webkit-text-fill-color: var(--monokai-fg);
}

/* Status Bar */
.status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    height: 30px;
    
    /* Liquid Glass Effect */
    background: rgba(39, 40, 34, 0.7);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 0.85rem;
    color: var(--monokai-comment);
}

.status-left, .status-right {
    display: flex;
    gap: 20px;
}

.cursor-position span {
    margin-right: 10px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Error Markers */
.line-number {
    position: relative;
    display: flex;
    justify-content: flex-end;
    padding-right: 12px; /* Increased from 5px to make space for dot */
}

.line-number.error::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--monokai-red);
    border-radius: 50%;
    box-shadow: 0 0 4px var(--monokai-red);
}

/* Status Colors */
.sql-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.sql-status.valid { color: var(--monokai-green); }
.sql-status.invalid { color: var(--monokai-red); }

/* Error Bar (Optional, for detailed message) */
.error-bar {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    background: rgba(40, 40, 40, 0.95);
    border-top: 1px solid var(--monokai-red);
    padding: 8px 20px;
    color: var(--monokai-red);
    display: flex;
    align-items: center;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 15;
}

.error-bar.active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .tool-title { display: none; }
    .toolbar-center { gap: 5px; }
    .toolbar-btn span { display: none; }
    .toolbar-btn { padding: 6px; }
}
/* Liquid Glass Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.glass-modal {
    background: rgba(45, 45, 45, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    width: 320px;
    padding: 24px;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-overlay.active .glass-modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--monokai-fg);
}

.modal-header i {
    color: var(--monokai-orange);
    font-size: 1.3rem;
}

.modal-body {
    color: rgba(248, 248, 242, 0.8);
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.modal-btn.cancel {
    background: transparent;
    color: var(--monokai-fg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-btn.confirm {
    background: rgba(249, 38, 114, 0.8);
    color: #fff;
    box-shadow: 0 4px 12px rgba(249, 38, 114, 0.3);
}

.modal-btn.confirm:hover {
    background: var(--monokai-red);
    box-shadow: 0 6px 16px rgba(249, 38, 114, 0.4), 0 0 10px rgba(249, 38, 114, 0.2);
    transform: translateY(-1px);
}
