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

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-elevated: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --error: #ef4444;
  --success: #10b981;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.menu-btn:hover {
  background: var(--surface);
}

/* Main */
.main {
  flex: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.hero .highlight {
  color: var(--primary);
}

.hero p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 320px;
  margin: 0 auto;
}

/* Card Selection */
.card-selection {
  margin-bottom: 2rem;
}

.card-selection h2,
.amount-section h2,
.payment-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.card-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.card-item:hover {
  background: var(--surface-elevated);
  transform: translateY(-2px);
}

.card-item.selected {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

.card-item .card-logo {
  width: 48px;
  height: 32px;
  object-fit: contain;
}

.card-item .card-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.card-item.selected .card-name {
  color: var(--primary);
}

/* Amount Section */
.amount-section {
  margin-bottom: 2rem;
  display: none;
}

.amount-section.active {
  display: block;
  animation: slideUp 0.3s ease;
}

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

.selected-card-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.selected-card-display img {
  width: 48px;
  height: 32px;
  object-fit: contain;
}

.selected-card-display .card-info {
  flex: 1;
}

.selected-card-display .card-info h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.selected-card-display .card-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.selected-card-display .change-btn {
  font-size: 0.75rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  padding: 0.5rem;
}

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

.amount-btn {
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.amount-btn:hover {
  background: var(--surface-elevated);
}

.amount-btn.selected {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
}

.custom-amount {
  margin-bottom: 1.5rem;
}

.custom-amount label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

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

.input-wrapper .currency {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 1.125rem;
  font-weight: 500;
}

.input-wrapper input {
  width: 100%;
  padding: 1rem 1rem 1rem 2.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input:focus {
  border-color: var(--primary);
}

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

/* Summary */
.summary {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Payment Section */
.payment-section {
  display: none;
}

.payment-section.active {
  display: block;
  animation: slideUp 0.3s ease;
}

.payment-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

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

.form-group input {
  padding: 1rem;
  font-size: 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

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

.form-group input.error {
  border-color: var(--error);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.submit-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loader {
  display: flex;
  align-items: center;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

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

.security-badges {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  max-width: 320px;
  width: 100%;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.success-icon {
  margin-bottom: 1rem;
}

.modal-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.modal-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.modal-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.modal-btn:hover {
  background: var(--primary-dark);
}

/* Footer */
.footer {
  padding: 1.5rem 1rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.footer-links a {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Tablet and Desktop */
@media (min-width: 480px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .hero p {
    max-width: 400px;
  }

  .card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) {
  .main {
    padding: 2rem 1.5rem;
  }

  .hero {
    margin-bottom: 3rem;
    padding: 2rem 0;
  }

  .hero h1 {
    font-size: 3rem;
  }

  .card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .card-item {
    padding: 1.25rem 0.75rem;
  }

  .amount-presets {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Touch feedback for mobile */
@media (hover: none) {
  .card-item:active,
  .amount-btn:active,
  .submit-btn:active:not(:disabled),
  .modal-btn:active {
    transform: scale(0.98);
  }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}
