/**
 * ASQL Playground Styles
 */

/* ========== Variables ========== */
:root {
    --asql-red: #c53030;
    --asql-red-light: #e57373;
    --asql-red-dark: #9b1c1c;
    --asql-red-bg: #fce8e6;
}

/* ========== Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    color: #333;
}

h1 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: #333;
}

/* ========== Layout ========== */
.container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-nav {
    background: white;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #dadce0;
}

.top-nav-buttons {
    display: flex;
    gap: 8px;
}

/* ========== Playground Grid ========== */
.playground {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-bottom: 0;
    border: 1px solid #dadce0;
    border-radius: 0;
    overflow: visible;
    flex: 1;
    min-height: 0;
    position: relative;
}

.panel {
    background: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel:first-child {
    border-right: 1px solid #dadce0;
}

.panel-header {
    background: white;
    color: #666;
    padding: 12px 16px;
    font-weight: 400;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dadce0;
    position: relative;
}

.panel-content {
    padding: 0;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0;
    margin-bottom: 0;
}

#input-editor, #output-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#input-editor-container, #output-editor-container {
    flex: 1;
    min-height: 0;
    position: relative;
}

#visual-editor-container, #output-visual-editor-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* ========== Swap Button ========== */
.panel-header-swap {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 0 8px;
    margin-top: -16px;
}

.swap-button-inline {
    background: white;
    border: 1px solid #dadce0;
    border-radius: 4px;
    cursor: pointer;
    padding: 6px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.swap-button-inline:hover {
    color: var(--asql-red);
    border-color: var(--asql-red);
    background: #f8f9fa;
}

.swap-icon {
    width: 18px;
    height: 18px;
}

/* ========== Language Selector ========== */
.language-selector-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.language-selector-inline label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.language-selector-inline select {
    padding: 4px 24px 4px 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: var(--asql-red);
    cursor: pointer;
    min-width: 120px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23c53030' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.language-selector-inline select:hover {
    border-color: var(--asql-red-light);
}

.language-selector-inline select:focus {
    outline: none;
    border-color: var(--asql-red);
}

/* ========== Visual Mode Toggle ========== */
.visual-mode-toggle,
.visual-style-toggle,
.show-columns-toggle {
    display: flex;
    margin-left: 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    overflow: hidden;
}

.view-toggle-btn,
.style-toggle-btn,
.columns-toggle-btn {
    padding: 4px 8px;
    border: none;
    background: white;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s ease;
}

.view-toggle-btn:first-child,
.style-toggle-btn:first-child {
    border-right: 1px solid #dadce0;
}

.view-toggle-btn:hover,
.style-toggle-btn:hover,
.columns-toggle-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.view-toggle-btn.active,
.style-toggle-btn.active,
.columns-toggle-btn.active {
    background: var(--asql-red);
    color: white;
}

.view-toggle-btn.active:hover,
.style-toggle-btn.active:hover,
.columns-toggle-btn.active:hover {
    background: var(--asql-red-dark);
}

/* ========== Visual Style Toggle (text/blocky/pipes) ========== */
.visual-style-toggle {
    display: flex;
    margin-left: 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    overflow: hidden;
}

.style-toggle-btn {
    padding: 4px 8px;
    border: none;
    background: white;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s ease;
    border-right: 1px solid #dadce0;
}

.style-toggle-btn:last-child {
    border-right: none;
}

.style-toggle-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.style-toggle-btn.active {
    background: var(--asql-red);
    color: white;
}

.style-toggle-btn.active:hover {
    background: var(--asql-red-dark);
}

/* ========== Show Columns Toggle ========== */
.show-columns-toggle {
    display: flex;
    margin-left: 8px;
}

.columns-toggle-btn {
    padding: 4px 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s ease;
}

.columns-toggle-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.columns-toggle-btn.active {
    background: var(--asql-red);
    color: white;
    border-color: var(--asql-red);
}

.columns-toggle-btn.active:hover {
    background: var(--asql-red-dark);
}

/* ========== Buttons ========== */
button {
    padding: 10px 24px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    background: white;
    color: var(--asql-red);
    font-weight: 500;
}

button:hover {
    background: #f8f9fa;
    border-color: var(--asql-red-light);
}

button:disabled {
    background: #f8f9fa;
    color: #999;
    cursor: not-allowed;
    border-color: #dadce0;
}

.nav-button {
    color: var(--asql-red) !important;
    background: white;
    font-weight: 500;
    padding: 8px 16px;
    border: 1px solid var(--asql-red);
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.nav-button:hover {
    background: #f8f9fa;
    border-color: var(--asql-red-light);
}

.copy-btn {
    background: transparent;
    padding: 6px;
    margin-left: 8px;
    border: none;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
    background: #f8f9fa;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.settings-btn {
    background: white;
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.settings-btn:hover {
    background: #f8f9fa;
    border-color: var(--asql-red-light);
    color: var(--asql-red);
}

.settings-btn.has-changes {
    border-color: var(--asql-red);
    color: var(--asql-red);
}

.settings-btn svg {
    width: 16px;
    height: 16px;
}

.reset-btn {
    background: white;
    color: #666;
    border: 1px solid #dadce0;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}

.reset-btn:hover {
    background: #f1f3f4;
    color: #333;
}

/* ========== Error Display ========== */
.error {
    background: var(--asql-red-bg);
    color: var(--asql-red-dark);
    padding: 12px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 13px;
}

#error.error-banner {
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid #f3b8b5;
    position: sticky;
    top: 0;
    z-index: 5;
}

#error .error-title {
    font-weight: 600;
    margin-bottom: 4px;
}

#error details {
    margin-top: 8px;
}

#error pre {
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(0, 0, 0, 0.03);
    padding: 8px;
    border-radius: 4px;
}

.detected-dialect {
    font-size: 11px;
    color: #999;
    font-style: italic;
    padding: 8px 16px;
    background: #f8f9fa;
    border-top: 1px solid #dadce0;
}

/* ========== Modal ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.modal.open {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin-top: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #dadce0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 16px 20px;
}

/* ========== Examples Modal ========== */
.example-section {
    margin-bottom: 20px;
}

.example-section h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
}

.example-section p {
    margin-bottom: 10px;
}

.example-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.example-btn {
    padding: 8px 10px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-size: 12px;
    transition: all 0.2s;
}

.example-btn:hover {
    background: #f8f9fa;
    border-color: var(--asql-red-light);
}

.example-title {
    font-weight: 500;
    margin-bottom: 4px;
    color: #333;
}

.example-desc {
    color: #666;
    font-size: 12px;
}

/* ========== Settings Modal ========== */
.settings-modal .modal-content {
    max-width: 600px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.settings-section-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.setting-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-field label {
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

.setting-field select,
.setting-field input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    color: #333;
}

.setting-field select:focus,
.setting-field input[type="text"]:focus {
    outline: none;
    border-color: var(--asql-red);
}

.setting-field-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.setting-field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--asql-red);
}

.setting-field-checkbox label {
    cursor: pointer;
}

.setting-description {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.settings-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid #dadce0;
    background: #f8f9fa;
}

.settings-footer-left {
    display: flex;
    gap: 8px;
}

.settings-modified-indicator {
    font-size: 12px;
    color: var(--asql-red);
    display: none;
}

.settings-modified-indicator.visible {
    display: inline;
}

/* ========== Toast Notification ========== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
}

/* ========== CodeMirror Styling ========== */
#input-editor .CodeMirror,
#output-editor .CodeMirror {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto !important;
    font-size: 14px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    border: none;
    border-radius: 0;
    padding: 12px;
}

.CodeMirror-scroll {
    overflow: auto !important;
}

.CodeMirror-vscrollbar, .CodeMirror-hscrollbar {
    display: block !important;
}

.CodeMirror-scrollbar-filler {
    background: transparent;
}

.CodeMirror-focused {
    outline: none;
}

.CodeMirror-readonly .CodeMirror-cursor {
    display: none;
}

/* Output editor - grey background to look less editable */
#output-editor .CodeMirror {
    background: #f8f9fa;
}

#output-editor .CodeMirror-scroll {
    background: #f8f9fa;
}

#output-editor .CodeMirror-gutters {
    background: #f1f3f4;
    border-right: 1px solid #e8eaed;
}

/* CodeMirror theme colors - red accents */
.CodeMirror-linenumber {
    color: #999;
}

.CodeMirror-cursor {
    border-left: 2px solid var(--asql-red);
}

.CodeMirror-selected {
    background: var(--asql-red-bg);
}

.CodeMirror-focused .CodeMirror-selected {
    background: var(--asql-red-bg);
}

/* SQL and ASQL syntax highlighting */
.CodeMirror .cm-keyword {
    color: var(--asql-red);
    font-weight: 600;
}

.CodeMirror .cm-string {
    color: #137333;
}

.CodeMirror .cm-number {
    color: #1967d2;
}

.CodeMirror .cm-comment {
    color: #999;
    font-style: italic;
}

.CodeMirror .cm-operator {
    color: var(--asql-red);
}

.CodeMirror .cm-variable {
    color: #333;
}

.CodeMirror .cm-def {
    color: var(--asql-red);
    font-weight: 500;
}

.CodeMirror .cm-atom {
    color: #1967d2;
}

/* ========== Responsive Design ========== */
@media (max-width: 968px) {
    .playground {
        grid-template-columns: 1fr;
    }
    
    .panel-header-swap {
        position: static;
        transform: none;
        justify-content: center;
        padding: 8px;
        margin: 0;
        border-top: 1px solid #dadce0;
        border-bottom: 1px solid #dadce0;
    }
    
    .container > div:first-child {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .container > div:first-child > div {
        width: 100%;
        justify-content: space-between;
    }
}



