/* VidLoad Pay Mini App — vanilla CSS, follows Telegram theme variables. */

:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg-2: var(--tg-theme-secondary-bg-color, #171a21);
  --text: var(--tg-theme-text-color, #f2f4f8);
  --muted: var(--tg-theme-hint-color, #8b93a1);
  --link: var(--tg-theme-link-color, #5aa9ff);
  --btn: var(--tg-theme-button-color, #3b82f6);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --ok: #35c07a;
  --warn: #f0b429;
  --bad: #ef5f5f;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(76px + var(--safe-b)); }

[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; }

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f8cff, #8b5cf6);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.brand-name { font-weight: 600; letter-spacing: -0.2px; }

.ghost-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
}

/* ── layout ──────────────────────────────────────────────── */
.screens { padding: 14px 14px 8px; display: grid; gap: 12px; }
.screen { display: grid; gap: 12px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title { margin: 0 0 6px; font-size: 15px; font-weight: 600; }

.muted { color: var(--muted); margin: 0 0 12px; font-size: 13.5px; }

.fineprint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 12px 0 0;
}

.row { display: flex; align-items: center; }
.gap { gap: 8px; flex-wrap: wrap; }

/* ── prompt ──────────────────────────────────────────────── */
.prompt-input {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.prompt-input:focus { outline: 2px solid var(--btn); outline-offset: 1px; }

.services { margin-top: 14px; }
.services-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }

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

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  cursor: pointer;
}

.chip:active { background: var(--line); }

/* ── buttons ─────────────────────────────────────────────── */
.btn {
  flex: 1 1 auto;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--btn); color: var(--btn-text); width: 100%; margin-top: 12px; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }

/* ── dropzone ────────────────────────────────────────────── */
.dropzone {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 16px;
  border: 1.5px dashed color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: 14px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
}

.dropzone.is-dragover { border-color: var(--btn); }

.dropzone-icon { font-size: 20px; color: var(--muted); }
.dropzone-title { font-weight: 600; font-size: 14px; }
.dropzone-hint { font-size: 12px; color: var(--muted); word-break: break-all; }

.captcha { margin-top: 12px; min-height: 0; }

/* ── progress ────────────────────────────────────────────── */
.progress {
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f8cff, #8b5cf6);
  transition: width 0.2s;
}

/* ── video list ──────────────────────────────────────────── */
.summary-row { display: flex; gap: 10px; }

.summary-item {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}

.summary-value { font-weight: 700; font-size: 16px; }
.summary-label { font-size: 11px; color: var(--muted); }

.list { display: grid; gap: 8px; }

.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 0; margin: 0; }

.video-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.video-thumb {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 17px;
}

.video-main { min-width: 0; }
.video-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-sub { font-size: 11.5px; color: var(--muted); }
.video-amount { font-size: 13px; font-weight: 600; text-align: right; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--line);
  color: var(--muted);
}

.badge[data-status="processing"], .badge[data-status="uploading"] { color: var(--warn); }
.badge[data-status="ready"], .badge[data-status="published"] { color: var(--ok); }
.badge[data-status="rejected"], .badge[data-status="failed"] { color: var(--bad); }

/* ── wallet ──────────────────────────────────────────────── */
.balance-card { display: grid; gap: 4px; }
.balance { font-size: 32px; font-weight: 700; letter-spacing: -1px; margin-bottom: 10px; }

.stake-box { font-size: 13.5px; }
.stake-box p { margin: 0; }
.stake-box .stake-line { display: flex; justify-content: space-between; padding: 5px 0; }
.stake-box .stake-line + .stake-line { border-top: 1px solid var(--line); }

/* ── tab bar ─────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  max-width: 180px;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.tab span { font-size: 16px; line-height: 1; }
.tab.is-active { color: var(--link); }

/* ── splash / toast ──────────────────────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: var(--bg);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-b));
  transform: translateX(-50%);
  max-width: min(90vw, 460px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #1e222b;
  color: #f2f4f8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
  text-align: center;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.toast[data-tone="ok"] { border-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.toast[data-tone="bad"] { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
