/* ===========================================================
   ChemLab — global styles, theme variables, layout shell
   =========================================================== */

:root {
  --bg:        #10151d;
  --panel:     #171d28;
  --panel-2:   #1b2230;
  --card:      #222c3c;
  --card-hover:#2a3750;
  --border:    #2a3445;
  --border-2:  #34425a;
  --accent:    #2196f3;
  --accent-2:  #64b5f6;
  --accent-dim:#1565c0;
  --text:      #e7edf5;
  --text-dim:  #9aa7b8;
  --text-mute: #6b7787;
  --danger:    #ef5350;
  --good:      #4caf50;
  --warn:      #ffb300;
  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 8px 28px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --t-fast:    .12s ease;
  --t:         .2s ease;
  --grid-line: rgba(120,150,190,.10);
  --grid-line-strong: rgba(120,150,190,.18);
  --workspace-bg: #0c1119;
}

body.light {
  --bg:        #eef2f7;
  --panel:     #f7f9fc;
  --panel-2:   #ffffff;
  --card:      #ffffff;
  --card-hover:#eaf2fd;
  --border:    #d7deea;
  --border-2:  #c2cdde;
  --accent:    #1976d2;
  --accent-2:  #1565c0;
  --accent-dim:#90caf9;
  --text:      #1a2230;
  --text-dim:  #51607a;
  --text-mute: #8a97a9;
  --shadow:    0 8px 28px rgba(40,60,90,.18);
  --shadow-sm: 0 2px 8px rgba(40,60,90,.12);
  --grid-line: rgba(80,110,160,.12);
  --grid-line-strong: rgba(80,110,160,.22);
  --workspace-bg: #e6ecf4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", "SF Pro Display", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  color: var(--text);
  outline: none;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); background-clip: padding-box; }

/* ---------- Main 3-column body ---------- */
#main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

.panel {
  position: relative;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width var(--t), margin var(--t), transform var(--t);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.panel-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-dim);
  flex: 1 1 auto;
}
.panel-collapse {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--card);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  transition: var(--t-fast);
}
.panel-collapse:hover { background: var(--accent); color: #fff; }

/* collapsed panels */
.panel.collapsed { width: 0 !important; min-width: 0; overflow: hidden; }

/* resizers */
.panel-resizer {
  position: absolute;
  top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize;
  z-index: 20;
}
.panel-resizer.left { right: auto; left: -3px; }
.panel-resizer:hover { background: linear-gradient(90deg, transparent, var(--accent), transparent); }

/* ---------- Status bar ---------- */
.statusbar {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.statusbar b { color: var(--accent-2); font-weight: 600; }
.status-spacer { flex: 1 1 auto; }
.status-item.muted { color: var(--text-mute); }

.hidden { display: none !important; }

/* generic small chip */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  background: var(--card);
  color: var(--text-dim);
}

/* fade animation utility */
@keyframes pop-in {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* toast notifications */
#toast-host {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .22s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
