:root {
  --primary: #005bff;
  --primary-dark: #0047cc;
  --primary-light: #e8f1ff;
  --accent: #f91155;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #001a34;
  --text-muted: #6b7c93;
  --border: #e5e9f0;
  --success: #00a046;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 26, 52, 0.08);
  --header-h: 64px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 91, 255, 0.3);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
}
.logo span { color: #ffdd57; }

.search-box {
  flex: 1;
  max-width: 600px;
  display: flex;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.search-box input {
  flex: 1;
  border: none;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
}

.search-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-btn {
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0.95;
  transition: opacity 0.2s;
  background: none;
  border: none;
}
.header-btn:hover { opacity: 1; }
.header-btn .icon { font-size: 22px; }

.cart-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cart-wrap { position: relative; }

/* Main layout */
.main { max-width: 1280px; margin: 0 auto; padding: 20px; min-height: calc(100vh - var(--header-h) - 120px); }

/* Hero banner */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7b2ff7 100%);
  border-radius: var(--radius);
  padding: 48px;
  color: #fff;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.hero h1 { font-size: 2.2rem; margin-bottom: 12px; }
.hero p { opacity: 0.9; font-size: 1.1rem; margin-bottom: 20px; }
.hero-btn {
  background: #fff;
  color: var(--primary);
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
}
.hero-emoji { font-size: 120px; opacity: 0.3; position: absolute; right: 40px; }

/* Categories */
.categories-bar {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  scrollbar-width: thin;
}

.cat-chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  white-space: nowrap;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cat-chip:hover, .cat-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Section */
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title a { font-size: 14px; font-weight: 500; }

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.product-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f0f2f5;
}

.product-body { padding: 12px; }

.product-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.product-old-price {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 6px;
}
.product-discount {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.product-title {
  font-size: 14px;
  margin: 8px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  min-height: 2.8em;
}

.product-rating {
  font-size: 13px;
  color: var(--text-muted);
}
.product-rating .stars { color: #ffa500; }

.btn-add-cart {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-add-cart:hover { background: var(--primary); color: #fff; }

/* Product detail */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 32px;
}

.product-detail-img {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 1;
  object-fit: cover;
  background: #f0f2f5;
}

.product-detail-info h1 { font-size: 1.6rem; margin-bottom: 12px; }
.product-detail-info .price-block { margin: 20px 0; }
.product-detail-info .desc { color: var(--text-muted); margin: 20px 0; line-height: 1.7; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}
.qty-control button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
}
.qty-control span { font-size: 18px; font-weight: 600; min-width: 30px; text-align: center; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #d90e48; }

/* Filters sidebar */
.catalog-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

.filters {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: calc(var(--header-h) + 20px);
}

.filters h3 { margin-bottom: 16px; font-size: 16px; }
.filter-group { margin-bottom: 20px; }
.filter-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.filter-group input, .filter-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

/* Cart */
.cart-page, .checkout-page, .account-page, .admin-page {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
}

.cart-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.cart-item img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.cart-item-info { flex: 1; }
.cart-item-actions { display: flex; align-items: center; gap: 16px; }
.cart-summary {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-total { font-size: 1.5rem; font-weight: 700; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.form-group input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }

.auth-box {
  max-width: 420px;
  margin: 40px auto;
  background: var(--card);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-box h2 { text-align: center; margin-bottom: 24px; }
.auth-tabs { display: flex; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.auth-tab.active { color: var(--primary); border-color: var(--primary); }

/* Orders */
.order-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.order-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.order-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-paid { background: #cce5ff; color: #004085; }
.status-shipped { background: #d4edda; color: #155724; }
.status-delivered { background: #d1ecf1; color: #0c5460; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* Admin */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--primary-light);
  padding: 20px;
  border-radius: var(--radius);
}
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { color: var(--text-muted); font-size: 14px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--bg); font-weight: 600; }
.admin-table img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 24px 0;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
}
.pagination button.active, .pagination button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Footer */
.footer {
  background: var(--text);
  color: rgba(255,255,255,0.7);
  padding: 40px 20px;
  margin-top: 40px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 32px;
}
.footer h4 { color: #fff; margin-bottom: 12px; }
.footer a { color: rgba(255,255,255,0.7); display: block; margin-bottom: 8px; font-size: 14px; }
.footer a:hover { color: #fff; }
.footer-bottom { text-align: center; margin-top: 32px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 14px 24px;
  border-radius: 8px;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--accent); }

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

/* Loading */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 64px; margin-bottom: 16px; }

/* Responsive */
@media (max-width: 768px) {
  .product-detail { grid-template-columns: 1fr; }
  .catalog-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .hero { padding: 24px; }
  .hero h1 { font-size: 1.5rem; }
  .hero-emoji { display: none; }
  .header-inner { gap: 10px; }
  .search-box { display: none; }
}

.hidden { display: none !important; }
