:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #222631;
  --border: #2c313f;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #e11d48;
  --wa: #25d366;
  --wa-hover: #1ebe5d;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Compact Sticky Top Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 17, 21, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  white-space: nowrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
  order: 3;
  width: 100%;
}

@media (min-width: 768px) {
  .search-box {
    order: 2;
    max-width: 520px;
    margin: 0 auto;
  }
}

.icon-search {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 34px 8px 36px;
  border-radius: 999px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

#searchInput:focus { border-color: var(--accent); }

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  order: 2;
}

@media (min-width: 768px) {
  .controls-right {
    order: 3;
    margin-left: 0;
  }
}

.mobile-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 960px) {
  .mobile-cat-btn { display: none; }
}

.lang-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.lang-btn span.active { color: #fff; }

/* Single-Row Top Department Strip (Always compact, never blocks products) */
.dept-bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.dept-tab {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.dept-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.dept-tab.active {
  background: var(--accent);
  color: #fff;
}

/* Main E-Commerce Layout: Sidebar + Product Grid */
.shop-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 16px 84px;
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

/* Persistent Scrollable Category Sidebar on Desktop */
.cat-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  z-index: 55;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}

.cat-sidebar.open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.7);
}

@media (min-width: 960px) {
  .cat-sidebar {
    position: sticky;
    top: 102px;
    width: 250px;
    flex-shrink: 0;
    max-height: calc(100vh - 118px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transform: none;
    z-index: 10;
  }
  .sidebar-close { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.sidebar-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: none;
  color: #d1d5db;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sidebar-item:hover {
  background: var(--surface-2);
  color: #fff;
}

.sidebar-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-count {
  font-size: 0.74rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.sidebar-item.active .sidebar-count {
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
}

/* Right Product Grid Area */
.shop-main {
  flex: 1;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
  gap: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.active-cat-heading {
  font-size: 1.15rem;
  font-weight: 700;
}

.result-count {
  font-size: 0.84rem;
  color: var(--muted);
}

.reset-pill {
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(225, 29, 72, 0.45);
  color: #fda4af;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.toggle-new {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
}

@media (min-width: 1200px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #3f4656;
}

.card-img-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  transition: transform 0.2s;
}

.card:hover .card-img-wrap img { transform: scale(1.03); }

.badge-new {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}

.card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 5px;
}

.card-sku {
  font-size: 0.71rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.card-cat {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: auto;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn-detail {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--wa);
  color: #072913;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  transition: background 0.15s;
}

.wa-btn:hover { background: var(--wa-hover); }

.load-more-wrap {
  text-align: center;
  margin-top: 24px;
}

.load-more-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 26px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* Product Detail Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 640px) {
  .modal-body { grid-template-columns: 1fr 1fr; }
}

.modal-media img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
}

.modal-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.modal-thumbs img {
  width: 52px;
  height: 52px;
  cursor: pointer;
  border: 2px solid transparent;
  padding: 3px;
}

.modal-thumbs img.active { border-color: var(--accent); }

.modal-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sku-badge {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-family: monospace;
  color: var(--muted);
}

.modal-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-cats span {
  background: var(--surface-2);
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--muted);
}

.modal-desc {
  font-size: 0.9rem;
  color: #d1d5db;
}

.modal-note {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
}

.wa-btn-lg {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.floating-wa {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--wa);
  color: #072913;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
