:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ink: #1f2937;
  --gray: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --max: 1280px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }
img { max-width: 100%; display: block; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Header */
header.site-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: var(--max);
  margin: 0 auto;
}
.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--blue);
}
.logo:hover { text-decoration: none; }
nav.main-nav ul {
  list-style: none;
  display: flex;
  gap: 24px;
  margin: 0;
  padding: 0;
}
nav.main-nav a {
  color: var(--ink);
  font-weight: 500;
}
.cart-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.cart-count {
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8rem;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: var(--ink);
  padding: 56px 20px;
  text-align: center;
}
.hero-eyebrow {
  display: inline-block;
  background: #fff;
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.hero h1 { font-size: 2.4rem; margin: 0 0 16px; color: var(--ink); }
.hero p { font-size: 1.1rem; max-width: 640px; margin: 0 auto; color: #374151; }
.hero p a { font-weight: 600; }
.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; text-decoration: none; }
.btn-white { background: #fff; color: var(--blue); }
.btn-white:hover { background: #f0f4ff; color: var(--blue); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; text-decoration: none; }
.btn-danger:disabled { background: #fecaca; cursor: not-allowed; }
.btn-block { width: 100%; text-align: center; }

/* Sections */
section.block { padding: 56px 20px; }
section.block.alt { background: var(--bg); }
.section-title { font-size: 1.8rem; margin: 0 0 8px; }
.section-sub { color: var(--gray); margin: 0 0 32px; }

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 24px;
}
.product-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.product-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.08); transform: translateY(-2px); }
.product-card a.thumb-link { display: block; background: var(--bg); }
.product-card img.thumb {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: var(--bg);
}
.product-card .card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.product-card h3 {
  font-size: 0.98rem;
  margin: 0 0 8px;
  line-height: 1.35;
  min-height: 2.7em;
}
.product-card h3 a { color: var(--ink); }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-forsale { background: #dcfce7; color: var(--green); }
.badge-archived { background: var(--amber-bg); color: var(--amber); }
.card-price { font-weight: 700; color: var(--blue); font-size: 1.05rem; margin-top: auto; padding-top: 10px; }
.card-archived-note { color: var(--gray); font-size: 0.85rem; margin-top: auto; padding-top: 10px; }

/* Filters (shop page) */
.shop-layout { display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: start; }
.filters { border: 1px solid var(--border); border-radius: 12px; padding: 20px; position: sticky; top: 90px; }
.filters h3 { font-size: 1rem; margin: 0 0 12px; }
.filters .group { margin-bottom: 22px; }
.filters input[type="text"], .filters select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}
.filters label.radio { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.92rem; cursor: pointer; }
#results-count { color: var(--gray); margin-bottom: 18px; }
@media (max-width: 860px) {
  .shop-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
}

/* Product detail page */
.breadcrumb { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--gray); }
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; padding: 48px 20px; max-width: var(--max); margin: 0 auto; }
.gallery-main { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); margin-bottom: 12px; }
.gallery-main img { width: 100%; height: 480px; object-fit: cover; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.gallery-thumbs img {
  width: 100%; height: 64px; object-fit: cover; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
}
.gallery-thumbs img.active { border-color: var(--blue); }
.product-detail h1 { font-size: 1.9rem; margin: 0 0 14px; }
.price-row { font-size: 1.9rem; font-weight: 800; color: var(--blue); margin-bottom: 6px; }
.stock-line { font-weight: 600; margin-bottom: 20px; }
.stock-in { color: var(--green); }
.archived-box {
  background: var(--amber-bg); color: var(--amber); border-radius: 10px;
  padding: 14px 16px; font-weight: 600; margin-bottom: 20px; font-size: 0.95rem;
}
.desc-block { border-top: 1px solid var(--border); padding-top: 22px; margin-top: 22px; }
.desc-block h3 { margin: 0 0 10px; }
.desc-block p { color: #374151; white-space: pre-wrap; }
.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.qty-box { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; }
.qty-box button { border: none; background: none; padding: 8px 14px; font-size: 1.1rem; cursor: pointer; }
.qty-box input { width: 44px; text-align: center; border: none; }
.perks { background: var(--bg); border-radius: 10px; padding: 20px; margin-top: 26px; }
.perks h3 { margin: 0 0 12px; font-size: 1.05rem; }
.perks ul { list-style: none; margin: 0; padding: 0; }
.perks li { margin-bottom: 8px; }

/* Cart page */
.cart-item { display: flex; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--border); align-items: center; }
.cart-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.cart-item .info { flex: 1; }
.summary-box { border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; }
.summary-row.total { font-weight: 800; font-size: 1.15rem; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }

/* Footer */
footer.site-footer { background: #1f2937; color: #d1d5db; padding: 48px 20px 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; max-width: var(--max); margin: 0 auto 32px; }
.footer-grid h4 { color: #fff; margin: 0 0 14px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: #d1d5db; }
.footer-bottom { text-align: center; padding-top: 20px; border-top: 1px solid #374151; max-width: var(--max); margin: 0 auto; font-size: 0.88rem; color: #9ca3af; }

/* Misc */
.empty-state { text-align: center; padding: 60px 20px; background: var(--bg); border-radius: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .product-detail { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  nav.main-nav ul { gap: 14px; }
  .footer-grid { grid-template-columns: 1fr; }
}

/* Category browse grid (homepage) */
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.category-card {
  position: relative; display: block; border-radius: 12px; overflow: hidden; height: 160px;
  background: var(--bg); color: #fff; text-decoration: none;
}
.category-card:hover { text-decoration: none; }
.category-card img {
  width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0;
  transition: transform 0.25s ease;
}
.category-card:hover img { transform: scale(1.06); }
.category-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.72) 100%);
}
.category-card-name { position: absolute; left: 14px; bottom: 30px; z-index: 1; font-weight: 700; font-size: 1.05rem; }
.category-card-count { position: absolute; left: 14px; bottom: 10px; z-index: 1; font-size: 0.82rem; color: #e5e7eb; }
@media (max-width: 900px) {
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Lightbox (click-to-enlarge product photo) */
.lightbox-overlay {
  display: none; position: fixed; inset: 0; background: rgba(17,24,39,0.92); z-index: 100;
  align-items: center; justify-content: center; padding: 30px; cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.lightbox-close {
  position: absolute; top: 18px; right: 24px; color: #fff; font-size: 2rem; line-height: 1;
  background: none; border: none; cursor: pointer;
}
.lightbox-loading { color: #fff; font-size: 0.95rem; }
.gallery-main-wrap { position: relative; cursor: zoom-in; }
.gallery-main-wrap::after {
  content: "\26F6"; position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,0.55);
  color: #fff; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; pointer-events: none;
}

/* ---------------------------------------------------------------- Admin */
body.admin { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; background: #111827; color: #d1d5db; padding: 24px 0; flex-shrink: 0;
}
.admin-sidebar .brand { color: #fff; font-weight: 800; padding: 0 20px 20px; font-size: 1.1rem; }
.admin-sidebar a {
  display: block; padding: 10px 20px; color: #d1d5db; font-weight: 500;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: #1f2937; color: #fff; text-decoration: none; }
.admin-main { flex: 1; padding: 32px 40px; max-width: 1100px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; vertical-align: middle; }
.admin-table th { color: var(--gray); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table img.thumb-sm { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; }
.admin-actions a { margin-right: 12px; font-size: 0.88rem; font-weight: 600; }
.admin-actions a.danger { color: var(--red); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
.form-group input[type="text"], .form-group input[type="number"], .form-group input[type="email"],
.form-group input[type="password"], .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; font-family: inherit;
}
.form-group textarea { min-height: 140px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.login-box { max-width: 380px; margin: 90px auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-weight: 600; font-size: 0.92rem; }
.flash-success { background: #dcfce7; color: var(--green); }
.flash-error { background: #fee2e2; color: var(--red); }
.pill-active { background: #dcfce7; color: var(--green); padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.pill-archived { background: var(--amber-bg); color: var(--amber); padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.star-toggle { font-size: 1.3rem; text-decoration: none; display: inline-block; }
.star-toggle.star-on { color: #d97706; }
.star-toggle.star-off { color: #d1d5db; }
.star-toggle:hover { color: #d97706; text-decoration: none; }
.badge-featured { background: #fef3c7; color: #92400e; }
.existing-images { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 10px; }
.existing-images figure { margin: 0; position: relative; }
.existing-images img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; }
.existing-images .del-img { position: absolute; top: 4px; right: 4px; background: rgba(220,38,38,0.9); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 0.7rem; cursor: pointer; line-height: 1; }
@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-main { padding: 24px; }
  .form-row { grid-template-columns: 1fr; }
}
