/* ============================================================
   Reusable UI components — mirrors the Flutter widget library
   (buttons/inputs from app_theme.dart, cards/tiles from each page)
   ============================================================ */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--fs-lg);
  font-weight: 600;
  transition: transform var(--dur-fast) var(--ease-standard), opacity var(--dur-fast);
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }

.btn-primary { background: var(--color-primary); color: var(--color-text-on-primary); }
.btn-outline { background: transparent; color: var(--color-primary); border: 1.5px solid var(--color-primary); }
.btn-danger-outline { background: transparent; color: var(--color-error); border: 1.5px solid var(--color-error); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); min-height: 40px; }
.btn-sm { min-height: 40px; font-size: var(--fs-base); padding: 0 var(--space-4); width: auto; }
.btn-block { width: 100%; }

.btn-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-outline .btn-spinner { border-color: rgba(26, 63, 224, 0.25); border-top-color: var(--color-primary); }

/* ---- Inputs ---- */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-hint);
  letter-spacing: 0.3px;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon-leading { position: absolute; left: var(--space-4); color: var(--color-text-secondary); pointer-events: none; font-size: 18px; }
.input-wrap .icon-trailing { position: absolute; right: var(--space-3); display: flex; align-items: center; gap: 4px; }

.input {
  width: 100%;
  min-height: 52px;
  background: var(--color-input-fill);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  font-size: var(--fs-md);
  color: var(--color-text-primary);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.input-wrap .icon-leading + .input { padding-left: 44px; }
.input-wrap .icon-trailing ~ .input { padding-right: 44px; }
.input:focus { border-color: var(--color-primary); background: var(--color-surface); }
.input.has-error { border-color: var(--color-error); }
.input:disabled { opacity: 0.6; }

.field-error {
  font-size: var(--fs-xs);
  color: var(--color-error);
  display: none;
}
.field.has-error .field-error { display: block; }

/* ---- Cards ---- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.card-flat {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

/* Wallet balance card (mirrors _BalanceCard in home_page.dart) */
.wallet-card {
  background: var(--gradient-dark);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.wallet-card__label { font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.7); font-weight: 500; }
.wallet-card__amount { font-size: var(--fs-3xl); font-weight: 700; margin-top: 6px; }
.wallet-card__actions { display: flex; flex-direction: column; gap: 6px; }
.wallet-card__chip {
  background: #fff;
  color: var(--color-primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.bonus-card {
  background: linear-gradient(135deg, var(--color-primary), #112b9b);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  color: #fff;
}

/* ---- Status pill (green/red — matches ReferralPage.dart status badges) ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 1px solid transparent;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill--active { color: var(--color-success); background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); }
.status-pill--inactive { color: var(--color-error); background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); }
.status-pill--pending { color: var(--color-warning); background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); }

/* ---- Service tile grid (AllServicesPage.dart / home services row) ---- */
.service-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
.service-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  position: relative;
}
.service-tile__icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.service-tile:active .service-tile__icon { transform: scale(0.92); }
.service-tile__label { font-size: var(--fs-xs); font-weight: 600; color: var(--color-text-primary); }
.service-tile--soon .service-tile__icon { opacity: 0.55; }
.service-tile--soon .service-tile__label { color: var(--color-text-hint); }
.service-tile__badge {
  position: absolute;
  bottom: 22px; right: -2px;
  background: var(--color-warning);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 1.5px solid #fff;
}

/* ---- Network selector card (Airtime.dart / BuyDataPage.dart) ---- */
.network-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.network-card {
  height: 80px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px;
  position: relative;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.network-card img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.network-card span { font-size: 10px; font-weight: 600; color: var(--color-text-secondary); }
.network-card.selected { border-width: 2px; box-shadow: var(--shadow-sm); }
.network-card__check {
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px;
}

/* ---- Transaction / history list item ---- */
.tx-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px;
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-divider) 60%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.tx-item__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.tx-item__body { flex: 1; min-width: 0; }
.tx-item__title { font-size: var(--fs-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-item__sub { font-size: var(--fs-xs); color: var(--color-text-hint); margin-top: 2px; }
.tx-item__amount { font-size: var(--fs-md); font-weight: 700; text-align: right; white-space: nowrap; }
.tx-item__amount--credit { color: var(--color-success); }
.tx-item__amount--debit { color: var(--color-text-primary); }

/* ---- PIN dots (LoginWithPinPage.dart / CreatePinPage.dart) ---- */
.pin-dots { display: flex; justify-content: center; gap: var(--space-3); }
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: all var(--dur-fast) var(--ease-standard);
}
.pin-dot.filled { width: 18px; height: 18px; background: #fff; border-color: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.55); }
.pin-dots.shake { animation: shake 0.45s; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); max-width: 300px; margin-inline: auto; }
.keypad-key {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  margin-inline: auto;
  transition: background var(--dur-fast);
}
.keypad-key:active { background: rgba(255, 255, 255, 0.16); }
.keypad-key:empty { visibility: hidden; }

/* ---- Modal / bottom sheet ---- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.overlay.open { opacity: 1; pointer-events: auto; }

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  padding: var(--space-5);
  transform: translateY(100%);
  transition: transform var(--dur-base) var(--ease-standard);
}
.overlay.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--color-divider); border-radius: var(--radius-full); margin: 0 auto var(--space-5); }

@media (min-width: 768px) {
  .overlay { align-items: center; }
  .sheet { border-radius: var(--radius-2xl); max-height: 85vh; }
}

.dialog {
  width: 100%;
  max-width: 340px;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-6) var(--space-5) var(--space-5);
  text-align: center;
}

/* ---- Toast ---- */
#toast-region {
  position: fixed;
  left: 50%;
  /* Clear the bottom nav's full rendered height, including its safe-area
     inset on notched phones — see .bottom-nav in layout.css. */
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0) + var(--space-4));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 420px);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: var(--fs-base);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-base) var(--ease-standard);
}
.toast--info { background: var(--color-primary); }
.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-error); }
.toast--warning { background: var(--color-warning); }
.toast.leaving { animation: toast-out var(--dur-base) var(--ease-standard) forwards; }

/* ---- Full-screen app loader (loader.js — port of widgets/loader.dart) ---- */
.app-loader-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
}
.app-loader-card {
  width: 90px; height: 90px;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
}
.app-loader-spin { animation: spin 2s linear infinite; }

/* ---- Loader / skeleton ---- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-divider);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-inline: auto;
}
.page-loader { display: flex; align-items: center; justify-content: center; padding: var(--space-8) 0; }

.skeleton { background: linear-gradient(90deg, var(--color-divider) 25%, #eef1f5 37%, var(--color-divider) 63%); background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite; border-radius: var(--radius-md); }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-circle { border-radius: 50%; }

/* ---- Empty / error states ---- */
.state-block { text-align: center; padding: var(--space-8) var(--space-4); }
.state-block__icon { font-size: 40px; color: var(--color-text-hint); margin-bottom: var(--space-3); }
.state-block__title { font-size: var(--fs-md); font-weight: 600; color: var(--color-text-secondary); margin-bottom: var(--space-1); }
.state-block__desc { font-size: var(--fs-sm); color: var(--color-text-hint); }

/* ---- Badge / avatar ---- */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---- Progress bar (milestone card) ---- */
.progress-track { height: 6px; border-radius: var(--radius-full); background: rgba(0, 0, 0, 0.06); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-warning); border-radius: var(--radius-full); transition: width var(--dur-slow) var(--ease-standard); }

/* ---- Menu tile (profile_page.dart _MenuTile) ---- */
.menu-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-2);
}
.menu-tile__icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--color-icon-bg-alt); color: var(--color-primary); flex-shrink: 0; font-size: 19px; }
.menu-tile__body { flex: 1; min-width: 0; }
.menu-tile__title { font-size: var(--fs-md); font-weight: 600; }
.menu-tile__sub { font-size: var(--fs-xs); color: var(--color-text-secondary); margin-top: 1px; }
.menu-tile--danger .menu-tile__icon { background: rgba(239, 68, 68, 0.1); color: var(--color-error); }
