/* Modern CSS Reset & Variables */
:root {
    --color-primary: #1D6491;
    --color-accent: #4361EE;
    --color-purple: #3B1AAF;
    --color-purple-soft: #A593E0;
    --color-purple-dark: #2C1154;
    --color-background: #FFFFFF;
    --color-light: #C8DFF8;
    --color-muted-text: #3A506B;
    --color-muted: #A6B1E1;
    --color-dark: #112B3C;
    
    /* Semantic color mappings */
    --primary: var(--color-primary);
    --primary-dark: var(--color-purple);
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --gray-50: #F8FAFC;
    --gray-100: var(--color-light);
    --gray-200: #E2E8F0;
    --gray-300: var(--color-muted);
    --gray-400: var(--color-purple-soft);
    --gray-500: var(--color-muted-text);
    --gray-600: var(--color-muted-text);
    --gray-700: var(--color-dark);
    --gray-800: var(--color-purple-dark);
    --gray-900: var(--color-dark);
    --white: var(--color-background);
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(29 100 145 / 0.05);
    --shadow: 0 1px 3px 0 rgb(29 100 145 / 0.1), 0 1px 2px -1px rgb(29 100 145 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(29 100 145 / 0.1), 0 4px 6px -4px rgb(29 100 145 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(29 100 145 / 0.1), 0 8px 10px -6px rgb(29 100 145 / 0.1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --color-primary: #4A9EFF;
    --color-accent: #6B73FF;
    --color-purple: #8B5FBF;
    --color-purple-soft: #7C3AED;
    --color-purple-dark: #5B21B6;
    --color-background: #0F172A;
    --color-light: #1E293B;
    --color-muted-text: #CBD5E1;
    --color-muted: #64748B;
    --color-dark: #F1F5F9;
    
    /* Dark mode semantic mappings */
    --gray-50: #0F172A;
    --gray-100: var(--color-light);
    --gray-200: #334155;
    --gray-300: var(--color-muted);
    --gray-400: var(--color-purple-soft);
    --gray-500: var(--color-muted-text);
    --gray-600: var(--color-muted-text);
    --gray-700: var(--color-dark);
    --gray-800: #F8FAFC;
    --gray-900: var(--color-dark);
    --white: var(--color-background);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

/* Joan Theme Variables - Ultra Dark */
[data-theme="joan"] {
    --color-primary: #6B7FFF;
    --color-accent: #8B8BFF;
    --color-purple: #9B7FBF;
    --color-purple-soft: #8C6AED;
    --color-purple-dark: #6B31C6;
    --color-background: #000000;
    --color-light: #111111;
    --color-muted-text: #CCCCCC;
    --color-muted: #666666;
    --color-dark: #EEEEEE;
    
    /* Joan mode semantic mappings */
    --gray-50: #000000;
    --gray-100: var(--color-light);
    --gray-200: #222222;
    --gray-300: var(--color-muted);
    --gray-400: var(--color-purple-soft);
    --gray-500: var(--color-muted-text);
    --gray-600: var(--color-muted-text);
    --gray-700: var(--color-dark);
    --gray-800: #F8F8F8;
    --gray-900: var(--color-dark);
    --white: var(--color-background);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.6), 0 1px 2px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.8), 0 8px 10px -6px rgb(0 0 0 / 0.6);
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--color-background) 0%, #1A202C 50%, var(--color-purple-dark) 100%);
}

[data-theme="joan"] body {
    background: linear-gradient(135deg, var(--color-background) 0%, #0A0A0A 50%, var(--color-purple-dark) 100%);
}

/* Dark mode header adjustments */
[data-theme="dark"] .app-header,
[data-theme="joan"] .app-header {
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--gray-200);
}

[data-theme="joan"] .app-header {
    background: rgba(0, 0, 0, 0.95);
}

[data-theme="dark"] .header-left h1,
[data-theme="joan"] .header-left h1 {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .schema-info,
[data-theme="joan"] .schema-info {
    color: var(--gray-500);
}

[data-theme="dark"] .field-stats,
[data-theme="joan"] .field-stats {
    background: var(--color-light);
    color: var(--gray-700);
}

/* Dark mode for banners */
[data-theme="dark"] .info-banner, 
[data-theme="dark"] .warning-banner,
[data-theme="joan"] .info-banner, 
[data-theme="joan"] .warning-banner {
    background: var(--color-light);
    color: var(--gray-700);
}

[data-theme="dark"] .error-banner,
[data-theme="joan"] .error-banner {
    background: #1F2937;
    color: #FCA5A5;
}

[data-theme="joan"] .error-banner {
    background: #111111;
}

[data-theme="dark"] .banner-text span,
[data-theme="joan"] .banner-text span {
    color: var(--gray-500);
}

/* Dark mode empty state */
[data-theme="dark"] .empty-state,
[data-theme="joan"] .empty-state {
    background: var(--color-background);
    color: var(--gray-700);
}

[data-theme="dark"] .empty-state h2,
[data-theme="joan"] .empty-state h2 {
    color: var(--gray-700);
}

[data-theme="dark"] .empty-state p,
[data-theme="joan"] .empty-state p {
    color: var(--gray-500);
}

[data-theme="dark"] .empty-icon,
[data-theme="joan"] .empty-icon {
    color: var(--gray-300);
}

/* Dark mode schema editor */
[data-theme="dark"] .schema-editor,
[data-theme="joan"] .schema-editor {
    background: var(--color-background);
    border: 1px solid var(--gray-200);
}

/* Dark mode table */
[data-theme="dark"] .field-name,
[data-theme="joan"] .field-name {
    color: var(--gray-700);
}

[data-theme="dark"] .field-description,
[data-theme="joan"] .field-description {
    color: var(--gray-500);
}

[data-theme="dark"] .field-comments,
[data-theme="joan"] .field-comments {
    color: var(--gray-500);
}

/* Dark mode form elements */
[data-theme="dark"] .form-field label,
[data-theme="joan"] .form-field label {
    color: var(--gray-500);
}

[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field select,
[data-theme="dark"] .form-field textarea,
[data-theme="dark"] .enum-input,
[data-theme="joan"] .form-field input,
[data-theme="joan"] .form-field select,
[data-theme="joan"] .form-field textarea,
[data-theme="joan"] .enum-input {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-700);
    resize: none;
    transition: height 0.1s ease;
}

[data-theme="dark"] .form-field input:focus,
[data-theme="dark"] .form-field select:focus,
[data-theme="dark"] .form-field textarea:focus,
[data-theme="dark"] .enum-input:focus,
[data-theme="joan"] .form-field input:focus,
[data-theme="joan"] .form-field select:focus,
[data-theme="joan"] .form-field textarea:focus,
[data-theme="joan"] .enum-input:focus {
    border-color: var(--color-primary);
}

[data-theme="dark"] .form-section h4,
[data-theme="joan"] .form-section h4 {
    color: var(--gray-700);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .checkbox-item label,
[data-theme="joan"] .checkbox-item label {
    color: var(--gray-500);
}

/* Dark mode search and filters */
[data-theme="dark"] .search-input input,
[data-theme="joan"] .search-input input {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .dropdown-trigger,
[data-theme="joan"] .dropdown-trigger {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .dropdown-content,
[data-theme="joan"] .dropdown-content {
    background: var(--color-background);
    border-color: var(--gray-200);
}

[data-theme="dark"] .dropdown-option,
[data-theme="joan"] .dropdown-option {
    color: var(--gray-600);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .dropdown-option:hover,
[data-theme="joan"] .dropdown-option:hover {
    background: var(--color-light);
}

[data-theme="dark"] .filter-toggle,
[data-theme="joan"] .filter-toggle {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-600);
}

[data-theme="dark"] .filter-toggle:hover,
[data-theme="joan"] .filter-toggle:hover {
    background: var(--gray-200);
    transform: translateY(-1px);
}

[data-theme="dark"] .results-info,
[data-theme="joan"] .results-info {
    color: var(--gray-500);
}

/* Dark mode loading and modals */
[data-theme="dark"] .loading-content,
[data-theme="joan"] .loading-content {
    background: var(--color-background);
    color: var(--gray-700);
}

[data-theme="dark"] .spinner,
[data-theme="joan"] .spinner {
    border-color: var(--gray-200);
    border-top-color: var(--color-primary);
}

/* Dark mode panel details */
[data-theme="dark"] .field-details-panel,
[data-theme="joan"] .field-details-panel {
    background: var(--color-background);
    border-left-color: var(--gray-200);
}

[data-theme="dark"] .panel-title h3,
[data-theme="joan"] .panel-title h3 {
    color: var(--gray-700);
}

[data-theme="dark"] .field-type-badge,
[data-theme="joan"] .field-type-badge {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

[data-theme="dark"] .panel-content,
[data-theme="joan"] .panel-content {
    background: var(--color-background);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 50%, var(--color-purple) 100%);
    color: var(--color-dark);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Layout */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    gap: 2rem;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.schema-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.field-stats {
    background: var(--gray-100);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 500;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-700);
}

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

.btn-success:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-ghost:hover {
    background: var(--gray-50);
    color: var(--gray-700);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-large {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

/* File Input */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Loading & States */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-xl);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Banners */
.info-banner, .warning-banner, .error-banner {
    background: var(--white);
    border-left: 4px solid var(--primary);
    margin: 0 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.warning-banner {
    border-left-color: var(--warning);
}

.error-banner {
    border-left-color: var(--danger);
    background: #fef2f2;
    color: var(--danger);
    padding: 1rem 1.5rem;
    font-weight: 500;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.banner-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.banner-text {
    flex: 1;
}

.banner-text strong {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.banner-text span {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.banner-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius);
}

.banner-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Main Content */
.app-main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 3rem;
    box-shadow: var(--shadow);
}

.empty-icon {
    color: var(--gray-300);
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.empty-state p {
    color: var(--gray-600);
    margin-bottom: 2rem;
    max-width: 400px;
}

/* Schema Editor */
.schema-editor {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

/* Filter Bar */
.filter-bar {
    background: var(--color-light);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.search-input {
    position: relative;
    min-width: 300px;
}

.search-input svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.search-input input {
    width: 100%;
    padding: 0.625rem 0.75rem 0.625rem 2.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--white);
    transition: all 0.2s ease;
}

.search-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

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

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    min-width: 140px;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    user-select: none;
}

.dropdown-trigger:hover {
    border-color: var(--gray-400);
}

.dropdown-trigger:focus,
.custom-dropdown.open .dropdown-trigger {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

.dropdown-label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.custom-dropdown.open .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background: var(--gray-50);
}

.dropdown-option.selected {
    background: rgba(67, 97, 238, 0.1);
    color: var(--color-accent);
    font-weight: 500;
}

.dropdown-option-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dropdown-option.selected .dropdown-option-checkbox {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.dropdown-option.selected .dropdown-option-checkbox::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.dropdown-selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 200px;
    overflow: hidden;
}

.dropdown-tag {
    background: var(--color-accent);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.dropdown-tag.more {
    background: var(--gray-500);
}

.filter-select {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.875rem;
    min-width: 120px;
    cursor: pointer;
}

.filter-select[multiple] {
    min-height: 80px;
    max-height: 120px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

.filter-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.5rem;
    width: fit-content;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    width: 170px;
    justify-content: flex-start;
}

.filter-toggle:hover {
    background: var(--gray-50);
    transform: translateY(-1px);
}

.indicator-icon {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.indicator-icon.comments {
    border-color: var(--success);
}

.indicator-icon.errors {
    border-color: var(--danger);
}

.indicator-icon.changes {
    border-color: var(--warning);
}

.indicator-icon.improvements {
    border-color: #8B5CF6;
}

.indicator-fill {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

/* Three states for indicator fill */
.filter-toggle[data-state="all"] .indicator-fill {
    background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.filter-toggle[data-state="true"] .indicator-fill {
    background: currentColor;
}

.filter-toggle[data-state="false"] .indicator-fill {
    background: transparent;
}

/* Color states */
.filter-toggle[data-filter="comments"] .indicator-fill {
    color: var(--success);
}

.filter-toggle[data-filter="errors"] .indicator-fill {
    color: var(--danger);
}

.filter-toggle[data-filter="changes"] .indicator-fill {
    color: var(--warning);
}

.filter-toggle[data-filter="improvements"] .indicator-fill {
    color: #8B5CF6;
}

.filter-label {
    font-weight: 500;
    flex: 1;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.indicator.comments { background: var(--success); }
.indicator.errors { background: var(--danger); }
.indicator.changes { background: var(--warning); }
.indicator.improvements { background: #8B5CF6; }

.results-info {
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Fields Table */
.fields-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.fields-table {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.table-header {
    display: grid;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--color-light);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-muted-text);
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-body {
    flex: 1;
    overflow-y: auto;
}

.field-row {
    display: grid;
    gap: 1rem;
    padding: 0.625rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: all 0.15s ease;
    align-items: center;
}

.field-row:hover {
    background: var(--gray-50);
}

.field-row.selected {
    background: rgba(200, 223, 248, 0.6);
    border-color: var(--color-primary);
}

.field-name {
    font-weight: 600;
    color: var(--gray-900);
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.875rem;
}

.field-type {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    width: fit-content;
}

.field-group {
    padding: 0.25rem 0.5rem;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    width: fit-content;
    display: inline-flex;
    align-items: center;
}

.field-description {
    color: var(--gray-600);
    font-size: 0.875rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.field-comments {
    color: var(--gray-600);
    font-size: 0.875rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}

.field-indicators {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
}

.field-indicators .indicator {
    width: 10px;
    height: 10px;
}

/* Field Details Panel */
.field-details-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 73vw;
    min-width: 400px;
    height: 100vh;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.field-details-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--color-light);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.panel-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
}

.field-type-badge {
    background: var(--primary);
    color: var(--white);
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.panel-close {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.2s ease;
}

.panel-close:hover {
    background: rgba(29, 100, 145, 0.1);
    color: var(--color-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Form Styles */
.form-section {
    margin-bottom: 2rem;
}

.form-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-900);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.form-field.full-width {
    grid-column: 1 / -1;
}

.form-field label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.form-field input,
.form-field select,
.form-field textarea {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--white);
    transition: all 0.2s ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

.form-field textarea {
    resize: none;
    min-height: 60px;
    max-height: 300px;
    overflow-y: hidden;
    line-height: 1.5;
    transition: height 0.1s ease;
    box-sizing: border-box;
}

.checkbox-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.checkbox-item label {
    font-size: 0.875rem;
    cursor: pointer;
}

/* Enum Editor */
.enum-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.enum-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.enum-item input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--white);
    transition: all 0.2s ease;
}

.enum-item input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

.enum-remove {
    background: var(--danger);
    color: var(--white);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.enum-remove:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.enum-add {
    background: var(--success);
    color: var(--white);
    border: none;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.enum-add:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Dark mode for enum editor */
[data-theme="dark"] .enum-item input {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .enum-item input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

[data-theme="dark"] .enum-item input::placeholder {
    color: var(--gray-400);
}

[data-theme="dark"] .enum-remove {
    background: var(--danger);
    color: white;
}

[data-theme="dark"] .enum-remove:hover {
    background: #dc2626;
}

[data-theme="dark"] .enum-add {
    background: var(--success);
    color: white;
}

[data-theme="dark"] .enum-add:hover {
    background: #059669;
}

/* Schema Editor */
.schema-editor-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.schema-json-editor {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-900);
    resize: none;
    min-height: 120px;
    max-height: 400px;
    overflow-y: hidden;
    transition: all 0.2s ease;
    white-space: pre;
    overflow-wrap: normal;
    word-break: normal;
}

.schema-json-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(102 126 234 / 0.1);
}

.schema-json-editor.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.schema-validation-message {
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Dark mode for schema editor */
[data-theme="dark"] .schema-json-editor {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .schema-json-editor:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

[data-theme="dark"] .schema-json-editor.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

[data-theme="dark"] .schema-validation-message {
    background: #1F2937;
    border-color: #374151;
    color: #FCA5A5;
}

/* Collapsible Form Sections */
.form-section.collapsible {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--gray-50);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.form-section-header:hover {
    background: var(--gray-100);
}

.form-section-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    border: none;
    padding: 0;
}

.collapse-icon {
    color: var(--gray-500);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.form-section-content {
    overflow: hidden;
    transition: all 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

.form-section-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
}

.form-section-content:not(.collapsed) {
    padding: 1rem;
}

/* Dark mode for collapsible sections */
[data-theme="dark"] .form-section.collapsible {
    border-color: var(--gray-200);
}

[data-theme="dark"] .form-section-header {
    background: var(--color-light);
}

[data-theme="dark"] .form-section-header:hover {
    background: var(--gray-200);
}

[data-theme="dark"] .form-section-header h4 {
    color: var(--gray-700);
}

[data-theme="dark"] .collapse-icon {
    color: var(--gray-400);
}

/* Settings Modal */
.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.settings-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: min(90vw, 600px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--color-light);
}

.settings-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.settings-close {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.2s ease;
}

.settings-close:hover {
    background: rgba(29, 100, 145, 0.1);
    color: var(--color-primary);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
}

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

.settings-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-900);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    flex: 1;
    min-width: 80px;
    justify-content: center;
}

.theme-option:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
}

.theme-option.active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.theme-option.active:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(67, 97, 238, 0.4);
}

/* Column Order List */
.column-order-list {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.column-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    cursor: move;
    transition: all 0.2s ease;
    user-select: none;
}

.column-item:last-child {
    border-bottom: none;
}

.column-item:hover {
    background: var(--gray-50);
}

.column-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.column-item.drag-over {
    background: var(--color-light);
    border-color: var(--color-primary);
}

.column-item .drag-handle {
    color: var(--gray-400);
    flex-shrink: 0;
}

.column-item:hover .drag-handle {
    color: var(--color-primary);
}

.column-label {
    flex: 1;
    font-weight: 500;
    min-width: 0;
}

.column-width-adjuster {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.width-slider {
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-200);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.width-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}

.width-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}

.width-slider:focus {
    outline: none;
}

.width-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.width-slider:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.width-display {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    min-width: 35px;
    text-align: center;
}

.column-visibility-toggle {
    background: none;
    border: none;
    padding: 0.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.column-visibility-toggle:hover {
    background: var(--gray-100);
}

.column-visibility-toggle.visible {
    color: var(--color-primary);
}

.column-visibility-toggle.hidden {
    color: var(--gray-400);
}

.column-visibility-toggle.hidden:hover {
    color: var(--gray-600);
}

.settings-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Dark mode adjustments for settings */
[data-theme="dark"] .settings-content {
    background: var(--color-background);
    border: 1px solid var(--gray-200);
}

[data-theme="dark"] .settings-header {
    background: var(--color-light);
}

[data-theme="dark"] .settings-header h3 {
    color: var(--gray-700);
}

[data-theme="dark"] .settings-section h4 {
    color: var(--gray-700);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .setting-item label {
    color: var(--gray-500);
}

[data-theme="dark"] .theme-option {
    background: var(--color-light);
    border-color: var(--gray-200);
    color: var(--gray-500);
}

[data-theme="dark"] .theme-option:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
}

[data-theme="dark"] .theme-option.active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(107, 115, 255, 0.3);
}

[data-theme="dark"] .theme-option.active:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(107, 115, 255, 0.4);
}

[data-theme="dark"] .column-item {
    background: var(--color-light);
    border-bottom-color: var(--gray-200);
    color: var(--gray-600);
}

[data-theme="dark"] .column-item:hover {
    background: var(--gray-200);
}

[data-theme="dark"] .column-item .drag-handle {
    color: var(--gray-400);
}

[data-theme="dark"] .column-item:hover .drag-handle {
    color: var(--color-primary);
}

[data-theme="dark"] .column-visibility-toggle:hover {
    background: var(--gray-200);
}

[data-theme="dark"] .column-visibility-toggle.visible {
    color: var(--color-primary);
}

[data-theme="dark"] .column-visibility-toggle.hidden {
    color: var(--gray-400);
}

[data-theme="dark"] .column-visibility-toggle.hidden:hover {
    color: var(--gray-300);
}

[data-theme="dark"] .settings-footer {
    background: var(--color-light);
    border-top-color: var(--gray-200);
}

[data-theme="dark"] .column-order-list {
    border-color: var(--gray-200);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .field-details-panel {
        width: 80vw;
        min-width: 350px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .filter-section {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .search-input {
        min-width: auto;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .custom-dropdown {
        min-width: 120px;
    }
    
    .filter-toggles {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
        max-width: 300px;
        margin: 0 auto;
    }
    
    .filter-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .field-details-panel {
        width: 100vw;
        min-width: unset;
        left: 0;
    }
    
    .table-header,
    .field-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    
    .table-header > *,
    .field-row > * {
        padding: 0.25rem 0;
    }
    
    .field-row {
        padding: 1rem;
        border-radius: var(--radius);
        margin-bottom: 0.5rem;
        border: 1px solid var(--gray-200);
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-content {
        width: 95vw;
        max-height: 90vh;
    }
    
    .theme-selector {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .theme-option {
        flex: none;
        min-width: auto;
    }
    
    .column-width-adjuster {
        flex-direction: column;
        gap: 0.25rem;
        align-items: center;
    }
    
    .width-slider {
        width: 60px;
    }
    
    .settings-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .settings-footer .btn {
        width: 100%;
    }
}
