:root {
  /* Dark Theme variables */
  --bg-color: #0F172A;
  --bg-panel: rgba(30, 41, 59, 0.7);
  --bg-panel-hover: rgba(51, 65, 85, 0.8);
  --border: rgba(99, 102, 241, 0.2);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --secondary: #8B5CF6;
  --accent: #22D3EE;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  
  /* Diff Colors */
  --added-bg: rgba(16, 185, 129, 0.15);
  --added-text: #34D399;
  --removed-bg: rgba(239, 68, 68, 0.15);
  --removed-text: #F87171;
  --modified-bg: rgba(245, 158, 11, 0.15);
  --modified-text: #FBBF24;
  --unchanged-bg: transparent;
  --unchanged-text: var(--text-muted);

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.2);
  
  --transition: all 0.25s ease;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Light Theme Variables */
:root.light {
  --bg-color: #F8FAFC;
  --bg-panel: rgba(255, 255, 255, 0.8);
  --bg-panel-hover: rgba(241, 245, 249, 0.9);
  --border: rgba(148, 163, 184, 0.3);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --text-main: #0F172A;
  --text-muted: #64748B;
  
  --added-bg: rgba(16, 185, 129, 0.1);
  --added-text: #059669;
  --removed-bg: rgba(239, 68, 68, 0.1);
  --removed-text: #DC2626;
  --modified-bg: rgba(245, 158, 11, 0.1);
  --modified-text: #D97706;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  transition: background-color var(--transition);
}

.hidden { display: none !important; }
.mt-lg { margin-top: 2rem; }

/* Glassmorphism utility */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

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

.glass-header {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

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

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

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

.dialect-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.glass-select {
  background: rgba(0,0,0,0.1);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  outline: none;
  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='%2394A3B8' 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.5rem center;
  transition: var(--transition);
}
.glass-select:focus { border-color: var(--primary); box-shadow: var(--shadow-glow); }
:root.light .glass-select { background-color: rgba(255,255,255,0.5); }

/* Buttons */
button { cursor: pointer; font-family: var(--font-sans); transition: var(--transition); }

.icon-button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 50%;
}
.icon-button:hover { color: var(--primary); background: rgba(99, 102, 241, 0.1); }

.primary-btn, .secondary-btn, .outline-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
}

.primary-btn {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(99, 102, 241, 0.6); }

.secondary-btn {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}
.secondary-btn:hover { background: rgba(99, 102, 241, 0.2); }

.outline-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.outline-btn:hover { border-color: var(--primary); }

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }
:root.light .action-btn:hover { background: rgba(0,0,0,0.05); }

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

/* Input Section */
.input-section { display: flex; flex-direction: column; gap: 1.5rem; }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: 60vh;
  min-height: 400px;
}

.input-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.panel-header h2 { font-size: 1rem; color: var(--text-main); font-weight: 600; }
.file-actions { display: flex; gap: 0.5rem; }

.code-editor {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1.5rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}
.code-editor::placeholder { color: var(--border); }
.code-editor::-webkit-scrollbar { width: 8px; }
.code-editor::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.action-bar { display: flex; justify-content: center; padding: 1rem 0; }

/* Results Section */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-value { font-size: 2.5rem; font-weight: 700; font-family: var(--font-mono); }
.stat-label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;}

.stat-card.added .stat-value { color: var(--added-text); }
.stat-card.removed .stat-value { color: var(--removed-text); }
.stat-card.modified .stat-value { color: var(--modified-text); }
.stat-card.unchanged .stat-value { color: var(--text-muted); }

/* Diff Layout */
.diff-container { display: flex; flex-direction: column; gap: 1rem; }

.diff-tabs {
  display: flex;
  padding: 0.5rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.tab-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
:root.light .tab-btn:hover { background: rgba(0,0,0,0.05); }
.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.diff-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 60vh;
  min-height: 500px;
  overflow: hidden;
}

.table-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.table-list::-webkit-scrollbar { width: 6px; }
.table-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.table-item {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  transition: var(--transition);
}
.table-item:hover { background: var(--bg-panel-hover); border-color: var(--border); }
.table-item.active { background: rgba(99, 102, 241, 0.15); border-color: var(--primary); }

.table-name { font-weight: 500; font-family: var(--font-mono); font-size: 0.875rem; }
.table-status-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 700;
}
.status-added { background: var(--added-bg); color: var(--added-text); }
.status-removed { background: var(--removed-bg); color: var(--removed-text); }
.status-modified { background: var(--modified-bg); color: var(--modified-text); }
.status-unchanged { border: 1px solid var(--border); color: var(--text-muted); }

.table-detail {
  padding: 1.5rem;
  overflow-y: auto;
  position: relative;
}
.table-detail::-webkit-scrollbar { width: 8px; }
.table-detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.empty-detail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 1rem;
}

/* Detailed Table Diff View */
.detail-header {
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.detail-header h3 { font-family: var(--font-mono); font-size: 1.5rem; }

.column-diff-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.diff-row {
  display: grid;
  grid-template-columns: 20px 1fr 1fr;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: rgba(0,0,0,0.1);
  border-left: 3px solid transparent;
}
:root.light .diff-row { background: rgba(0,0,0,0.02); }

.diff-row.added { border-left-color: var(--added-text); background: var(--added-bg); }
.diff-row.removed { border-left-color: var(--removed-text); background: var(--removed-bg); }
.diff-row.modified { border-left-color: var(--modified-text); background: var(--modified-bg); }
.diff-row.unchanged { border-left-color: var(--border); }

.diff-sign { font-weight: bold; }
.diff-row.added .diff-sign { color: var(--added-text); }
.diff-row.removed .diff-sign { color: var(--removed-text); }

.diff-content-left { color: var(--removed-text); text-decoration: line-through; }
.diff-row.unchanged .diff-content-left, .diff-row.modified .diff-content-left { text-decoration: none; color: var(--text-muted); }

.diff-content-right { color: var(--added-text); }
.diff-row.unchanged .diff-content-right { color: var(--text-main); }
.diff-row.removed .diff-content-right { display: none; }
.diff-row.added .diff-content-left { display: none; }

.section-title { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 1.5rem 0 1rem; }

/* Generated Migration Panel */
.migration-sql-panel pre {
  padding: 1.5rem;
  overflow-x: auto;
  background: rgba(0,0,0,0.3);
  margin: 0;
  border-top: 1px solid var(--border);
}
:root.light .migration-sql-panel pre { background: rgba(0,0,0,0.02); }
.migration-sql-panel code {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Tooltips */
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: var(--text-main);
  color: var(--bg-color);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 100;
  font-family: var(--font-sans);
}
.tooltip:hover::after { opacity: 1; transform: translateX(-50%) translateY(-8px); }

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: var(--bg-color);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
.toast.hidden { transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; }

/* Responsive */
@media (max-width: 1024px) {
  .panel-grid { grid-template-columns: 1fr; height: auto; }
  .diff-layout { grid-template-columns: 1fr; height: auto; display: flex; flex-direction: column; }
  .table-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 300px; }
  .table-detail { min-height: 400px; }
}
@media (max-width: 640px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .header-content { flex-direction: column; gap: 1rem; align-items: flex-start; }
}
