:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --accent: #10B981;
    --bg: #0F172A;
    --surface: rgba(15, 23, 42, .7);
    --border: rgba(255, 255, 255, .08);
    --text: #E2E8F0;
    --text-muted: #64748B;
    --error: #EF4444;
    --warning: #F59E0B;
    --radius: 12px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden
}

.glass {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border)
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    z-index: 10
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary)
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent
}

.logo i {
    width: 22px;
    height: 22px
}

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

.icon-btn {
    background: rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s
}

.icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary)
}

.icon-btn i {
    width: 18px;
    height: 18px
}

.btn-primary,
.btn-sm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
    border: none
}

.btn-primary {
    background: var(--primary);
    color: #fff
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px)
}

.btn-sm {
    padding: 6px 12px;
    font-size: .8rem
}

.btn-sm i {
    width: 14px;
    height: 14px
}

.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden
}

/* Schema Pane */
.schema-pane {
    width: 280px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    flex-shrink: 0
}

.pane-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center
}

.pane-header h2 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px
}

.pane-header h2 i {
    width: 18px;
    height: 18px;
    color: var(--primary)
}

.schema-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px
}

.schema-list::-webkit-scrollbar {
    width: 4px
}

.schema-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px
}

.schema-table {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    animation: slideIn .2s ease
}

.schema-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, .2);
    cursor: pointer
}

.schema-table-header h3 {
    font-size: .85rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px
}

.schema-table-header h3 i {
    width: 14px;
    height: 14px
}

.schema-table-actions {
    display: flex;
    gap: 4px
}

.schema-table-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all .2s
}

.schema-table-actions button:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, .1)
}

.schema-table-actions button i {
    width: 14px;
    height: 14px
}

.schema-cols {
    padding: 8px 12px
}

.schema-col {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: .8rem;
    border-bottom: 1px solid var(--border)
}

.schema-col:last-child {
    border: none
}

.schema-col .col-name {
    flex: 1;
    color: var(--text)
}

.schema-col .col-type {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: .75rem
}

.schema-col .col-pk {
    color: var(--warning);
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 4px;
    background: rgba(245, 158, 11, .1);
    border-radius: 3px
}

.add-col-row {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    border-top: 1px solid var(--border)
}

.add-col-row input,
.add-col-row select {
    flex: 1;
    background: rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: .75rem;
    font-family: inherit
}

.add-col-row button {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600
}

/* Content Pane */
.content-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow-y: auto
}

.query-section,
.sql-section,
.results-section {
    border-radius: var(--radius);
    padding: 20px
}

.query-header,
.sql-header,
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px
}

.query-header h2,
.sql-header h2,
.results-header h2 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px
}

.query-header h2 i,
.sql-header h2 i,
.results-header h2 i {
    width: 18px;
    height: 18px;
    color: var(--primary)
}

.query-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start
}

.nl-input {
    flex: 1;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: .95rem;
    font-family: inherit;
    resize: none;
    transition: all .2s;
    line-height: 1.5
}

.nl-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .15)
}

.quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px
}

.chip {
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .2);
    color: var(--primary);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit
}

.chip:hover {
    background: rgba(59, 130, 246, .15);
    border-color: var(--primary)
}

.sql-actions {
    display: flex;
    gap: 8px
}

.sql-code {
    background: rgba(0, 0, 0, .4);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    font-family: var(--mono);
    font-size: .85rem;
    line-height: 1.6;
    overflow-x: auto;
    color: var(--accent);
    white-space: pre-wrap
}

.sql-explanation {
    margin-top: 12px;
    font-size: .85rem;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 12px;
    background: rgba(16, 185, 129, .05);
    border: 1px solid rgba(16, 185, 129, .15);
    border-radius: 8px
}

.results-table-wrapper {
    overflow-x: auto
}

.results-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem
}

.results-table-wrapper th {
    background: rgba(0, 0, 0, .3);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0
}

.results-table-wrapper td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .8rem;
    color: var(--text-muted)
}

.results-table-wrapper tr:hover td {
    background: rgba(255, 255, 255, .02)
}

.result-count {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: var(--mono)
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .85);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s
}

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

.modal {
    width: 600px;
    max-width: 90vw;
    border-radius: var(--radius);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform .3s
}

.modal-overlay.active .modal {
    transform: translateY(0)
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border)
}

.modal-header h2 {
    font-size: 1.1rem
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto
}

.import-textarea {
    width: 100%;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 14px;
    font-family: var(--mono);
    font-size: .85rem;
    resize: vertical;
    margin-bottom: 12px
}

.import-textarea:focus {
    outline: none;
    border-color: var(--primary)
}

.history-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .2s
}

.history-item:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, .05)
}

.history-item .h-nl {
    font-size: .85rem;
    margin-bottom: 4px
}

.history-item .h-sql {
    font-size: .75rem;
    color: var(--accent);
    font-family: var(--mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.history-item .h-time {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 4px
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: .85rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .3);
    z-index: 200;
    opacity: 0;
    transition: all .3s cubic-bezier(.175, .885, .32, 1.275)
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@media(max-width:768px) {
    .main-layout {
        flex-direction: column
    }

    .schema-pane {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border)
    }

    .query-input-wrapper {
        flex-direction: column
    }

    .content-pane {
        padding: 12px
    }
}