/* ==========================================================================
   Design System & Modern Fintech Stylesheet
   ========================================================================== */

:root {
  --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Color Palette - Dark Fintech Theme */
  --bg-main: #090d16;
  --bg-surface: rgba(18, 24, 38, 0.82);
  --bg-surface-elevated: rgba(28, 38, 59, 0.7);
  --bg-input: rgba(13, 19, 33, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  --border-hover: rgba(255, 255, 255, 0.16);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
  --primary-hover: linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #7e22ce 100%);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --card-gradient: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #1e293b 100%);
  --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --glow-shadow: 0 0 25px rgba(99, 102, 241, 0.35);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode Overrides */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-surface-elevated: rgba(248, 250, 252, 0.95);
  --bg-input: #ffffff;
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-hover: rgba(0, 0, 0, 0.2);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --glass-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --card-gradient: linear-gradient(135deg, #312e81 0%, #4338ca 50%, #1e293b 100%);
}

/* Base & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle Animated Ambient Background Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}
.ambient-glow-1 {
  width: 500px;
  height: 500px;
  top: -150px;
  left: -100px;
  background: radial-gradient(circle, #6366f1, #3b82f6);
}
.ambient-glow-2 {
  width: 450px;
  height: 450px;
  bottom: -100px;
  right: -80px;
  background: radial-gradient(circle, #ec4899, #8b5cf6);
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  background: rgba(9, 13, 22, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.875rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Stepper Progress Bar */
.stepper-container {
  max-width: 680px;
  margin: 1.75rem auto 1rem;
  width: 100%;
  padding: 0 1rem;
  position: relative;
  z-index: 10;
}

.stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
}

.stepper::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 36px;
  right: 36px;
  height: 2px;
  background: var(--border-subtle);
  z-index: 1;
}

.stepper-progress-fill {
  position: absolute;
  top: 18px;
  left: 36px;
  height: 2px;
  background: var(--primary-gradient);
  z-index: 2;
  transition: width var(--transition-normal);
  width: 0%;
}

.step-item {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition-normal);
}

.step-item.active .step-circle {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.5);
}

.step-item.completed .step-circle {
  background: var(--accent-emerald);
  border-color: transparent;
  color: #fff;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: var(--transition-fast);
}

.step-item.active .step-label {
  color: var(--text-primary);
}

/* Main Container */
.main-wrapper {
  flex: 1;
  max-width: 780px;
  margin: 0 auto 3rem;
  width: 100%;
  padding: 0 1rem;
  position: relative;
  z-index: 10;
}

/* Multi-Page Card Container */
.checkout-card {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 2rem;
  overflow: hidden;
  transition: transform var(--transition-normal);
}

/* Page Views */
.page-view {
  display: none;
  animation: fadeInSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.page-view.active {
  display: block;
}

@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Page Header */
.page-header {
  margin-bottom: 1.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
  font-family: var(--font-mono);
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  transition: var(--transition-fast);
  outline: none;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

select option {
  background-color: #0f172a;
  color: #fff;
}

input.has-prefix {
  padding-left: 2.25rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}

select:hover, input:hover {
  border-color: var(--border-hover);
}

select:focus, input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.input-hint {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Preset Quick Select Chips */
.presets-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.preset-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.775rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-chip:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.12);
  transform: translateY(-1px);
}

/* Merchant Context Preview Card (Page 1) */
.context-preview-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
}

.merchant-preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.merchant-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.merchant-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.merchant-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.preview-line-items {
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.line-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.line-item.total {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* Action Buttons */
.btn-primary {
  width: 100%;
  padding: 0.95rem 1.5rem;
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.button-row {
  display: flex;
  gap: 0.75rem;
}

/* ==========================================================================
   PAGE 2: Checkout & Virtual Card
   ========================================================================== */

/* Context Summary Banner */
.context-summary-banner {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.summary-icon {
  font-size: 1.5rem;
}

.summary-details h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.summary-details span {
  font-size: 0.75rem;
  color: #a5b4fc;
}

.summary-amount {
  text-align: right;
}

.summary-amount .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #a5b4fc;
  font-weight: 600;
}

.summary-amount .value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

/* Interactive Virtual Credit Card Preview */
.card-preview-container {
  margin-bottom: 1.75rem;
  perspective: 1000px;
}

.virtual-card {
  width: 100%;
  max-width: 380px;
  height: 220px;
  margin: 0 auto;
  border-radius: 18px;
  background: var(--card-gradient);
  padding: 1.5rem;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip-graphic {
  width: 44px;
  height: 32px;
  background: linear-gradient(135deg, #fcd34d 0%, #d97706 100%);
  border-radius: 6px;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

.chip-graphic::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.3);
}

.card-brand-badge {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  font-style: italic;
  text-transform: uppercase;
}

.card-number-display {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.card-holder-label, .card-expiry-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.08em;
}

.card-holder-val {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-expiry-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Extension Helper Callout */
.extension-callout {
  background: rgba(6, 182, 212, 0.08);
  border: 1px dashed rgba(6, 182, 212, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: #67e8f9;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ==========================================================================
   PAGE 3: Payment Success Screen
   ========================================================================== */

.success-container {
  text-align: center;
  padding: 1rem 0;
}

.success-icon-wrapper {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--accent-emerald);
  margin: 0 auto 1.25rem;
  animation: scaleBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleBounce {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.receipt-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.75rem 0;
  text-align: left;
}

.receipt-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.receipt-amount-display {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent-emerald);
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.875rem;
}

.receipt-label {
  color: var(--text-secondary);
}

.receipt-val {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.receipt-val.highlight {
  color: #818cf8;
}

/* ==========================================================================
   Extension Debug Drawer & Toast
   ========================================================================== */

.debug-drawer {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  max-width: 360px;
  width: calc(100vw - 2rem);
}

.debug-drawer-toggle {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  transition: var(--transition-fast);
}

.debug-drawer-toggle:hover {
  background: #334155;
  color: #7dd3fc;
}

.debug-panel-content {
  display: none;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.debug-panel-content.open {
  display: block;
}

.debug-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: #94a3b8;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.debug-code-box {
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.6rem;
  color: #a5f3fc;
  overflow-x: auto;
  max-height: 180px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 640px) {
  .checkout-card {
    padding: 1.25rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .virtual-card {
    height: 190px;
    padding: 1.15rem;
  }
  .card-number-display {
    font-size: 1.05rem;
  }
}
