/* =============================================================================
   TETRA Staking dApp — Standalone styles
   Self-contained (does NOT load the marketing styles.css). Reuses TETRA brand
   tokens so it matches the ecosystem look while running as its own window.
   ============================================================================= */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --bg-elevated: #22222e;
  --bg-hover: #2a2a38;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-tertiary: #606070;
  --border-primary: #2a2a38;
  --purple: #a855f7;
  --cyan: #38bdf8;
  --green: #4ade80;
  --gradient: linear-gradient(135deg, #a855f7 0%, #38bdf8 50%, #4ade80 100%);
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Author display rules (flex/inline-flex) otherwise override the UA [hidden]
   rule, so the hidden attribute must be enforced explicitly. */
[hidden] { display: none !important; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(168, 85, 247, 0.12), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(56, 189, 248, 0.10), transparent 45%),
    var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ----------------------------- Header -------------------------------------- */
.dapp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-primary);
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.dapp-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.dapp-logo { width: 30px; height: 30px; }
.dapp-brand-text { font-weight: 800; font-size: 18px; letter-spacing: -0.3px; }
.dapp-brand-sub { color: var(--text-secondary); font-weight: 600; }

.btn-connect {
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-connect:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(168, 85, 247, 0.35); }

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 9999px;
  padding: 8px 14px 8px 12px;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
}
.account-pill:hover { border-color: var(--purple); }
.account-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.account-addr { font-weight: 600; font-variant-numeric: tabular-nums; }
.account-native { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ----------------------------- Banners ------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  font-size: 14px;
  text-align: center;
}
.banner-warn { background: rgba(245, 158, 11, 0.12); border-bottom: 1px solid rgba(245, 158, 11, 0.3); color: #fcd34d; }
.banner-info { background: rgba(59, 130, 246, 0.10); border-bottom: 1px solid rgba(59, 130, 246, 0.25); color: #93c5fd; }
.banner-pending { background: rgba(139, 92, 246, 0.12); border-bottom: 1px solid rgba(139, 92, 246, 0.35); color: #c4b5fd; }
.banner strong { color: #fff; }
.banner-pending a { color: #ddd6fe; text-decoration: underline; font-weight: 600; }
.tx-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(196, 181, 253, 0.35); border-top-color: #c4b5fd;
  display: inline-block; animation: tx-spin 0.7s linear infinite; flex: none;
}
@keyframes tx-spin { to { transform: rotate(360deg); } }

.btn-sm {
  background: var(--warning);
  color: #1a1a24;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

/* ------------------------------ Main --------------------------------------- */
.dapp-main {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 64px;
  flex: 1;
}

.dapp-intro { text-align: center; margin-bottom: 32px; }
.dapp-intro h1 { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin-bottom: 12px; }
.dapp-intro p { color: var(--text-secondary); font-size: 16px; line-height: 1.6; max-width: 580px; margin: 0 auto; }

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
}
.stat-label { display: block; font-size: 12px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-bottom: 8px; }
.stat-value { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Grid — four cards in two equal columns; align-items:stretch makes the two cards
   in each row (Stake/Unstake, then Next Distribution/Rewards) match height. */
.dapp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card h2 { font-size: 17px; font-weight: 700; }
.balance-chip { font-size: 13px; color: var(--text-secondary); }
.balance-chip b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.divider { height: 1px; background: var(--border-primary); margin: 24px 0; }

/* Inputs */
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: 6px 12px 6px 16px;
  margin-bottom: 14px;
}
.input-group:focus-within { border-color: var(--purple); }
.amount-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.amount-input::placeholder { color: var(--text-muted, #404050); }
.btn-max {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: none;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.input-suffix { color: var(--text-secondary); font-weight: 600; font-size: 14px; }

/* Buttons */
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 11px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary { background: var(--gradient); color: #fff; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(168, 85, 247, 0.3); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-primary); }
.btn-secondary:hover:not(:disabled) { border-color: var(--purple); }
.btn-block { width: 100%; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Distribution panel */
.dist-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-primary); font-size: 14px; color: var(--text-secondary); }
.dist-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.eligibility {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
.eligibility-muted { background: var(--bg-tertiary); color: var(--text-secondary); }
.eligibility-yes { background: rgba(34, 197, 94, 0.12); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.eligibility-no { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.3); }
.dist-note { margin-top: 14px; font-size: 12.5px; color: var(--text-tertiary); line-height: 1.6; }
.dist-note b { color: var(--text-secondary); }

/* Rewards */
.rewards-amount { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.rewards-label { display: block; font-size: 13px; color: var(--text-tertiary); margin: 2px 0 10px; }
.rewards-list { margin: 0 0 16px; }
.reward-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border-primary); }
.reward-row:last-child { border-bottom: none; }
.reward-sym { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.reward-amt { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.rewards-empty { font-size: 14px; color: var(--text-tertiary); padding: 6px 0 8px; }

/* ----------------------------- Footer -------------------------------------- */
.dapp-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 20px 24px;
  border-top: 1px solid var(--border-primary);
  color: var(--text-tertiary);
  font-size: 12.5px;
}
.dapp-footer a { color: var(--text-secondary); text-decoration: none; }
.dapp-footer a:hover { color: var(--purple); }
.dapp-footer .dot { color: var(--text-muted, #404050); }

/* ----------------------------- Toasts -------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-left-width: 3px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.18s ease;
}
.toast a { color: var(--cyan); }
.toast-info { border-left-color: var(--info); }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-pending { border-left-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* -------------------------- Wallet picker modal ---------------------------- */
.wallet-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.wallet-modal[hidden] { display: none; }
.wallet-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 9, 0.72); backdrop-filter: blur(4px); }
.wallet-sheet {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.18s ease;
}
.wallet-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.wallet-sheet-head h3 { font-size: 17px; font-weight: 700; }
.wallet-close { background: none; border: none; color: var(--text-secondary); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.wallet-close:hover { color: var(--text-primary); }
.wallet-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.wallet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.wallet-option:hover { border-color: var(--purple); transform: translateY(-1px); }
.wallet-ico { width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; background: var(--bg-elevated); overflow: hidden; flex-shrink: 0; }
.wallet-ico img { width: 100%; height: 100%; object-fit: contain; }
.wc-ico { background: linear-gradient(135deg, #3396ff, #1577f2); }
.wallet-name { display: flex; flex-direction: column; line-height: 1.3; }
.wallet-name small { color: var(--text-tertiary); font-size: 12px; font-weight: 500; }
.wallet-wc { margin-top: 4px; }
.wallet-empty { color: var(--text-tertiary); font-size: 13.5px; text-align: center; padding: 10px 0; }
.wallet-hint { margin-top: 12px; font-size: 12px; color: var(--text-tertiary); line-height: 1.5; text-align: center; }

/* ----------------------------- Responsive ---------------------------------- */
@media (max-width: 760px) {
  .dapp-grid { grid-template-columns: minmax(0, 1fr); }
  .stats-strip { grid-template-columns: minmax(0, 1fr); }
  .action-row { grid-template-columns: 1fr; }
  .dapp-intro h1 { font-size: 32px; }
  .dapp-intro p { font-size: 15px; }
  .dapp-header { padding: 13px 16px; }
  .dapp-main { padding: 28px 16px 48px; }
  .card { padding: 20px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

/* Small phones — keep everything inside the viewport and tappable */
@media (max-width: 420px) {
  .dapp-brand-text { font-size: 16px; }
  .btn-connect { padding: 10px 16px; font-size: 13px; }
  .account-pill { padding: 7px 10px 7px 9px; font-size: 12px; gap: 7px; }
  .account-native { display: none; } /* keep just the address on tiny screens */
  .dapp-intro h1 { font-size: 27px; }
  .amount-input { font-size: 19px; }
  .input-suffix { font-size: 13px; }
  .stat-value { font-size: 20px; }
  .rewards-amount { font-size: 26px; }
  .dapp-footer { font-size: 11.5px; gap: 8px; }
}
