/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: all 0.3s ease;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Light Theme Variables */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-primary: #8b5cf6;
  --accent-secondary: #a78bfa;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --warning-text: #92400e;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Dark Theme Variables */
.dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --border-color: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --accent-primary: #8b5cf6;
  --accent-secondary: #a78bfa;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-bg: #451a03;
  --warning-border: #92400e;
  --warning-text: #fed7aa;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

/* Main Container */
.app-container {
  min-height: 100vh;
  color: var(--text-primary);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  position: relative;
  transition: all 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--accent-primary);
  color: white;
}

/* Disclaimer Section */
.disclaimer {
  width: 100%;
  background: var(--warning-bg);
  padding: 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--warning-border);
  margin-bottom: 1.5rem;
  margin-top: 1.5rem;
  color: var(--warning-text);
  box-shadow: var(--shadow-sm);
}

.disclaimer p {
  margin-bottom: 0.5rem;
}

.disclaimer p:last-child {
  margin-bottom: 0;
}

.disclaimer strong {
  font-weight: 600;
}

.disclaimer a {
  color: var(--accent-primary);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.disclaimer a:hover {
  color: var(--accent-secondary);
}

/* Input Section */
.input-section {
  width: 100%;
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

/* Input Field Styles */
.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

/* Card Input Container */
.card-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.card-input {
  width: 100%;
  padding-right: 3rem;
  /* Space for logo */
}

.card-logo {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.card-logo-img {
  width: 2rem;
  height: auto;
  max-height: 1.5rem;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.1));
}

.dark .card-logo-img {
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.3)) brightness(1.1);
}

.input-control {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.input-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgb(139 92 246 / 0.1);
}

.input-control.input-error {
  border-color: var(--error-color);
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.1);
}

.input-control::placeholder {
  color: var(--text-secondary);
}

/* Bank Selector */
.bank-selector {
  position: relative;
}

.bank-dropdown {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Card Network Display */
.card-network {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.card-network-value {
  font-weight: 600;
  color: var(--accent-primary);
}

/* Error Message */
.error-message {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  border: 1px solid rgba(239, 68, 68, 0.2);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* Generate Button */
.generate-button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  padding: 1rem;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  margin-bottom: 1rem;
}

.generate-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.generate-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* UPI Result Section */
.upi-result {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.5s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.upi-id-display {
  text-align: center;
  font-size: 0.875rem;
  width: 100%;
  /* Ensure full width */
}

.upi-id-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Center align all children */
  width: 100%;
}

.upi-id-value {
  color: var(--success-color);
  font-weight: 600;
  word-break: break-all;
}

.upi-box-row {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Center the row */
  gap: 8px;
  margin-top: 6px;
  width: 100%;
  /* Take full width */
}

.upi-id-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 16px;
  font-family: monospace;
  min-width: 220px;
  word-break: break-all;
  text-align: center;
  /* Center text inside the box */
}

/* Copy Button Styles */
.copy-button {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.copy-button:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.copy-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.copy-icon {
  width: 1rem;
  height: 1rem;
  transition: all 0.2s ease;
}

.copy-icon.success {
  color: var(--success-color);
  animation: checkmark 0.3s ease-in-out;
}

@keyframes checkmark {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.copy-success-message {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--success-color);
  font-weight: 500;
  animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }

  15% {
    opacity: 1;
    transform: translateY(0);
  }

  85% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* QR Code Container */
.qr-container {
  position: relative;
  width: 13rem;
  height: 13rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.qr-code.blurred {
  filter: blur(8px);
}

.qr-reveal-button {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.reveal-btn {
  padding: 0.75rem 1.5rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.reveal-btn:hover {
  background: var(--accent-secondary);
  transform: scale(1.05);
}

/* Saved Cards Section Styles */
.saved-cards-section {
  margin-bottom: 2rem;
}

/* Save Card Button and Form */
.save-card-container {
  margin: 1rem 0;
  text-align: center;
}

.save-card-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.save-card-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.save-card-form {
  margin-top: 1rem;
}

.save-card-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.save-card-input {
  padding: 10px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 14px;
  min-width: 200px;
  transition: border-color 0.3s ease;
}

.save-card-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.save-card-confirm {
  background: #28a745;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.save-card-confirm:hover {
  background: #218838;
}

.save-card-cancel {
  background: #6c757d;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.save-card-cancel:hover {
  background: #5a6268;
}

.save-error-message {
  color: #dc3545;
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

.save-success-message {
  color: #28a745;
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
  font-weight: 600;
}

/* Expandable Saved Cards Section */
.saved-cards-expandable {
  background: linear-gradient(145deg, #f8f9ff 0%, #e8ecff 100%);
  border: 1px solid #e1e8ff;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.saved-cards-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.3s ease;
}

.saved-cards-header:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.saved-cards-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clear-all-button {
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-all-button:hover {
  background: rgba(220, 53, 69, 1);
  transform: scale(1.05);
}

.expand-icon {
  font-size: 16px;
  transition: transform 0.3s ease;
}

.expand-icon.expanded {
  transform: rotate(180deg);
}

.saved-cards-content {
  padding: 20px;
  background: white;
}

/* Individual Saved Card Items */
.saved-card-item {
  background: linear-gradient(145deg, #ffffff 0%, #f8f9ff 100%);
  border: 1px solid #e8ecff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.saved-card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.saved-card-item:last-child {
  margin-bottom: 0;
}

.saved-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8ecff;
}

.saved-card-name {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.delete-card-button {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.delete-card-button:hover {
  background: #c82333;
  transform: scale(1.05);
}

.saved-card-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-card-field label {
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.saved-card-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fa;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: #2c3e50;
  border: 1px solid #e9ecef;
}

.eye-button {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.eye-button:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.eye-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.eye-icon {
  width: 1rem;
  height: 1rem;
  transition: all 0.2s ease;
}

.saved-card-qr {
  margin: 12px 0;
  display: flex;
  justify-content: center;
}

.use-card-button {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.use-card-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
  background: linear-gradient(135deg, #218838 0%, #1ba085 100%);
}

/* Dark theme styles */
[data-theme="dark"] .saved-cards-expandable {
  background: linear-gradient(145deg, #2c3e50 0%, #34495e 100%);
  border-color: #4a5568;
}

[data-theme="dark"] .saved-cards-content {
  background: #2d3748;
}

[data-theme="dark"] .saved-card-item {
  background: linear-gradient(145deg, #2d3748 0%, #374151 100%);
  border-color: #4a5568;
}

[data-theme="dark"] .saved-card-name {
  color: #e2e8f0;
  background: linear-gradient(135deg, #81c784 0%, #64b5f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .saved-card-field label {
  color: #a0aec0;
}

[data-theme="dark"] .saved-card-value {
  background: #4a5568;
  color: #e2e8f0;
}

/* Responsive Design */
@media (min-width: 768px) {
  .app-container {
    max-width: 36rem;
    padding: 2rem;
  }

  .input-section {
    padding: 2rem;
  }

  .disclaimer {
    padding: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .app-container {
    max-width: 42rem;
    padding: 2.5rem;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 1rem;
    max-width: 100%;
  }

  .disclaimer {
    margin-top: 3rem;
    padding: 0.75rem;
    font-size: 0.8125rem;
  }

  .input-section {
    padding: 1rem;
  }

  .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.5rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}