/* ==========================================================
   admin.css — لوحة التحكم
   ========================================================== */
body.admin-open { overflow: hidden; }
#adminRoot { position: fixed; inset: 0; z-index: 5000; background: #f4f3f0; color: var(--ink); overflow: hidden; }
.adm { height: 100%; display: flex; flex-direction: column; font-size: 15px; }
.adm-top { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem; background: var(--deep-900); color: #fff; flex-shrink: 0; }
.adm-logo { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-size: 1rem; }
.adm-status { margin-inline-start: auto; font-size: .8rem; color: #b9c5bd; }
.adm-status.is-dirty { color: var(--gold-light); }
.adm-burger { display: none; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; width: 38px; height: 38px; border-radius: 6px; cursor: pointer; }
.adm-body { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.adm-side { background: #fff; border-inline-end: 1px solid var(--line); overflow-y: auto; padding: 1rem .7rem 2rem; }
.adm-side__label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--ink-3); margin: 1.2rem .6rem .4rem; }
.adm-nav { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .5rem; text-align: start; background: none; border: 0; padding: .55rem .7rem; border-radius: 6px; cursor: pointer; font-size: .9rem; color: var(--ink-2); font-weight: 500; }
.adm-nav:hover { background: var(--bg); color: var(--ink); }
.adm-nav.is-active { background: var(--deep); color: #fff; }
.adm-count { font-size: .72rem; background: var(--bg-tint); color: var(--ink-3); border-radius: 100px; padding: 0 .5rem; min-width: 22px; text-align: center; }
.adm-nav.is-active .adm-count { background: rgba(255,255,255,.18); color: #fff; }
.adm-count--hot { background: var(--danger); color: #fff; }
.adm-main { overflow-y: auto; padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 4rem; }
.adm-page { max-width: 1040px; }
.adm-page__head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.adm-page__tools { display: flex; gap: .6rem; flex-wrap: wrap; }
.adm-h1 { font-size: 1.45rem; margin-bottom: 1rem; }
.adm-page__head .adm-h1 { margin: 0; }
.adm-muted { color: var(--ink-3); font-size: .88rem; }
.adm-note { background: #fbf6e7; border: 1px solid #ecdcae; color: #5d4712; padding: .7rem 1rem; border-radius: 6px; font-size: .85rem; margin-bottom: 1rem; }
.adm-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem; margin-bottom: 1.2rem; }
.adm-card h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.adm-card__head { display: flex; justify-content: space-between; align-items: center; }
.adm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.adm-kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; text-align: start; cursor: pointer; transition: border-color .2s, transform .2s; }
.adm-kpi:hover { border-color: var(--gold); transform: translateY(-2px); }
.adm-kpi b { display: block; font-family: var(--display); font-size: 1.8rem; color: var(--green); }
.adm-kpi span { font-size: .85rem; color: var(--ink-2); }
.adm-pct { font-family: var(--display); font-weight: 700; color: var(--green); }
.adm-progress { height: 8px; border-radius: 100px; background: var(--bg-tint); overflow: hidden; margin: .6rem 0 1rem; }
.adm-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--green)); border-radius: 100px; }
.adm-checks li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--bg-tint); font-size: .9rem; }
.adm-checks li > span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #f6e6c7; color: #7a5c1e; font-size: .8rem; flex-shrink: 0; }
.adm-checks li.is-ok { color: var(--ink-3); }
.adm-checks li.is-ok > span { background: #dcefe3; color: var(--ok); }
.adm-link { margin-inline-start: auto; background: none; border: 0; color: var(--green); font-weight: 700; cursor: pointer; font-size: .85rem; }
.adm-tips { display: grid; gap: .4rem; font-size: .88rem; color: var(--ink-2); list-style: disc; padding-inline-start: 1.2rem; }

/* أزرار */
.adm-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .45rem 1.1rem; border-radius: 6px; border: 1px solid var(--deep); background: var(--deep); color: #fff; font-weight: 700; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.adm-btn:hover { background: var(--deep-900); }
.adm-btn--ghost { background: transparent; color: inherit; border-color: currentColor; opacity: .9; }
.adm-top .adm-btn--ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.adm-main .adm-btn--ghost { color: var(--ink); border-color: var(--line-strong); }
.adm-btn--danger { background: var(--danger); border-color: var(--danger); }
.adm-btn--sm { min-height: 34px; padding: .3rem .8rem; font-size: .82rem; }
.adm-btn[disabled] { opacity: .6; }
.adm-icon { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: .9rem; color: var(--ink-2); }
.adm-icon:hover:not([disabled]) { border-color: var(--ink-3); color: var(--ink); }
.adm-icon[disabled] { opacity: .35; cursor: default; }
.adm-icon--danger { color: var(--danger); }
.adm-icon.is-armed { width: auto; padding: 0 .6rem; background: var(--danger); color: #fff; border-color: var(--danger); font-size: .78rem; font-weight: 700; }
.adm-search { min-height: 40px; padding: .4rem .9rem; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; min-width: 220px; }

/* قائمة العناصر */
.adm-list { display: grid; gap: .6rem; }
.adm-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; transition: border-color .2s, box-shadow .2s; }
.adm-item.is-open { border-color: var(--gold); box-shadow: 0 10px 30px -18px rgba(10,10,12,.4); }
.adm-item__bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem .5rem .8rem; }
.adm-item__title { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; background: none; border: 0; text-align: start; cursor: pointer; padding: .3rem; font-weight: 600; font-size: .95rem; }
.adm-item__title > span:not(.adm-tag):not(.adm-item__dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-item__title img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.adm-item__dot { width: 40px; height: 40px; border-radius: 6px; background: var(--bg-tint); display: grid; place-items: center; color: var(--green); flex-shrink: 0; }
.adm-item__tools { display: flex; gap: .3rem; }
.adm-item__form { padding: 0 1.2rem 1.2rem; border-top: 1px solid var(--bg-tint); padding-top: 1.1rem; }
.adm-tag { font-size: .7rem; font-weight: 700; padding: .1rem .5rem; border-radius: 100px; background: #f6e6c7; color: #7a5c1e; flex-shrink: 0; }
.adm-tag--warn { background: #f8e2dc; color: var(--danger); }
.adm-empty-inline { padding: 2rem; text-align: center; color: var(--ink-3); border: 1.5px dashed var(--line-strong); border-radius: 10px; background: #fff; }

/* النماذج */
.adm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.adm-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.adm-field--full { grid-column: 1 / -1; }
.adm-label { font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.adm-label em { color: var(--danger); font-style: normal; }
.adm-field input:not([type=checkbox]):not([type=file]), .adm-field select, .adm-field textarea { width: 100%; padding: .6rem .8rem; border: 1.3px solid var(--line-strong); border-radius: 6px; background: #fbfaf7; font-size: .92rem; }
.adm-field textarea { resize: vertical; line-height: 1.7; }
.adm-field input:focus, .adm-field select:focus, .adm-field textarea:focus { outline: none; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(193,154,63,.22); }
.adm-field.is-invalid input, .adm-field.is-invalid textarea { border-color: var(--danger); }
.adm-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .85rem !important; }
.adm-hint { font-size: .75rem; color: var(--ink-3); }
.adm-form__foot { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--bg-tint); }
.adm-field--switch { justify-content: center; }
.adm-switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; font-size: .9rem; font-weight: 600; }
.adm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.adm-switch span { width: 42px; height: 24px; border-radius: 100px; background: var(--line-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.adm-switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.adm-switch input:checked + span { background: var(--green); }
.adm-switch input:checked + span::after { transform: translateX(-18px); }
.adm-switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.adm-image__box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.adm-image__preview { width: 180px; aspect-ratio: 16 / 10; border-radius: 8px; border: 1px dashed var(--line-strong); background: var(--bg); display: grid; place-items: center; overflow: hidden; font-size: .8rem; color: var(--ink-3); }
.adm-image__preview img { width: 100%; height: 100%; object-fit: cover; }
.adm-image__actions { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.adm-image__actions label.adm-btn { cursor: pointer; }
.adm-toolbar { display: flex; flex-wrap: wrap; gap: .3rem; }
.adm-toolbar button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .25rem .65rem; font-size: .78rem; cursor: pointer; }
.adm-toolbar button:hover { border-color: var(--green); color: var(--green); }
.adm-preview { border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; background: #fff; max-height: 460px; overflow: auto; }

/* الطلبات */
.adm-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.adm-chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 100px; padding: .3rem .9rem; font-size: .82rem; cursor: pointer; }
.adm-chip span { color: var(--ink-3); margin-inline-start: .2rem; }
.adm-chip.is-active { background: var(--deep); color: #fff; border-color: var(--deep); }
.adm-chip.is-active span { color: #c9cfc7; }
.adm-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.adm-table { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 820px; }
.adm-table th { text-align: start; font-size: .75rem; color: var(--ink-3); font-weight: 700; padding: .8rem; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.adm-table td { padding: .8rem; border-bottom: 1px solid var(--bg-tint); vertical-align: top; }
.adm-table td small { display: block; color: var(--ink-3); font-size: .75rem; margin-top: .15rem; }
.adm-table select { border: 1px solid var(--line-strong); border-radius: 6px; padding: .3rem .5rem; background: #fff; }
.adm-msg { max-width: 280px; white-space: pre-wrap; color: var(--ink-2); }
.ltr-cell { direction: ltr; text-align: end; }

/* مكتبة الصور */
.adm-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.adm-media__item { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.adm-media__item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.adm-media__item figcaption { display: flex; justify-content: space-between; align-items: center; padding: .4rem .6rem; font-size: .75rem; color: var(--ink-3); }
.adm-media__item.is-orphan { border-style: dashed; }

/* حالات */
.adm-empty { max-width: 420px; margin: 12vh auto; text-align: center; display: grid; gap: 1rem; justify-items: center; }
.adm-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.adm-modal { position: fixed; inset: 0; background: rgba(7,20,15,.55); display: grid; place-items: center; z-index: 5100; padding: 16px; }
.adm-modal__card { background: #fff; border-radius: 12px; padding: 1.5rem; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.adm-modal__card p { margin-bottom: 1.2rem; font-weight: 600; }
.adm-modal__actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.adm-modal__actions .adm-btn--ghost { color: var(--ink); border-color: var(--line-strong); }

@media (max-width: 860px) {
  .adm-burger { display: block; }
  .adm-body { grid-template-columns: 1fr; }
  .adm-side { position: fixed; top: 58px; bottom: 0; right: 0; width: 270px; z-index: 10; transform: translateX(105%); transition: transform .3s; box-shadow: -20px 0 40px -20px rgba(0,0,0,.3); }
  .adm-side.is-open { transform: none; }
  .adm-grid { grid-template-columns: 1fr; }
  .adm-status { display: none; }
  .adm-logo { font-size: .9rem; }
  .adm-search { min-width: 0; flex: 1; }
}

/* ---------- إضافات: هياكل التحميل، تحديد جماعي، ترقيم، مسودات، نسخ سابقة ---------- */
.adm-skel { background: linear-gradient(90deg, #ece9df 25%, #f6f4ec 50%, #ece9df 75%); background-size: 200% 100%; animation: adm-shimmer 1.3s infinite linear; border-radius: 8px; }
.adm-skel--title { height: 30px; width: 200px; margin-bottom: 1.2rem; }
.adm-skel--row { height: 64px; margin-bottom: .8rem; }
@keyframes adm-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .adm-skel { animation: none; } }

.adm-color { display: flex; align-items: center; gap: .5rem; }
.adm-color input { flex: 1; }
.adm-color i { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line-strong); flex-shrink: 0; }

.adm-tag--draft { background: #fbe9c9; color: #6b4a0a; border-color: #d9b46a; }

.adm-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .7rem 1rem; margin-bottom: .8rem; background: #fff; border: 1px solid var(--green); border-radius: 10px; }
.adm-bulk select { border: 1px solid var(--line-strong); border-radius: 6px; padding: .3rem .5rem; background: #fff; min-height: 34px; }
.adm-pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; color: var(--ink-2); font-size: .88rem; }
.adm-btn:disabled { opacity: .5; cursor: not-allowed; }

.adm-draft { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .7rem 1rem; margin-bottom: 1rem; background: #fff7e0; border: 1px solid #d9b46a; border-radius: 8px; color: #5a3f08; font-size: .88rem; }
.adm-draft span { flex: 1 1 220px; }

.adm-modal__card--wide { max-width: 560px; max-height: 80vh; overflow: auto; }
.adm-revs { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .5rem; }
.adm-revs li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; }
.adm-revs small { display: block; color: var(--ink-3); }

.adm-media__row { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.adm-media__tools { display: flex; gap: .3rem; }
.adm-media__alt { width: 100%; min-height: 34px; padding: .3rem .6rem; border: 1px solid var(--line-strong); border-radius: 6px; font-size: .8rem; background: #fff; }
.adm-checks li div { flex: 1; }
.adm-media__item figcaption { flex-direction: column; align-items: stretch; }
.adm-login{max-width:380px;margin:8vh auto;text-align:right}
.adm-login form{display:grid;gap:12px}
.adm-err{color:#b3261e;font-weight:600;margin:0}
