/* ==========================================================================
   base.css: reset, typography, scrollbars, focus rings, shared controls.
   Every color is a CSS custom property generated from themes/*.json
   (--vscode-*) or themes/millionscope.tokens.js (--ms-*).
   ========================================================================== */

:root {
  --ms-font-ui: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", system-ui, Ubuntu, sans-serif;
  --ms-font-mono: "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ms-fs: 13px;
  --ms-fs-small: 12px;
  --ms-fs-tiny: 11px;
  --ms-fs-mono: 12px;
  --ms-h-topbar: 32px;
  --ms-h-header: 28px;
  --ms-h-tab: 32px;
  --ms-h-status: 22px;
  --ms-h-composer-min: 44px;
  --ms-radius: 4px;
  --ms-radius-sm: 3px;
  --ms-row-h: 22px;
  --ms-ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--ms-font-ui);
  font-size: var(--ms-fs);
  line-height: 1.4;
  color: var(--vscode-foreground);
  background: var(--vscode-editor-background);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }

code, kbd, pre, samp, .ms-mono {
  font-family: var(--ms-font-mono);
  font-size: var(--ms-fs-mono);
}

/* All numbers align in columns. */
.ms-num, .ms-bv, .ms-tabular, table, .ms-statusbar, input[type="number"] {
  font-variant-numeric: tabular-nums;
}

a { color: var(--vscode-textLink-foreground); text-decoration: none; }
a:hover, a:focus-visible { color: var(--vscode-textLink-activeForeground); text-decoration: underline; }

::selection { background: var(--vscode-editor-selectionBackground); }

/* ---------- focus rings ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 1px solid var(--vscode-focusBorder);
  outline-offset: -1px;
}

/* ---------- scrollbars (VS Code-like) ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--vscode-scrollbarSlider-background) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--vscode-scrollbarSlider-background); border: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--vscode-scrollbarSlider-hoverBackground); }
::-webkit-scrollbar-thumb:active { background: var(--vscode-scrollbarSlider-activeBackground); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- utilities ---------- */
.ms-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.ms-hidden { display: none !important; }
.ms-grow { flex: 1 1 auto; min-width: 0; }
.ms-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ms-col { display: flex; flex-direction: column; min-height: 0; }
.ms-muted { color: var(--vscode-descriptionForeground); }
.ms-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ms-small { font-size: var(--ms-fs-small); }
.ms-tiny { font-size: var(--ms-fs-tiny); }
.ms-spacer { flex: 1 1 auto; }
.ms-error-text { color: var(--vscode-errorForeground); }

/* ---------- icon buttons ---------- */
.ms-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 22px;
  height: 22px;
  padding: 0 3px;
  border: 1px solid transparent;
  border-radius: var(--ms-radius);
  background: transparent;
  color: var(--vscode-icon-foreground);
  line-height: 1;
  flex: 0 0 auto;
}
.ms-icon-btn:hover:not(:disabled) { background: var(--vscode-toolbar-hoverBackground); }
.ms-icon-btn:active:not(:disabled) { background: var(--vscode-toolbar-activeBackground); }
.ms-icon-btn .codicon { font-size: 16px; }
.ms-icon-btn.is-small .codicon { font-size: 14px; }
.ms-icon-btn .ms-caret { font-size: 10px; opacity: .8; }

/* toggles (pin, sync, filters) */
.ms-toggle[aria-pressed="true"],
.ms-icon-btn[aria-pressed="true"] {
  background: var(--vscode-inputOption-activeBackground);
  border-color: var(--vscode-inputOption-activeBorder);
  color: var(--vscode-inputOption-activeForeground, var(--vscode-foreground));
}

/* ---------- text buttons ---------- */
.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--vscode-button-border, transparent);
  border-radius: var(--ms-radius);
  background: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
  white-space: nowrap;
  flex: 0 0 auto;
}
.ms-btn:hover:not(:disabled) { background: var(--vscode-button-hoverBackground); }
.ms-btn.is-secondary {
  background: var(--vscode-button-secondaryBackground);
  color: var(--vscode-button-secondaryForeground);
  border-color: var(--vscode-button-border, transparent);
}
.ms-btn.is-secondary:hover:not(:disabled) { background: var(--vscode-button-secondaryHoverBackground); }
.ms-btn.is-small { height: 20px; padding: 0 6px; font-size: var(--ms-fs-small); }
.ms-btn .codicon { font-size: 14px; }

/* ---------- inputs ---------- */
.ms-input, .ms-select, .ms-textarea {
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--vscode-input-border, transparent);
  border-radius: var(--ms-radius-sm);
  background: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
  min-width: 0;
}
.ms-input::placeholder, .ms-textarea::placeholder { color: var(--vscode-input-placeholderForeground); }
.ms-input:focus, .ms-select:focus, .ms-textarea:focus {
  outline: 1px solid var(--vscode-focusBorder);
  outline-offset: -1px;
  border-color: var(--vscode-focusBorder);
}
.ms-select {
  background: var(--vscode-dropdown-background);
  color: var(--vscode-dropdown-foreground);
  border-color: var(--vscode-dropdown-border);
  padding-right: 2px;
}
.ms-select option { background: var(--vscode-dropdown-listBackground, var(--vscode-dropdown-background)); }
.ms-input.is-small, .ms-select.is-small { height: 20px; font-size: var(--ms-fs-small); }
.ms-textarea { height: auto; padding: 4px 6px; resize: vertical; }

.ms-checkbox {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
}
.ms-checkbox input {
  appearance: none;
  width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--vscode-checkbox-border);
  border-radius: var(--ms-radius-sm);
  background: var(--vscode-checkbox-background);
  display: inline-grid; place-content: center;
}
.ms-checkbox input:checked::after {
  content: "\2713";
  font-size: 12px; line-height: 1;
  color: var(--vscode-checkbox-foreground);
}

/* range sliders */
input[type="range"].ms-range {
  appearance: none;
  background: transparent;
  height: 18px;
  min-width: 60px;
  margin: 0;
}
input[type="range"].ms-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--ms-range-fill, var(--vscode-button-background)) var(--ms-range-pct, 50%), var(--vscode-input-background) var(--ms-range-pct, 50%));
  border: 1px solid var(--vscode-input-border, transparent);
}
input[type="range"].ms-range::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border, transparent);
}
input[type="range"].ms-range::-moz-range-progress { height: 4px; background: var(--ms-range-fill, var(--vscode-button-background)); }
input[type="range"].ms-range::-webkit-slider-thumb {
  appearance: none;
  width: 12px; height: 12px; margin-top: -5px;
  border-radius: 50%;
  background: var(--vscode-foreground);
  border: 2px solid var(--vscode-editor-background);
}
input[type="range"].ms-range::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--vscode-foreground);
  border: 2px solid var(--vscode-editor-background);
}
input[type="range"].ms-range:focus-visible { outline: 1px solid var(--vscode-focusBorder); outline-offset: 1px; }

/* ---------- badges & keybinding labels ---------- */
.ms-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 5px;
  border-radius: 8px;
  background: var(--vscode-badge-background);
  color: var(--vscode-badge-foreground);
  font-size: var(--ms-fs-tiny);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ms-kbd {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid var(--vscode-keybindingLabel-border);
  border-bottom-color: var(--vscode-keybindingLabel-bottomBorder);
  border-radius: 3px;
  background: var(--vscode-keybindingLabel-background);
  color: var(--vscode-keybindingLabel-foreground);
  font-family: var(--ms-font-ui);
  font-size: var(--ms-fs-tiny);
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- progress line ---------- */
.ms-progress {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  overflow: hidden; pointer-events: none;
}
.ms-progress::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: -30%; width: 30%;
  background: var(--vscode-progressBar-background);
  animation: ms-progress-slide 1.1s var(--ms-ease) infinite;
}
@keyframes ms-progress-slide { from { left: -30%; } to { left: 100%; } }

/* ---------- spinner ---------- */
.ms-spin { animation: ms-spin 1s linear infinite; display: inline-block; }
@keyframes ms-spin { to { transform: rotate(360deg); } }

/* ---------- reduced motion (OS setting or app toggle) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
html.ms-reduced-motion *, html.ms-reduced-motion *::before, html.ms-reduced-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

/* High contrast / forced colors: keep provenance glyphs and borders visible. */
@media (forced-colors: active) {
  .ms-icon-btn, .ms-btn, .ms-input, .ms-select { border: 1px solid CanvasText; }
}
