/* Design System & Custom Properties */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  
  /* Color Palette */
  --bg-primary: #0a0b10;
  --bg-secondary: rgba(18, 20, 29, 0.7);
  --bg-card: rgba(26, 29, 46, 0.45);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #a855f7; /* Purple */
  --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  
  --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  padding: 20px;
}

/* Background Gradients & Ambient Glow */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: radial-gradient(circle at 50% 50%, #151829 0%, var(--bg-primary) 100%);
}

.circle-blur {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}

.circle-1 {
  top: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: var(--accent-primary);
}

.circle-2 {
  bottom: -15%;
  left: -10%;
  width: 60vw;
  height: 60vw;
  background: var(--accent-secondary);
}

/* Layout Containers */
.app-container {
  width: 100%;
  max-width: 540px;
  margin: auto;
  z-index: 1;
}

/* Glassmorphic Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid var(--border-color);
  padding: 40px;
  box-shadow: var(--card-shadow);
  transition: var(--transition-smooth);
  width: 100%;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Checkout Header */
.checkout-header {
  margin-bottom: 30px;
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 100px;
  color: #818cf8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.checkout-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* Product Summary Box */
.product-summary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
}

.product-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-details h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.product-details p {
  color: var(--text-secondary);
  font-size: 13px;
}

.product-price {
  text-align: right;
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.product-price .currency {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  vertical-align: super;
}

.product-price .amount {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.product-price .currency-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-left: 4px;
}

/* Form Styles */
.form-group-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .form-group-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.secure-badge {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-group input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-group input:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.form-group input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

/* Custom Card Element Wrapper */
.stripe-field-group {
  margin-top: 20px;
  margin-bottom: 30px;
}

#card-element-wrapper {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  transition: var(--transition-smooth);
}

#card-element-wrapper:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

#card-element-wrapper.focused {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Error Field */
.field-error {
  color: var(--error);
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
  transition: var(--transition-smooth);
}

/* Submit Button & Spinner */
.submit-button {
  background: var(--accent-gradient);
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  padding: 16px;
  width: 100%;
  transition: var(--transition-smooth);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.5);
  position: relative;
  overflow: hidden;
}

.submit-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: 0.5s;
}

.submit-button:hover:not(:disabled)::before {
  left: 100%;
}

.submit-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -8px rgba(99, 102, 241, 0.6);
}

.submit-button:active:not(:disabled) {
  transform: translateY(0);
}

.submit-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.spinner {
  width: 20px;
  height: 20px;
  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); }
}

/* Success Card States */
.success-card {
  text-align: center;
}

.success-icon-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.success-icon {
  width: 80px;
  height: 80px;
}

.success-circle {
  stroke: var(--success);
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  animation: draw-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-check {
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: draw-check 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}

@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

.success-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.success-message {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 30px;
  line-height: 1.5;
}

.receipt-details {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 30px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

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

.receipt-value {
  color: var(--text-primary);
  font-weight: 500;
}

.receipt-value.highlighted {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.receipt-value.code {
  font-family: monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

/* Secondary Button (Reset) */
.secondary-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Configuration Error Card Styles */
.error-card {
  text-align: center;
  border-color: rgba(239, 68, 68, 0.3);
}

.error-icon {
  font-size: 40px;
  margin-bottom: 20px;
}

.error-card h2 {
  font-family: var(--font-display);
  color: #fff;
  font-size: 22px;
  margin-bottom: 12px;
}

.error-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.steps {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.1);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.steps code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #fca5a5;
}

/* Transactions Card & Table Styles */
.transactions-card {
  margin-top: 24px;
  padding: 30px !important;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.card-header-row h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.refresh-button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 10px;
  transition: var(--transition-smooth);
}

.refresh-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.refresh-button:active {
  transform: translateY(0);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.payments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.payments-table th, 
.payments-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.payments-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.payments-table tbody tr:last-child td {
  border-bottom: none;
}

.payments-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.payments-table td.status-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.payments-table .date-cell {
  color: var(--text-secondary);
  white-space: nowrap;
}

.payments-table .payment-id-cell {
  font-family: monospace;
  color: var(--text-secondary);
  white-space: nowrap;
}

.payments-table .amount-cell {
  font-weight: 600;
  font-family: var(--font-display);
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge.succeeded {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.requires_payment_method {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.requires_confirmation,
.status-badge.requires_action {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge.failed,
.status-badge.canceled {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Footer styling */
.app-footer {
  margin-top: 30px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
