/* ==========================================================================
   GainGerms — User area styles (app.css)
   Dashboard shell: sidebar, level bar, stat tiles, panels, widgets.
   Requires theme.css.
   ========================================================================== */

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 70;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: linear-gradient(180deg, #0b1220, #080d19);
  border-right: 1px solid var(--line);
  transition: transform .28s var(--ease);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px 22px; }
.sidebar-head .brand-mark { width: 40px; height: 40px; border-radius: 13px; font-size: 1.1rem; }
.sidebar-close {
  display: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  place-items: center;
}

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: .72rem .85rem;
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.side-link:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.side-link.active {
  background: linear-gradient(100deg, rgba(45, 212, 167, .16), rgba(56, 189, 248, .1));
  border-color: rgba(45, 212, 167, .28);
  color: var(--text);
}
.side-link .ico { flex: none; width: 22px; display: grid; place-items: center; color: currentColor; opacity: .9; }
.side-link.active .ico { color: var(--brand); opacity: 1; }
.side-link.danger:hover { color: #fecaca; background: rgba(248, 113, 113, .1); }

.sidebar-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: .84rem;
}
.sidebar-foot a { color: var(--text-mute); }
.sidebar-foot a:hover { color: var(--brand); }

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(4, 8, 16, .6);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease);
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- Main column ---------- */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 22px clamp(16px, 3vw, 32px) 60px;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 26px;
}
.menu-btn {
  display: none;
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  place-items: center;
}
.level-progress { flex: 1; display: flex; align-items: center; gap: 16px; min-width: 0; }
.level-count { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-dim); }
.level-progress .progress { flex: 1; }
.level-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .42rem .95rem;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-weight: 700; font-size: .9rem;
  white-space: nowrap;
}
.level-pill::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 10px var(--ok);
}

.page-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0; }
.page-title p { margin: 0; color: var(--text-mute); font-size: .95rem; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 22px; }

/* ---------- Action cards (Invite / Roll / Lottery) ---------- */
.action-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); margin-bottom: 22px; }
.action-card {
  text-align: center;
  padding: 30px 24px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
}
.action-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.action-card h3 { margin: 0; font-size: 1.28rem; }
.action-card p { margin: 0; color: var(--text-dim); font-size: .94rem; }
.action-card .btn { margin-top: 8px; }
.action-card.featured {
  background: linear-gradient(140deg, #2f7bf6, #1d5fd8);
  border-color: transparent;
  box-shadow: 0 20px 44px rgba(47, 123, 246, .34);
  color: #fff;
}
.action-card.featured p { color: rgba(255, 255, 255, .86); }
.action-card.featured .btn { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .34); color: #fff; }
.action-card.featured .btn:hover { background: rgba(255, 255, 255, .28); }

/* ---------- Two-column content ---------- */
.cols-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-2-wide { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.cols-3-app { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.4fr) 200px minmax(0, 1.1fr); align-items: start; }

/* ---------- Lottery ---------- */
.counter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.counter-btn {
  width: 42px; height: 42px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid transparent;
  background: linear-gradient(120deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
  transition: transform .16s var(--ease), filter .16s var(--ease);
}
.counter-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.counter-input {
  width: 96px; text-align: center;
  padding: .62rem .6rem;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.kv {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.kv-label {
  padding: .42rem .9rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  font-weight: 700; font-size: .93rem;
}
.kv-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- Roll ---------- */
.roll-side { display: grid; gap: 14px; }
.roll-stat {
  text-align: center;
  padding: 20px 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}
.roll-stat b { display: block; font-size: 1.75rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.roll-stat span { font-size: .85rem; color: var(--text-mute); }
.roll-timer {
  text-align: center;
  padding: 18px 14px;
  border-radius: var(--r-lg);
  background: linear-gradient(150deg, rgba(45, 212, 167, .12), rgba(56, 189, 248, .08));
  border: 1px solid rgba(45, 212, 167, .26);
}
.roll-timer .lbl { font-size: .82rem; color: var(--text-mute); }
.roll-timer .val { font-size: 1.05rem; font-weight: 800; margin: .25rem 0; }
.roll-timer .cd { color: var(--warn); font-weight: 700; font-variant-numeric: tabular-nums; }

.roll-dice {
  width: 96px; height: 96px;
  margin: 6px auto 14px;
  display: grid; place-items: center;
  border-radius: 26px;
  background: linear-gradient(140deg, #1c2942, #121a2c);
  border: 1px solid var(--line-strong);
  font-size: 2.1rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.roll-dice.rolling { animation: spin .7s linear infinite; }
.roll-action { border-top: 1px solid var(--line); background: rgba(255, 255, 255, .015); }

/* ---------- Referrals ---------- */
.ref-link-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ref-link-row .input { flex: 1; min-width: 220px; font-family: var(--mono); font-size: .9rem; }
.mini-progress { width: 140px; }

/* ---------- Deposits / Withdrawal ---------- */
.amount-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill-out {
  padding: .62rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--brand-2);
  background: rgba(56, 189, 248, .08);
  font-weight: 700;
  white-space: nowrap;
}
.withdraw-bar { display: grid; gap: 12px; grid-template-columns: 200px minmax(180px, 1.4fr) 130px auto auto auto; align-items: center; }
.static-pill {
  display: flex; align-items: center; gap: .5rem;
  padding: .8rem 1rem;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 700;
  white-space: nowrap;
}
.static-pill span { color: var(--text-mute); font-weight: 600; font-size: .88rem; }

/* ---------- User level ---------- */
.donut-wrap { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; justify-content: center; }
.legend { display: grid; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: .93rem; color: var(--text-dim); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.gauge-wrap { text-align: center; }
.gauge-value {
  font-size: clamp(2.6rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -.03em;
}
.gauge-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.gauge-split span { display: block; font-size: .85rem; color: var(--text-mute); }
.gauge-split b { font-size: 1.15rem; }

.act-item { display: flex; gap: 14px; align-items: flex-start; }
.act-card {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.act-card h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 .3rem; }
.act-card time { font-size: .84rem; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.act-note {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, .08);
  border: 1px solid rgba(56, 189, 248, .2);
  font-size: .88rem;
  color: var(--text-dim);
}
.bonus-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.bonus-row:last-child { border-bottom: 0; }
.bonus-row span { color: var(--text-dim); }

/* ---------- Smart contracts ---------- */
.contract {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 210px;
  align-items: stretch;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 18px;
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
}
.contract:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.contract-art {
  display: grid; place-items: center;
  padding: 22px;
  background: linear-gradient(150deg, rgba(139, 92, 246, .22), rgba(56, 189, 248, .16));
  border-right: 1px solid var(--line);
}
.contract-body { padding: 24px; display: flex; flex-direction: column; gap: .35rem; justify-content: center; }
.contract-body h3 { margin: 0; font-size: 1.15rem; }
.contract-body .meta { color: var(--text-dim); font-size: .93rem; margin: 0; }
.contract-reward { color: var(--brand-2); font-weight: 800; margin-top: .4rem; }
.contract-cta {
  display: grid; place-items: center;
  padding: 22px;
  background: rgba(59, 130, 246, .07);
  border-left: 1px solid var(--line);
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(92vw, 360px);
}
.toast {
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  font-size: .92rem;
  animation: toast-in .28s var(--ease);
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .cols-3-app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cols-3-app .roll-side { grid-column: span 2; grid-template-columns: repeat(3, 1fr); display: grid; }
}
@media (max-width: 1100px) {
  .cols-2-wide { grid-template-columns: 1fr; }
  .withdraw-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: grid; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .contract { grid-template-columns: 1fr; }
  .contract-art { border-right: 0; border-bottom: 1px solid var(--line); }
  .contract-cta { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 780px) {
  .cols-3-app, .cols-3-app .roll-side { grid-template-columns: 1fr; }
  .cols-3-app .roll-side { grid-column: auto; }
  .withdraw-bar { grid-template-columns: 1fr; }
  .app-topbar { flex-wrap: wrap; }
  .level-progress { order: 3; flex: 1 0 100%; }
}
