:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-elevated: #1f1f23;
    --border: #2a2a2e;
    --border-highlight: #3a3a3e;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #5a8486;
    --accent-dim: #3d5f62;
    --accent-glow: rgba(90, 132, 134, 0.15);
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.03;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.app-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    overflow-x: hidden;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.logo-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo h1 span {
    color: var(--accent);
}

.stats-bar {
    display: flex;
    gap: 2rem;
    font-size: 0.875rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, var(--accent-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.drop-zone:hover::before, .drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.drop-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--accent);
}

.drop-zone h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.file-input {
    display: none;
}

.workspace {
    display: none;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.workspace.visible {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    min-width: 0;
}

.panel-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

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

/* Filter Panel Styles */
.filters-container {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.filter-section {
    border-bottom: 1px solid var(--border);
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s ease;
}

.filter-header:hover {
    background: var(--bg-tertiary);
}

.filter-column-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-badge {
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}

.filter-toggle {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.filter-toggle.open {
    transform: rotate(180deg);
}

.filter-content {
    display: none;
    padding: 0.5rem 1rem 1rem;
}

.filter-content.open {
    display: block;
}

.filter-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.filter-search:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-search::placeholder {
    color: var(--text-muted);
}

.filter-options {
    max-height: 220px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.virtual-scroll-container {
    scrollbar-width: thin;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.8rem;
    box-sizing: border-box;
}

.filter-option:hover {
    background: var(--bg-tertiary);
}

.filter-option input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.filter-option input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.filter-option input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-option-label {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.filter-option-count {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.filter-action-btn {
    flex: 1;
    padding: 0.4rem;
    font-size: 0.7rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.active-filters {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: none;
}

.active-filters.visible {
    display: block;
}

.active-filters-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.active-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.active-filter-tag {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--accent-glow);
    border: 1px solid var(--accent-dim);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--accent);
}

.active-filter-tag .remove {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.active-filter-tag .remove:hover {
    opacity: 1;
}

.clear-all-filters {
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-filters:hover {
    background: var(--bg-elevated);
    color: var(--error);
    border-color: var(--error);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    overflow: hidden;
}

.query-editor {
    padding: 1rem;
}

.query-input {
    width: 100%;
    min-height: 80px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.query-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.query-input::placeholder {
    color: var(--text-muted);
}

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

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
    color: var(--bg-primary);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-highlight);
}

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

.quick-filters {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.chip {
    padding: 0.375rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'JetBrains Mono', monospace;
}

.chip:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.results-panel {
    flex: 1;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.results-info .count {
    color: var(--accent);
    font-weight: 500;
}

.results-info .time {
    font-family: 'JetBrains Mono', monospace;
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 400px);
    min-height: 300px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: var(--bg-tertiary);
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

th:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

th.sorted {
    color: var(--accent);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tr:hover td {
    background: var(--bg-tertiary);
}

.null-value {
    color: var(--text-muted);
    font-style: italic;
}

.number-value {
    color: var(--accent);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 11, 0.9);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.5rem;
}

.loading-overlay.visible {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error-message {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 1rem;
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
    display: none;
}

.error-message.visible {
    display: block;
}

.schema-preview {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem;
}

.schema-tag {
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.schema-tag .type {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
}

.schema-tag .name {
    color: var(--text-primary);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
}

.remove-file {
    margin-left: auto;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-file:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-highlight);
}

@media (max-width: 1024px) {
    .workspace.visible {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: -1;
    }

    .filters-container {
        max-height: 250px;
    }

    .table-container {
        max-height: calc(100vh - 500px);
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: flex-start;
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .logo {
        gap: 1rem;
    }

    .stats-bar {
        gap: 0.75rem;
        flex-wrap: wrap;
        font-size: 0.75rem;
    }

    .stat {
        gap: 0.25rem;
    }

    .query-editor {
        padding: 0.75rem;
    }

    .query-input {
        min-height: 60px;
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    .query-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .quick-filters {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .chip {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .file-info {
        flex-wrap: wrap;
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .file-name {
        font-size: 0.85rem;
        word-break: break-all;
    }

    .panel-header {
        padding: 0.75rem;
    }

    .panel-title {
        font-size: 0.7rem;
    }

    th, td {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
    }

    .pagination {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .table-container {
        max-height: calc(100vh - 550px);
        min-height: 200px;
    }

    .sidebar {
        margin-bottom: 1rem;
    }

    .filter-header {
        padding: 0.6rem 0.75rem;
    }

    .filter-content {
        padding: 0.5rem 0.75rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 1.25rem 1rem;
    }

    header {
        gap: 1.25rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .logo {
        gap: 0.75rem;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .logo-icon img {
        width: 20px;
        height: 20px;
    }

    .stats-bar {
        font-size: 0.7rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .drop-zone h2 {
        font-size: 1rem;
    }

    .drop-zone p {
        font-size: 0.8rem;
    }

    .drop-icon {
        width: 48px;
        height: 48px;
    }

    .drop-icon svg {
        width: 20px;
        height: 20px;
    }
}
