/* Whop Chart Studio — dark studio chrome */

/* Inter, vendored — the app works fully offline and preview matches export */
@font-face {
  font-family: 'Inter';
  src: url('../vendor/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #09090b;
  --panel: #101013;
  --panel-2: #17171b;
  --panel-3: #1e1e24;
  --border: #232329;
  --border-2: #2e2e36;
  --text: #e8eaef;
  --sub: #9ca1ab;
  --faint: #62666e;
  --accent: #fa4616;
  --accent-soft: rgba(250, 70, 22, 0.14);
  --good: #39d0b2;
  --radius: 10px;
  --sidebar-w: 316px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 13.5px/1.45 Inter, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-y: hidden;
  overflow-x: auto;
  min-width: 960px; /* floor: below this the page scrolls instead of crushing */
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a31; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */

#app { display: grid; grid-template-rows: auto 1fr; height: 100vh; min-width: 960px; }

header {
  display: flex; align-items: center; gap: 10px 14px;
  flex-wrap: wrap; /* narrow windows: toolbar wraps to a second row */
  min-height: 52px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 14px; letter-spacing: -0.01em; margin-right: 6px; }
.brand .mark { display: inline-flex; align-items: center; }
.brand .mark svg { width: 24px; height: auto; display: block; }
.brand .muted { color: var(--faint); font-weight: 500; }

.spacer { flex: 1; }

main { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }

/* ---------- sidebar ---------- */

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 14px 40px;
}

.section { margin-bottom: 22px; }
.section > h3 {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 9px;
  display: flex; align-items: center; gap: 8px;
}
.section > h3::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row > * { flex: 1; }
.row > label.inline { flex: 0 0 auto; color: var(--sub); font-size: 12.5px; }

.field { margin-bottom: 10px; }
.field > label {
  display: block; font-size: 11.5px; color: var(--sub); margin-bottom: 4px; font-weight: 500;
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 12.8px;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='9' height='6' viewBox='0 0 9 6'><path d='M1 1l3.5 3.5L8 1' fill='none' stroke='%239ca1ab' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 26px;
}
select:focus, input:focus { border-color: var(--accent); }
select:disabled { opacity: 0.4; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

/* drop zone */
#dropzone {
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  color: var(--sub);
  cursor: pointer;
  transition: all 0.18s;
  font-size: 12.5px;
}
#dropzone:hover, #dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
#dropzone .big { font-size: 13px; font-weight: 600; color: var(--text); display: block; margin-bottom: 3px; }

/* file chips */
#files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.file-chip:hover { border-color: var(--faint); }
.file-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.file-chip .name {
  flex: 1; font-size: 12.3px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-chip .meta { font-size: 11px; color: var(--faint); flex-shrink: 0; }
.file-chip .x {
  color: var(--faint); border: none; background: none; cursor: pointer; font-size: 14px;
  padding: 0 2px; line-height: 1; border-radius: 4px;
}
.file-chip .x:hover { color: var(--text); }

/* chart type grid */
#chart-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ct {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 9px 4px 7px;
  cursor: pointer;
  color: var(--sub);
  font-size: 10.3px;
  font-weight: 550;
  transition: all 0.14s;
  text-align: center;
}
.ct svg { width: 26px; height: 20px; opacity: 0.85; }
.ct:hover { border-color: var(--faint); color: var(--text); }
.ct.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.ct.active svg { opacity: 1; }
.ct:disabled { opacity: 0.32; cursor: default; }
.ct:disabled:hover { border-color: var(--border-2); color: var(--sub); }

/* y-field checklist */
#y-fields { display: flex; flex-direction: column; gap: 3px; max-height: 168px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 5px; }
#y-fields label {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 6px;
  font-size: 12.4px; cursor: pointer; color: var(--sub);
}
#y-fields label:hover { background: var(--panel-3); color: var(--text); }
#y-fields input { accent-color: var(--accent); }
#y-fields label.checked { color: var(--text); }

/* segmented control */
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 2px; }
.seg button {
  flex: 1; border: none; background: none; color: var(--sub); font: inherit; font-size: 12px;
  font-weight: 550; padding: 5px 4px; border-radius: 6px; cursor: pointer; transition: all 0.13s;
  white-space: nowrap;
}
.seg button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.35); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.toggle-row label { font-size: 12.6px; color: var(--sub); }

/* switch */
.switch { position: relative; width: 32px; height: 18px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--panel-3); border: 1px solid var(--border-2);
  border-radius: 10px; cursor: pointer; transition: all 0.15s;
}
.switch .track::after {
  content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: var(--sub); top: 2px; left: 2px; transition: all 0.15s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { left: 16px; background: #fff; }

/* ---------- toolbar ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: 12.6px; font-weight: 550;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff5a2e; }
.btn svg { width: 13px; height: 13px; }
.btn:disabled { opacity: 0.4; cursor: default; }

header select { width: auto; padding: 6px 26px 6px 9px; font-size: 12.4px; }
header .dim-inputs { display: none; align-items: center; gap: 4px; }
header .dim-inputs input { width: 64px; padding: 6px 7px; font-size: 12.3px; }
header .dim-inputs.show { display: flex; }
header .dim-inputs span { color: var(--faint); }

/* ---------- stage ---------- */

#stage-wrap { position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

#stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  padding: 28px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(250,70,22,0.035), transparent),
    var(--bg);
}

#slide-holder { position: relative; flex-shrink: 0; }
#slide {
  position: relative;
  transform-origin: top left;
  border-radius: 4px;
  box-shadow: 0 8px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border);
  /* checker peeks through where the export is transparent */
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.028) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.028) 75%),
    linear-gradient(45deg, rgba(255,255,255,0.028) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.028) 75%);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
}
#slide.bg-dark { background-color: #0b0b0c; }
#slide.bg-light { background-color: #f4f4f5; }
#slide svg { display: block; }

.stage-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  color: var(--faint); font-size: 11.3px; letter-spacing: 0.01em;
  display: flex; gap: 14px; align-items: center;
  background: rgba(16,16,19,0.82); backdrop-filter: blur(6px);
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
  pointer-events: none; white-space: nowrap;
}

/* empty state */
#empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--faint);
}
#empty .glyph { font-size: 40px; opacity: 0.5; }
#empty .t { font-size: 15px; font-weight: 600; color: var(--sub); }
#empty .s { font-size: 12.5px; }

/* ---------- tooltip ---------- */

#tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: rgba(20, 20, 24, 0.94); backdrop-filter: blur(8px);
  border: 1px solid var(--border-2); border-radius: 9px;
  padding: 8px 10px; font-size: 12px; min-width: 130px; max-width: 320px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.1s;
}
#tip.show { opacity: 1; }
#tip .tip-title { font-weight: 650; margin-bottom: 5px; color: var(--text); font-size: 12.2px; }
#tip .tip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
#tip .tip-key { width: 12px; height: 3px; border-radius: 2px; flex-shrink: 0; }
#tip .tip-label { color: var(--sub); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tip .tip-value { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
#tip .tip-row.strong .tip-label { color: var(--text); }

/* ---------- data table ---------- */

#table-panel {
  height: 0; overflow: hidden; transition: height 0.22s ease;
  background: var(--panel); border-top: 1px solid var(--border);
}
#table-panel.open { height: 260px; }
#table-scroll { overflow: auto; height: 100%; }
#table-panel table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px; }
#table-panel th {
  position: sticky; top: 0; background: var(--panel-2); color: var(--sub);
  text-align: left; padding: 7px 12px; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--border-2); z-index: 1;
}
#table-panel th .ty { color: var(--faint); font-weight: 500; margin-left: 5px; font-size: 10.5px; }
#table-panel td {
  padding: 5px 12px; border-bottom: 1px solid var(--border); color: var(--text);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
#table-panel td.num { text-align: right; }
#table-panel td.null { color: var(--faint); }

/* ---------- toast ---------- */

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 14px);
  background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 12.8px; font-weight: 550;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  opacity: 0; transition: all 0.2s; z-index: 60; pointer-events: none;
  display: flex; gap: 8px; align-items: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { border-color: rgba(57, 208, 178, 0.4); }
#toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }

/* series panel */
#series-list { display: flex; flex-direction: column; gap: 3px; max-height: 220px; overflow-y: auto; }
.series-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 7px; font-size: 12.3px; color: var(--text);
}
.series-row:hover { background: var(--panel-2); }
.series-row.off { opacity: 0.42; }
.series-row input[type="checkbox"] { accent-color: var(--accent); flex: 0 0 auto; }
.series-row input[type="color"] {
  width: 22px; height: 18px; padding: 0; border: 1px solid var(--border-2);
  border-radius: 5px; background: none; cursor: pointer; flex: 0 0 auto;
}
.series-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 1px; }
.series-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }
.series-row .sname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.series-row .pin { font-size: 10px; color: var(--accent); flex: 0 0 auto; cursor: pointer; }

.hidden { display: none !important; }
