@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── CSS Variables ─── */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-input: rgba(15, 23, 42, 0.9);
  --border-color: rgba(99, 102, 241, 0.15);
  --border-hover: rgba(99, 102, 241, 0.4);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --gradient-2: linear-gradient(135deg, #0a0e1a 0%, #1e1b4b 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

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

/* ─── Layout ─── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Navbar ─── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-logo {
  width: 40px;
  height: 40px;
  background: var(--gradient-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  box-shadow: var(--shadow-glow);
}

.navbar-title {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.nav-link.active {
  border-color: var(--accent);
  color: var(--accent);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.sandbox {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.live {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.stat-value.success { color: var(--success); }
.stat-value.error { color: var(--error); }
.stat-value.accent { color: var(--accent); }

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Main Layout ─── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 968px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Card Component ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 18px;
}

.card-body {
  padding: 24px;
}

/* ─── Form Styles ─── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

.form-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

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

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--gradient-1);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
}

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

.btn-full {
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-ghost.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ─── Spinner ─── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn.loading .spinner {
  display: inline-block;
}

.btn.loading .btn-text {
  display: none;
}

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

/* ─── Result Box ─── */
.result-box {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: none;
  animation: slideIn 0.3s ease;
}

.result-box.show {
  display: block;
}

.result-box.success {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.result-box.error {
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.result-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  font-family: 'JetBrains Mono', monospace;
}

.result-detail strong {
  color: var(--text-primary);
  font-weight: 500;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Recent Transactions (sidebar) ─── */
.tx-list {
  list-style: none;
}

.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 15px;
}

.tx-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tx-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tx-status.completed {
  background: var(--success-bg);
  color: var(--success);
}

.tx-status.failed,
.tx-status.error {
  background: var(--error-bg);
  color: var(--error);
}

/* ─── History Page — Table ─── */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.05);
  white-space: nowrap;
}

.data-table tr:hover td {
  background: rgba(99, 102, 241, 0.03);
}

.data-table .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ─── Filter Bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px 10px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='M21 21l-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-buttons {
  display: flex;
  gap: 6px;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 300px;
  margin: 0 auto;
}

/* ─── Config Warning ─── */
.config-warning {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideIn 0.3s ease;
}

.config-warning .icon {
  font-size: 20px;
  flex-shrink: 0;
}

.config-warning .text {
  font-size: 13px;
  color: var(--warning);
  line-height: 1.6;
}

.config-warning .text strong {
  font-weight: 600;
}

/* ─── Utilities ─── */
.hidden { display: none !important; }
.mb-0 { margin-bottom: 0; }
.mt-12 { margin-top: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app-container {
    padding: 0 16px;
  }

  .navbar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table td, .data-table th {
    padding: 10px 12px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .navbar-nav {
    width: 100%;
    justify-content: center;
  }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ─── Card Number Visual ─── */
.card-visual {
  background: linear-gradient(135deg, #1e1b4b, #312e81, #4338ca);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-visual::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.card-visual .card-chip {
  width: 40px;
  height: 30px;
  background: linear-gradient(135deg, #d4a574, #c4956a);
  border-radius: 6px;
  margin-bottom: 16px;
}

.card-visual .card-number-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 16px;
}

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

.card-visual .card-name-display {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
}

.card-visual .card-expiry-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.card-visual .card-brand-logo {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 24px;
  opacity: 0.7;
}
