@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

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

body {
  font-family: 'Sarabun', sans-serif;
  background: #f4f6f8;
  color: #333;
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: #fff;
  border-right: 1px solid #e0e4ea;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.sidebar-summary {
  padding: 18px 16px 14px;
  border-bottom: 1px solid #e0e4ea;
}

.sidebar-summary .label {
  font-size: 18px;
  font-weight: 700;
  color: #1a73e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-summary .total-price {
  font-size: 22px;
  font-weight: 700;
  color: #1a73e8;
  margin-top: 4px;
}

.btn-summary {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #c5d9fb;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-summary:hover { background: #d2e3fc; }

/* Selected items in sidebar */
.sidebar-items {
  padding: 10px 16px;
  border-bottom: 1px solid #e0e4ea;
  max-height: 160px;
  overflow-y: auto;
}

.sidebar-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed #eee;
}

.sidebar-item-row:last-child { border-bottom: none; }

.sidebar-item-name { flex: 1; color: #444; line-height: 1.3; }

.sidebar-item-price { font-weight: 600; color: #1a73e8; white-space: nowrap; margin-left: 8px; }

.btn-remove {
  background: none;
  border: none;
  color: #e53935;
  cursor: pointer;
  font-size: 16px;
  margin-left: 6px;
  line-height: 1;
}

/* Category list */
.sidebar-cat-header {
  padding: 14px 16px 8px;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-reset-cat {
  background: none;
  border: none;
  color: #1a73e8;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  display: flex;
  align-items: center;
  gap: 4px;
}

.category-list { padding: 0 10px 16px; }

.category-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  margin-bottom: 4px;
  transition: all 0.15s;
}

.category-item:hover { background: #f0f4ff; }

.category-item.active {
  border-color: #1a73e8;
  background: #e8f0fe;
}

.cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f0f4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.category-item.active .cat-icon { background: #d2e3fc; }

.cat-info { flex: 1; }

.cat-name { font-size: 14px; font-weight: 600; color: #333; }

.cat-desc { font-size: 11px; color: #888; margin-top: 2px; line-height: 1.4; }

.cat-count {
  font-size: 12px;
  color: #1a73e8;
  font-weight: 600;
  background: #e8f0fe;
  border-radius: 10px;
  padding: 2px 8px;
  align-self: center;
}

/* ===== MAIN CONTENT ===== */
#main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: #1a73e8;
}

.product-count {
  font-size: 14px;
  color: #888;
  margin-top: 2px;
}

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid #d0d7e2;
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  min-width: 260px;
}

.search-box input {
  border: none;
  outline: none;
  padding: 9px 0;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  width: 100%;
  background: transparent;
}

.search-box button {
  background: #1a73e8;
  border: none;
  border-radius: 6px;
  color: #fff;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Filter row */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 12px;
  color: #888;
  font-weight: 600;
}

.filter-group select {
  padding: 7px 28px 7px 10px;
  border: 1.5px solid #d0d7e2;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  background: #fff;
  color: #333;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.btn-reset {
  padding: 7px 16px;
  background: #fff;
  border: 1.5px solid #d0d7e2;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: flex-end;
  transition: all 0.15s;
}

.btn-reset:hover { border-color: #1a73e8; color: #1a73e8; }

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e8ecf2;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
  box-shadow: 0 4px 20px rgba(26,115,232,0.15);
  transform: translateY(-2px);
}

.card-image {
  position: relative;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-image .paint-can {
  width: 80px;
  height: 100px;
  border-radius: 8px 8px 4px 4px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 4px 12px rgba(0,0,0,0.15);
}

.card-image .paint-can::before {
  content: '';
  position: absolute;
  top: -8px;
  width: 50px;
  height: 10px;
  background: rgba(0,0,0,0.15);
  border-radius: 4px 4px 0 0;
}

.card-image .paint-can .can-label {
  background: rgba(255,255,255,0.9);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 9px;
  font-weight: 700;
  color: #333;
  text-align: center;
  width: 60px;
}

.brand-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #e0e4ea;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #333;
}

.discount-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #e53935;
  color: #fff;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
}

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

.card-name {
  font-size: 14px;
  font-weight: 700;
  color: #222;
  line-height: 1.4;
  margin-bottom: 6px;
}

.card-spec {
  font-size: 12px;
  color: #777;
  line-height: 1.5;
  flex: 1;
}

.card-price {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price-now {
  font-size: 18px;
  font-weight: 700;
  color: #1a73e8;
}

.price-old {
  font-size: 13px;
  color: #bbb;
  text-decoration: line-through;
}

.card-actions {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-add {
  width: 100%;
  padding: 9px;
  background: #fff;
  border: 1.5px solid #1a73e8;
  color: #1a73e8;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add:hover { background: #1a73e8; color: #fff; }
.btn-add.added { background: #1a73e8; color: #fff; }

.btn-detail {
  text-align: center;
  font-size: 12px;
  color: #1a73e8;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-family: 'Sarabun', sans-serif;
  padding: 0;
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 3px; }

/* Responsive */
@media (max-width: 1100px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; min-width: unset; height: auto; position: static; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}
