/* ===== DESIGN SYSTEM ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors - Dark Mode (default) */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-elevated: #1e1e2e;
  --bg-card: rgba(26, 26, 40, 0.7);
  --bg-card-hover: rgba(30, 30, 48, 0.85);
  --bg-glass: rgba(20, 20, 35, 0.6);
  --bg-input: rgba(26, 26, 40, 0.8);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.15);
  --border-active: rgba(124, 100, 255, 0.4);

  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-tertiary: #6b6b85;
  --text-muted: #4a4a60;

  --accent-primary: #7c64ff;
  --accent-primary-hover: #9580ff;
  --accent-primary-glow: rgba(124, 100, 255, 0.15);
  --accent-secondary: #00d4aa;
  --accent-secondary-glow: rgba(0, 212, 170, 0.15);

  --success: #00d4aa;
  --success-bg: rgba(0, 212, 170, 0.1);
  --warning: #ffb347;
  --warning-bg: rgba(255, 179, 71, 0.1);
  --error: #ff6b8a;
  --error-bg: rgba(255, 107, 138, 0.1);
  --info: #64b5f6;
  --info-bg: rgba(100, 181, 246, 0.1);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #7c64ff 0%, #a78bfa 50%, #c084fc 100%);
  --gradient-accent: linear-gradient(135deg, #00d4aa 0%, #00b8d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(124, 100, 255, 0.05) 0%, rgba(0, 212, 170, 0.03) 100%);
  --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(124, 100, 255, 0.12) 0%, transparent 60%);
  --gradient-sidebar: linear-gradient(180deg, #0e0e18 0%, #0a0a12 100%);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 50px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px rgba(124, 100, 255, 0.15);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 1px rgba(255, 255, 255, 0.05);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --header-height: 60px;
}

/* Light Mode */
[data-theme="light"] {
  --bg-primary: #f8f9fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f5;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-input: rgba(240, 241, 245, 0.9);

  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.12);
  --border-active: rgba(124, 100, 255, 0.4);

  --text-primary: #1a1a2e;
  --text-secondary: #5a5a7a;
  --text-tertiary: #8a8aa5;
  --text-muted: #b0b0c5;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 50px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.1);

  --gradient-sidebar: linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
  --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(124, 100, 255, 0.06) 0%, transparent 60%);
}

/* ===== BASE RESET ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.6;
}

::selection {
  background: rgba(124, 100, 255, 0.3);
  color: var(--text-primary);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-primary) 0%, rgba(124, 100, 255, 0.4) 100%);
  border-radius: var(--radius-full);
  border: 3px solid var(--bg-secondary);
  background-clip: content-box;
  transition: background var(--duration-fast) var(--ease-default);
  min-height: 40px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent-primary-hover) 0%, var(--accent-primary) 100%);
  border: 2px solid var(--bg-secondary);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: var(--bg-secondary);
}

/* Firefox scrollbar styling */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-secondary);
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--gradient-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: width var(--duration-normal) var(--ease-default),
    transform var(--duration-normal) var(--ease-default);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 60px;
}

.sidebar-brand .brand-icon {
  width: 34px;
  height: 34px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-brand .brand-text {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--duration-fast) var(--ease-default);
}

.sidebar-brand .brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .brand-text span {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}

.sidebar.collapsed .brand-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--duration-fast) var(--ease-default);
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--accent-primary-glow);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.nav-item .nav-label {
  overflow: hidden;
  transition: opacity var(--duration-fast) var(--ease-default);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: all var(--duration-fast) var(--ease-default);
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-hover);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--duration-normal) var(--ease-default);
  position: relative;
}

.main-content::before {
  content: '';
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 300px;
  background: var(--gradient-glow);
  pointer-events: none;
  z-index: 0;
  transition: left var(--duration-normal) var(--ease-default);
}

.sidebar.collapsed~.main-content {
  margin-left: var(--sidebar-collapsed);
}

.sidebar.collapsed~.main-content::before {
  left: var(--sidebar-collapsed);
}

/* ===== HEADER ===== */
.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Connection status chip */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  transition: all var(--duration-fast) var(--ease-default);
}

.status-chip.connected {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(0, 212, 170, 0.2);
}

.status-chip.disconnected {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(255, 107, 138, 0.2);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Dialect badge */
.dialect-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.dialect-badge.postgres {
  color: #336791;
  background: rgba(51, 103, 145, 0.1);
  border-color: rgba(51, 103, 145, 0.2);
}

.dialect-badge.mysql {
  color: #00758f;
  background: rgba(0, 117, 143, 0.1);
  border-color: rgba(0, 117, 143, 0.2);
}

.dialect-badge.oracle {
  color: #f80000;
  background: rgba(248, 0, 0, 0.1);
  border-color: rgba(248, 0, 0, 0.2);
}

/* Safe mode toggle */
.safe-mode-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.toggle-switch {
  width: 38px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border-default);
  transition: all var(--duration-fast) var(--ease-default);
}

.toggle-switch.active {
  background: var(--success);
  border-color: var(--success);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.toggle-switch.active::after {
  transform: translateX(18px);
}

/* Theme switch */
.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--duration-fast) var(--ease-default);
}

.theme-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: scale(1.05);
}

/* ===== PAGE AREA ===== */
.page-area {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: visible;
  min-height: calc(100vh - var(--header-height));
  position: relative;
  z-index: 1;
}

/* Page transitions */
.page {
  display: none;
  animation: pageIn var(--duration-slow) var(--ease-default);
}

.page.active {
  display: block;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--duration-normal) var(--ease-default);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 100, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-default);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card-flat {
  transform: none !important;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 10px rgba(124, 100, 255, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(124, 100, 255, 0.4);
  transform: translateY(-1px);
}

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

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

.btn-success {
  background: linear-gradient(135deg, #00d4aa, #00b8d4);
  color: white;
  box-shadow: 0 2px 10px rgba(0, 212, 170, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #ff6b8a, #ff4757);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== INPUTS ===== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all var(--duration-fast) var(--ease-default);
  outline: none;
}

.input-field:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
  background: var(--bg-elevated);
}

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

.input-field.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

textarea.input-field {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ===== SQL CODE BLOCK ===== */
.sql-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  position: relative;
  overflow-x: auto;
}

.sql-block pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.sql-block .copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-default);
}

.sql-block:hover .copy-btn {
  opacity: 1;
}

/* ===== TABLES ===== */
.data-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-tertiary);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  position: sticky;
  top: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}

.data-table th:hover {
  color: var(--text-primary);
}

.data-table th .sort-icon {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:hover td {
  background: var(--accent-primary-glow);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-lg);
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  animation: tabIn var(--duration-normal) var(--ease-default);
}

.tab-content.active {
  display: block;
}

@keyframes tabIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== SKELETON LOADERS ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-sm);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-block {
  height: 200px;
  border-radius: var(--radius-md);
}

.skeleton-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.skeleton-row .skeleton {
  flex: 1;
  height: 40px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  min-width: 300px;
  max-width: 420px;
  animation: toastIn var(--duration-normal) var(--ease-spring);
  cursor: pointer;
}

.toast.toast-out {
  animation: toastOut var(--duration-fast) var(--ease-default) forwards;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--info);
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info .toast-icon {
  color: var(--info);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-default);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--duration-fast) var(--ease-default);
}

.modal-close:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* ===== CONNECT PAGE ===== */
.connect-page {
  max-width: 520px;
  margin: 0 auto;
  padding-top: var(--space-2xl);
}

.connect-card {
  text-align: center;
}

.connect-card .card-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-lg);
  background: var(--gradient-primary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: var(--shadow-glow);
}

.connect-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.connect-card p {
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  font-size: 14px;
}

.connect-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  text-align: left;
}

.connect-form .input-row {
  display: flex;
  gap: var(--space-sm);
}

.connect-form .input-row .input-field {
  flex: 1;
}

.connection-presets {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-sm);
}

.preset-btn {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

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

/* Loading animation */
.connecting-animation {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl) 0;
}

.connecting-animation.show {
  display: flex;
}

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

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

.connecting-text {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

/* ===== SCHEMA EXPLORER ===== */
.schema-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
  min-height: 60vh;
}

.schema-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: var(--space-sm);
}

.schema-table-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
  border: 1px solid transparent;
}

.schema-table-item:hover {
  background: var(--accent-primary-glow);
  color: var(--text-primary);
}

.schema-table-item.active {
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
  border-color: rgba(124, 100, 255, 0.15);
}

.schema-table-item .table-icon {
  font-size: 14px;
  opacity: 0.6;
}

.schema-detail-view {
  overflow: hidden;
}

.schema-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.schema-detail-header h3 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.schema-meta {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.meta-chip .meta-value {
  color: var(--accent-primary);
  font-weight: 700;
}

.schema-section {
  margin-bottom: var(--space-lg);
}

.schema-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-md);
}

/* ===== AI QUERY PAGE ===== */
.ai-query-input-area {
  margin-bottom: var(--space-xl);
}

.ai-input-wrapper {
  position: relative;
}

.ai-input {
  width: 100%;
  padding: 18px 60px 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  min-height: 64px;
  max-height: 200px;
  outline: none;
  transition: all var(--duration-fast) var(--ease-default);
}

.ai-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-glow);
}

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

.ai-send-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--duration-fast) var(--ease-default);
  box-shadow: 0 2px 10px rgba(124, 100, 255, 0.3);
}

.ai-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(124, 100, 255, 0.4);
}

.ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* AI thinking animation */
.ai-thinking {
  display: none;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.ai-thinking.show {
  display: flex;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: thinkBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinkBounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.thinking-text {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.retry-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  margin-left: var(--space-md);
}

/* Typewriter effect */
.typewriter {
  overflow: hidden;
  border-right: 2px solid var(--accent-primary);
  animation: blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {

  from,
  to {
    border-color: transparent;
  }

  50% {
    border-color: var(--accent-primary);
  }
}

/* ===== RESULTS AREA ===== */
.results-area {
  animation: fadeSlideUp var(--duration-slow) var(--ease-default);
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  max-width: 100%;
}

.chart-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: chartFadeIn var(--duration-slow) var(--ease-default);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: var(--bg-card);
}

.chart-card img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 45vh;
  display: block;
  border-radius: var(--radius-md);
  object-fit: contain;
}

@keyframes chartFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== DASHBOARD PAGE ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.dashboard-card {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dashboard-card .card-content {
  padding: var(--space-lg);
}

.dashboard-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.dashboard-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.dashboard-card img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 45vh;
  border-radius: var(--radius-md);
  object-fit: contain;
  transition: transform var(--duration-normal) var(--ease-default);
}

.dashboard-card:hover img {
  transform: scale(1.02);
}

.dashboard-card .fullscreen-hint {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-default);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.dashboard-card:hover .fullscreen-hint {
  opacity: 1;
}

/* Stagger animation for dashboard cards */
.dashboard-card:nth-child(1) {
  animation-delay: 0s;
}

.dashboard-card:nth-child(2) {
  animation-delay: 0.08s;
}

.dashboard-card:nth-child(3) {
  animation-delay: 0.16s;
}

.dashboard-card:nth-child(4) {
  animation-delay: 0.24s;
}

.dashboard-card:nth-child(5) {
  animation-delay: 0.32s;
}

@keyframes cardStagger {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-card.animate-in {
  animation: cardStagger var(--duration-slow) var(--ease-default) both;
}

/* ===== SQL OPTIMIZER PAGE ===== */
.optimizer-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.optimizer-panel h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.editor-area {
  min-height: 250px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.editor-area:focus {
  border-color: var(--accent-primary);
}

/* Performance score */
.perf-score-container {
  margin: var(--space-lg) 0;
}

.perf-score-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: 13px;
  font-weight: 600;
}

.perf-score-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.perf-score-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s var(--ease-default);
  background: var(--gradient-primary);
}

.perf-score-fill.low {
  background: linear-gradient(90deg, #ff6b8a, #ff4757);
}

.perf-score-fill.medium {
  background: linear-gradient(90deg, #ffb347, #ff9500);
}

.perf-score-fill.high {
  background: linear-gradient(90deg, #00d4aa, #00b8d4);
}

/* Explanation panel */
.explanation-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-top: var(--space-lg);
}

.explanation-panel h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.explanation-content {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
}

.explanation-content strong {
  color: var(--text-primary);
}

/* Diff highlighting */
.diff-added {
  background: rgba(0, 212, 170, 0.1);
  border-left: 3px solid var(--success);
  padding-left: var(--space-sm);
  display: block;
}

.diff-removed {
  background: rgba(255, 107, 138, 0.1);
  border-left: 3px solid var(--error);
  padding-left: var(--space-sm);
  text-decoration: line-through;
  opacity: 0.6;
  display: block;
}

/* ===== QUERY HISTORY ===== */
.history-panel {
  margin-top: var(--space-xl);
}

.history-panel h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.history-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.history-item .history-query {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .history-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-tertiary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.6;
}

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

  .schema-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-card img,
  .dashboard-card img {
    max-height: 50vh;
  }
}

@media (max-width: 768px) {

  .chart-card img,
  .dashboard-card img {
    max-height: 40vh;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 200;
    width: var(--sidebar-width);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .main-content::before {
    left: 0 !important;
  }

  .page-area {
    padding: var(--space-md);
  }

  /* Enable vertical scrolling for the entire page */
  html,
  body {
    height: 100%;
    overflow-y: auto;
  }

  /* Ensure main content scrolls properly inside layout */
  .main-content {
    overflow-y: auto;
  }


  .header {
    padding: 0 var(--space-md);
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-default);
  }

  .mobile-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }
}

.mobile-menu-btn {
  display: none !important;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* ===== UTILITY CLASSES ===== */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.text-center {
  text-align: center;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.csv-preview {
  max-height: 400px;
  overflow: auto;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

/* Image responsiveness enhancements */
.chart-card img,
.dashboard-card img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 45vh;
  background: var(--bg-tertiary);
}

.modal {
  max-width: 90vw;
  width: auto;
  display: inline-block;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

#chartModalImg {
  max-height: 80vh;
  object-fit: contain;
}