/* ============================================
   Store Design System
   Palette: warm ledger/general-store feel
   ============================================ */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --ink: #1B1B1B;
  --muted: #6B6F76;
  --border: #E4E1D8;
  --brand: #1F4B43;       /* deep teal-green - trust, headers, nav */
  --brand-dark: #143530;
  --accent: #E8873A;      /* warm amber - buttons, CTAs, price tags */
  --accent-dark: #C96F27;
  --danger: #B3423A;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0 0 0.5em 0;
  letter-spacing: -0.01em;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Navbar ---------- */
.navbar {
  background: var(--brand);
  color: #fff;
  padding: 1rem 0;
}
.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.navbar .logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}
.navbar nav a {
  color: #EFEDE6;
  margin-left: 1.25rem;
  font-size: 0.95rem;
}
.navbar nav a:hover { color: #fff; }

/* ---------- Auth pages (login/signup) ---------- */
.auth-wrap {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -1px; left: 2rem;
  width: 40px; height: 4px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.auth-card h1 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}
.auth-card .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--brand-dark);
}
.field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--bg);
}
.field input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  background: #fff;
}
.btn {
  display: inline-block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--accent-dark); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand);
}
.btn-outline:hover { background: var(--brand); color: #fff; }

.error-msg {
  background: #FBEAE8;
  color: var(--danger);
  border: 1px solid #EFC6C1;
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.auth-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- Navbar extras: cart badge ---------- */
.cart-link {
  position: relative;
}
.cart-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* ---------- Category filter pills ---------- */
.category-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}
.category-pill {
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--brand-dark);
  background: var(--surface);
}
.category-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.category-pill:hover { text-decoration: none; border-color: var(--brand); }

/* ---------- Product grid ---------- */
.page-title {
  margin-top: 1.5rem;
  font-size: 1.6rem;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 3rem;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card .thumb .placeholder {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
.product-card .info {
  padding: 0.9rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.product-card .cat-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-bottom: 0.3rem;
}
.product-card h3 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}
.product-card .price-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand-dark);
  margin-top: auto;
  padding-top: 0.6rem;
}
.product-card .btn {
  margin-top: 0.6rem;
  padding: 0.5rem;
  font-size: 0.85rem;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 0;
}

/* ---------- Product detail page ---------- */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin: 2rem 0;
}
.product-detail .thumb-large {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-detail .thumb-large img { width: 100%; height: 100%; object-fit: cover; }
.product-detail .price-tag-large {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 0.75rem 0 1.25rem;
}
.product-detail .stock-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.qty-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}
.qty-form input[type="number"] {
  width: 70px;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.qty-form .btn { width: auto; padding: 0.75rem 1.5rem; }

@media (max-width: 700px) {
  .product-detail { grid-template-columns: 1fr; }
}

/* ---------- Cart page ---------- */
.cart-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}
.cart-table th, .cart-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.cart-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.cart-table .remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
}
.cart-total-row {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  align-items: baseline;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
}
.cart-total-row .amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-dark);
}
.checkout-btn-wrap { text-align: right; }
.checkout-btn-wrap .btn { width: auto; padding: 0.8rem 2rem; }

/* ---------- Admin panel ---------- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
}
.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-family: var(--font-mono);
}
.stat-card .value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--brand-dark);
  margin-top: 0.25rem;
}
.admin-section {
  margin: 2.5rem 0;
}
.admin-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}
.admin-table th {
  background: var(--bg);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-mono);
}
.status-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.status-paid { background: #E3EFE9; color: var(--brand-dark); }
.status-pending { background: #FBF1DF; color: #92650F; }
.status-cancelled { background: #FBEAE8; color: var(--danger); }
.status-shipped { background: #E3E8EF; color: #2E4674; }
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.admin-form-grid .field-full { grid-column: 1 / -1; }
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  resize: vertical;
  min-height: 90px;
}
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
}
.inline-form { display: inline; }
.action-link-btn {
  background: none; border: none; padding: 0; font-family: inherit;
  font-size: 0.85rem; cursor: pointer; color: var(--brand);
}
.action-link-btn.danger { color: var(--danger); }
.new-category-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.new-category-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.new-category-form .btn { width: auto; padding: 0.5rem 1.1rem; font-size: 0.85rem; }
