/* GeoAI Lab v5.0 — Coal Geochemistry Edition (Linear / Benchling / ioGAS Minimalist UI) */
:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-hover: #E2E8F0;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-faint: #94A3B8;
  --accent: #0F766E;
  --accent-hover: #0D9488;
  --accent-soft: rgba(15, 118, 110, 0.10);
  --danger: #DC2626;
  --warn: #D97706;
  --ok: #059669;
  --radius: 8px;
  --radius-sm: 6px;
  --titlebar-h: 38px;
  --sidebar-w: 224px;
}

html.dark, html[data-theme="dark"] {
  --bg: #0B0D10;
  --surface: #12161C;
  --surface-2: #181D25;
  --surface-hover: #212833;
  --border: #232A35;
  --border-strong: #323C4B;
  --text: #E6EDF3;
  --text-muted: #8B949E;
  --text-faint: #6E7681;
  --accent: #2DD4BF;
  --accent-hover: #14B8A6;
  --accent-soft: rgba(45, 212, 191, 0.12);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.font-mono, .tabular-nums, td.num, th.num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Custom Frameless Desktop Titlebar */
#desktopTitlebar {
  height: var(--titlebar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 12px;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 95;
}
#desktopTitlebar.hidden { display: none !important; }
.titlebar-drag {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.titlebar-btn {
  width: 34px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.titlebar-btn:hover { background: var(--surface-2); color: var(--text); }
.titlebar-btn.close-btn:hover { background: #DC2626; color: #FFFFFF; }

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* Sidebar */
#appSidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.18s ease, transform 0.18s ease;
}
#appSidebar.sidebar-collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  border-right-width: 0;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
@media (max-width: 1024px) {
  #appSidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    transform: translateX(0);
  }
  #appSidebar.sidebar-collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
}

.nav-item, .nav-tab-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-item:hover, .nav-tab-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active, .tab-btn-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-color: transparent;
}
.theme-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}
.theme-mode-btn:hover { color: var(--text); }
.theme-btn-active {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
#sidebarBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 50;
}
@media (min-width: 1025px) {
  #sidebarBackdrop { display: none !important; }
}

/* Cards & Surfaces */
.geo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.geo-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

/* Tables */
.data-table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.geo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.geo-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.01em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.geo-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.geo-table tbody tr:hover td {
  background: var(--surface-2);
}

/* Subtabs */
.subtab-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}
.subtab-btn:hover { color: var(--text); background: var(--surface-2); }
.subtab-btn.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  font-weight: 600;
}

/* Badges */
.badge-warn { background: rgba(217, 119, 6, 0.12); color: #B45309; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-err { background: rgba(220, 38, 38, 0.12); color: #B91C1C; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-ok { background: rgba(5, 150, 105, 0.12); color: #047857; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
html.dark .badge-warn, html[data-theme="dark"] .badge-warn { color: #FBBF24; }
html.dark .badge-err, html[data-theme="dark"] .badge-err { color: #F87171; }
html.dark .badge-ok, html[data-theme="dark"] .badge-ok { color: #34D399; }

/* Inputs & Selects */
.geo-input, select.geo-input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
}
.geo-input:focus {
  border-color: var(--accent);
}

/* Dark theme Tailwind compatibility overrides */
html.dark body, html[data-theme="dark"] body { background-color: var(--bg) !important; color: var(--text) !important; }
html.dark .bg-white, html[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
html.dark .bg-slate-50, html.dark .bg-slate-100, html[data-theme="dark"] .bg-slate-50, html[data-theme="dark"] .bg-slate-100 { background-color: var(--surface-2) !important; }
html.dark .border-slate-200, html.dark .border-slate-100, html.dark .border-slate-300, html[data-theme="dark"] .border-slate-200, html[data-theme="dark"] .border-slate-100, html[data-theme="dark"] .border-slate-300 { border-color: var(--border) !important; }
html.dark .text-slate-900, html.dark .text-slate-800, html[data-theme="dark"] .text-slate-900, html[data-theme="dark"] .text-slate-800 { color: var(--text) !important; }
html.dark .text-slate-700, html.dark .text-slate-600, html[data-theme="dark"] .text-slate-700, html[data-theme="dark"] .text-slate-600 { color: #C9D1D9 !important; }
html.dark .text-slate-500, html.dark .text-slate-400, html[data-theme="dark"] .text-slate-500, html[data-theme="dark"] .text-slate-400 { color: var(--text-muted) !important; }
html.dark input, html.dark select, html.dark textarea, html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background-color: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html.dark .hover\:bg-slate-50:hover, html.dark .hover\:bg-slate-100:hover, html[data-theme="dark"] .hover\:bg-slate-50:hover, html[data-theme="dark"] .hover\:bg-slate-100:hover {
  background-color: var(--surface-hover) !important;
}

/* Command Palette Modal (Ctrl+K) */
#modalCommandPalette {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
#modalCommandPalette.hidden { display: none !important; }
.cmd-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.cmd-item {
  width: 100%;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
}
.cmd-item:hover, .cmd-item.selected {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Sticky AI Drawer */
#aiQuickDrawer {
  background: var(--surface);
  border-left: 1px solid var(--border);
}

/* Print Styles */
@media print {
  #desktopTitlebar, #appSidebar, #topHeaderBar, #aiQuickDrawer, .no-print { display: none !important; }
  body { background: #FFFFFF !important; color: #000000 !important; }
}
