/* Bonus Buy — control panel */

:root {
  color-scheme: dark;

  --bg: #08102b;
  --surface: #0e1838;
  --surface-2: #132048;
  --surface-3: #1a2a5a;
  --border: #1f2f63;
  --border-strong: #2c4185;

  --text: #eef3ff;
  --text-2: #a7b6dc;
  --text-3: #6e81b2;

  --brand: #2f6bff;
  --brand-hover: #4a7fff;
  --brand-soft: #2f6bff24;
  --focus: #5b8dff;
  --good: #3ee07f;
  --good-soft: #3ee07f1f;
  --bad: #ff5a6a;
  --bad-soft: #ff5a6a1f;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-pop: 0 12px 32px #0009, 0 0 0 1px var(--border-strong);

  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.i { width: 18px; height: 18px; flex: none; display: block; }
.muted { color: var(--text-3); }
.good { color: var(--good); }
.bad { color: var(--bad); }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 11px var(--font);
  color: var(--text-2);
}

/* ================================================================= layout */

.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: #08102be6;
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { height: 30px; display: block; }
.brand__title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand__sub { font-size: 13px; color: var(--text-3); }
.brand__sub b { color: var(--focus); font-weight: 600; }

.topbar__actions { display: flex; align-items: center; gap: 14px; }

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
  transition: color .3s;
}
.save-state .i { width: 15px; height: 15px; }
.save-state.is-fresh { color: var(--good); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 20px;
  width: 100%;
  max-width: 1600px;
  padding: 20px 24px 32px;
}

.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* ================================================================ controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--brand-hover); }
.btn .i { width: 16px; height: 16px; }

.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--danger { background: transparent; border-color: #ff5a6a55; color: #ff8e99; }
.btn--danger:hover { background: var(--bad-soft); color: #ffb3ba; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ inputs */

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: var(--focus); background: var(--surface-3); box-shadow: 0 0 0 3px #5b8dff26; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 52px; }
.input-wrap--prefix .input { padding-left: 28px; padding-right: 12px; }
.input-affix {
  position: absolute;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  pointer-events: none;
}
.input-affix--end { right: 12px; }
.input-affix--start { left: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--text-3); text-transform: uppercase; }

/* segmented control */
.seg {
  display: inline-flex;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.seg button {
  flex: 1;
  min-width: 64px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; box-shadow: 0 2px 8px #2f6bff55; }

/* ================================================================ settings */

/* wraps onto a second line in narrow windows (OBS docks) instead of overflowing */
.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 16px;
}
.settings > .field:first-child { flex: 0 0 110px; }
.settings > .field:nth-child(2) { flex: 1 1 180px; }

.upload {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload:hover { border-color: var(--focus); background: var(--brand-soft); }
.upload__thumb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  overflow: hidden;
}
.upload__thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ================================================================= summary */

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
}
.metric { padding: 12px 16px; background: var(--surface); }
.metric__label { font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--text-3); }
.metric__value { margin-top: 2px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================================================================= bonuses */

.bonuses { padding: 8px 8px 12px; }

.bonuses__cols,
.brow {
  display: grid;
  grid-template-columns: 26px 26px minmax(0, 1fr) 150px 150px 70px 34px;
  align-items: center;
  gap: 8px;
}

.bonuses__cols {
  padding: 8px 8px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-3);
}
.bonuses__cols > :nth-child(6) { text-align: center; }

.bonuses__list { position: relative; }

.brow {
  position: relative;
  margin-bottom: 4px;
  padding: 5px 8px;
  border-radius: var(--radius);
  transition: transform .22s var(--ease), background .15s, box-shadow .2s;
}
.brow:hover { background: #ffffff06; }

.brow.is-current { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }

.brow__grip {
  display: grid;
  place-items: center;
  width: 26px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: grab;
  touch-action: none;
}
.brow__grip:hover { color: var(--text); background: var(--surface-3); }

.brow__num { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-3); }
.brow.is-current .brow__num { color: var(--focus); }

.xchip {
  justify-self: center;
  min-width: 60px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--text-3);
}
.xchip.is-good { background: var(--good-soft); color: var(--good); }
.xchip.is-bad { background: var(--bad-soft); color: var(--bad); }
.xchip.is-current { background: var(--brand); color: #fff; font-weight: 600; }

/* dragging */
.brow.is-lifted {
  z-index: 10;
  background: var(--surface-3);
  box-shadow: 0 14px 34px #000b, 0 0 0 1px var(--focus);
  transition: background .15s, box-shadow .2s;
}
.brow.is-settling { transition: transform .2s var(--ease), box-shadow .2s; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }

.add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  margin-top: 4px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
  transition: border-color .15s, background .15s, color .15s;
}
.add-row:hover { border-color: var(--focus); background: var(--brand-soft); color: var(--text); }
.add-row kbd { margin-left: 6px; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-3);
}
.empty b { display: block; margin-bottom: 4px; font-size: 16px; color: var(--text-2); }

.bonuses__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
}

/* =================================================================== texts */

.texts summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
}
.texts summary::-webkit-details-marker { display: none; }
.texts summary .i { transition: transform .2s var(--ease); color: var(--text-3); }
.texts[open] summary .i { transform: rotate(90deg); }
.texts summary .muted { font-weight: 400; font-size: 13px; }

.texts__body { padding: 0 16px 16px; }

.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.token {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 12px;
  color: var(--text-2);
  transition: background .15s, border-color .15s;
}
.token code { font-family: ui-monospace, Consolas, monospace; color: var(--focus); }
.token:hover { border-color: var(--focus); background: var(--brand-soft); }
.tokens__hint { width: 100%; font-size: 12px; color: var(--text-3); }

.text-group {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.text-group > .i { width: 26px; height: 26px; margin-top: 8px; }
.text-group__fields { display: grid; gap: 8px; }
.text-field { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: center; gap: 12px; }
.text-field span { font-size: 13px; color: var(--text-2); }

.texts__footer { display: flex; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--border); }

/* =================================================================== notes */

.notes {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 106px);
  min-height: 320px;
  padding: 16px;
}
.notes__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.notes__head h2 { margin: 0; font-size: 16px; }
.notes textarea {
  flex: 1;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}
.notes textarea::placeholder { color: var(--text-3); }
.notes textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px #5b8dff26; }

/* ========================================================= slot suggestions */

.suggest {
  position: fixed;
  z-index: 50;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-pop);
  animation: pop .12s var(--ease);
}
.suggest__body { display: grid; grid-template-columns: minmax(0, 1fr) 176px; }
.suggest__list {
  min-width: 0;
  max-height: 324px;            /* ~9 rows, the rest scrolls */
  padding: 4px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.suggest__list::-webkit-scrollbar { width: 8px; }
.suggest__list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--surface-2); }
.suggest__count { margin-left: auto; }
.suggest__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
}
.suggest__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.suggest__meta { flex: none; display: flex; align-items: center; gap: 8px; }
.badge {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--focus);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}

.suggest__preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.suggest__caption { font-size: 13px; font-weight: 600; line-height: 1.3; }
.suggest__provider { font-size: 12px; color: var(--text-3); }

/* slot cover: picture over an initials placeholder (shown while loading or when there's no picture) */
.cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 235 / 320;   /* 1win game cards are portrait */
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-3);
}

.hovercard {
  position: fixed;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 190px;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  animation: pop .12s var(--ease);
}
.suggest__item mark { background: none; color: var(--text); font-weight: 700; }
.suggest__item.is-active { background: var(--brand-soft); color: var(--text); }
.suggest__item small { font-size: 11px; color: var(--text-3); }
.suggest__foot {
  display: flex;
  gap: 14px;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
}

/* =================================================================== toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--surface-3);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  transform: translateX(-50%);
  animation: rise .2s var(--ease);
}
.toast button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--focus);
  font-weight: 700;
}
.toast button:hover { background: var(--brand); color: #fff; }

@keyframes pop  { from { opacity: 0; transform: translateY(-4px); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ============================================================== responsive */

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .notes { position: static; height: 320px; }
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar, .layout { padding-left: 14px; padding-right: 14px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bonuses__cols, .brow { grid-template-columns: 22px 20px minmax(0, 1fr) 96px 96px 34px; }
  .bonuses__cols > :nth-child(6), .xchip { display: none; }
  .input-wrap .input { padding-right: 34px; }
  .input-affix--end { right: 9px; }
  .text-field { grid-template-columns: 1fr; gap: 4px; }
}

/* ============================================================= sync status */

.save-state__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background .3s, box-shadow .3s;
}
.save-state[data-state="saved"].is-fresh .save-state__dot,
.save-state[data-state="online"] .save-state__dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.save-state[data-state="syncing"] .save-state__dot { background: var(--focus); }
.save-state[data-state="offline"] { color: var(--bad); }
.save-state[data-state="offline"] .save-state__dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ======================================================= history & records */

.records {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
}
.records .metric { background: var(--surface-2); }
.records .metric__value small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}

.history__grid { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 20px; }
.history__title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-3);
}

.favorites { margin: 0; padding: 0; list-style: none; }
.favorites li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto 64px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.favorites li:last-child { border-bottom: 0; }
.favorites li.muted { display: block; font-size: 13px; }
.fav__pos { font-weight: 700; color: var(--text-3); }
.fav__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.favorites li > :last-child { text-align: right; font-weight: 700; }

.history__table-wrap { min-width: 0; overflow-x: auto; }
.sessions { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.sessions th {
  padding: 0 10px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-3);
}
.sessions td { padding: 8px 10px; border-top: 1px solid var(--border); }
.sessions td:last-child { width: 34px; padding: 2px; }
.sessions tbody tr:hover td { background: #ffffff05; }
.empty-cell { padding: 20px 10px !important; text-align: center; white-space: normal; }

/* =================================================================== login */

.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #050a1fe6;
  backdrop-filter: blur(6px);
}
.login__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.login__logo { height: 34px; align-self: center; }
.login__card h2 { margin: 4px 0 0; font-size: 20px; }
.login__card p { margin: 0 0 4px; font-size: 14px; }
.login__error { min-height: 18px; font-size: 13px; color: var(--bad); }
.login__card .btn { height: 42px; }

@media (max-width: 1100px) {
  .records { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history__grid { grid-template-columns: minmax(0, 1fr); }
}
