@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --p50:  #f5f0ff;
  --p100: #ede0ff;
  --p200: #d9bfff;
  --p400: #a855f7;
  --p500: #8b38e8;
  --p600: #7219d4;
  --p700: #5b10b0;
  --p900: #2e0669;

  --white: #ffffff;
  --gray50: #fafafa;
  --gray100: #f4f3f7;
  --gray200: #e8e6ef;
  --gray400: #9e9aaf;
  --gray600: #5c5875;
  --gray800: #2a2638;
  --gray900: #141220;

  --success: #22c55e;
  --danger:  #ef4444;
  --warning: #f59e0b;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', sans-serif;

  --shadow-sm:  0 1px 3px rgba(114,25,212,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(114,25,212,.12), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:  0 12px 40px rgba(114,25,212,.18), 0 4px 12px rgba(0,0,0,.08);
  --shadow-xl:  0 24px 60px rgba(114,25,212,.22);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --transition: .22s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

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

/* ── NOISE TEXTURE OVERLAY ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ── NAVBAR ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(168,85,247,.12);
  padding: 0 2rem;
  height: 68px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 20px rgba(114,25,212,.06);
}

.nav-brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none;
}

.nav-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--p500), var(--p700));
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(114,25,212,.35);
}

.nav-brand-icon svg { width: 18px; height: 18px; fill: white; }

.nav-brand-text {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700;
  color: var(--gray900);
  letter-spacing: -.01em;
}

.nav-links {
  display: flex; align-items: center; gap: .25rem;
  list-style: none;
}

.nav-links a {
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 500;
  color: var(--gray600);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}

.nav-links a:hover { color: var(--p500); background: var(--p50); }

.nav-links a.active {
  color: var(--p600);
  background: var(--p50);
  font-weight: 600;
}

.nav-links a.active::after {
  content: '';
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px;
  background: var(--p500);
  border-radius: 99px;
}

.nav-right {
  display: flex; align-items: center; gap: .75rem;
}

.nav-balance {
  display: flex; align-items: center; gap: .5rem;
  background: linear-gradient(135deg, var(--p50), var(--p100));
  border: 1px solid var(--p200);
  border-radius: var(--radius-md);
  padding: .4rem .9rem;
  font-size: .85rem; font-weight: 600;
  color: var(--p700);
}

.nav-balance-icon { font-size: 1rem; }

.nav-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; color: white;
  cursor: pointer; border: 2px solid var(--p200);
  transition: var(--transition);
}
.nav-avatar:hover { transform: scale(1.05); box-shadow: var(--shadow-sm); }

.nav-logout {
  display: flex; align-items: center; gap: .35rem;
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 500;
  color: var(--gray400);
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-logout:hover { color: var(--danger); border-color: rgba(239,68,68,.2); background: rgba(239,68,68,.04); }

/* ── PAGE WRAPPER ── */
.page-wrapper {
  position: relative; z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page-header {
  margin-bottom: 2.5rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 700;
  color: var(--gray900);
  line-height: 1.2;
}

.page-subtitle {
  margin-top: .4rem;
  font-size: .95rem; color: var(--gray400);
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(168,85,247,.08);
  overflow: hidden;
}

.card-body { padding: 2rem; }
.card-header {
  padding: 1.5rem 2rem 0;
  border-bottom: 1px solid var(--gray100);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 600;
  color: var(--gray800);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: .9rem; font-weight: 600;
  cursor: pointer; border: none;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--p500), var(--p700));
  color: white;
  box-shadow: 0 4px 14px rgba(114,25,212,.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(114,25,212,.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--p600);
  border: 1.5px solid var(--p300, var(--p200));
}
.btn-outline:hover { background: var(--p50); border-color: var(--p400); }

.btn-ghost {
  background: var(--gray100);
  color: var(--gray600);
}
.btn-ghost:hover { background: var(--gray200); color: var(--gray800); }

.btn-lg { padding: .85rem 2rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: .4rem .9rem; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

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

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: .85rem; font-weight: 600;
  color: var(--gray600);
  margin-bottom: .45rem;
  letter-spacing: .01em;
}

.form-control {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--gray200);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--gray900);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--p400);
  box-shadow: 0 0 0 3px rgba(168,85,247,.14);
}

.form-control::placeholder { color: var(--gray400); }

/* ── ALERTS ── */
.alert {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .9rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: .9rem;
  margin-bottom: 1.25rem;
  animation: slideIn .25s ease;
}

@keyframes slideIn {
  from { opacity:0; transform: translateY(-6px); }
  to   { opacity:1; transform: translateY(0); }
}

.alert-success { background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.25); color: #15803d; }
.alert-danger  { background: rgba(239,68,68,.08);  border: 1px solid rgba(239,68,68,.25);  color: #b91c1c; }
.alert-info    { background: var(--p50);           border: 1px solid var(--p200);           color: var(--p700); }

/* ── AUTH PAGES ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--gray100) 0%, var(--p50) 50%, var(--gray100) 100%);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(168,85,247,.12) 0%, transparent 70%);
  top: -200px; right: -100px;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(114,25,212,.08) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.auth-card {
  width: 100%; max-width: 440px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(168,85,247,.12);
  padding: 3rem 2.5rem;
  position: relative; z-index: 1;
  animation: authIn .4s cubic-bezier(.4,0,.2,1);
}

@keyframes authIn {
  from { opacity:0; transform: translateY(20px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 2rem;
}

.auth-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--p400), var(--p700));
  border-radius: 18px;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(114,25,212,.35);
  margin-bottom: 1rem;
}

.auth-logo-icon svg { width: 32px; height: 32px; fill: white; }

.auth-title {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  color: var(--gray900);
  text-align: center;
}

.auth-subtitle {
  font-size: .9rem; color: var(--gray400);
  text-align: center; margin-top: .3rem;
}

.auth-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 1.5rem 0;
  color: var(--gray400); font-size: .82rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--gray200);
}

.auth-footer {
  text-align: center; margin-top: 1.5rem;
  font-size: .88rem; color: var(--gray400);
}
.auth-footer a { color: var(--p500); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { color: var(--p700); text-decoration: underline; }

/* ── TOPUP PAGE ── */
.topup-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .topup-grid { grid-template-columns: 1fr; }
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.amount-btn {
  padding: .9rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--gray200);
  background: var(--white);
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 600;
  color: var(--gray700, var(--gray800));
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.amount-btn:hover {
  border-color: var(--p400);
  color: var(--p600);
  background: var(--p50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.amount-btn.selected {
  border-color: var(--p500);
  background: linear-gradient(135deg, var(--p50), var(--p100));
  color: var(--p700);
  box-shadow: 0 0 0 3px rgba(168,85,247,.12);
}

/* ── QR PANEL ── */
.qr-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--p200);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.qr-panel-header {
  background: linear-gradient(135deg, var(--p500), var(--p700));
  padding: 1.25rem 1.5rem;
  color: white;
  text-align: center;
}

.qr-panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
}

.qr-panel-body { padding: 1.75rem; text-align: center; }

.qr-amount {
  font-family: var(--font-display);
  font-size: 2.5rem; font-weight: 700;
  color: var(--p600);
  margin: .5rem 0;
}

.qr-amount span { font-size: 1rem; color: var(--gray400); font-weight: 400; font-family: var(--font-body); }

.qr-image-wrap {
  width: 200px; height: 200px;
  margin: 1rem auto;
  border-radius: var(--radius-md);
  border: 3px solid var(--p100);
  overflow: hidden;
  position: relative;
  background: var(--gray50);
  display: grid; place-items: center;
}

.qr-image-wrap img { width: 100%; height: 100%; object-fit: contain; }

.qr-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  color: var(--gray400); font-size: .85rem;
}

/* ── COUNTDOWN ── */
.countdown-wrap {
  margin: 1rem 0;
}

.countdown-bar-bg {
  height: 5px; background: var(--gray200);
  border-radius: 99px; overflow: hidden;
  margin-bottom: .5rem;
}

.countdown-bar {
  height: 100%; background: linear-gradient(90deg, var(--p400), var(--p600));
  border-radius: 99px;
  transition: width 1s linear, background-color .5s;
}

.countdown-bar.urgent { background: linear-gradient(90deg, var(--warning), var(--danger)); }

.countdown-time {
  font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--gray800);
}

.countdown-time.urgent { color: var(--danger); animation: pulse .8s infinite; }

@keyframes pulse {
  0%,100% { opacity:1; } 50% { opacity:.6; }
}

/* ── STATUS BADGE ── */
.status-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 99px;
  font-size: .8rem; font-weight: 600;
}

.badge-pending { background: rgba(245,158,11,.1); color: #92400e; }
.badge-paid    { background: rgba(34,197,94,.1);  color: #14532d; }
.badge-expired { background: rgba(156,163,175,.1); color: var(--gray600); }

/* ── BALANCE CARD ── */
.balance-card {
  background: linear-gradient(135deg, var(--p500) 0%, var(--p700) 60%, var(--p900) 100%);
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: white;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.balance-card::before {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.07);
  border-radius: 50%;
  top: -80px; right: -40px;
}

.balance-card::after {
  content: '';
  position: absolute;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
  bottom: -30px; left: 30px;
}

.balance-label {
  font-size: .82rem; opacity: .75; letter-spacing: .08em; text-transform: uppercase;
}

.balance-amount {
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 700;
  line-height: 1.1;
  margin: .5rem 0;
}

.balance-amount small { font-size: 1.2rem; font-weight: 400; opacity: .8; }

/* ── TOPUP LOG TABLE ── */
.log-table { width: 100%; border-collapse: collapse; }
.log-table th {
  font-size: .8rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--gray400);
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray100);
}
.log-table td {
  padding: .8rem 1rem;
  font-size: .9rem; color: var(--gray800);
  border-bottom: 1px solid var(--gray50);
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--gray50); }

/* ── HERO (index) ── */
.hero {
  background: linear-gradient(135deg, var(--p500) 0%, var(--p700) 100%);
  border-radius: var(--radius-xl);
  padding: 3rem;
  color: white;
  margin-bottom: 2.5rem;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-greeting {
  font-size: .9rem; opacity: .75; margin-bottom: .25rem; letter-spacing: .05em;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.2rem; font-weight: 700;
  margin-bottom: .75rem;
}

.hero-balance-row {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}

.hero-balance {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
}

.hero-balance-label { font-size: .75rem; opacity: .7; text-transform: uppercase; letter-spacing: .08em; }
.hero-balance-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }

/* ── LOADING SPINNER ── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--p200);
  border-top-color: var(--p500);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 1rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}

.toast {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1.2rem;
  background: var(--gray900);
  color: white;
  border-radius: var(--radius-md);
  font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-xl);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--p400); }

@keyframes toastIn {
  from { opacity:0; transform: translateX(20px) scale(.95); }
  to   { opacity:1; transform: translateX(0) scale(1); }
}

/* ── PASSWORD STRENGTH ── */
.pwd-strength { margin-top: .4rem; }
.pwd-bars { display: flex; gap: .25rem; margin-bottom: .25rem; }
.pwd-bar { flex:1; height: 3px; border-radius: 99px; background: var(--gray200); transition: var(--transition); }
.pwd-bar.filled-1 { background: var(--danger); }
.pwd-bar.filled-2 { background: var(--warning); }
.pwd-bar.filled-3 { background: var(--success); }
.pwd-text { font-size: .78rem; color: var(--gray400); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .navbar { padding: 0 1rem; }
  .page-wrapper { padding: 1.5rem 1rem; }
  .auth-card { padding: 2rem 1.5rem; }
  .amount-grid { grid-template-columns: repeat(2,1fr); }
  .hero { padding: 2rem; }
  .hero-title { font-size: 1.6rem; }
}
