:root {
    /* Modern Dark Palette */
    --primary: #6366F1;
    --primary-hover: #4f46e5;
    --secondary: #818cf8;
    --accent: #14b8a6;
    --bg-dark: #0F1219;
    --bg-panel: #1E222D;
    --bg-input: #0F1219;
    --border: #2D3342;
    --border-focus: #6366F1;

    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;

    --error: #ef4444;
    --success: #10b981;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    /* Very subtle noisy/glassmorphism background */
    background-image:
        radial-gradient(circle at 10% 0%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 90% 100%, rgba(20, 184, 166, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Form Elements */
.schema-config {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.flex-1 {
    flex: 1;
}

input[type="text"],
input[type="number"],
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.small-select {
    padding: 0.4rem 2rem 0.4rem 0.8rem !important;
    font-size: 0.85rem !important;
    height: 32px;
    background-color: var(--bg-panel) !important;
}

/* Fields Container */
.fields-container {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.fields-header {
    display: flex;
    gap: 1rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.field-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.field-item {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.field-item:hover {
    border-color: var(--border);
    background: var(--bg-input);
}

.field-item .drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 0 0.25rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

.btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--border);
}

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

.btn.ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn.danger:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.btn.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    height: 32px;
}

.full-width {
    width: 100%;
}

.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.icon-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Table Preview */
.table-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: var(--bg-input);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    text-align: left;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    z-index: 10;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    text-align: center;
}

.preview-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Utils */
.hidden {
    display: none !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    z-index: 100;
    transition: all 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .app-container {
        height: auto;
        display: block;
    }

    .schema-panel {
        margin-bottom: 1.5rem;
        max-height: 600px;
    }

    .preview-panel {
        min-height: 500px;
    }
}