/* ==========================================================================
   Arb Bot · Mini App — дизайн-система GroguBet (тёмная, teal-акцент)
   ========================================================================== */

:root {
  --bg: #0a0b0e;
  --bg2: #12141a;
  --bg3: #1a1d26;
  --card: #161921;
  --border: #2a2d38;
  --text: #e8eaed;
  --muted: #8b8fa3;
  --accent: #00d4aa;
  --accent2: #00b894;
  --accent-glow: rgba(0, 212, 170, .15);
  --gold: #ffd700;
  --red: #ff4757;
  --green: #00d4aa;
  --blue: #4facfe;
  --radius: 12px;

  --tabbar-h: 62px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  overflow-x: hidden;
  width: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }

#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* атмосфера: тонкое сияние сверху, как на сайте GroguBet */
#app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, var(--accent-glow), transparent 60%);
  z-index: 0;
}

/* ---------------------------------- topbar ------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(18, 20, 26, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ---------------------------------- content ------------------------------ */
.content {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bottom-spacer { height: 4px; flex-shrink: 0; }

/* ---------------------------------- tabbar -------------------------------- */
.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: rgba(18, 20, 26, .96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  background: transparent;
  border: none;
  border-top: 2px solid transparent;
  color: var(--muted);
  padding: 8px 4px 6px;
  transition: color .15s ease;
}

.tab-btn.active {
  color: var(--accent);
  border-top-color: var(--accent);
}

.tab-btn:active { opacity: .7; }

.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 11px; font-weight: 600; }

/* ---------------------------------- status card --------------------------- */
.status-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 14px 16px;
  animation: fadeInUp .35s ease both;
}

.status-card.status-ok { border-color: rgba(0, 212, 170, .35); }
.status-card.status-warn { border-color: rgba(255, 215, 0, .4); }
.status-card.status-bad { border-color: rgba(255, 71, 87, .45); background: rgba(255, 71, 87, .06); }
.status-card.status-idle { border-style: dashed; }

.status-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.status-card.status-warn .status-text { color: var(--gold); }
.status-card.status-bad .status-text { color: var(--red); }

.status-stats {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.status-stat {
  flex: 1;
  text-align: center;
  background: var(--bg3);
  border-radius: 10px;
  padding: 8px 4px;
}

.status-stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.status-stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------------------------------- group card ----------------------------- */
.group-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 16px;
  animation: fadeInUp .4s ease both;
}

.group-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.group-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.group-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 16px;
}

.group-fields:first-child { margin-top: 0; }

.field { min-width: 0; }

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* ---------------------------------- toggle switch --------------------------- */
.field-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
}

.field-text { flex: 1; min-width: 0; }

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 31px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .2s ease, border-color .2s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #cfd2dc;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), background .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.switch input:checked ~ .switch-track {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
}

.switch input:checked ~ .switch-track .switch-thumb {
  transform: translateX(21px);
  background: #0a0b0e;
}

/* big master toggles on main screen get extra room */
#content .status-card + .group-card .field-toggle,
.group-card .field-toggle {
  padding: 2px 0;
}

/* ---------------------------------- number / slider -------------------------- */
.field-number { display: flex; flex-direction: column; }

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.field-value {
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.value-num { font-size: 22px; }
.value-unit { font-size: 13px; margin-left: 2px; font-weight: 700; opacity: .85; }

.slider-wrap {
  position: relative;
  height: 40px;
  margin-top: 12px;
  display: flex;
  align-items: center;
}

.slider-track-base {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
}

.slider-track-fill {
  position: absolute;
  left: 0;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  pointer-events: none;
}

.slider-zones {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
}

.slider-zones .zone {
  position: absolute;
  top: 0; bottom: 0;
  opacity: .55;
}

.zone-good { background: var(--green); }
.zone-bad { background: var(--red); }

.slider-input {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  margin: 0;
}

.slider-input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 100%;
  background: transparent;
}

.slider-input::-moz-range-track {
  height: 100%;
  background: transparent;
  border: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  margin-top: 0;
  cursor: grab;
  position: relative;
  z-index: 2;
}

.slider-input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  cursor: grab;
}

.slider-input:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.08); }

.zone-note {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.4;
}

.zone-note-good {
  color: var(--green);
  background: rgba(0, 212, 170, .1);
  border: 1px solid rgba(0, 212, 170, .25);
}

.zone-note-bad {
  color: var(--red);
  background: rgba(255, 71, 87, .1);
  border: 1px solid rgba(255, 71, 87, .25);
}

.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.preset-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  min-height: 32px;
  transition: border-color .15s ease, transform .1s ease;
}

.preset-chip:active { transform: scale(.95); }
.preset-chip:hover { border-color: var(--accent); }

/* ---------------------------------- multi / chips ----------------------------- */
.bulk-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
}

.bulk-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 6px;
  min-height: 38px;
  transition: border-color .15s ease, color .15s ease;
}

.bulk-btn:active { transform: scale(.97); }
.bulk-btn:hover { border-color: var(--accent); color: var(--accent); }

.chip-subheader {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 14px 0 8px;
}

.chip-subheader:first-of-type { margin-top: 10px; }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  min-height: 44px;
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
  max-width: 100%;
}

.chip:active { transform: scale(.97); }

.chip.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.chip-mark {
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}

.chip-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chip-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-hint {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.35;
  /* Переносим, а не режем многоточием: подсказка объясняет, почему спорт
     не работает («Pinnacle не котирует live») — обрезать её бессмысленно. */
  max-width: 62vw;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.state-ok { background: var(--green); box-shadow: 0 0 6px var(--accent-glow); }
.state-wait { background: var(--gold); }
.state-off { background: var(--muted); }
.state-beta { background: var(--blue); }

/* ---------------------------------- toast --------------------------------- */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: 480px;
  width: 100%;
  background: #201217;
  border: 1px solid rgba(255, 71, 87, .4);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------------------------- save indicator -------------------------- */
.save-indicator {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 212, 170, .14);
  border: 1px solid rgba(0, 212, 170, .35);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.save-indicator.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.save-indicator-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------------------------------- states (loading/error/forbidden) -------- */
.state-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 40px 24px;
  min-height: 50vh;
}

.state-icon { font-size: 40px; line-height: 1; }

.state-title { font-size: 16px; font-weight: 700; }

.state-text {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 320px;
}

.spinner {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

.btn-retry {
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0a0b0e;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  min-height: 44px;
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn-retry:active { transform: scale(.96); }
.btn-retry:hover { box-shadow: 0 8px 24px var(--accent-glow); }

/* ---------------------------------- animations ------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content > *:nth-child(1) { animation-delay: 0s; }
.content > *:nth-child(2) { animation-delay: .04s; }
.content > *:nth-child(3) { animation-delay: .08s; }
.content > *:nth-child(4) { animation-delay: .12s; }
.content > *:nth-child(5) { animation-delay: .16s; }

@media (prefers-reduced-motion: reduce) {
  .group-card, .status-card { animation: none; }
  * { transition-duration: .01ms !important; }
}
