:root {
  --blue: #4f8cff;
  --blue-dark: #3a6fd8;
  --blue-light: #e8f0fe;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ====== Header ====== */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 100%;
}
.header-logo img { height: 36px; }
.header-search {
  flex: 1; max-width: 500px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 24px; padding: 8px 16px;
}
.header-search input {
  border: none; background: transparent; outline: none;
  font-size: 14px; flex: 1; font-family: inherit;
  color: var(--text);
}
.header-search svg { color: var(--text-muted); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.btn-cart {
  position: relative; background: none; border: none;
  cursor: pointer; padding: 8px; border-radius: 50%;
  color: var(--text); transition: background 0.15s;
}
.btn-cart:hover { background: var(--bg); }
.cart-badge {
  position: absolute; top: 0; right: 0;
  background: var(--blue); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 50%; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.btn-auth {
  background: var(--blue); color: #fff;
  border: none; border-radius: 24px;
  padding: 8px 20px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-auth:hover { background: var(--blue-dark); }

.user-menu {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
}
.user-menu button {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
  font-size: 12px; color: var(--text-secondary);
}

/* ====== Banner Slider ====== */
.banner-slider {
  position: relative; overflow: hidden;
  max-width: 1280px; margin: 16px auto 0;
  border-radius: var(--radius); background: var(--border);
  aspect-ratio: 3.5;
}
.banner-track {
  display: flex; transition: transform 0.5s ease;
  height: 100%;
}
.banner-track img {
  min-width: 100%; height: 100%; object-fit: cover;
}
.banner-dots {
  position: absolute; bottom: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 6px;
}
.banner-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.5); border: none;
  cursor: pointer; transition: background 0.2s;
}
.banner-dot.active { background: #fff; }

/* ====== Main ====== */
.main {
  max-width: 1280px; margin: 0 auto;
  padding: 20px; flex: 1;
  width: 100%;
}

/* ====== Categories ====== */
.categories-bar {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 16px; margin-bottom: 8px;
  scrollbar-width: none;
}
.categories-bar::-webkit-scrollbar { display: none; }
.category-pill {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 16px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; font-family: inherit;
  color: var(--text-secondary); transition: all 0.15s;
}
.category-pill:hover { border-color: var(--blue); color: var(--blue); }
.category-pill.active {
  background: var(--blue); border-color: var(--blue);
  color: #fff;
}

/* ====== Products Grid ====== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: box-shadow 0.2s, transform 0.2s;
}
.product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.product-card-img {
  aspect-ratio: 1; background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.product-card-img img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 12px;
}
.product-card-img .no-img {
  color: var(--text-muted); font-size: 40px;
}
.product-card-body { padding: 12px 14px; }
.product-card-title {
  font-size: 13px; font-weight: 500;
  line-height: 1.4; height: 2.8em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  color: var(--text);
}
.product-card-price {
  font-size: 20px; font-weight: 700;
  color: var(--blue); margin-top: 6px;
}
.product-card-stock {
  font-size: 11px; color: var(--green);
  margin-top: 2px;
}
.product-card-btn {
  width: 100%; margin-top: 8px;
  background: var(--blue); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.product-card-btn:hover { background: var(--blue-dark); }

/* ====== Loading / Empty ====== */
.loading-state, .empty-state {
  grid-column: 1 / -1; text-align: center;
  padding: 60px 20px; color: var(--text-muted);
}
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ====== Product Modal ====== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-panel {
  background: var(--bg-card); border-radius: var(--radius);
  max-width: 900px; width: 100%; max-height: 90vh;
  overflow-y: auto; position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: var(--bg); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 18px;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; z-index: 1;
}
.modal-body { padding: 24px; }
.modal-product { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.modal-images { display: flex; flex-direction: column; gap: 8px; }
.modal-main-img {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; background: #f8fafc;
}
.modal-main-img img { width: 100%; height: 100%; object-fit: contain; }
.modal-thumbs { display: flex; gap: 6px; overflow-x: auto; }
.modal-thumb {
  width: 60px; height: 60px; border-radius: 6px;
  border: 2px solid var(--border); overflow: hidden;
  cursor: pointer; flex-shrink: 0;
}
.modal-thumb.active { border-color: var(--blue); }
.modal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.modal-info { display: flex; flex-direction: column; gap: 12px; }
.modal-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.modal-code { font-size: 12px; color: var(--text-muted); }
.modal-price { font-size: 28px; font-weight: 800; color: var(--blue); }
.modal-stock { font-size: 13px; color: var(--green); font-weight: 500; }
.modal-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.modal-qty {
  display: flex; align-items: center; gap: 8px;
}
.modal-qty button {
  width: 32px; height: 32px; border: 1px solid var(--border);
  background: var(--bg); border-radius: 6px; cursor: pointer;
  font-size: 16px; font-weight: 600;
}
.modal-qty input {
  width: 50px; text-align: center; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px; font-size: 14px; font-family: inherit;
}
.modal-add-btn {
  background: var(--blue); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 12px 24px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s; width: 100%;
}
.modal-add-btn:hover { background: var(--blue-dark); }

/* ====== Cart Sidebar ====== */
.cart-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.4);
}
.cart-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 400px; max-width: 100vw;
  background: var(--bg-card); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.cart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.cart-header h3 { font-size: 16px; }
.cart-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--text-secondary);
}
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; }
.cart-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item-img {
  width: 60px; height: 60px; border-radius: 6px;
  background: #f8fafc; overflow: hidden; flex-shrink: 0;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: contain; }
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 13px; font-weight: 500; line-height: 1.3; }
.cart-item-price { font-size: 14px; font-weight: 700; color: var(--blue); margin-top: 4px; }
.cart-item-qty {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
}
.cart-item-qty button {
  width: 24px; height: 24px; border: 1px solid var(--border);
  background: var(--bg); border-radius: 4px; cursor: pointer; font-size: 14px;
}
.cart-item-qty span { font-size: 13px; font-weight: 600; min-width: 20px; text-align: center; }
.cart-item-remove {
  background: none; border: none; color: var(--red);
  cursor: pointer; font-size: 11px; margin-top: 4px;
}
.cart-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.cart-total {
  display: flex; justify-content: space-between;
  font-size: 16px; margin-bottom: 12px;
}
.cart-total strong { font-size: 20px; color: var(--blue); }
.btn-checkout {
  width: 100%; background: var(--green); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 12px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-checkout:hover { background: #16a34a; }
.btn-checkout:disabled { background: var(--text-muted); cursor: not-allowed; }
.cart-login-hint { font-size: 12px; color: var(--text-secondary); text-align: center; margin-top: 8px; }
.cart-login-hint a { color: var(--blue); }
.cart-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ====== Auth Modal ====== */
.auth-panel { max-width: 420px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 14px; text-align: center;
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.auth-form { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.form-group input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--blue); }
.btn-primary {
  background: var(--blue); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
}
.btn-primary:hover { background: var(--blue-dark); }
.auth-error { color: var(--red); font-size: 13px; text-align: center; }

/* ====== WhatsApp Float ====== */
.whatsapp-float {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; display: flex;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(37,211,102,0.4);
  z-index: 500; transition: transform 0.2s;
  animation: wpPulse 2s infinite;
}
.whatsapp-float:hover { transform: scale(1.1); }
@keyframes wpPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(37,211,102,0.4); }
  50% { box-shadow: 0 4px 24px rgba(37,211,102,0.6); }
}

/* ====== Footer ====== */
.footer {
  background: var(--text); color: #fff; padding: 24px 20px;
  text-align: center; margin-top: auto;
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.footer-logo { height: 28px; margin-bottom: 8px; filter: brightness(10); }
.footer p { font-size: 12px; color: rgba(255,255,255,0.6); }

/* ====== Utilities ====== */
.hidden { display: none !important; }

/* ====== Responsive ====== */
@media (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .header-search { max-width: none; }
  .modal-product { grid-template-columns: 1fr; }
  .cart-panel { width: 100%; }
}
@media (max-width: 480px) {
  .products-grid { grid-template-columns: 1fr; gap: 12px; }
  .header-inner { gap: 8px; padding: 0 12px; }
  .header-logo img { height: 28px; }
  .btn-auth { padding: 6px 14px; font-size: 12px; }
}
