@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg:           #050b18;
  --surface:      #0d1526;
  --surface-2:    #111d35;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text:         #f1f5f9;
  --text-muted:   #475569;
  --text-subtle:  #94a3b8;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.12);
  --purple:       #6366f1;
  --purple-light: #818cf8;
  --purple-glow:  rgba(99,102,241,0.25);
  --red-dim:      rgba(239,68,68,0.1);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Navbar ─────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5,11,24,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.navbar-brand span { color: var(--purple-light); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.8rem;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 9999px;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--purple-light);
  text-transform: capitalize;
}
.plan-badge.free {
  background: rgba(100,116,139,0.12);
  border-color: rgba(100,116,139,0.3);
  color: var(--text-subtle);
}

/* ─── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--purple);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #5254cc;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99,102,241,0.45);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--purple);
  color: var(--purple-light);
  background: rgba(99,102,241,0.07);
}

.btn-ghost {
  background: transparent;
  color: var(--text-subtle);
  padding: 0.5rem 0.9rem;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── Auth pages ─────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem 2rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.auth-logo h1 span { color: var(--purple-light); }
.auth-logo p { color: var(--text-subtle); font-size: 0.9rem; }

.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-subtle);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.925rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}
.form-input::placeholder { color: var(--text-muted); }

.form-submit { width: 100%; padding: 0.8rem; font-size: 0.95rem; margin-top: 0.25rem; }

.auth-footer {
  text-align: center;
  margin-top: 1.4rem;
  font-size: 0.875rem;
  color: var(--text-subtle);
}
.auth-footer a { color: var(--purple-light); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

.alert {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
}
.alert-success {
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.3);
  color: #86efac;
}

/* ─── Dashboard ──────────────────────────── */
.dashboard {
  max-width: 1160px;
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}
.section-header h2 {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  background: linear-gradient(160deg, #fff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.section-header p {
  color: var(--text-subtle);
  font-size: 1.05rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ─── Pricing grid ───────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 3.5rem;
}

.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.pricing-card:hover { transform: translateY(-4px); }

.pricing-card.pro {
  border-color: rgba(99,102,241,0.5);
  background: linear-gradient(160deg, #0e1628 0%, #0d152a 100%);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.25), 0 0 50px rgba(99,102,241,0.18);
}
.pricing-card.pro:hover {
  box-shadow: 0 0 0 1px rgba(99,102,241,0.45), 0 0 70px rgba(99,102,241,0.28);
}

.badge-popular {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.28rem 1rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.card-icon { font-size: 1.75rem; margin-bottom: 0.85rem; line-height: 1; }
.card-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.4rem; }
.card-desc { color: var(--text-subtle); font-size: 0.85rem; margin-bottom: 1.4rem; line-height: 1.55; }

.card-price { margin-bottom: 1.5rem; }
.card-price .amount {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.card-price .period { color: var(--text-subtle); font-size: 0.85rem; margin-top: 0.2rem; }

.features-list { list-style: none; margin-bottom: 1.75rem; flex: 1; }
.features-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.35rem 0;
  font-size: 0.875rem;
  color: var(--text-subtle);
}
.features-list li .check { color: var(--green); flex-shrink: 0; margin-top: 1px; }
.features-list li.hl { color: var(--text); font-weight: 500; }

.card-cta {
  width: 100%;
  padding: 0.8rem;
  font-size: 0.9rem;
  border-radius: 10px;
}

.pricing-card.pro .card-cta.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 18px rgba(99,102,241,0.4);
}
.pricing-card.pro .card-cta.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5254cc, #7c3aed);
  box-shadow: 0 6px 28px rgba(99,102,241,0.55);
}

.current-plan-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.8rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--green);
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.28);
  border-radius: 10px;
}

/* ─── Credits section ────────────────────── */
.credits-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.25rem 2rem;
}

.credits-header { margin-bottom: 1.25rem; }
.credits-header h3 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.4rem; }
.credits-header p { color: var(--text-subtle); font-size: 0.9rem; }

.credits-balance {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: #86efac;
  margin-bottom: 1.4rem;
}

.credit-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.credit-pill {
  padding: 0.55rem 1.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
  font-family: var(--font);
}
.credit-pill:hover:not(:disabled) {
  border-color: var(--purple);
  background: rgba(99,102,241,0.08);
  color: var(--purple-light);
}
.credit-pill.active {
  border-color: var(--purple);
  background: rgba(99,102,241,0.12);
  color: var(--purple-light);
}
.credit-pill:disabled { opacity: 0.45; cursor: not-allowed; }

.custom-amount-wrapper {
  display: none;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}
.custom-amount-wrapper.show { display: flex; }

.custom-amount-prefix {
  color: var(--text-subtle);
  font-size: 1rem;
  font-weight: 500;
}

.custom-input {
  padding: 0.6rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  width: 130px;
  outline: none;
  transition: border-color 0.15s;
}
.custom-input:focus { border-color: var(--purple); }

/* ─── Success / Cancel pages ─────────────── */
.result-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.result-card {
  text-align: center;
  max-width: 460px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem 2.25rem;
}

.result-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2.2rem;
}
.result-icon.success {
  background: rgba(34,197,94,0.1);
  border: 2px solid rgba(34,197,94,0.35);
}
.result-icon.cancel {
  background: rgba(239,68,68,0.08);
  border: 2px solid rgba(239,68,68,0.25);
}

.result-card h1 { font-size: 1.7rem; font-weight: 800; margin-bottom: 0.65rem; }
.result-card p { color: var(--text-subtle); margin-bottom: 2rem; font-size: 0.95rem; }

/* ─── Toast ──────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0.75rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 9999;
  max-width: 320px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast.ok    { border-color: rgba(34,197,94,0.4); }

/* ─── Spinner ────────────────────────────── */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 860px) {
  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
  }
  .section-header h2 { font-size: 2rem; }
}

@media (max-width: 540px) {
  .navbar { padding: 0.75rem 1rem; }
  .dashboard { padding: 2rem 1rem 4rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .credits-section { padding: 1.75rem 1.25rem; }
  .toast { bottom: 1rem; right: 1rem; left: 1rem; max-width: none; }
}
