/* =========================================================
   أركان: الأساسيات المشتركة بين الموقع ولوحة التحكم
   الألوان مستوحاة من القهوة السعودية والنحاس والزعفران
   ========================================================= */

/* ---------- المتغيرات ---------- */
:root {
  --ink: #1E130C;
  --coffee: #3A2417;
  --coffee-2: #5C3B23;
  --gold: #C9973F;
  --gold-soft: #EBD6A6;
  --gold-deep: #8F6420;
  --saffron: #E0822A;
  --saffron-soft: #FCEBDA;
  --paper: #FCFBF9;
  --sand: #F5EFE7;
  --sand-2: #ECE3D6;
  --line: #E7DDCF;
  --text: #2A1C12;
  --muted: #76665A;
  --ok: #2F7D4F;
  --ok-soft: #E3F1E8;
  --danger: #B4432A;
  --danger-soft: #F7E4DE;

  --r-xl: 32px;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(58, 36, 23, .06);
  --shadow: 0 1px 2px rgba(58, 36, 23, .05), 0 14px 32px -18px rgba(58, 36, 23, .35);
  --head: "Noto Kufi Arabic", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --hh: 72px;
  --wrap: 1240px;
}

/* ---------- إعادة الضبط ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--hh) + 20px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.4; margin: 0; color: var(--ink); font-weight: 700; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--gold-soft); color: var(--ink); }
main:focus { outline: none; }

/* ---------- أدوات عامة ---------- */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 26px; height: 26px; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 24px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
[hidden] { display: none !important; }
.js .no-js-only { display: none !important; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #D6A54C; box-shadow: 0 8px 20px -10px rgba(201, 151, 63, .9); }
.btn-dark { background: var(--coffee); color: #fff; }
.btn-dark:hover { background: var(--ink); }
.btn-line { background: #fff; border-color: var(--line); color: var(--coffee); }
.btn-line:hover { border-color: var(--gold); }
.btn-danger { background: #fff; border-color: #EBC9BF; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost-light { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .18); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .14); }
.btn-wa { background: #1F7A4A; color: #fff; }
.btn-wa:hover { background: #196640; }
.btn.sm { height: 38px; padding: 0 16px; font-size: 14px; }
.btn.xs { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 38px; padding: 0; }

/* ---------- الشرائح والشارات ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; background: var(--sand); color: var(--coffee-2);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; border: 1px solid transparent;
}
a.chip:hover { border-color: var(--gold); }
.chip.gold { background: var(--saffron-soft); color: #8A4A10; }
.chip.dark { background: var(--coffee); color: var(--gold-soft); }
.chip .ic { width: 15px; height: 15px; }
.badge-ver { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-size: 13px; font-weight: 600; vertical-align: middle; }
.badge-ver .ic { width: 17px; height: 17px; }

/* ---------- الصور الرمزية (الحرف الأول أو الشعار) ---------- */
.av { display: grid; place-items: center; flex: none; font-family: var(--head); font-weight: 700; color: #fff; overflow: hidden; position: relative; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.org { border-radius: 12px; }
.av.ind { border-radius: 50%; }
.av.s { width: 36px; height: 36px; font-size: 15px; }
.av.m { width: 52px; height: 52px; font-size: 21px; }
.av.l { width: 112px; height: 112px; font-size: 44px; border: 5px solid #fff; box-shadow: var(--shadow); }
.av.l.org { border-radius: 26px; }

/* ---------- حقول النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field label, .field .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field label i { color: var(--danger); font-style: normal; }
.select, .input, .textarea {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 0 14px; outline: 0; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2376665A' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 14px center; padding-left: 38px;
}
.select:disabled { background-color: var(--sand); color: #A8978A; cursor: not-allowed; }
.textarea { height: auto; min-height: 150px; padding: 12px 14px; resize: vertical; line-height: 1.8; }
.select:focus, .input:focus, .textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 151, 63, .18); }
.input[dir="ltr"], .textarea[dir="ltr"] { text-align: left; }
.err { font-size: 13px; color: var(--danger); display: none; }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.field.invalid .err { display: block; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 14.5px; }
.check input {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid #CDBFAE; display: grid; place-items: center; flex: none; cursor: pointer; margin: 0; background: #fff;
}
.check input:checked { background: var(--coffee); border-color: var(--coffee); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--gold-soft); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.check input[type=radio] { border-radius: 50%; }
.check input[type=radio]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--gold-soft); transform: none; }
.check .n { margin-inline-start: auto; font-size: 12.5px; color: var(--muted); background: var(--sand); border-radius: 999px; padding: 0 8px; line-height: 22px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--sand); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; height: 36px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--coffee-2); cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid var(--gold); }

.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 13.5px; color: var(--coffee-2); line-height: 1.6; margin-top: 6px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: #D9CDBE; position: relative; flex: none; cursor: pointer; margin: 2px 0 0; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: right .15s; }
.toggle input:checked { background: var(--saffron); }
.toggle input:checked::after { right: 19px; }
.toggle.off { opacity: .5; pointer-events: none; }

/* ---------- النوافذ المنبثقة ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 19, 12, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 80; display: none; align-items: center; justify-content: center; padding: 20px;
}
.overlay.open { display: flex; }
.modal { background: var(--paper); border-radius: var(--r-xl); width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); }
@media (prefers-reduced-motion: no-preference) {
  .overlay.open .modal { animation: pop .25s cubic-bezier(.2, .7, .2, 1); }
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 6px; }
.modal-head h3 { font-size: 20px; }
.modal-body { padding: 10px 26px 8px; }
.modal-body > p { color: var(--muted); font-size: 14.5px; margin-bottom: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: space-between; padding: 18px 26px 24px; flex-wrap: wrap; }
.x { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; }

/* ---------- التنبيه السريع ---------- */
.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 20px;
  border-radius: 14px; font-size: 14.5px; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ic { color: var(--gold); }

/* ---------- الترقيم ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 36px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 42px; height: 42px; padding: 0 12px; border-radius: 12px; display: inline-grid; place-items: center;
  font-weight: 600; font-size: 14.5px; border: 1px solid var(--line); background: #fff; color: var(--coffee-2);
}
.pager a:hover { border-color: var(--gold); }
.pager .current { background: var(--coffee); border-color: var(--coffee); color: #fff; }
.pager .gap { border: 0; background: none; min-width: 20px; padding: 0; }
.pager .disabled { opacity: .45; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
