/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --accent: #f97316;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --bg: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: .25s ease;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ========== Header ========== */
.header { background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 22px; font-weight: 800; text-decoration: none; color: var(--text); }
.logo span { color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 16px; }

/* Search */
.search-box { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 24px; overflow: hidden; }
.search-box input { border: none; background: transparent; padding: 8px 16px; width: 200px; font-size: 14px; outline: none; color: var(--text); }
.search-box button { border: none; background: transparent; padding: 8px 14px 8px 0; cursor: pointer; color: var(--text-light); }
.search-box button:hover { color: var(--primary); }

/* Cart Button */
.cart-btn { position: relative; border: none; background: var(--bg); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; color: var(--text); transition: var(--transition); }
.cart-btn:hover { background: var(--primary-light); color: var(--primary); }
.cart-count { position: absolute; top: -4px; right: -4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ========== Category Nav ========== */
.category-nav { background: var(--white); border-bottom: 1px solid var(--border); overflow-x: auto; }
.category-nav ul { display: flex; list-style: none; gap: 0; }
.category-nav li { padding: 12px 20px; cursor: pointer; font-size: 14px; color: var(--text-light); white-space: nowrap; border-bottom: 2px solid transparent; transition: var(--transition); }
.category-nav li:hover { color: var(--primary); }
.category-nav li.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ========== Banner ========== */
.banner { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%); color: #fff; padding: 60px 0; position: relative; overflow: hidden; }
.banner-slider { position: relative; min-height: 120px; }
.banner-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; display: flex; align-items: center; }
.banner-slide.active { opacity: 1; position: relative; }
.banner-content h2 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.banner-content p { font-size: 16px; opacity: .9; margin-bottom: 20px; }
.btn-primary { border: none; background: #fff; color: var(--primary); padding: 10px 28px; border-radius: 24px; font-size: 15px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.banner-dots { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.banner-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.4); cursor: pointer; transition: var(--transition); }
.banner-dot.active { background: #fff; width: 24px; border-radius: 4px; }

/* ========== Main / Products ========== */
.main { padding: 32px 0 60px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-header h2 { font-size: 22px; font-weight: 700; }
.sort-options { display: flex; gap: 4px; }
.sort-btn { padding: 6px 14px; border-radius: 20px; font-size: 13px; cursor: pointer; color: var(--text-light); transition: var(--transition); }
.sort-btn:hover { color: var(--primary); background: var(--primary-light); }
.sort-btn.active { background: var(--primary); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.product-card { background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: var(--transition); cursor: pointer; }
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.product-img { width: 100%; height: 200px; display: flex; align-items: center; justify-content: center; font-size: 56px; position: relative; }
.product-img .badge { position: absolute; top: 10px; left: 10px; background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.product-info { padding: 16px; }
.product-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-desc { font-size: 12px; color: var(--text-lighter); margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.product-bottom { display: flex; align-items: center; justify-content: space-between; }
.product-price { font-size: 20px; font-weight: 700; color: #ef4444; }
.product-price .symbol { font-size: 13px; }
.product-price .original { font-size: 12px; color: var(--text-lighter); text-decoration: line-through; margin-left: 6px; font-weight: 400; }
.product-sales { font-size: 12px; color: var(--text-lighter); }
.btn-add { border: none; background: var(--primary); color: #fff; padding: 6px 16px; border-radius: 20px; font-size: 13px; cursor: pointer; font-weight: 600; transition: var(--transition); }
.btn-add:hover { background: var(--primary-dark); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-lighter); }
.empty-state svg { margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }
.btn-outline { border: 1px solid var(--primary); background: transparent; color: var(--primary); padding: 8px 24px; border-radius: 24px; cursor: pointer; font-size: 14px; transition: var(--transition); }
.btn-outline:hover { background: var(--primary-light); }

/* ========== Cart Sidebar ========== */
.cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; opacity: 0; visibility: hidden; transition: var(--transition); }
.cart-overlay.open { opacity: 1; visibility: visible; }
.cart-sidebar { position: fixed; top: 0; right: 0; width: 380px; max-width: 100%; height: 100vh; background: var(--white); z-index: 201; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .3s ease; box-shadow: var(--shadow-lg); }
.cart-sidebar.open { transform: translateX(0); }
.cart-header { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--border); }
.cart-header h3 { font-size: 18px; }
.cart-close { border: none; background: none; cursor: pointer; color: var(--text-light); padding: 4px; }
.cart-close:hover { color: var(--text); }
.cart-items { flex: 1; overflow-y: auto; padding: 16px; }
.cart-empty { text-align: center; padding: 60px 20px; color: var(--text-lighter); }
.cart-empty p { margin-top: 12px; }
.cart-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item-icon { width: 50px; height: 50px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 14px; color: #ef4444; font-weight: 600; }
.cart-item-qty { display: flex; align-items: center; gap: 4px; }
.cart-item-qty button { width: 26px; height: 26px; border: 1px solid var(--border); background: var(--white); border-radius: 50%; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; color: var(--text); transition: var(--transition); }
.cart-item-qty button:hover { border-color: var(--primary); color: var(--primary); }
.cart-item-qty span { width: 30px; text-align: center; font-size: 14px; }
.cart-item-del { border: none; background: none; cursor: pointer; color: var(--text-lighter); font-size: 18px; padding: 4px; }
.cart-item-del:hover { color: #ef4444; }
.cart-footer { padding: 20px; border-top: 1px solid var(--border); }
.cart-total { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cart-total-price { font-size: 24px; font-weight: 700; color: #ef4444; }
.btn-checkout { width: 100%; border: none; background: var(--primary); color: #fff; padding: 14px; border-radius: var(--radius-sm); font-size: 16px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.btn-checkout:hover { background: var(--primary-dark); }

/* ========== Toast ========== */
.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px); background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 24px; font-size: 14px; z-index: 300; opacity: 0; visibility: hidden; transition: all .3s ease; white-space: nowrap; }
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ========== Footer ========== */
.footer { background: var(--white); border-top: 1px solid var(--border); padding: 24px 0; text-align: center; }
.footer p { color: var(--text-lighter); font-size: 13px; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px; }
  .search-box input { width: 140px; }
  .banner { padding: 40px 0; }
  .banner-content h2 { font-size: 24px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .product-img { height: 150px; font-size: 40px; }
  .section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .cart-sidebar { width: 100%; }
}

/* ========== Animations ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.product-card { animation: fadeInUp .4s ease both; }
