/* assets/css/mini-app.css */

/* ── Reset + root ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ma-bg:       #0d1f15;
  --ma-card:     #1a3024;
  --ma-border:   #2a4a34;
  --ma-brand:    #3d9e72;
  --ma-text:     #ffffff;
  --ma-muted:    #7ec49a;
  --ma-accent:   #f4b350;
  --ma-danger:   #e05555;
  --ma-radius:   14px;
  --ma-radius-sm:10px;
  --nav-height:  72px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ma-bg);
  color: var(--ma-text);
  font-family: -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
#bi-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.bi-screen {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--nav-height) + 16px);
  -webkit-overflow-scrolling: touch;
}
.bi-screen--active {
  display: block;
}

/* ── Bottom navigation ────────────────────────────────────────────────────── */
#bi-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--ma-bg);
  border-top: 1px solid var(--ma-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bi-tab {
  background: none;
  border: none;
  color: #5a7865;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px 4px;
  gap: 2px;
  transition: color 0.15s;
}
.bi-tab--active {
  color: var(--ma-brand);
}
.bi-tab--active .bi-tab__label {
  font-weight: 700;
}
.bi-tab__icon { font-size: 24px; }
.bi-tab__label { font-size: 11px; letter-spacing: 0.01em; }

/* ── Typography ───────────────────────────────────────────────────────────── */
.bi-greeting {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 2px;
}
.bi-subtitle {
  font-size: 13px;
  color: var(--ma-muted);
  margin-bottom: 16px;
}
.bi-section-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.bi-card {
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  padding: 14px;
  margin-bottom: 10px;
}
.bi-card--brand {
  background: var(--ma-brand);
  border-color: transparent;
}
.bi-card--clickable {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.bi-card--clickable:active { opacity: 0.85; }

/* ── Subscription card ────────────────────────────────────────────────────── */
.bi-sub-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.bi-sub-card__title { font-weight: 700; font-size: 14px; }
.bi-badge {
  background: var(--ma-brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}
.bi-badge--accent { background: var(--ma-accent); color: #1a2e22; }
.bi-progress-label {
  font-size: 12px;
  color: var(--ma-muted);
  margin-bottom: 6px;
}
.bi-progress {
  background: var(--ma-bg);
  border-radius: 8px;
  height: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}
.bi-progress__bar {
  background: var(--ma-brand);
  height: 100%;
  border-radius: 8px;
  transition: width 0.3s;
}
.bi-sub-card__footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.bi-sub-card__footer span:first-child { color: #aaa; }
.bi-sub-card__footer span:last-child  { color: var(--ma-muted); }

/* ── Quick cards grid ─────────────────────────────────────────────────────── */
.bi-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bi-quick-card {
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius-sm);
  padding: 12px;
  cursor: pointer;
  user-select: none;
}
.bi-quick-card__label {
  font-size: 11px;
  color: var(--ma-muted);
  margin-bottom: 4px;
}
.bi-quick-card__value {
  font-size: 20px;
  font-weight: 800;
  color: var(--ma-text);
}
.bi-quick-card__sub {
  font-size: 11px;
  color: var(--ma-brand);
  margin-top: 2px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.bi-btn {
  display: block;
  width: 100%;
  background: var(--ma-brand);
  color: #fff;
  border: none;
  border-radius: var(--ma-radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  margin-bottom: 10px;
  -webkit-tap-highlight-color: transparent;
}
.bi-btn:active { opacity: 0.85; }
.bi-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bi-btn--ghost {
  background: transparent;
  border: 1px solid var(--ma-border);
  color: var(--ma-muted);
}
.bi-btn--danger { background: var(--ma-danger); }

/* ── Plan cards ───────────────────────────────────────────────────────────── */
.bi-plan {
  background: var(--ma-card);
  border: 2px solid var(--ma-border);
  border-radius: var(--ma-radius-sm);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin-bottom: 8px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bi-plan--selected {
  border-color: var(--ma-brand);
  background: rgba(61,158,114,0.12);
}
.bi-plan__label { font-weight: 700; font-size: 13px; }
.bi-plan__sub   { font-size: 11px; color: var(--ma-muted); margin-top: 2px; }
.bi-plan__price { font-weight: 800; font-size: 15px; }
.bi-plan__badge {
  position: absolute;
  top: -9px;
  right: 10px;
  background: var(--ma-accent);
  color: #1a2e22;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ── Key display ──────────────────────────────────────────────────────────── */
.bi-key-box {
  background: var(--ma-bg);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: 11px;
  color: var(--ma-muted);
  word-break: break-all;
  cursor: pointer;
  margin-bottom: 10px;
  line-height: 1.5;
}
.bi-key-box:active { opacity: 0.8; }

/* ── QR code wrapper ──────────────────────────────────────────────────────── */
.bi-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}
.bi-qr-wrap canvas,
.bi-qr-wrap img { border-radius: 8px; }

/* ── FAQ accordion ────────────────────────────────────────────────────────── */
.bi-faq-item {
  border-bottom: 1px solid var(--ma-border);
  padding: 12px 0;
}
.bi-faq-q {
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bi-faq-q::after { content: '▼'; font-size: 10px; color: var(--ma-muted); transition: transform 0.2s; }
.bi-faq-item--open .bi-faq-q::after { transform: rotate(180deg); }
.bi-faq-a {
  display: none;
  color: var(--ma-muted);
  font-size: 13px;
  margin-top: 8px;
  line-height: 1.6;
}
.bi-faq-item--open .bi-faq-a { display: block; }

/* ── Referral link box ────────────────────────────────────────────────────── */
.bi-ref-link {
  background: var(--ma-bg);
  border: 1px dashed var(--ma-brand);
  border-radius: var(--ma-radius-sm);
  padding: 12px;
  font-size: 12px;
  color: var(--ma-muted);
  word-break: break-all;
  cursor: pointer;
  margin-bottom: 10px;
}

/* ── Stat row ─────────────────────────────────────────────────────────────── */
.bi-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--ma-border);
  font-size: 13px;
}
.bi-stat-row:last-child { border-bottom: none; }
.bi-stat-row__label { color: var(--ma-muted); }
.bi-stat-row__value { font-weight: 700; }

/* ── Textarea ─────────────────────────────────────────────────────────────── */
.bi-textarea {
  width: 100%;
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius-sm);
  color: var(--ma-text);
  font-size: 14px;
  padding: 12px;
  resize: none;
  outline: none;
  margin-bottom: 10px;
}
.bi-textarea:focus { border-color: var(--ma-brand); }

/* ── Refbal checkbox row ──────────────────────────────────────────────────── */
.bi-refbal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.bi-refbal-row input[type=checkbox] { accent-color: var(--ma-brand); width: 18px; height: 18px; cursor: pointer; }
.bi-refbal-row label { cursor: pointer; font-size: 13px; flex: 1; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.bi-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ma-brand);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.bi-toast--show { opacity: 1; }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.bi-loader {
  text-align: center;
  color: var(--ma-muted);
  padding: 40px 0;
  font-size: 13px;
}

/* ── Payment polling screen ───────────────────────────────────────────────── */
.bi-polling-screen {
  text-align: center;
  padding: 40px 20px;
}
.bi-polling-screen__icon { font-size: 48px; margin-bottom: 16px; }
.bi-polling-screen__title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.bi-polling-screen__sub { font-size: 13px; color: var(--ma-muted); }

/* ── Routing card ─────────────────────────────────────────────────────────── */
.bi-routing-card {
  display: flex;
  gap: 12px;
  background: linear-gradient(135deg, #1a3024 60%, #1e3d28);
  border: 1.5px solid var(--ma-brand);
  border-radius: var(--ma-radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.bi-routing-card__icon { font-size: 26px; flex-shrink: 0; margin-top: 2px; }
.bi-routing-card__title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.bi-routing-card__desc { font-size: 12px; color: var(--ma-muted); line-height: 1.5; margin-bottom: 10px; }
.bi-routing-card .bi-btn--secondary {
  background: var(--ma-brand);
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 0;
  text-decoration: none;
  display: block;
  border-radius: var(--ma-radius-sm);
  font-weight: 700;
  text-align: center;
}
.bi-btn--secondary { background: var(--ma-brand); color: #fff; }

/* ── Step-by-step instructions ────────────────────────────────────────────── */
.bi-faq-a--steps { padding: 4px 0 4px; }
.bi-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ma-text);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.bi-step:last-child { border-bottom: none; }
.bi-step__num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--ma-brand);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* ── App download links ────────────────────────────────────────────────────── */
.bi-app-links {
  display: flex;
  gap: 8px;
  margin: 6px 0 8px 32px;
  flex-wrap: wrap;
}
.bi-app-link {
  display: inline-block;
  background: rgba(61,158,114,0.18);
  border: 1px solid var(--ma-brand);
  color: var(--ma-brand);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.bi-app-link:active { opacity: 0.75; }
