/* ============================================================================
   DbGate Custom Theme — Matched to Tower Portal Design System
   PRIMARY mechanism: Override DbGate's --theme-* CSS custom properties.
   DbGate 5.x uses these variables for ALL UI colors.
   SECONDARY: class-fragment selectors as fallback (may not match Svelte hashes).
   ============================================================================ */

/* ===== Override DbGate internal theme CSS variables ===== */
:root {
  /* Backgrounds */
  --theme-bg-0: #f9fafb !important;
  --theme-bg-1: #ffffff !important;
  --theme-bg-2: #f3f4f6 !important;
  --theme-bg-3: #e5e7eb !important;
  --theme-bg-4: #10b981 !important;
  /* Fonts */
  --theme-font-0: #ffffff !important;
  --theme-font-1: #111827 !important;
  --theme-font-2: #374151 !important;
  --theme-font-3: #6b7280 !important;
  --theme-font-alt: #3b82f6 !important;
  /* Interactive states */
  --theme-bg-hover: #f3f4f6 !important;
  --theme-bg-selected: #3b82f6 !important;
  --theme-bg-selected-visual: #dbeafe !important;
  /* Status bar (dark, like Tower header) */
  --theme-bg-statusbar: #1f2937 !important;
  --theme-font-statusbar: #d1d5db !important;
  /* Borders */
  --theme-border: #e5e7eb !important;
  /* Modal header */
  --theme-bg-modalheader: #f9fafb !important;
  /* Accent colors */
  --theme-bg-gold: #f59e0b !important;
  --theme-bg-green: #10b981 !important;
  --theme-bg-red: #ef4444 !important;
  --theme-bg-volcano: #f97316 !important;
  --theme-bg-blue: #3b82f6 !important;
  --theme-icon-green: #10b981 !important;
  --theme-icon-blue: #3b82f6 !important;
  --theme-icon-red: #ef4444 !important;
  --theme-icon-gold: #f59e0b !important;

  /* Tower custom variables (for fallback selectors below) */
  --tower-bg: #f9fafb;
  --tower-card: #ffffff;
  --tower-border: #e5e7eb;
  --tower-text: #111827;
  --tower-text-secondary: #6b7280;
  --tower-accent: #10b981;
  --tower-header-bg: #1f2937;
  --tower-hover: #f3f4f6;
  --tower-table-header: #f9fafb;
  --tower-radius: 8px;
  --tower-font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
}

/* ===== Global font + background ===== */
html, body {
  background: #f9fafb !important;
  margin: 0 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif !important;
  color: #111827 !important;
  -webkit-font-smoothing: antialiased !important;
}

/* Font catch-all */
div, span, p, a, button, input, select, textarea, td, th, label, li, ul, ol {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif !important;
}

/* ===== Hide the widget icon sidebar ===== */
[class*="WidgetIconPanel"],
[class*="widget-icon"],
[class*="widgetIcon"],
[class*="icon-bar"],
[class*="iconBar"],
[class*="leftSideBarIcons"] {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
}

[title="Database connections"]:is(div, button, a),
[title="Saved files"]:is(div, button, a),
[title="History"]:is(div, button, a),
[title="Archive"]:is(div, button, a),
[title="Plugins"]:is(div, button, a),
[title="Favorites"]:is(div, button, a),
[title="Closed tabs"]:is(div, button, a),
[title="Tools"]:is(div, button, a),
[title="Cell data"]:is(div, button, a),
[title="Settings"]:is(div, button, a) {
  display: none !important;
}

/* ===== Hide connection management buttons — connections are injected by our JS ===== */
[title="Add new connection"],
[title="Add new connection folder"],
[title="New Connection"] {
  display: none !important;
}

/* ===== Scrollbars — thin, subtle ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== Search inputs ===== */
input[type="text"],
input[type="search"] {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 6px !important;
  color: #111827 !important;
  font-size: 13px !important;
  padding: 6px 10px !important;
}
input[type="text"]:focus,
input[type="search"]:focus {
  border-color: #3b82f6 !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1) !important;
}

/* ===== Fallback selectors (may not match Svelte hashes, but kept for coverage) ===== */

[class*="StatusBar"],
[class*="statusBar"],
[class*="status-bar"] {
  background: #1f2937 !important;
  color: #d1d5db !important;
  border-top: 1px solid #374151 !important;
  font-size: 12px !important;
}

[class*="toolbar"],
[class*="ToolBar"],
[class*="toolBar"],
[class*="MenuBar"],
[class*="menuBar"],
[class*="menu-bar"] {
  background: #ffffff !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #111827 !important;
}

[class*="LeftPanel"],
[class*="leftPanel"],
[class*="left-panel"] {
  background: #ffffff !important;
  border-right: 1px solid #e5e7eb !important;
}

[class*="TabsPanel"],
[class*="tabsPanel"],
[class*="tabs-panel"] {
  background: #f9fafb !important;
}

[class*="DataGrid"],
[class*="dataGrid"],
[class*="data-grid"] {
  font-size: 13px !important;
  border: 1px solid #e5e7eb !important;
}

[class*="DropDownMenu"],
[class*="dropDownMenu"],
[class*="context-menu"],
[class*="ContextMenu"] {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
  color: #111827 !important;
}

[class*="DropDownMenu"] [class*="item"]:hover,
[class*="dropDownMenu"] [class*="item"]:hover {
  background: #f3f4f6 !important;
}

[class*="Splitter"],
[class*="splitter"],
[class*="split-handle"] {
  background: #e5e7eb !important;
  width: 1px !important;
  min-width: 1px !important;
}
