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

body {
  font-family: var(--font-family);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  scroll-behavior: smooth;
  padding-bottom: 80px; /* Space for sticky bar */
  overflow-x: hidden;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Typography */
h1, h2, h3, h4, h5, h6 { margin-bottom: var(--space-sm); }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font-family); border: none; cursor: pointer; outline: none; }
input, select, textarea { font-family: var(--font-family); }

/* Utility */
.section {
  background: var(--bg-card);
  margin-top: var(--space-sm);
  padding: var(--space-md);
  overflow: hidden;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}
img {
  max-width: 100%;
  height: auto;
}

/* Flash Sale Banner */
.flash-sale-bar {
  background: var(--primary-gradient);
  color: var(--text-white);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}
.countdown {
  background: rgba(0,0,0,0.2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 15px;
}
.countdown.flash {
  animation: countdown-flash 1s infinite alternate;
}

/* Image Carousel */
.carousel {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f5f5f5;
}
.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease-out;
}
.carousel-slide,
.carousel-item {
  min-width: 100%;
  width: 100%;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}
.carousel-slide img,
.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f0f0f0;
}
.carousel-counter {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(0,0,0,0.5);
  color: var(--text-white);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  z-index: 5;
}
.carousel-dots {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99 !important;
  pointer-events: auto !important;
  touch-action: manipulation;
  transition: all 0.2s ease;
  user-select: none;
  outline: none;
  backdrop-filter: blur(4px);
  padding-bottom: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.carousel-btn:hover, .carousel-btn:active {
  background: rgba(0, 0, 0, 0.75);
  transform: translateY(-50%) scale(1.1);
  border-color: #ffffff;
}
.carousel-prev {
  left: 10px;
}
.carousel-next {
  right: 10px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: all 0.3s ease;
  cursor: pointer;
}
.dot.active {
  background: var(--primary);
  width: 16px;
  border-radius: 4px;
}

/* Carousel Navigation Arrows */
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: #333;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  line-height: 1;
}
.carousel-arrow:hover { background: #fff; }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}
.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  padding: 16px;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}
.lightbox-overlay.active .lightbox-content img {
  transform: scale(1);
}
.lightbox-counter {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}
.lightbox-caption {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-align: center;
  margin-top: 6px;
  max-width: 90%;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }

/* Product Gallery */
.gallery-section {
  background: var(--bg-card);
  overflow: hidden;
}
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  overflow: hidden;
}
.gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f8f8f8;
  box-shadow: var(--shadow-sm);
  width: 100%;
}
.gallery-item img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
  transition: transform 0.3s;
}
.gallery-item img:active {
  transform: scale(0.98);
}
.gallery-caption {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: linear-gradient(135deg, #f0f8f6, #fff);
  border-top: 1px solid var(--border-light);
  line-height: 1.4;
}

/* Trust Badges */
.trust-section {
  background: var(--bg-card);
}
.trust-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.trust-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #f0f8f6, #e8f4f0);
  padding: 14px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(45, 122, 107, 0.1);
}
.trust-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.trust-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Product Info */
.product-info {
  background: var(--bg-card);
  padding: var(--space-md);
}
.price-section {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.price-current {
  color: var(--text-price);
  font-size: 28px;
  font-weight: 800;
}
.price-original {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 14px;
}
.discount-badge {
  background: var(--primary);
  color: var(--text-white);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.product-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}
.rating .stars {
  color: #FFB800;
  margin-right: 4px;
}
.live-viewers {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(45, 122, 107, 0.1);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: #E8A838;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}
.feature-card {
  background: var(--bg-secondary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.feature-icon {
  font-size: 24px;
  margin-bottom: var(--space-sm);
}
.feature-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.feature-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Reviews */
.review-card {
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) 0;
}
.review-card:last-child {
  border-bottom: none;
}
.review-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.reviewer-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-white);
  font-weight: 600;
  font-size: 14px;
}
.reviewer-info {
  flex: 1;
}
.reviewer-name {
  font-size: 14px;
  font-weight: 600;
}
.review-date {
  font-size: 12px;
  color: var(--text-muted);
}
.review-stars {
  color: #FFB800;
  font-size: 12px;
}
.review-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Product Description */
.product-description {
  font-size: 14px;
  line-height: 1.6;
}
.product-description img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: var(--space-sm) 0;
}

/* Sticky Bottom Bar */
.sticky-bottom {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
}
.bottom-product-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  overflow: hidden;
}
.bottom-product-info img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.bottom-product-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.bottom-product-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}
.btn-buy-now {
  background: var(--primary-gradient);
  color: var(--text-white);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow-glow);
  animation: pulse-button 2s infinite;
  white-space: nowrap;
}

/* Modal Overlay */
.modal-overlay, .success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active, .success-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: var(--bg-primary);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-md);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.modal-overlay.active .modal-content {
  transform: translateY(0);
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-md);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}
.modal-close {
  background: none;
  font-size: 24px;
  color: var(--text-secondary);
}
.modal-body {
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Order Summary inside Modal */
.order-product-summary {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}
.order-product-summary img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
}
.order-product-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.order-product-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}
.quantity-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.qty-btn {
  background: var(--bg-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-primary);
}
.qty-value {
  width: 40px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

/* Form Styles */
.form-group {
  margin-bottom: var(--space-md);
  position: relative;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 16px; /* Prevents iOS zoom */
  background: var(--bg-secondary);
  transition: border-color 0.3s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  background: var(--bg-primary);
}
.form-group input.invalid, .form-group select.invalid {
  border-color: var(--primary);
}
.error-msg {
  color: var(--primary);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}
.error-msg.active {
  display: block;
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  margin: var(--space-lg) 0 var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}
.total-amount {
  color: var(--primary);
  font-size: 20px;
}
.payment-method {
  background: rgba(45, 122, 107, 0.05);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: var(--space-lg);
  border: 1px dashed rgba(45, 122, 107, 0.3);
}
.btn-submit-order {
  width: 100%;
  background: var(--primary-gradient);
  color: var(--text-white);
  padding: 16px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--shadow-glow);
  display: flex;
  justify-content: center;
  align-items: center;
}
.btn-submit-order:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-right: 8px;
}

/* Success Modal */
.success-overlay {
  align-items: center;
}
.success-content {
  background: var(--bg-primary);
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.success-overlay.active .success-content {
  transform: scale(1);
}
.success-checkmark {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
}
.success-checkmark svg circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.success-checkmark svg path {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}
.success-content h2 {
  color: #4CAF50;
  margin-bottom: var(--space-sm);
}
.success-content p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}
.success-order-info {
  background: var(--bg-secondary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 14px;
  margin-bottom: var(--space-lg);
}
.success-order-info div {
  margin-bottom: 8px;
}
.success-order-info div:last-child {
  margin-bottom: 0;
}
.btn-continue {
  background: var(--primary);
  color: var(--text-white);
  padding: 14px 24px;
  border-radius: var(--radius-full);
  font-weight: 600;
  width: 100%;
}

/* Notifications Container */
.notifications-container {
  position: fixed;
  bottom: 80px; /* Above sticky bar */
  right: var(--space-md);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}
.toast-notification {
  background: rgba(0,0,0,0.8);
  color: var(--text-white);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  max-width: 250px;
}
.toast-notification.hide {
  animation: fadeOut 0.3s ease forwards;
}
.toast-avatar {
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
}

/* Animations */
@keyframes pulse-button {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(45, 122, 107, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(45, 122, 107, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(45, 122, 107, 0); }
}
@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(232, 168, 56, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(232, 168, 56, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(232, 168, 56, 0); }
}
@keyframes countdown-flash {
  from { color: inherit; }
  to { color: var(--text-price); }
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}
@keyframes stroke {
  100% { stroke-dashoffset: 0; }
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(10px); }
}
