:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

/* ── Top bar ─────────────────────────────────────────────────────────────── */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-wrap { display: flex; flex-direction: column; }
.brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-tag { font-size: 0.75rem; color: var(--muted); }

.nav-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

#unread-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #ffedd5;
  border-bottom: 2px solid var(--accent);
  font-size: 0.95rem;
}
#unread-banner a { font-weight: 700; white-space: nowrap; }

#nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
}

#nav button {
  background: none;
  border: none;
  color: var(--accent-dark);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

main { max-width: 960px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }
.success { color: var(--ok); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

button, .btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  text-align: center;
}
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 0.9rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"],
input[type="email"], textarea, select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
}
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }
.checkbox-row label { margin: 0; font-weight: 400; font-size: 0.95rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ── Catalog ─────────────────────────────────────────────────────────────── */

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

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.product-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.product-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #eee;
}
.product-card .info { padding: 10px 12px; }
.product-card .name { font-weight: 600; font-size: 0.95rem; }
.product-card .price { color: var(--accent-dark); font-weight: 700; font-size: 0.95rem; }

.placeholder-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eee;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Hero (all customer-facing pages) ────────────────────────────────────── */

#hero { max-width: 960px; margin: 0 auto; padding: 16px 16px 0; }

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #ffedd5, #fff7ed);
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 0;
}

.hero-media {
  position: relative;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: #fed7aa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 2.2rem;
  color: #9a3412;
}
.hero-media::before { content: 'G'; }
.hero-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-text h1 { margin: 0 0 8px; font-size: 1.3rem; line-height: 1.3; }
.hero-text p { margin: 0 0 6px; color: #7c2d12; font-size: 0.95rem; }
.hero-text .hero-trust { margin: 0; font-weight: 600; }

/* ── Product detail ──────────────────────────────────────────────────────── */

.gallery img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 8px;
}
.thumbnails { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbnails img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
}
.thumbnails img.selected { border-color: var(--accent); }

.price-big { font-size: 1.5rem; font-weight: 800; color: var(--accent-dark); }

/* ── Orders / queue ───────────────────────────────────────────────────────── */

.order-list { display: flex; flex-direction: column; gap: 12px; }

.order-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.order-card.unread { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25); }
.new-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: middle;
}
.order-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
}
.order-card .head:hover { background: #f9fafb; }
.order-card .body { border-top: 1px solid var(--border); padding: 12px 16px; }

.status-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-placed { background: #e0e7ff; color: #3730a3; }
.status-printing { background: #fef3c7; color: #92400e; }
.status-ready_for_pickup { background: #dcfce7; color: #166534; }
.status-picked_up { background: #e5e7eb; color: #374151; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ── Messages ────────────────────────────────────────────────────────────── */

.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f3f4f6;
  align-self: flex-start;
}
.msg.mine { background: #ffedd5; align-self: flex-end; }
.msg .who { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.msg .when { font-size: 0.7rem; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-break: break-word; }

.msg-form { display: flex; gap: 8px; margin-top: 8px; }
.msg-form textarea { min-height: 44px; flex: 1; }

/* ── Unread modal ─────────────────────────────────────────────────────────── */

#unread-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  padding: 20px;
}
.modal-order { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; }

/* ── Admin products ──────────────────────────────────────────────────────── */

.admin-product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.admin-product-row .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: #eee; }
.admin-product-row .meta { flex: 1; min-width: 0; }
.admin-product-row .actions { display: flex; gap: 8px; flex-shrink: 0; }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.image-grid { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.image-grid .img-cell { position: relative; }
.image-grid img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.image-grid .img-cell button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.8rem;
  line-height: 1;
}

/* ── Login ───────────────────────────────────────────────────────────────── */

.auth-card { max-width: 420px; margin: 24px auto; }
.auth-card .card { padding: 24px; }
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
  box-sizing: border-box;
}
.google-btn:hover { background: #f9fafb; text-decoration: none; }
.divider { text-align: center; color: var(--muted); margin: 16px 0; font-size: 0.85rem; }
.toggle-link { text-align: center; margin-top: 12px; font-size: 0.9rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  main { padding: 24px; }
  #hero { padding: 24px 24px 0; }
  .hero { padding: 24px; gap: 20px; }
  .hero-media { width: 128px; height: 128px; }
  .hero-text h1 { font-size: 1.7rem; }
  .hero-text p { font-size: 1rem; }
}

@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
