/* ============================================================
   Simba Crackers — Ordering (storefront + admin)
   Festive red / amber theme. Adjust the tokens below to match
   the site's logo/banner branding.
   ============================================================ */
:root {
  --primary: #c8102e;
  --primary-dark: #9e0c24;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
/* The `hidden` attribute must always win over any display rule (e.g. .modal-overlay's flex). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
.container { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }

/* ---------- Top contact strip ---------- */
.topbar { background: var(--primary-dark); color: #fde8ec; font-size: .85rem; }
.topbar-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; padding: 7px 16px; }
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar-tag { margin-left: auto; font-weight: 600; letter-spacing: .02em; }

/* ---------- Header ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.header-inner { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.brand img { height: 46px; width: auto; object-fit: contain; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.main-nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.main-nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink); font-size: .92rem; font-weight: 500; text-decoration: none; }
.main-nav a:hover { background: var(--bg); }
.main-nav a.active { background: var(--primary); color: #fff; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.3rem; padding: 4px 10px; cursor: pointer; }

/* ---------- Banner ---------- */
.banner img { width: 100%; max-height: 340px; object-fit: cover; display: block; }
.banner-fallback {
  background: linear-gradient(120deg, var(--primary) 0%, #e11d48 45%, var(--accent) 100%);
  color: #fff; padding: 56px 16px; text-align: center;
}
.banner-fallback h1 { font-size: 1.9rem; margin-bottom: .4rem; }
.banner-fallback p { margin: 0; opacity: .92; font-size: 1.05rem; }

/* ---------- Storefront layout ---------- */
.storefront { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 24px 16px 48px; align-items: start; }
.catalogue-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.catalogue-head h2 { margin: 0; font-size: 1.4rem; }

.controls { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.controls input { flex: 1; min-width: 200px; }

.category-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: .85rem; cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.product-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.product-img { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: #f1f5f9; }
.product-placeholder {
  aspect-ratio: 1 / 1; width: 100%; display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: #cbd5e1; font-size: 2rem; font-weight: 800;
}
.product-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.product-name { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.product-meta { font-size: .78rem; color: var(--muted); }
.product-price { font-weight: 700; font-size: 1rem; }
.product-unit { font-size: .75rem; color: var(--muted); }

/* Quantity stepper */
.qty { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.qty button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 700; color: var(--ink); font-size: 1rem; line-height: 1;
}
.qty button:hover { background: var(--bg); }
.qty .qty-val { min-width: 28px; text-align: center; font-weight: 600; font-size: .95rem; }
.add-btn {
  margin-top: 8px; background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 8px; font-weight: 600; cursor: pointer; transition: .15s;
}
.add-btn:hover { background: var(--primary-dark); }

/* Cart panel */
.cart-panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: 1.05rem; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 0; }
.link-btn:hover { color: var(--danger); }

.cart-lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cart-line { display: flex; gap: 10px; align-items: center; }
.cart-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #f1f5f9; flex-shrink: 0; }
.cart-thumb.ph { width: 44px; height: 44px; border-radius: 8px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; color: #cbd5e1; font-weight: 700; flex-shrink: 0; }
.cart-info { flex: 1; min-width: 0; }
.cart-info .n { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-info .p { font-size: .78rem; color: var(--muted); }
.cart-info .t { font-size: .84rem; font-weight: 700; }
.cart-empty { color: var(--muted); text-align: center; padding: 16px 0; font-size: .9rem; }

.cart-summary { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.cart-summary .row { display: flex; justify-content: space-between; color: var(--muted); }
.cart-summary .row.total { color: var(--ink); font-weight: 800; font-size: 1.05rem; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .85rem; color: var(--ink); margin-bottom: 4px; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: var(--card);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(200, 16, 46, .12); }
input.narrow { width: 140px; }
.form-error { color: var(--danger); font-size: .85rem; margin: 4px 0 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #111827; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.note { margin-top: 10px; line-height: 1.45; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-wide { max-width: 680px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Image zoom (hover preview of a product photo) ---------- */
.zoom-card {
  position: fixed;
  z-index: 200;
  width: 300px;
  pointer-events: none; /* never block the cursor, so it closes cleanly on mouse-out */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .28);
  overflow: hidden;
}
.zoom-card img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #f1f5f9;
  display: block;
}
.zoom-name {
  padding: 8px 12px;
  font-size: .85rem;
  font-weight: 600;
  border-top: 1px solid var(--line);
}

/* Success */
.success { text-align: center; padding: 12px 4px; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: #dcfce7; color: var(--success); font-size: 2rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.order-number { font-size: 1.7rem; font-weight: 800; color: var(--primary); font-family: ui-monospace, Menlo, monospace; margin: 6px 0; }
.success-total { color: var(--ink); }

/* Footer */
.site-footer { background: #1f2430; color: #cbd5e1; margin-top: 24px; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; padding: 32px 16px; }
.footer-logo { height: 44px; width: auto; margin-bottom: 8px; }
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: 8px; }
.site-footer a { display: block; color: #cbd5e1; margin-bottom: 6px; font-size: .88rem; }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #2b3040; padding: 14px 16px; font-size: .82rem; color: #94a3b8; text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: .95rem; }

/* ============================================================
   Admin
   ============================================================ */
.admin-body { background: var(--bg); }
.admin-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.admin-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.admin-logo { height: 40px; width: auto; margin-right: 10px; }
.admin-header-inner .brand { display: flex; align-items: center; }
.admin-actions { display: flex; gap: 8px; }

.admin-main { padding: 20px 16px 60px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: none; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { max-width: 260px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; background: #f8fafc; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #f8fafc; }
.table .right { text-align: right; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: capitalize; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.contacted { background: #dbeafe; color: #1d4ed8; }
.badge.converted { background: #d1fae5; color: #065f46; }
.badge.cancelled { background: #e5e7eb; color: #4b5563; }
.badge.on { background: #d1fae5; color: #065f46; }
.badge.off { background: #e5e7eb; color: #6b7280; }

.item-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f1f5f9; }
.item-thumb.ph { width: 40px; height: 40px; border-radius: 8px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; color: #cbd5e1; font-weight: 700; font-size: .8rem; }
.item-image-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.item-image-preview { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #f1f5f9; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .88rem; margin: 6px 0 12px; }
.settings-card { max-width: 420px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(140deg, var(--primary) 0%, #7f0d1d 55%, var(--ink) 100%); }
.login-card { background: var(--card); border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.35); text-align: center; }
.login-card h1 { font-size: 1.3rem; margin: 8px 0 2px; }
.login-logo { height: 54px; width: auto; margin: 0 auto; }
.login-card .field { text-align: left; }
.back-link { display: inline-block; margin-top: 14px; font-size: .85rem; color: var(--muted); }

/* Mobile order bar (fixed at the bottom on small screens) */
.mobile-order-bar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .storefront { grid-template-columns: 1fr; }
  .cart-panel { position: static; max-height: none; overflow: visible; }
  .store-body { padding-bottom: 74px; }
  .mobile-order-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px;
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .08);
  }
  .mobile-order-bar .mob-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
  .mobile-order-bar .mob-count { font-size: .75rem; color: var(--muted); }
  .mobile-order-bar .mob-total { font-weight: 800; font-size: 1.05rem; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--card); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px 16px;
  }
  .main-nav.open { display: flex; }
  .nav-toggle { display: block; }
  .topbar-tag { display: none; }
}
@media (max-width: 560px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}
