/* =====================================================================
   MTJR Store — storefront theme
   Brand colours are injected inline from settings (--brand, --dark, --accent).
   ===================================================================== */
:root {
  --brand:#a4161a; --brand-2:#7a1013; --dark:#14161a; --accent:#e5b23b;
  --ink:#191c21; --muted:#6d7480; --line:#e8eaee; --bg:#f6f7f9; --card:#fff;
  --ok:#15803d; --warn:#b45309; --bad:#b91c1c;
  --r:16px; --r-sm:10px;
  --shadow:0 1px 2px rgba(16,20,28,.04), 0 8px 24px rgba(16,20,28,.06);
  --shadow-lg:0 12px 40px rgba(16,20,28,.14);
  --font:'Tajawal','Segoe UI',system-ui,-apple-system,sans-serif;
}
* { box-sizing:border-box; }
html,body { margin:0; padding:0; }
body {
  font-family:var(--font); background:var(--bg); color:var(--ink);
  font-size:15px; line-height:1.7; -webkit-font-smoothing:antialiased;
}
img { max-width:100%; display:block; }
a { color:inherit; text-decoration:none; }
button, input, select, textarea { font-family:inherit; font-size:inherit; }
h1,h2,h3,h4 { margin:0 0 .5em; line-height:1.35; font-weight:800; letter-spacing:-.2px; }
.wrap { max-width:1200px; margin:0 auto; padding:0 16px; }
.muted { color:var(--muted); }
.center { text-align:center; }
.hide { display:none !important; }

/* ─── Header ─────────────────────────────────────────────────────── */
.topbar { background:var(--dark); color:#cfd4dc; font-size:12px; padding:4px 0; }
.topbar .wrap { display:flex; gap:14px; align-items:center; justify-content:space-between; flex-wrap:wrap; }
.topbar a { color:#cfd4dc; }
.topbar a:hover { color:#fff; }

header.site {
  position:sticky; top:0; z-index:60; background:rgba(255,255,255,.92);
  backdrop-filter:saturate(160%) blur(12px); border-bottom:1px solid var(--line);
}
/* NOTE: use the padding longhands here — a `padding: 12px 0` shorthand would
   wipe the 16px side padding .wrap gives, gluing the header to the screen edge. */
.head-row { display:flex; align-items:center; gap:14px; padding-top:7px; padding-bottom:7px; }
.brand { display:flex; align-items:center; gap:9px; font-weight:800; font-size:17px; white-space:nowrap; }
.brand .mark {
  width:31px; height:31px; border-radius:9px; display:grid; place-items:center; color:#fff;
  background:linear-gradient(135deg,var(--brand),var(--brand-2)); font-size:18px; font-weight:900;
  box-shadow:0 4px 12px rgba(164,22,26,.35);
}
.brand img { height:31px; width:auto; border-radius:7px; }
.head-actions { display:flex; align-items:center; gap:8px; }
.icon-btn {
  position:relative; display:inline-flex; align-items:center; gap:6px; padding:7px 12px;
  border-radius:999px; border:1px solid var(--line); background:#fff; cursor:pointer;
  font-weight:600; font-size:13.5px; transition:.16s; white-space:nowrap;
}
.icon-btn:hover { border-color:var(--brand); color:var(--brand); }
.icon-btn.solid { background:var(--brand); border-color:var(--brand); color:#fff; }
.icon-btn.solid:hover { background:var(--brand-2); color:#fff; }
.badge-count {
  position:absolute; top:-6px; inset-inline-end:-6px; min-width:19px; height:19px; padding:0 5px;
  background:var(--accent); color:#3a2a00; border-radius:999px; font-size:11px; font-weight:800;
  display:grid; place-items:center;
}
nav.cats { border-top:1px solid var(--line); background:#fff; }
nav.cats .wrap { display:flex; gap:5px; overflow-x:auto; padding-top:5px; padding-bottom:5px; }
/* The category strip is swiped, not dragged — no need for a visible bar. */
nav.cats .wrap { scrollbar-width:none; -ms-overflow-style:none; }
nav.cats .wrap::-webkit-scrollbar { display:none; }
nav.cats a {
  padding:5px 12px; border-radius:999px; font-size:13.5px; font-weight:600; color:var(--muted);
  white-space:nowrap; transition:.15s;
}
nav.cats a:hover { background:#f2f3f5; color:var(--ink); }
nav.cats a.on { background:var(--brand); color:#fff; }

/* ─── Buttons / forms ────────────────────────────────────────────── */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px; cursor:pointer;
  padding:11px 20px; border-radius:12px; border:1px solid transparent; font-weight:700;
  background:var(--brand); color:#fff; transition:.16s; font-size:15px;
}
.btn:hover { background:var(--brand-2); transform:translateY(-1px); }
.btn:disabled, .btn.disabled { opacity:.5; cursor:not-allowed; transform:none; }
.btn.ghost { background:#fff; border-color:var(--line); color:var(--ink); }
.btn.ghost:hover { border-color:var(--brand); color:var(--brand); background:#fff; }
.btn.dark { background:var(--dark); }
.btn.dark:hover { background:#000; }
.btn.block { width:100%; }
.btn.sm { padding:7px 13px; font-size:13.5px; border-radius:10px; }
.btn.lg { padding:14px 28px; font-size:16.5px; }

label.f { display:block; margin-bottom:14px; }
label.f > span { display:block; font-size:13.5px; font-weight:700; margin-bottom:6px; color:#3b414b; }
.inp, input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], select, textarea {
  width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:11px; background:#fff;
  outline:none; transition:.15s;
}
.inp:focus, input:focus, select:focus, textarea:focus { border-color:var(--brand); box-shadow:0 0 0 4px rgba(164,22,26,.09); }
textarea { min-height:92px; resize:vertical; }
.row2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.check { display:flex; align-items:flex-start; gap:9px; cursor:pointer; margin-bottom:10px; }
.check input { width:18px; height:18px; margin-top:3px; accent-color:var(--brand); }

/* ─── Cards & layout ─────────────────────────────────────────────── */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow); }
.card.pad { padding:20px; }
/* Longhands: `.section` is often combined with `.wrap` (<div class="wrap section">),
   and a `padding: 44px 0` shorthand would cancel .wrap's 16px side padding. */
.section { padding-top:44px; padding-bottom:44px; }
.section-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:22px; }
.section-head h2 { font-size:25px; margin:0; }
.section-head p { margin:4px 0 0; color:var(--muted); font-size:14.5px; }

.alert { padding:12px 16px; border-radius:12px; margin-bottom:14px; font-weight:600; font-size:14.5px; }
.alert.ok  { background:#e9f8ef; color:#14663a; border:1px solid #bfe8d0; }
.alert.bad { background:#fdecec; color:#93221f; border:1px solid #f6c9c7; }
.alert.warn{ background:#fff6e6; color:#8a5a08; border:1px solid #f6dfae; }

.badge { display:inline-block; padding:3px 10px; border-radius:999px; font-size:12px; font-weight:700; }
.b-ok { background:#e9f8ef; color:#15803d; } .b-warn { background:#fff4e0; color:#b45309; }
.b-bad { background:#fdecec; color:#b91c1c; } .b-info { background:#eaf1fd; color:#1d4ed8; }

/* ─── Hero ───────────────────────────────────────────────────────── */
.hero {
  position:relative; overflow:hidden; border-radius:24px; margin:22px 0;
  background:linear-gradient(120deg,var(--dark) 0%, #23262d 45%, var(--brand-2) 130%);
  color:#fff; padding:58px 44px; box-shadow:var(--shadow-lg);
}
.hero::after {
  content:''; position:absolute; inset-inline-end:-90px; top:-90px; width:340px; height:340px;
  background:radial-gradient(circle,rgba(229,178,59,.28),transparent 65%); border-radius:50%;
}
.hero h1 { font-size:40px; margin:0 0 14px; max-width:16ch; }
.hero p { font-size:17px; opacity:.9; max-width:52ch; margin:0 0 26px; }
.hero .btn.ghost { background:rgba(255,255,255,.1); border-color:rgba(255,255,255,.35); color:#fff; }
.hero-img { position:absolute; inset-inline-end:36px; bottom:0; max-height:78%; opacity:.95; }

/* ─── Product grid ───────────────────────────────────────────────── */
.grid-products { display:grid; grid-template-columns:repeat(auto-fill,minmax(215px,1fr)); gap:18px; }
.p-card {
  background:#fff; border:1px solid var(--line); border-radius:var(--r); overflow:hidden;
  display:flex; flex-direction:column; transition:.2s; position:relative;
}
.p-card:hover { transform:translateY(-3px); box-shadow:var(--shadow-lg); border-color:#dfe2e8; }
.p-thumb { position:relative; aspect-ratio:1/1; background:#f2f3f5; overflow:hidden; }
.p-thumb img { width:100%; height:100%; object-fit:cover; transition:.35s; }
.p-card:hover .p-thumb img { transform:scale(1.05); }
.p-tag {
  position:absolute; top:10px; inset-inline-start:10px; background:var(--brand); color:#fff;
  padding:3px 10px; border-radius:999px; font-size:11.5px; font-weight:800;
}
.p-tag.out { background:#454b55; }
.p-tag.new { background:var(--accent); color:#3a2a00; }
.p-body { padding:13px 14px 15px; display:flex; flex-direction:column; gap:7px; flex:1; }
.p-cat { font-size:11.5px; color:var(--muted); font-weight:600; }
.p-name { font-weight:700; font-size:15px; line-height:1.5; min-height:2.9em; }
.p-price { display:flex; align-items:baseline; gap:8px; margin-top:auto; }
.p-price .now { font-size:18px; font-weight:800; color:var(--brand); }
.p-price .was { font-size:13px; color:var(--muted); text-decoration:line-through; }
.p-stock { font-size:12px; font-weight:700; }
.p-stock.ok { color:var(--ok); } .p-stock.low { color:var(--warn); } .p-stock.out { color:var(--bad); }
.p-actions { display:flex; gap:7px; margin-top:6px; }
.p-actions .btn { flex:1; padding:9px 12px; font-size:14px; border-radius:10px; }

/* ─── Filters sidebar ────────────────────────────────────────────── */
.shop-layout { display:grid; grid-template-columns:250px 1fr; gap:22px; align-items:start; }
/* Grid children default to min-width:auto, so a wide table would blow the page
   out horizontally instead of scrolling inside .table-wrap. */
.shop-layout > * { min-width:0; }
.filters { position:sticky; top:96px; }
.filters h4 { font-size:14.5px; margin:16px 0 8px; }
.filters .list a { display:flex; justify-content:space-between; padding:6px 10px; border-radius:9px; font-size:14px; color:#464c56; }
.filters .list a:hover { background:#f4f5f7; }
.filters .list a.on { background:var(--brand); color:#fff; }
.filters .list a.on span { color:#fff; }
.toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.filters-toggle { display:none; }

/* ─── Product detail ─────────────────────────────────────────────── */
.pd { display:grid; grid-template-columns:1.05fr 1fr; gap:34px; align-items:start; }
.pd-gallery { background:#fff; border:1px solid var(--line); border-radius:var(--r); overflow:hidden; }
.pd-gallery .main { aspect-ratio:1/1; background:#f2f3f5; }
.pd-gallery .main img { width:100%; height:100%; object-fit:cover; }
.pd-thumbs { display:flex; gap:8px; padding:10px; overflow-x:auto; }
.pd-thumbs img { width:66px; height:66px; object-fit:cover; border-radius:10px; border:2px solid transparent; cursor:pointer; }
.pd-thumbs img.on { border-color:var(--brand); }
.pd h1 { font-size:28px; }
.price-big { font-size:31px; font-weight:900; color:var(--brand); }
.qty { display:inline-flex; align-items:center; border:1px solid var(--line); border-radius:12px; overflow:hidden; background:#fff; }
.qty button { width:40px; height:44px; border:0; background:#fff; font-size:19px; cursor:pointer; color:var(--ink); }
.qty button:hover { background:#f4f5f7; }
.qty input { width:56px; height:44px; border:0; text-align:center; font-weight:700; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }

/* ─── Tables (cart, orders, invoice) ─────────────────────────────── */
table.tbl { width:100%; border-collapse:collapse; background:#fff; }
table.tbl th, table.tbl td { padding:12px 14px; border-bottom:1px solid var(--line); text-align:start; }
table.tbl th { background:#fafbfc; font-size:13px; color:#4b515b; font-weight:800; }
table.tbl tr:last-child td { border-bottom:0; }
.table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:var(--r); background:#fff; }
/* Slim, blended scrollbars instead of the chunky default ones. */
.table-wrap, .pd-thumbs { scrollbar-width:thin; scrollbar-color:#d9dde3 transparent; }
.table-wrap::-webkit-scrollbar, .pd-thumbs::-webkit-scrollbar { width:8px; height:8px; }
.table-wrap::-webkit-scrollbar-track, .pd-thumbs::-webkit-scrollbar-track { background:transparent; }
.table-wrap::-webkit-scrollbar-thumb, .pd-thumbs::-webkit-scrollbar-thumb { background:#d9dde3; border-radius:999px; }
.table-wrap::-webkit-scrollbar-thumb:hover, .pd-thumbs::-webkit-scrollbar-thumb:hover { background:#bfc5cf; }
.cart-thumb { width:56px; height:56px; border-radius:10px; object-fit:cover; background:#f2f3f5; }

/* Quantity stepper  −  n  +  (direction:ltr keeps − left / + right in RTL) */
.qty-step { display:inline-flex; direction:ltr; align-items:stretch; border:1px solid var(--line);
  border-radius:9px; overflow:hidden; background:#fff; }
.qty-step .qs { border:0; background:#f4f5f7; width:30px; font-size:17px; line-height:1; cursor:pointer;
  color:#333; font-weight:700; padding:0; }
.qty-step .qs:hover { background:#eceef2; }
.qty-step .qs:active { background:#e3e6ea; }
.qty-step input { width:42px !important; border:0 !important; text-align:center; font-size:14px;
  -moz-appearance:textfield; appearance:textfield; padding:6px 2px; }
.qty-step input::-webkit-outer-spin-button, .qty-step input::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }
.m-tot-lbl { display:none; }   /* the "total" caption is shown only in the mobile card view */

.summary { position:sticky; top:96px; }
.sum-row { display:flex; justify-content:space-between; padding:8px 0; font-size:14.5px; }
.sum-row.total { border-top:1px dashed var(--line); margin-top:8px; padding-top:14px; font-size:18px; font-weight:800; }

/* ─── Footer ─────────────────────────────────────────────────────── */
footer.site { background:var(--dark); color:#aab1bd; margin-top:56px; padding:44px 0 0; }
footer.site h4 { color:#fff; font-size:15.5px; margin-bottom:12px; }
footer.site a { color:#aab1bd; display:block; padding:3px 0; }
footer.site a:hover { color:#fff; }
.foot-grid { display:grid; grid-template-columns:1.6fr 1fr 1fr 1.2fr; gap:28px; padding-bottom:30px; }
.foot-bottom { border-top:1px solid #262a31; padding-top:16px; padding-bottom:16px; font-size:13px; display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.pay-icons { display:flex; gap:8px; align-items:center; }
.pay-icons span { background:#20242b; border-radius:7px; padding:4px 9px; font-size:11.5px; color:#c9cfd8; }

/* ─── Mobile bottom nav ──────────────────────────────────────────── */
.botnav { display:none; }
@media (max-width:900px) {
  /* !important on purpose: several pages set an inline two-column
     grid-template-columns, and an inline style would otherwise win here and
     squeeze the main column to 0px on phones. */
  .shop-layout { grid-template-columns:1fr !important; }
  .filters { position:static; padding:12px; }
  /* Filters collapse behind a button so products stay above the fold. */
  .filters-toggle { display:flex; }
  .filters .filter-body { display:none; }
  .filters.open .filter-body { display:block; }
  .pd { grid-template-columns:1fr; }
  .foot-grid { grid-template-columns:1fr 1fr; }
  .hero { padding:38px 24px; border-radius:20px; }
  .hero h1 { font-size:29px; }
  .hero p { font-size:15.5px; }
  .head-actions .lbl { display:none; }
  .botnav {
    display:flex; position:fixed; bottom:0; inset-inline:0; z-index:70; background:#fff;
    border-top:1px solid var(--line); padding:3px 4px calc(3px + env(safe-area-inset-bottom));
    justify-content:space-around; box-shadow:0 -4px 18px rgba(0,0,0,.06);
  }
  .botnav a { flex:1; text-align:center; font-size:10px; color:var(--muted); font-weight:600; padding:2px 0; }
  .botnav a .ic { font-size:16px; display:block; line-height:1.25; }
  .botnav a.on { color:var(--brand); }
  /* Must clear the bar above: keep this in step with the paddings above. */
  body { padding-bottom:52px; }
  .summary { position:static; }
}
@media (max-width:700px) {
  /* One row is enough now that the search box has moved to the shop filters. */
  .head-row { flex-wrap:nowrap; }
  .brand { flex:1; min-width:0; font-size:15.5px; }
  .brand span { overflow:hidden; text-overflow:ellipsis; }
}
@media (max-width:560px) {
  .grid-products { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:12px; }
  .row2 { grid-template-columns:1fr; }
  .foot-grid { grid-template-columns:1fr; }
  .section { padding-top:30px; padding-bottom:30px; }
  .p-name { font-size:14px; }

  /* ── Cart rows become compact cards on phones ──────────────────────
     The 6-column table used to overflow .table-wrap, hiding the ✕ delete
     button behind a horizontal scroll. Each row is now a 2-line card:
     line 1 = thumb + full-width name + ✕ · line 2 = price · qty · total.
     Scoped to .cart-tbl / .cart-wrap so admin tables are untouched. */
  .cart-wrap { overflow:visible; border:0; background:transparent; border-radius:0; }
  .cart-tbl, .cart-tbl tbody { display:block; }
  .cart-tbl thead { display:none; }
  /* Deterministic 2-line card. The delete ✕ (line 1) and the total (line 2)
     share the same end column so the left edge of every row lines up:
       line 1 = [thumb] [name .................... ] [✕]
       line 2 = [thumb] [ − qty + ]            [الإجمالي total] */
  .cart-tbl tr {
    display:grid; grid-template-columns:44px 1fr auto;
    align-items:center; column-gap:8px; row-gap:6px;
    background:#fff; border:1px solid var(--line); border-radius:12px;
    padding:8px; margin-bottom:8px;
  }
  .cart-tbl td { border:0 !important; padding:0 !important; font-size:12.5px; min-width:0; }
  .cart-tbl td:nth-child(1) { grid-column:1; grid-row:1 / span 2; }          /* thumb */
  .cart-tbl td:nth-child(1) .cart-thumb { width:44px; height:44px; border-radius:9px; }
  .cart-tbl td:nth-child(2) { grid-column:2; grid-row:1; }                   /* name — the big cell */
  .cart-tbl td:nth-child(2) a { font-size:13.5px; line-height:1.3; display:inline-block; }
  .cart-tbl td:nth-child(6) { grid-column:3; grid-row:1; justify-self:end; align-self:start; } /* ✕ end column */
  .cart-tbl td:nth-child(6) .btn { padding:5px 9px; font-size:13px; line-height:1; }
  .cart-tbl td:nth-child(3) { display:none; }                                /* unit price hidden on phones */
  .cart-tbl td:nth-child(4) { grid-column:2; grid-row:2; justify-self:start; } /* stepper under the name */
  .cart-tbl td:nth-child(5) { grid-column:3; grid-row:2; justify-self:end; font-weight:800; } /* total, aligned under ✕ */
  .cart-tbl .m-tot-lbl { display:inline; color:var(--muted); font-weight:600; font-size:10.5px; }
}

/* ─── Landing blocks ─────────────────────────────────────────────── */
.features { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:16px; }
.feature { background:#fff; border:1px solid var(--line); border-radius:var(--r); padding:22px; text-align:center; transition:.2s; }
.feature:hover { transform:translateY(-3px); box-shadow:var(--shadow); }
.feature .ic { font-size:30px; }
.feature h3 { font-size:16.5px; margin:10px 0 5px; }
.feature p { margin:0; color:var(--muted); font-size:14px; }
.cta-band {
  background:linear-gradient(120deg,var(--brand),var(--brand-2)); color:#fff; border-radius:22px;
  padding:38px; display:flex; align-items:center; justify-content:space-between; gap:20px; flex-wrap:wrap;
}
.cta-band h2 { margin:0; font-size:26px; }
.cta-band .btn { background:#fff; color:var(--brand); }
.cta-band .btn:hover { background:#f5f5f5; }
.cat-strip { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:14px; }
.cat-tile {
  background:#fff; border:1px solid var(--line); border-radius:var(--r); padding:18px 12px; text-align:center;
  font-weight:700; transition:.18s;
}
.cat-tile:hover { border-color:var(--brand); color:var(--brand); transform:translateY(-2px); }
.cat-tile .ic { font-size:26px; display:block; margin-bottom:6px; }

/* ─── Steps / misc ───────────────────────────────────────────────── */
.steps { display:flex; gap:8px; margin-bottom:20px; flex-wrap:wrap; }
.step { flex:1; min-width:120px; padding:10px 12px; border-radius:12px; background:#fff; border:1px solid var(--line); font-size:13.5px; font-weight:700; color:var(--muted); text-align:center; }
.step.on { background:var(--brand); border-color:var(--brand); color:#fff; }
.step.done { color:var(--ok); border-color:#bfe8d0; background:#f2fbf5; }
.pager { display:flex; gap:6px; justify-content:center; margin-top:24px; flex-wrap:wrap; }
.pager a { padding:7px 13px; border:1px solid var(--line); border-radius:10px; background:#fff; font-weight:600; }
.pager a.on { background:var(--brand); border-color:var(--brand); color:#fff; }
.empty { text-align:center; padding:56px 20px; color:var(--muted); }
.empty .ic { font-size:44px; margin-bottom:10px; }
.chip { display:inline-flex; align-items:center; gap:6px; background:#f2f3f5; border-radius:999px; padding:5px 12px; font-size:13px; font-weight:600; }
.print-only { display:none; }
@media print {
  .no-print, header.site, footer.site, .botnav, .topbar { display:none !important; }
  body { background:#fff; }
  .print-only { display:block; }
  .card { box-shadow:none; border:0; }
}

/* ─── Variant option picker (product page) ───────────────────────────── */
.opt-btn{
  padding:9px 16px;border:1.5px solid var(--line,#dcdfe6);border-radius:10px;
  background:#fff;color:inherit;font:inherit;font-size:14px;cursor:pointer;
  transition:border-color .15s,background .15s,box-shadow .15s;
}
.opt-btn:hover{border-color:var(--brand,#111)}
.opt-btn.on{
  border-color:var(--brand,#111);background:var(--brand,#111);color:#fff;
  box-shadow:0 2px 8px rgba(0,0,0,.15);
}
.pd-options .lbl{font-size:14px}
.pd-options .alert{margin-top:8px}

/* Specs of the selected variant — filled by JS as the buyer picks options. */
.pd-specs{width:100%;border-collapse:collapse;font-size:14.5px}
.pd-specs td{padding:7px 0;border-bottom:1px solid var(--line,#eceef2)}
.pd-specs tr:last-child td{border-bottom:0}
.pd-specs td:first-child{color:var(--muted,#6b7280);width:40%;padding-inline-end:12px}
.pd-specs td:last-child{font-weight:600}
