/* ---------------------------------------------------------------------------
   Whistant Platform — Styles
   --------------------------------------------------------------------------- */

:root {
  --bg: #10161d;
  --card-bg: rgba(18, 27, 36, 0.92);
  --border: rgba(118, 138, 156, 0.18);
  --text: #eef4f7;
  --muted: #93a4af;
  --accent: #1ea672;
  --accent-hover: #27ba81;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(30, 166, 114, 0.18), transparent 36%),
    linear-gradient(180deg, #0d141a 0%, #10161d 48%, #0c1218 100%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 32px;
}
.platform-header-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: block;
  margin: 0 auto 16px;
  box-shadow: 0 10px 28px rgba(30, 166, 114, 0.22);
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}
header p {
  color: var(--muted);
  margin-top: 4px;
}

main {
  flex: 1;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.card h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* User header */
.user-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-header > div {
  flex: 1;
  min-width: 0;
}
.user-header strong {
  display: block;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-header .muted {
  display: block;
  margin-top: 2px;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar {
  font-size: 2rem;
  line-height: 1;
}

/* Buttons */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--text); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge.free { background: #374151; color: #9ca3af; }
.badge.monthly { background: #1e3a5f; color: #60a5fa; }
.badge.monthly\\.heavy { background: #4a1d6b; color: #c084fc; }

/* Section headers + status */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.plan-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.balance-amount {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
#plan-expires {
  font-size: 0.9rem;
  color: var(--muted);
}

.payment-source {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.payment-source select {
  min-width: 200px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

/* Plans grid */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.plan-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  text-align: center;
  color: var(--text);
  width: 100%;
}
.plan-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  background: rgba(30, 166, 114, 0.08);
}
.plan-card.selected {
  border-color: var(--accent);
  background: rgba(30, 166, 114, 0.08);
}
.plan-card h4 {
  font-size: 1.1rem;
  margin-bottom: 0;
}
.plan-card-custom {
  cursor: default;
  grid-column: 1 / span 2;
  padding: 18px 14px;
}
.plan-card-custom:hover {
  transform: none;
}
.custom-topup-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: nowrap;
}
.custom-topup-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.custom-topup-input {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.custom-topup-input input {
  width: 72px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}
.topup-action {
  display: flex;
  justify-content: flex-start;
}
.topup-action .btn-primary {
  width: 100%;
  max-width: calc(50% - 6px);
  min-width: 220px;
}

/* Quota progress bar */
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Apple Sign-In button */
.apple-signin-btn-container {
  margin: 16px auto;
  display: flex;
  justify-content: center;
}
.apple-signin-btn {
  display: block;
  width: 100%;
  max-width: 300px;
  padding: 12px 20px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.apple-signin-btn:hover { background: #1a1a1a; }

/* Divider */
.divider {
  text-align: center;
  color: var(--muted);
  margin: 20px 0;
  font-size: 0.85rem;
}

/* Native token flow */
details {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
details textarea {
  width: 100%;
  margin-top: 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
}

/* States */
.error {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 12px;
  font-size: 0.9rem;
}
.loading {
  color: var(--muted);
  font-style: italic;
  padding: 12px 0;
}
.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
  color: var(--success);
  font-weight: 600;
}
.result-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--success);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.result-close:hover {
  color: var(--text);
}
.note {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}
.note p { margin-bottom: 4px; }
.note p:last-child { margin-bottom: 0; }

/* Utility */
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.muted { color: var(--muted); }
.text-center { text-align: center; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: auto;
  padding-top: 40px;
}
footer a {
  color: var(--muted);
  text-decoration: none;
}
footer a:hover {
  color: var(--text);
}

/* Credit balance + transactions */
.txn-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.txn-row:last-child { border-bottom: none; }
.txn-type { font-weight: 600; }
.txn-type.topup { color: var(--success); }
.txn-type.spend { color: var(--danger); }
.txn-amount { font-weight: 600; }
.txn-date { color: var(--muted); font-size: 0.8rem; }

/* Responsive */
@media (max-width: 480px) {
  .section-header {
    align-items: flex-start;
  }
  .plans-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .container {
    padding: 20px 12px 40px;
  }
  .plan-card-custom {
    grid-column: 1 / -1;
  }
  .custom-topup-row {
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .topup-action .btn-primary {
    max-width: 100%;
  }
  .user-header {
    flex-wrap: wrap;
  }
  .user-header .btn-secondary {
    width: 100%;
  }
  .txn-row {
    grid-template-columns: 1fr auto;
  }
  .txn-date {
    grid-column: 1 / -1;
  }
}
