:root {
  --olive: #615c49;
  --olive-dark: #4a4638;
  --charcoal: #3b3b3b;
  --charcoal-dark: #232323;
  --white: #ffffff;
  --cream: #ece9e2;
  --danger: #8a2e2e;
  --danger-bg: #f6e4e4;
  --ok: #3d6b3d;
  --font-heading: 'Big Shoulders Stencil Text', 'Oswald', sans-serif;
  --font-body: 'Montserrat', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--charcoal);
  background: var(--cream);
  line-height: 1.5;
}
a { color: inherit; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--charcoal-dark);
  margin: 0 0 0.5em;
}

button, input, select, textarea { font-family: var(--font-body); font-size: 1rem; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 3px;
  padding: 0.7em 1.4em;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--olive);
  color: var(--white);
  transition: background 0.15s ease;
}
.btn:hover { background: var(--olive-dark); }
.btn:disabled { background: #9a9a9a; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--charcoal); border: 2px solid var(--charcoal); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 0.4em 0.9em; font-size: 0.85rem; }

/* -------------------- Header -------------------- */
.site-header {
  background: var(--charcoal-dark);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .bar {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.2rem;
}
.site-header .logo img { height: 64px; }
.site-header nav { display: flex; gap: 1.2rem; flex: 1; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; font-weight: 600; font-size: 0.92rem; opacity: 0.9; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }
.site-header .cart-link { position: relative; font-family: var(--font-heading); font-size: 1.1rem; text-decoration: none; }
.cart-badge {
  position: absolute; top: -8px; right: -14px;
  background: var(--danger); color: white; border-radius: 50%;
  width: 20px; height: 20px; font-size: 0.7rem; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body);
}
.site-header .nav-toggle {
  display: none;
  background: none; border: none; color: var(--white);
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0.2em 0.3em;
}

/* Below this width the link list can't fit the header in one row (it was
   wrapping into a tall stack that, combined with the sticky header, ate most
   of the screen) — collapse it behind a hamburger toggle instead. */
@media (max-width: 780px) {
  .site-header .logo img { height: 44px; }
  .site-header .bar { flex-wrap: wrap; gap: 0.8rem; }
  .site-header .logo { order: 1; }
  .site-header .cart-link { order: 2; margin-left: auto; }
  .site-header .nav-toggle { display: block; order: 3; }
  .site-header nav {
    display: none;
    order: 4;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0;
    margin-top: 0.4rem;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .site-header nav.nav-open { display: flex; }
  .site-header nav a {
    padding: 0.8em 0.2em;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
}

/* -------------------- Hero -------------------- */
.hero {
  background-image: linear-gradient(rgba(35,35,35,0.72), rgba(35,35,35,0.82)), url('/assets/camo-texture.png');
  background-size: 480px;
  color: var(--white);
  padding: 4rem 1.2rem;
  text-align: center;
}
.hero h1 { color: var(--white); font-size: 2.6rem; }
.hero p { max-width: 640px; margin: 0 auto 1.5rem; opacity: 0.9; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.2rem; }

.about-section { margin-top: 1rem; }
.about-section p { max-width: 760px; color: #444; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.category-card {
  background: var(--white);
  border: 1px solid #d8d3c6;
  border-radius: 6px;
  padding: 1.2rem 1rem;
  text-align: center;
  text-decoration: none;
  color: var(--charcoal);
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
}
.category-card:hover { border-color: var(--olive); }
.category-card .count { display: block; font-family: var(--font-body); font-size: 0.8rem; color: #777; margin-top: 0.3em; }

/* -------------------- Product grid -------------------- */
.filters { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1.2rem; align-items: center; }
.filters input, .filters select { padding: 0.5em 0.7em; border: 1px solid #ccc; border-radius: 4px; }
.filters input[type="search"] { flex: 1; min-width: 200px; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}
.product-card {
  background: var(--white);
  border: 1px solid #d8d3c6;
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.product-card .desc { font-weight: 600; font-size: 0.92rem; min-height: 2.6em; }
.product-card .sku { font-size: 0.75rem; color: #888; }
.product-card .price { font-family: var(--font-heading); font-size: 1.3rem; color: var(--olive-dark); }
.product-card .stock { font-size: 0.8rem; }
.product-card .stock.in { color: var(--ok); }
.product-card .stock.unknown { color: #a67c00; }
.product-card .stock.out { color: var(--danger); }

/* auto-fill's 220px minimum collapses to one column on a phone — force two,
   narrower cards instead, with everything inside sized down to match. */
@media (max-width: 560px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .product-card { padding: 0.6rem; gap: 0.3rem; }
  .product-card .desc { font-size: 0.82rem; min-height: 2.4em; }
  .product-card .price { font-size: 1.05rem; }
  .product-card .sku, .product-card .stock { font-size: 0.7rem; }
  .product-card .btn.small { padding: 0.4em 0.5em; font-size: 0.78rem; }
  .badge { font-size: 0.62rem; padding: 0.2em 0.45em; }
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.25em 0.6em;
  border-radius: 3px;
  background: var(--danger-bg);
  color: var(--danger);
  width: fit-content;
}

.pagination { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }

/* -------------------- Product detail -------------------- */
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 720px) { .product-detail { grid-template-columns: 1fr; } }
/* object-fit:contain, not cover — real product photos (especially the bulk-
   imported batch) span everything from square to 16:9 landscape to portrait.
   "cover" crops whichever dimension overflows a fixed 4:3 box, which was
   slicing real parts off products with a very different aspect ratio; a
   light neutral backdrop fills the resulting letterbox space so the photo
   still reads as "framed" rather than floating on the card's own white. */
.product-card-image, .product-detail-image {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 6px;
  object-fit: contain;
  background: #f2f0ea;
}
/* Shown instead of an <img> when a product has no photo yet — shares sizing
   with .product-card-image/.product-detail-image above, source order here
   makes flex/background win over the plain-image rules for this element. */
.image-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--olive);
  background-image: linear-gradient(rgba(35,35,35,0.15), rgba(35,35,35,0.15)), url('/assets/camo-texture.png');
  background-size: 480px;
  color: rgba(255,255,255,0.6);
  font-family: var(--font-heading);
}
.product-thumbs {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem;
}
.product-thumb {
  width: 72px; height: 72px; object-fit: cover; border-radius: 4px;
  border: 2px solid transparent; cursor: pointer; transition: border-color 0.15s ease;
}
.product-thumb:hover { border-color: var(--olive); }
.compliance-note {
  background: var(--danger-bg);
  color: var(--danger);
  border-left: 4px solid var(--danger);
  padding: 0.8rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* -------------------- Cart / checkout -------------------- */
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th, .cart-table td { text-align: left; padding: 0.7em 0.5em; border-bottom: 1px solid #ddd; }
.cart-table input[type="number"] { width: 60px; padding: 0.3em; }
.cart-totals { text-align: right; margin-top: 1rem; font-family: var(--font-heading); font-size: 1.3rem; }

/* A plain table with a wide first column doesn't reflow — on a narrow screen
   the description column got squeezed thin enough to wrap one word per line.
   Below this width, turn each row into a small card instead: the header row
   hides, and every cell's own data-label (set at render time) becomes its
   label via ::before, so each value is legible on its own line. Used by both
   the cart page and the account order-history table (same .cart-table class). */
@media (max-width: 640px) {
  .cart-table thead { display: none; }
  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td { display: block; width: 100%; }
  .cart-table tr {
    border: 1px solid #ddd; border-radius: 6px;
    padding: 0.7em 0.9em; margin-bottom: 0.8em;
  }
  .cart-table td {
    border-bottom: none; padding: 0.35em 0;
    display: flex; align-items: center; justify-content: space-between; gap: 0.8em;
  }
  .cart-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-weight: 700; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.03em; color: #888; flex-shrink: 0;
  }
  /* The description/order-summary cell is the one long piece of text — give
     it its own full-width line (label above, text below) instead of forcing
     it to share a row with its label. */
  .cart-table td:first-child { flex-direction: column; align-items: flex-start; }
  .cart-table td:first-child::before { margin-bottom: 0.15em; }
  .cart-table td:last-child { justify-content: flex-end; }
}

.checkout-form { max-width: 640px; }
.checkout-form label { display: block; margin: 1rem 0 0.3rem; font-weight: 600; font-size: 0.9rem; }
.checkout-form input[type="text"],
.checkout-form input[type="email"],
.checkout-form input[type="tel"],
.checkout-form input[type="password"],
.checkout-form input[type="file"],
.checkout-form select {
  width: 100%; padding: 0.6em; border: 1px solid #ccc; border-radius: 4px; font-family: var(--font-body); font-size: 1rem;
}
.checkout-form .field-hint { font-size: 0.8rem; color: #666; margin-top: 0.2em; }
.checkout-form .checkbox-row { display: flex; align-items: center; gap: 0.5em; margin-top: 1rem; }
.checkout-form .checkbox-row label { margin: 0; font-weight: 500; }
.pickup-notice {
  background: var(--cream);
  border: 1px solid var(--olive);
  padding: 1rem;
  border-radius: 6px;
  margin: 1.5rem 0;
}

.error-banner {
  background: var(--danger-bg); color: var(--danger); padding: 0.8rem 1rem; border-radius: 4px; margin-bottom: 1rem;
}
.success-banner {
  background: #e6f0e6; color: var(--ok); padding: 0.8rem 1rem; border-radius: 4px; margin-bottom: 1rem;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: var(--charcoal-dark); color: var(--white);
  padding: 0.8em 1.4em; border-radius: 6px; font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100; max-width: 90vw; text-align: center;
}
.toast-visible { opacity: 1; transform: translate(-50%, 0); }

footer {
  background: var(--charcoal-dark); color: rgba(255,255,255,0.75);
  text-align: center; padding: 2rem 1rem; margin-top: 3rem; font-size: 0.85rem;
}
footer a { text-decoration: underline; margin: 0 0.5em; }

/* -------------------- Admin -------------------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 200px; background: var(--charcoal-dark); color: white; padding: 1.5rem 1rem; flex-shrink: 0;
}
.admin-sidebar a {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5em;
  padding: 0.6em 0.4em; text-decoration: none; color: rgba(255,255,255,0.85); border-radius: 4px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--olive); color: white; }
.nav-badge {
  background: var(--danger); color: white; border-radius: 50%;
  min-width: 20px; height: 20px; padding: 0 5px; font-size: 0.72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); flex-shrink: 0;
}
.admin-main { flex: 1; padding: 1.5rem 2rem; }
.admin-table { width: 100%; border-collapse: collapse; background: white; }
.admin-table th, .admin-table td { padding: 0.6em 0.7em; border-bottom: 1px solid #eee; text-align: left; font-size: 0.9rem; }
.admin-table th { background: #f2f0ea; }
.status-pill { padding: 0.2em 0.6em; border-radius: 10px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.status-pending_payment { background: #eee; color: #666; }
.status-paid { background: #dbe9fa; color: #1f5c99; }
.status-awaiting_verification { background: #fdf0d5; color: #8a5a00; }
.status-items_ordered { background: #eae0f5; color: #5a3a8a; }
.status-ready_for_collection { background: #dcefe0; color: var(--ok); }
.status-completed { background: #dde6f5; color: #2a4a8a; }
.status-cancelled { background: var(--danger-bg); color: var(--danger); }
.status-active { background: #dcefe0; color: var(--ok); }

.login-box { max-width: 360px; margin: 4rem auto; background: white; padding: 2rem; border-radius: 8px; }
.login-box input { width: 100%; padding: 0.6em; margin: 0.4em 0 1em; border: 1px solid #ccc; border-radius: 4px; }
