/* Root Variables & Modern Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #6366F1;
  --secondary: #94A3B8;
  --bg-dark: #0F172A;
  --bg-card: rgba(30, 41, 59, 0.7);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --success: #22C55E;
  --error: #EF4444;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Glassmorphism Classes */
.glass {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
}

/* Navigation */
nav {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 5%;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--glass-border);
}

nav .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 1rem 2rem;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #818CF8, #C084FC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--text-muted);
}

/* Product Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 2rem 5% 5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.product-card {
  border-radius: 1.5rem;
  overflow: hidden;
  transition: var(--transition);
  position: relative;
  text-align: center;
}

.product-image {
  width: 100%;
  height: 200px;
  object-fit: contain;
  margin-top: 1rem;
  padding: 1rem;
  transition: var(--transition);
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

.product-card:hover {
  transform: translateY(-10px);
  border-color: var(--primary);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.product-info {
  padding: 2.5rem;
}

.product-tag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary);
  margin-bottom: 1rem;
  opacity: 0.8;
}

.product-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.product-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.product-price {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1.5rem;
}

.buy-btn {
  width: 100%;
  padding: 1.25rem;
  border: none;
  border-radius: 1rem;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.buy-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Payment Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 3rem;
  border-radius: 2.5rem;
  position: relative;
  text-align: center;
  animation: modalEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.close-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height:1;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 1rem 0 2rem;
}

.modal-input {
  width: 100%;
  padding: 1.25rem;
  border-radius: 1rem;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: white;
  font-size: 1rem;
  margin-bottom: 1.5rem;
  outline: none;
}

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

#qr-container {
  background: white;
  padding: 1rem;
  border-radius: 1.5rem;
  display: inline-block;
  margin: 2rem 0;
  min-width: 200px;
  min-height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#amount-display {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

#status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.order-info {
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  font-family: monospace;
  font-size: 0.8rem;
}

.order-info .label { color: var(--text-muted); }
.order-info #orderIdDisp { color: var(--primary); font-weight: 700; margin-left: 0.5rem;}

.primary-btn, .secondary-btn {
  width: 100%;
  padding: 1.25rem;
  border-radius: 1rem;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.primary-btn {
  background: var(--primary);
  color: white;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  margin: 0 auto 2rem;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 480px) {
  .hero h1 { font-size: 2.5rem; }
  .modal-card { padding: 2rem; }
}

/* --- NEW PAYMENT MODAL STYLES --- */
#payment-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none; /* Controlled by JS */
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#modal-card {
  background: white;
  color: #1e293b;
  width: 90%;
  max-width: 400px;
  padding: 24px;
  border-radius: 12px;
  position: relative;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#loading-state {
  padding: 40px 0;
}

#qr-container {
  margin: 16px auto;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#amount-display {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  margin: 8px 0;
}

#breakdown {
  font-size: 14px;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
  margin-top: 16px;
  text-align: left;
}

#breakdown p {
  margin: 4px 0;
  display: flex;
  justify-content: space-between;
}

#expiry-timer {
  font-size: 14px;
  color: #f59e0b; /* Amber */
  font-weight: 500;
  margin-top: 8px;
}

#status-text {
  font-size: 14px;
  color: #64748b;
  margin-top: 4px;
}

#success-state p {
  color: #10b981; /* Green */
  font-weight: 700;
  font-size: 1.25rem;
  padding: 24px 0;
}

#expired-state p, #error-state p {
  color: #ef4444; /* Red */
  font-weight: 500;
  padding: 24px 0;
}

#modal-card > button {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s;
}

#modal-card > button:hover {
  color: #475569;
}

/* Mobile responsive refinements */
@media (max-width: 480px) {
  #modal-card {
    padding: 20px;
    width: 95%;
  }
  #amount-display {
    font-size: 22px;
  }
}
