/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #6c47ff;
  --primary-dark: #5535e0;
  --accent: #ff6b35;
  --bg: #f8f7ff;
  --surface: #ffffff;
  --border: #e8e4ff;
  --text: #1a1a2e;
  --muted: #7b7a99;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 2px 16px rgba(108,71,255,0.08);
  --shadow-hover: 0 8px 32px rgba(108,71,255,0.16);
}
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: -0.5px;
}
.brand-icon { font-size: 1.5rem; }
.nav-links { display: flex; align-items: center; gap: 0.5rem; }
.nav-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--primary); }
.cart-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.cart-btn:hover { background: var(--primary-dark); }
.cart-badge {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* ── Main & Pages ── */
.main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #a78bff 100%);
  color: white;
  border-radius: var(--radius);
  padding: 3rem 2rem;
  margin-bottom: 2rem;
  text-align: center;
}
.hero h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 0.5rem; }
.hero p { font-size: 1.1rem; opacity: 0.85; }

/* ── Filters ── */
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Products Grid ── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.25rem;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}
.product-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
.product-card-body { padding: 1rem; }
.product-category {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.3rem;
}
.product-card-body h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.product-card-body p { font-size: 0.83rem; color: var(--muted); margin-bottom: 0.75rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-footer { display: flex; align-items: center; justify-content: space-between; }
.price { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.btn-add {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-add:hover { background: var(--primary-dark); }

/* ── Product Detail ── */
.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  display: block;
}
.product-detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}
.product-detail-layout img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.detail-info h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem; }
.detail-category { color: var(--primary); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; margin-bottom: 0.75rem; }
.detail-desc { color: var(--muted); line-height: 1.6; margin-bottom: 1.5rem; }
.detail-price { font-size: 2rem; font-weight: 800; color: var(--primary); margin-bottom: 1.5rem; }
.qty-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.qty-ctrl { display: flex; align-items: center; gap: 0.5rem; background: var(--bg); border-radius: 8px; padding: 0.25rem; }
.qty-ctrl button { width: 32px; height: 32px; border: none; border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 1rem; font-weight: 700; transition: background 0.15s; }
.qty-ctrl button:hover { background: var(--primary); color: white; }
.qty-ctrl span { width: 32px; text-align: center; font-weight: 700; }
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-block;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-large { width: 100%; text-align: center; padding: 1rem; font-size: 1.05rem; margin-top: 1rem; }
.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 0.75rem 1.75rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-block;
  width: 100%;
  text-align: center;
}
.btn-secondary:hover { background: var(--primary); color: white; }

/* ── Cart ── */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; align-items: start; }
.cart-item {
  display: flex;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  align-items: center;
}
.cart-item img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.cart-item-info { flex: 1; }
.cart-item-info h4 { font-weight: 700; margin-bottom: 0.25rem; }
.cart-item-info .price { font-size: 1rem; }
.cart-item-qty { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.cart-item-qty button { width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; font-weight: 700; }
.cart-item-qty span { font-weight: 600; }
.cart-remove { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 1.2rem; padding: 0.25rem; }
.cart-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: sticky;
  top: 80px;
}
.cart-summary h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; }
.summary-row { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.6rem; color: var(--muted); }
.summary-row.total { font-weight: 800; color: var(--text); font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 0.75rem; margin-top: 0.5rem; }
.cart-empty { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.cart-empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── Checkout ── */
.checkout-layout { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; align-items: start; }
.checkout-form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.checkout-form-wrap h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; }
.form-group input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border 0.15s;
  background: var(--bg);
}
.form-group input:focus { border-color: var(--primary); background: white; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.demo-note { font-size: 0.78rem; color: var(--muted); margin-top: 0.75rem; text-align: center; }
.checkout-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: sticky;
  top: 80px;
}
.checkout-summary h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; }
.checkout-item { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.checkout-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.checkout-item-info { flex: 1; font-size: 0.85rem; }
.checkout-item-info strong { display: block; font-weight: 600; }

/* ── Confirm ── */
.confirm-box {
  max-width: 480px;
  margin: 4rem auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  box-shadow: var(--shadow);
}
.confirm-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.confirm-box h2 { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.75rem; }
.confirm-box p { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Analytics ── */
.analytics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.stat-card .value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.analytics-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.panel h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; }
.panel-row { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.panel-row:last-child { border-bottom: none; }
.panel-row .count { font-weight: 700; color: var(--primary); background: var(--bg); padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.8rem; }
.events-table { overflow-x: auto; }
.events-table table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.events-table th { text-align: left; padding: 0.6rem 0.75rem; background: var(--bg); font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 0.73rem; letter-spacing: 0.05em; }
.events-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.event-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag-api_request { background: #e0f2fe; color: #0369a1; }
.tag-product_view { background: #fef3c7; color: #b45309; }
.tag-purchase { background: #dcfce7; color: #15803d; }
.tag-add_to_cart { background: #ede9fe; color: #7c3aed; }
.tag-page_view { background: #fce7f3; color: #be185d; }

/* ── Utility ── */
.loading { text-align: center; padding: 3rem; color: var(--muted); font-size: 1rem; }
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-weight: 500;
  z-index: 999;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 768px) {
  .product-detail-layout, .cart-layout, .checkout-layout, .analytics-panels { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.5rem; }
}