:root {
    --bg-color: #0d1117;
    --glass-bg: rgba(22, 27, 34, 0.7);
    --glass-border: rgba(240, 246, 252, 0.1);
    --accent-primary: #58a6ff;
    --accent-secondary: #1f6feb;
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 50%, #161b22 0%, #0d1117 100%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 100%;
    max-width: 1000px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(to right, #58a6ff, #bc8cff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 900px) {
    main {
        flex-direction: row;
        align-items: stretch;
    }

    .column {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 2rem;
        min-width: 0;
    }

    .glass-container {
        max-width: 1400px;
    }
}

.field {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

select,
input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: all 0.2s ease;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.variable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

button {
    padding: 0.8rem 2rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#run-btn {
    background: var(--accent-secondary);
    color: white;
}

#run-btn:hover:not(:disabled) {
    background: #388bfd;
    transform: translateY(-1px);
}

#run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.query-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

.panel-header {
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#toggle-query {
    background: transparent;
    color: var(--accent-primary);
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
}

pre {
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    overflow-x: auto;
    background: #0d1117;
}

.hidden {
    display: none;
}

#results-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid var(--glass-border);
    color: var(--accent-primary);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Chat Viewer Styles */
.conversation-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}

.chat-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 600px;
}

.message-box {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.message-box.left {
    align-self: flex-start;
}

.message-box.right {
    align-self: flex-end;
}

.message-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.message-box.right .message-meta {
    flex-direction: row-reverse;
}

.message-speaker {
    font-weight: 600;
}

.message-bubble {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.message-box.left .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 2px;
    color: var(--text-main);
}

.message-box.right .message-bubble {
    background: var(--accent-secondary);
    border-top-right-radius: 2px;
    color: white;
}

/* Custom scrollbar for chat wrapper */
.chat-wrapper::-webkit-scrollbar {
    width: 6px;
}

.chat-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.chat-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}