/* ============================
   Design Tokens
   ============================ */
:root {
  --white: #ffffff;
  --bg: #f0f4ff;
  --bg-card: #ffffff;
  --bg-input: #f5f7ff;
  --border: #e2e8f5;
  --border-focus: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-label: #64748b;

  --brand: #6366f1;
  --brand-light: #818cf8;
  --brand-dark: #4f46e5;
  --brand-bg: #eef2ff;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info-color: #1d4ed8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(99, 102, 241, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 48px rgba(99, 102, 241, 0.14), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 8px 32px rgba(99, 102, 241, 0.12);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-title: 'Outfit', sans-serif;
}

/* ============================
   Reset
   ============================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  position: relative;
  overflow-x: hidden;
}

/* ============================
   Background Blobs
   ============================ */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #c7d2fe, #a5b4fc);
  top: -200px;
  right: -100px;
  animation: blobFloat 12s ease-in-out infinite;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #bbf7d0, #86efac);
  bottom: -150px;
  left: -100px;
  animation: blobFloat 15s ease-in-out infinite reverse;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #fde68a, #fcd34d);
  top: 40%;
  left: 50%;
  animation: blobFloat 10s ease-in-out infinite alternate;
  opacity: 0.25;
}

@keyframes blobFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -20px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 30px) scale(0.97);
  }
}

/* ============================
   Layout
   ============================ */
.page-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1040px;
}

/* ============================
   Header
   ============================ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.logo-text {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.header-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-bg);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #c7d2fe;
  letter-spacing: 0.5px;
}

/* ============================
   Main Card
   ============================ */
.main-card {
  background: var(--bg-card);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(99, 102, 241, 0.08);
  overflow: hidden;
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-card-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 560px;
}

/* ============================
   Input Panel (Left)
   ============================ */
.input-panel {
  padding: 44px 40px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.panel-header {
  margin-bottom: 32px;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.panel-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.form-section {
  flex: 1;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.form-label svg {
  color: var(--brand);
}

.label-optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Input */
.input-wrapper {
  position: relative;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 44px 13px 15px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.form-input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.form-input:focus {
  border-color: var(--border-focus);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-input.is-error {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.08);
}

.input-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.input-clear:hover {
  opacity: 0.7;
}

.input-clear svg {
  width: 18px;
  height: 18px;
}

/* Merchant search */
.select-wrapper {
  position: relative;
}

.search-input-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  padding-left: 38px;
}

.merchant-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: #c7d2fe transparent;
}

.merchant-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f1f5f9;
}

.merchant-option:last-child {
  border-bottom: none;
}

.merchant-option:hover {
  background: var(--brand-bg);
  color: var(--brand);
}

.merchant-empty {
  color: var(--text-muted);
  font-style: italic;
}

.merchant-option-icon {
  font-size: 15px;
}

.selected-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 12px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--success);
}

.tag-remove {
  background: none;
  border: none;
  color: #86efac;
  cursor: pointer;
  font-size: 13px;
  margin-left: auto;
  padding: 0 2px;
  transition: color 0.15s;
}

.tag-remove:hover {
  color: var(--error);
}

/* Alert */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
}

.alert.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.alert.info {
  background: var(--info-bg);
  color: var(--info-color);
  border: 1px solid var(--info-border);
}

/* Submit button */
.submit-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
  animation: fadeInUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-loader {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Support badges */
.support-badges {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.support-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.support-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-blue {
  background: #3b82f6;
}

.dot-green {
  background: #22c55e;
}

.dot-purple {
  background: #a855f7;
}

/* ============================
   Result Panel (Right)
   ============================ */
.result-panel {
  background: linear-gradient(160deg, #f8faff 0%, #eef2ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 36px;
}

/* Empty state */
.result-empty {
  text-align: center;
}

.empty-graphic {
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
}

.empty-card-visual {
  width: 200px;
  height: 126px;
  background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 50%, #818cf8 100%);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.25);
  position: relative;
  overflow: hidden;
}

.empty-card-visual::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

.card-chip {
  width: 28px;
  height: 22px;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  border-radius: 5px;
  margin-bottom: 10px;
}

.card-line {
  height: 6px;
  width: 80%;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  margin-bottom: 6px;
}

.card-line.short {
  width: 50%;
}

.card-num-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 2px;
  margin-top: auto;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Success state */
.result-success {
  width: 100%;
  animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Virtual Card */
.virtual-card {
  border-radius: 18px;
  padding: 22px 24px 20px;
  color: white;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  min-height: 170px;
  display: flex;
  flex-direction: column;
}

.virtual-card::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.virtual-card::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}

.vc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.vc-source {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
}

.vc-product {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  opacity: 0.9;
}

.vc-number {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 3px;
  margin-bottom: 18px;
  flex: 1;
  display: flex;
  align-items: center;
  word-break: break-all;
}

.vc-footer {
  display: flex;
  gap: 24px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.vc-field-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 3px;
}

.vc-field-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

/* Color themes for virtual card */
.vc-indigo {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #3730a3 100%);
}

.vc-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
}

.vc-rose {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be123c 100%);
}

.vc-amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
}

.vc-sky {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.detail-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  transition: var(--transition);
}

.detail-item:hover {
  border-color: #c7d2fe;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

.detail-item.full {
  grid-column: 1 / -1;
}

.di-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.di-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.di-value.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.di-value.highlight {
  color: var(--brand);
}

.di-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
  flex-shrink: 0;
  margin-left: 8px;
}

.copy-btn:hover {
  background: var(--brand-bg);
  color: var(--brand);
}

/* Copy all button */
.copy-all-btn {
  width: 100%;
  padding: 11px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.copy-all-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-bg);
}

/* ============================
   Footer
   ============================ */
.site-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* open-card-action */
.open-card-action {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.open-hint {
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.open-hint::before {
  content: '💳';
}

/* history-banner */
.history-banner {
  grid-column: 1 / -1;
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
}

/* ============================
   Animations
   ============================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.spin {
  animation: spinAnim 1s linear infinite;
}

@keyframes spinAnim {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
  .main-card-inner {
    grid-template-columns: 1fr;
  }

  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 28px 24px;
  }

  .result-panel {
    padding: 28px 24px;
  }

  .site-header {
    margin-bottom: 20px;
  }

  .panel-title {
    font-size: 24px;
  }

  .header-badge {
    display: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
