/* Classic catalog: public site and admin panel */
:root {
  --black: #16171B;
  --black-2: #2A2B31;
  --gold: #C89B5A;
  --gold-dark: #8A5A2B;
  --bg: #F4F1EC;
  --card: #FFFFFF;
  --line: #E2DACE;
  --line-strong: #CFC6BA;
  --ink: #171717;
  --muted: #5C5C57;
  --green: #0E7A3E;
  --red: #A12A1B;
  --sans: Inter, "Noto Sans Arabic", system-ui, sans-serif;
  --serif: "Playfair Display", "Noto Sans Arabic", Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--sans); }
[dir="rtl"] body { font-family: "Noto Sans Arabic", Inter, system-ui, sans-serif; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.2; }
[dir="rtl"] h1, [dir="rtl"] h2 { font-family: "Noto Sans Arabic", var(--serif); font-weight: 700; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.spacer { flex: 1; }

/* App bar */
.appbar { background: var(--black); color: #fff; border-bottom: 3px solid var(--gold); border-radius: 0 0 22px 22px; position: sticky; top: 0; z-index: 10; }
.appbar-inner { max-width: 1200px; margin: 0 auto; padding: 8px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.appbar-row { display: flex; align-items: center; gap: 8px; }
.logo img { height: 52px; width: auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; background: var(--black-2); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.langs { display: flex; background: var(--black-2); border-radius: 22px; padding: 4px; gap: 2px; }
.langs a { min-width: 40px; height: 36px; padding: 0 10px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #E4E4E8; }
.langs a.on { background: var(--gold); color: var(--black); }
.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; background: #fff; border-radius: 23px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 16px 16px 110px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-title { font-size: 26px; margin-bottom: 14px; }
.title-row .page-title { margin-bottom: 0; }
.since { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; color: var(--gold-dark); text-transform: uppercase; }
[dir="rtl"] .since { letter-spacing: 0; font-size: 13px; }
.section-title { font-size: 20px; margin: 28px 0 12px; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* Category cards on the home page */
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cat-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cat-img { display: block; aspect-ratio: 16 / 10; background-color: #6B4226; background-image: repeating-linear-gradient(91deg, rgba(0,0,0,0.1) 0 1px, transparent 1px 8px); }
.cat-img img { width: 100%; height: 100%; object-fit: cover; }
.tone-0 .cat-img { background-color: #D9CBB6; } .tone-1 .cat-img { background-color: #3A3D40; }
.tone-2 .cat-img { background-color: #6B4226; } .tone-3 .cat-img { background-color: #50604F; }
.tone-4 .cat-img { background-color: #C9C6C0; } .tone-5 .cat-img { background-color: #B8895A; }
.tone-6 .cat-img { background-color: #2F3B4A; }
.cat-name { padding: 12px 14px; font-family: var(--serif); font-weight: 600; font-size: 18px; }
[dir="rtl"] .cat-name { font-family: inherit; font-weight: 700; }

/* Category tabs and sub-category chips */
.tabs, .chips { display: flex; gap: 8px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
.tabs::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.tabs { gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 10px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }
.chips a { height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line-strong); background: #fff; display: inline-flex; align-items: center; font-size: 14px; font-weight: 600; flex: none; }
.chips a.on { background: var(--black); border-color: var(--black); color: #fff; }

/* Product tiles */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card-img { display: block; aspect-ratio: 4 / 5; background: #E9E2D8; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.card-name { font-weight: 600; font-size: 15px; line-height: 1.35; }
.card-code { font-size: 13px; color: var(--muted); }

/* Product page */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { padding: 6px 0; }
.crumbs span { color: var(--gold-dark); padding: 6px 0; }
.product { display: grid; gap: 16px; }
.gallery-main { position: relative; background: #E9E2D8; border-radius: 16px; overflow: hidden; aspect-ratio: 4 / 5; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-count { position: absolute; top: 10px; inset-inline-end: 10px; padding: 4px 10px; border-radius: 12px; background: var(--black); color: #fff; font-size: 12px; font-weight: 600; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 2px; }
.thumb { width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 12px; background: #E9E2D8; overflow: hidden; flex: none; cursor: pointer; }
.thumb.on { border-color: var(--gold); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-info { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.pill { padding: 5px 12px; border-radius: 14px; background: var(--black); color: #fff; font-size: 12px; font-weight: 600; }
.product-name { font-size: 28px; }
.code-card { align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
[dir="rtl"] .code-card { padding: 12px 16px 12px 12px; }
.code-label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
[dir="rtl"] .code-label { letter-spacing: 0; }
.code-value { font-weight: 600; font-size: 22px; letter-spacing: 0.04em; }

/* The logo doubles as the hidden way into the admin panel (hold, or double-click) */
.logo[data-admin] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.logo[data-admin] img { pointer-events: none; }

/* Buttons */
.btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px var(--sans); cursor: pointer; }
.btn-primary { background: var(--black); border-color: var(--black); color: #fff; }
.btn-save { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { border-color: #E3B4AC; color: var(--red); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* WhatsApp bar */
.wa-bar { position: fixed; inset-inline: 0; bottom: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); z-index: 9; }
.wa-btn { max-width: 520px; margin: 0 auto; height: 52px; border-radius: 14px; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 16px; }

@media (min-width: 640px) {
  .cat-grid, .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 900px) {
  .appbar { border-radius: 0; }
  .appbar-inner { flex-direction: row; align-items: center; gap: 12px; padding: 10px 24px; }
  .appbar-row { display: contents; }
  .appbar-row .spacer { display: none; }
  .logo { order: 1; margin-inline-end: 12px; }
  .search { order: 2; flex: 1; max-width: 520px; margin-inline-end: auto; }
  .langs { order: 3; }
  .icon-btn { order: 4; }
  .container { padding: 28px 24px 120px; }
  .cat-grid, .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
  .page-title { font-size: 34px; }
  .tabs, .chips { margin-inline: 0; padding-inline: 0; }
  .product { grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 32px; align-items: start; }
  .product-name { font-size: 36px; }
}

/* ---------- Admin panel ---------- */
.admin .appbar { border-radius: 0; position: static; }
.admin .appbar-inner { flex-direction: row; align-items: center; flex-wrap: wrap; padding: 10px 24px; }
.admin-tag { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; color: var(--gold); }
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.admin-nav a, .admin-nav button { min-height: 44px; padding: 0 14px; border-radius: 22px; display: inline-flex; align-items: center; font: 500 14px var(--sans); color: #E4E4E8; background: none; border: 0; cursor: pointer; }
.admin-nav a.on { background: var(--black-2); color: #fff; }
.admin-nav form { margin: 0; }
.admin .container { padding-bottom: 60px; }
.admin-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.admin-head .page-title { margin: 0; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; background: #E4F2E9; color: #0B5C2F; border: 1px solid #B9DCC6; }
.flash.error { background: #FBEAE7; color: var(--red); border-color: #E3B4AC; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel + .panel { margin-top: 16px; }
.narrow { max-width: 640px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters input, .filters select { flex: 1 1 200px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; padding: 12px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
td.actions { white-space: nowrap; text-align: end; }
td.actions form { display: inline; }
.thumb-sm { width: 48px; height: 48px; border-radius: 8px; background: #E9E2D8; object-fit: cover; display: block; }
.sub-row td:first-child { padding-inline-start: 36px; }
.sub-row { background: #FBFAF7; }
.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field select, .filters input, .filters select {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font: 400 15px var(--sans); color: var(--ink); width: 100%;
}
.field input[type="file"] { padding: 12px; border: 1px dashed #8C7A66; border-radius: 12px; background: var(--bg); font: inherit; width: 100%; }
.file-error { font-weight: 500; color: var(--red); }
fieldset.field { border: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; display: inline-flex; }
.choice[hidden] { display: none; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice span { min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 22px; background: #fff; display: inline-flex; align-items: center; font: 600 14px var(--sans); color: var(--ink); }
.choice input:checked + span { background: var(--black); border-color: var(--black); color: #fff; }
.choice input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }
.photo-list { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.photo-item { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.photo-item img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: #E9E2D8; }
.photo-item label { display: flex; align-items: center; gap: 6px; min-height: 28px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.errors { margin: 0 0 16px; padding: 12px 16px 12px 32px; border-radius: 12px; background: #FBEAE7; color: var(--red); border: 1px solid #E3B4AC; font-weight: 500; }
