@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #eef3f8; --surface: #ffffff; --text: #1a1a1a; --muted: #7a7570;
  --border: #e0dbd3; --accent: #2d4a3e; --accent-light: #e8f0ed;
  --accent-hover: #1e3329; --tag-bg: #f0ebe3; --danger: #c0392b; --badge: #e8c547;
}

body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 2rem; display: flex; align-items: center;
  justify-content: space-between; height: 64px; position: sticky; top: 0; z-index: 100;
}

.logo { font-family: 'DM Serif Display', serif; font-size: 22px; color: var(--accent); letter-spacing: -0.5px; }
.logo span { color: var(--muted); font-size: 14px; font-family: 'DM Sans', sans-serif; margin-left: 6px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.search-bar {
  display: flex; align-items: center; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px; height: 36px; gap: 8px; width: 220px;
}
.search-bar input { border: none; background: transparent; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); outline: none; width: 100%; }
.search-bar input::placeholder { color: var(--muted); }

.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; position: relative; transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg); }

.cart-badge {
  position: absolute; top: -6px; right: -6px; background: var(--accent);
  color: white; font-size: 10px; font-weight: 500; border-radius: 10px;
  min-width: 18px; height: 18px; display: flex; align-items: center;
  justify-content: center; padding: 0 4px;
}

#filterBtn { display: none; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 64px); }

aside { position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 1.5rem; }

.sidebar-section { margin-bottom: 2rem; }
.sidebar-title { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.75rem; }

.category-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-size: 14px; color: var(--text); transition: background 0.12s; margin-bottom: 2px;
}
.category-item:hover { background: var(--bg); }
.category-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.category-item.active .category-count { background: var(--accent); color: white; }

.category-count { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 7px; border-radius: 10px; }

#favBtn { color: var(--muted) !important; }
#favBtn.active { color: #e74c3c !important; background: #fdecea; }

.price-range { display: flex; flex-direction: column; gap: 10px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.price-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--tag-bg); border: 1px solid var(--border); cursor: pointer; transition: all 0.12s; }
.tag:hover, .tag.active { background: var(--accent); color: white; border-color: var(--accent); }

main { padding: 1.5rem 2rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.results-count { font-size: 13px; color: var(--muted); }
.results-count strong { color: var(--text); }
.sort-select { font-family: 'DM Sans', sans-serif; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); color: var(--text); cursor: pointer; outline: none; }

.product-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 16px; }

.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

.product-img { width: 100%; height: auto; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 48px; background: var(--bg); position: relative; object-fit:contain; image-rendering:auto; }

.product-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 500; padding: 3px 8px; border-radius: 6px; }
.badge-new { background: var(--accent); color: white; }
.badge-sale { background: var(--danger); color: white; }

.product-info { padding: 12px; display: flex; flex-direction: column; flex: 1; }
.product-cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.product-name { font-size: 14px; font-weight: 500; margin-bottom: 6px; line-height: 1.3; text-transform: capitalize; flex: 1; }
.product-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-price { font-size: 15px; font-weight: 500; color: var(--accent); }
.product-old-price { font-size: 12px; color: var(--muted); text-decoration: line-through; margin-left: 4px; }

.fav-btn { font-size: 25px; cursor: pointer; color: var(--border); transition: color 0.15s; line-height: 1; }
.fav-btn.active { color: #e74c3c; }
.fav-btn:hover { color: #e74c3c; }

.add-btn { background: var(--accent); color: white; border: none; border-radius: 7px; width: 30px; height: 30px; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.12s; line-height: 1; }
.add-btn:hover { background: var(--accent-hover); }

.cart-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 200; }
.cart-overlay.open { display: block; }

.cart-panel { position: fixed; top: 0; right: -400px; width: 360px; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); z-index: 201; display: flex; flex-direction: column; transition: right 0.25s cubic-bezier(0.4,0,0.2,1); }
.cart-panel.open { right: 0; }

.cart-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-title { font-family: 'DM Serif Display', serif; font-size: 18px; }
.close-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.cart-items { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; }
.cart-empty { text-align: center; color: var(--muted); font-size: 14px; padding: 3rem 0; }

.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.cart-item-emoji { font-size: 32px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 8px; }
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 13px; font-weight: 500; }
.cart-item-price { font-size: 12px; color: var(--muted); }
.cart-item-qty { display: flex; align-items: center; gap: 8px; }
.qty-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 5px; width: 24px; height: 24px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.qty-num { font-size: 13px; font-weight: 500; min-width: 16px; text-align: center; }

.cart-footer { padding: 1.25rem 1.5rem; border-top: 1px solid var(--border); }
.cart-total { display: flex; justify-content: space-between; font-size: 15px; font-weight: 500; margin-bottom: 1rem; }

.checkout-btn { width: 100%; background: var(--accent); color: white; border: none; border-radius: 9px; padding: 13px; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.12s; }
.checkout-btn:hover { background: var(--accent-hover); }

.clear-btn { width: 100%; background: none; border: 1px solid var(--border); border-radius: 9px; padding: 10px; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--muted); cursor: pointer; margin-bottom: 10px; transition: all 0.12s; }
.clear-btn:hover { border-color: var(--danger); color: var(--danger); }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 2rem; }
.page-btn { width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:hover:not(.active) { background: var(--bg); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--accent); color: white; padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 300; transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); white-space: nowrap; }
.toast.show { transform: translateX(-50%) translateY(0); }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300; align-items: flex-start; padding-top: 60px; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; width: 420px; overflow: hidden; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: 'DM Serif Display', serif; font-size: 18px; }
.modal-body { padding: 1.5rem; display: flex; flex-wrap: wrap; gap: 12px; }
.modal-body input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none; }
.input-full { width: 100% !important; }
.input-half { width: calc(50% - 6px) !important; }
.modal-body input:focus { border-color: var(--accent); }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

.filter-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 140; }
.filter-overlay.open { display: block; }

.sidebar-close { display: none; }

@media (max-width: 768px) {
  #filterBtn { display: flex; }
  .layout { grid-template-columns: 1fr; }
  aside { display: block; position: fixed; top: 0; left: -280px; width: 280px; height: 100vh; z-index: 150; transition: left 0.25s cubic-bezier(0.4,0,0.2,1); overflow-y: auto; padding-top: 4rem; border-right: 1px solid var(--border); }
  aside.open { left: 0; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  main { padding: 1rem; }
  header { padding: 0 1rem; }
  .search-bar { width: 150px; }
  .cart-panel { right: -100%; width: 100%; }
  .modal { width: 95%; margin: 0 auto; }
  .sidebar-close { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
  .sidebar-close button { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
}

.preview-panel {
  background: var(--surface);
  border-radius: 16px;
  width: 780px;
  max-width: 95%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  overflow: hidden;
  margin-top: 60px;
}
.preview-img { background: var(--bg); height: 350px; display: flex; align-items: center; justify-content: center; padding: 20px; }
.preview-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-info { padding: 2rem; display: flex; flex-direction: column; gap: 12px; }
.preview-cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.preview-name { font-family: 'DM Serif Display', serif; font-size: 22px; line-height: 1.3; }
.preview-price { font-size: 24px; font-weight: 500; color: var(--accent); }
.preview-specs { flex: 1; }
.preview-specs table { width: 100%; font-size: 13px; border-collapse: collapse; }
.preview-specs td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.preview-specs td:first-child { color: var(--muted); width: 40%; }
.preview-actions { display: flex; gap: 10px; }

@media (max-width: 768px) {
  .preview-panel { position:relative; grid-template-columns: 1fr; margin-top: 20px; }
  .preview-img { aspect-ratio: unset; height: 250px; }
}