/* ============================================================
   Payvix — Design System & Global Styles
   Mobile-first. 375px base. Max content width: 480px.
   ============================================================ */

/* ---------- Google Fonts Import ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Primary — Deep Indigo */
  --color-primary:       #4F46E5;
  --color-primary-dark:  #3730A3;
  --color-primary-light: #818CF8;
  --color-primary-bg:    #EEF2FF;

  /* Accent */
  --color-accent: #7C3AED;

  /* Semantic */
  --color-success:       #10B981;
  --color-success-light: #D1FAE5;
  --color-danger:        #EF4444;
  --color-danger-light:  #FEE2E2;
  --color-warning:       #F59E0B;
  --color-warning-light: #FEF3C7;

  /* Neutrals */
  --color-bg:             #F5F6FF;
  --color-surface:        #FFFFFF;
  --color-surface-2:      #F9FAFB;
  --color-border:         #E5E7EB;
  --color-border-light:   #F3F4F6;
  --color-text-primary:   #111827;
  --color-text-secondary: #6B7280;
  --color-text-disabled:  #D1D5DB;
  --color-text-white:     #FFFFFF;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 100%);
  --gradient-warm:    linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  --font-regular:  400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;

  /* Spacing (8pt grid) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border Radius */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:  0 8px 24px rgba(79,70,229,0.15);
  --shadow-xl:  0 16px 48px rgba(79,70,229,0.2);

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow:   0.4s ease;

  /* Z-index scale */
  --z-base:    1;
  --z-dropdown: 100;
  --z-sticky:  200;
  --z-modal:   300;
  --z-toast:   400;
  --z-overlay: 500;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ---------- App Shell ---------- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  position: relative;
  overflow-x: hidden;
}

/* ---------- Page System ---------- */
.page {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  animation: pageEnter 0.28s ease-out;
}

.page.active {
  display: flex;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Typography ---------- */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }

.font-medium   { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold     { font-weight: var(--font-bold); }
.font-mono     { font-family: var(--font-mono); }

.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-brand     { color: var(--color-primary); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-white     { color: var(--color-text-white); }

.text-center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  font-family: var(--font-primary);
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  border: none;
  cursor: pointer;
  width: 100%;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary {
  background: var(--gradient-primary);
  color: var(--color-text-white);
  box-shadow: var(--shadow-lg);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-xl);
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-primary-bg);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-sm {
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
}

.btn-loading .btn-text { visibility: hidden; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- Inputs ---------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.input-field {
  height: 56px;
  padding: 0 var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  width: 100%;
}

.input-field::placeholder { color: var(--color-text-disabled); }

.input-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.input-field.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.input-with-prefix {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-with-prefix:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.input-with-prefix.error {
  border-color: var(--color-danger);
}

.input-prefix {
  padding: 0 var(--space-4);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  border-right: 1.5px solid var(--color-border);
  height: 54px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.input-with-prefix .input-field {
  border: none;
  box-shadow: none;
  border-radius: 0;
  flex: 1;
}

.input-with-prefix .input-field:focus { box-shadow: none; }

.input-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  display: none;
}

.input-error.visible { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-body {
  padding: var(--space-4) var(--space-5);
}

/* ---------- Header ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.header-back-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface-2);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.header-back-btn:hover { background: var(--color-border); }

.header-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  flex: 1;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--space-2) var(--space-2);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  z-index: var(--z-sticky);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  flex: 1;
  color: var(--color-text-disabled);
}

.nav-item.active { color: var(--color-primary); }

.nav-item svg { width: 22px; height: 22px; }

.nav-label {
  font-size: 10px;
  font-weight: var(--font-semibold);
  letter-spacing: 0.3px;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  width: calc(100% - var(--space-8));
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  animation: toastIn 0.3s ease-out;
  pointer-events: all;
  backdrop-filter: blur(10px);
}

.toast.success { background: var(--color-success); color: white; }
.toast.error   { background: var(--color-danger);  color: white; }
.toast.info    { background: var(--color-primary);  color: white; }
.toast.warning { background: var(--color-warning);  color: white; }

.toast.removing { animation: toastOut 0.25s ease-in forwards; }

@keyframes toastIn  {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-12px) scale(0.95); }
}

/* ---------- Loader / Spinner ---------- */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.dark {
  border-color: rgba(79,70,229,0.2);
  border-top-color: var(--color-primary);
}

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

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

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--color-border-light);
  margin: var(--space-4) 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-primary { background: var(--color-primary-bg);    color: var(--color-primary); }

/* ---------- Modal / Bottom Sheet ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  display: none;
  align-items: flex-end;
  backdrop-filter: blur(2px);
}

.overlay.active { display: flex; }

.bottom-sheet {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5) calc(var(--space-8) + env(safe-area-inset-bottom));
  animation: sheetUp 0.3s ease-out;
  max-height: 90vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-5);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ---------- Utilities ---------- */
.flex            { display: flex; }
.flex-col        { display: flex; flex-direction: column; }
.items-center    { align-items: center; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1          { flex: 1; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.pt-4 { padding-top: var(--space-4); }
.pb-4 { padding-bottom: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Page content padding from bottom nav */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* Full page content (no bottom nav) */
.page-content-full {
  flex: 1;
  overflow-y: auto;
}

/* ---------- OTP Input ---------- */
.otp-container {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.otp-input {
  width: 48px; height: 56px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  font-family: var(--font-mono);
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: all var(--transition-fast);
  outline: none;
  caret-color: var(--color-primary);
}

.otp-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
  transform: scale(1.05);
}

.otp-input.filled {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.otp-input.error {
  border-color: var(--color-danger);
  background: var(--color-danger-light);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  60%       { transform: translateX(6px); }
  80%       { transform: translateX(-3px); }
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-4);
  text-align: center;
}

.empty-state-icon {
  width: 80px; height: 80px;
  background: var(--color-primary-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-2);
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
