/* ============================================================
   مجلس التقنية — لوحة التحكم (Admin)
   تصميم فاتح متّسق مع هوية الموقع | الخط: IBM Plex Sans Arabic
   ============================================================ */

@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 400; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+2066-2069;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 500; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+2066-2069;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 600; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+2066-2069;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 700; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+2066-2069;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 400; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 600; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}
@font-face {
    font-family: "IBM Plex Sans Arabic";
    font-style: normal; font-weight: 700; font-display: swap;
    src: url("/assets/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}

:root {
    --ink: #1d1d1f;
    --bg: #f5f5f7;
    --panel: #ffffff;
    --muted: #6e6e73;
    --accent: #9b1e77;
    --accent-d: #7d1860;
    --line: #e3e3e8;
    --ok: #1c7c43;
    --ok-bg: #e7f6ec;
    --warn: #9a6b00;
    --warn-bg: #fdf3da;
    --err: #b42318;
    --err-bg: #fdecea;
    --radius: 16px;
    --shadow: 0 18px 40px -28px rgba(0, 0, 0, .35);
    --ease: cubic-bezier(.16, 1, .3, 1);
    --page-max: 1240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- شاشة الدخول ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(120% 120% at 100% 0%, #fbeef6 0%, var(--bg) 55%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 36px 30px;
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    text-align: center;
}
.auth-brand img { height: 52px; width: auto; }
.auth-brand h1 { font-size: 1.15rem; font-weight: 700; }
.auth-brand p { color: var(--muted); font-size: .9rem; }
.auth-links { margin-top: 18px; text-align: center; font-size: .9rem; }
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-links .sep { color: var(--muted); margin: 0 8px; }
.auth-back { margin-top: 12px; text-align: center; font-size: .85rem; }
.auth-back a { color: var(--muted); text-decoration: none; }
.auth-back a:hover { color: var(--ink); }

/* ---------- التخطيط العام ---------- */
.layout {
    display: grid;
    grid-template-columns: 264px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-inline-start: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}
.sidebar-head img { height: 34px; width: auto; }
.sidebar-head strong { font-size: 1rem; font-weight: 700; }
.sidebar-head span { display: block; font-size: .72rem; color: var(--muted); }

.nav-admin { padding: 14px 12px; flex: 1; }
.nav-admin a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 500;
    font-size: .95rem;
    transition: background .2s var(--ease), color .2s var(--ease);
    margin-bottom: 2px;
}
.nav-admin a:hover { background: #f3eef2; color: var(--ink); }
.nav-admin a.active { background: var(--accent); color: #fff; }
.nav-admin a.active .nav-ico svg { stroke: #fff; }
.nav-ico { display: inline-flex; width: 20px; height: 20px; }
.nav-ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.nav-badge {
    margin-inline-start: auto;
    background: var(--err);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.nav-admin a.active .nav-badge { background: rgba(255, 255, 255, .25); }

/* مجموعة قابلة للطيّ في القائمة الجانبية */
.nav-group { margin-bottom: 2px; }
.nav-group summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 500;
    font-size: .95rem;
    cursor: pointer;
    list-style: none;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: #f3eef2; color: var(--ink); }
.nav-group summary.has-active { color: var(--ink); font-weight: 600; }
.nav-caret { margin-inline-start: auto; display: inline-flex; width: 16px; height: 16px; transition: transform .2s var(--ease); }
.nav-caret svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.nav-group-items {
    margin: 2px 0 4px;
    padding-inline-start: 16px;
    border-inline-start: 1px solid var(--line);
    margin-inline-start: 22px;
}
.nav-group-items a { font-size: .9rem; padding: 9px 12px; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg);
    margin-bottom: 10px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}
.user-chip .meta { overflow: hidden; }
.user-chip .meta b { display: block; font-size: .88rem; }
.user-chip .meta small { color: var(--muted); font-size: .75rem; }

/* ---------- المحتوى ---------- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 5;
    background: rgba(245, 245, 247, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 26px;
    max-width: var(--page-max); width: 100%; margin-inline: auto;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
.topbar .spacer { flex: 1; }
.burger-admin {
    display: none;
    width: 40px; height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
    align-items: center; justify-content: center;
}
.burger-admin span { width: 18px; height: 2px; background: var(--ink); position: relative; }
.burger-admin span::before, .burger-admin span::after {
    content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: var(--ink);
}
.burger-admin span::before { top: -6px; }
.burger-admin span::after { top: 6px; }

.page { padding: 26px; max-width: var(--page-max); width: 100%; margin-inline: auto; }

/* ---------- بوابة العملاء ---------- */
.portal-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.portal-brand img { height: 28px; width: auto; }
.portal-brand strong { font-size: 1.05rem; font-weight: 700; }
.portal-topnav { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 18px; }
.portal-topnav a {
    padding: 8px 14px; border-radius: 10px; text-decoration: none;
    color: var(--muted); font-size: .92rem; font-weight: 600;
}
.portal-topnav a:hover { background: var(--panel); color: var(--ink); }
.portal-topnav a.active { background: var(--panel); color: var(--accent); }
.portal-user { display: inline-flex; align-items: center; gap: 8px; }
.portal-user-name { font-size: .9rem; font-weight: 600; }
.topbar--portal .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
@media (max-width: 640px) {
    .portal-topnav { margin-inline-start: 8px; }
    .portal-user-name { display: none; }
    .portal-brand strong { display: none; }
    .portal-hide-sm { display: none !important; }
}

/* حقل مصيدة الروبوتات: مخفي بصريًا دون توسيع عرض الصفحة (لا يسبّب تمريرًا أفقيًا) */
.hp-field {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ---------- الشبكة والبطاقات ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--muted); font-size: .88rem; }
.stat .value { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.stat .ico {
    width: 42px; height: 42px; border-radius: 12px;
    background: #f6edf3; color: var(--accent);
    display: grid; place-items: center; margin-bottom: 4px;
}
.stat .ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }

.dash-welcome { color: var(--muted); margin: 0 0 18px; font-size: 1rem; }

/* ---------- مخطّط الاتجاه ---------- */
.trend-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.trend-head h2 { margin-bottom: 0; }
.trend-legend { color: var(--muted); font-size: .82rem; display: inline-flex; align-items: center; gap: 6px; }
.trend-legend .lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-inline-start: 8px; }
.trend-legend .lg-views { background: #e3c3d8; }
.trend-legend .lg-visitors { background: var(--accent); }

.trend {
    display: flex; align-items: stretch; gap: 7px;
    height: 200px; margin-top: 10px;
}
.trend-col {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.trend-val { font-size: .7rem; font-weight: 600; color: var(--muted); min-height: 1em; }
.trend-track {
    flex: 1 1 auto; width: 100%;
    display: flex; align-items: flex-end; justify-content: center;
}
.trend-bar {
    position: relative; width: 72%; max-width: 28px;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, #edd3e4, #e3c3d8);
    display: flex; align-items: flex-end;
    transition: filter .15s ease;
}
.trend-bar-visitors {
    width: 100%; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--accent), #b5749f);
}
.trend-col:hover .trend-bar { filter: brightness(.96); }
.trend-day { font-size: .66rem; color: var(--muted); direction: ltr; }

.trend-summary {
    display: flex; flex-wrap: wrap; gap: 18px;
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: .85rem; color: var(--muted);
}
.trend-summary strong { color: var(--ink); font-weight: 700; }

/* ---------- شارة تغيّر (دلتا) ---------- */
.stat .delta {
    font-size: .78rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 2px;
    margin-top: 2px;
}
.stat .delta.up { color: #1a7f4b; }
.stat .delta.down { color: #c0392b; }

/* ---------- أبرز المصادر ---------- */
.ref-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.ref-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 10px; }
.ref-name { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-bar { height: 8px; background: var(--line); border-radius: 980px; overflow: hidden; }
.ref-bar span { display: block; height: 100%; border-radius: 980px; background: linear-gradient(90deg, var(--accent), #c98fb8); }
.ref-hits { font-size: .85rem; font-weight: 700; color: var(--ink); min-width: 2ch; text-align: start; }

/* ---------- دليل مقاسات الصور ---------- */
.size-guide {
    margin-top: 10px;
    padding: 12px 14px;
    background: #faf7f9;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: .85rem;
    line-height: 1.7;
}
.size-guide strong { display: block; margin-bottom: 6px; }
.size-guide ul { margin: 0; padding-inline-start: 18px; }
.size-guide li { margin-bottom: 4px; color: var(--muted, #555); }

/* ---------- سلسلة الردود ---------- */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.thread-item {
    border: 1px solid var(--line); border-radius: 12px; padding: 14px;
    background: #faf7f9;
}
.thread-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.thread-meta .muted { font-size: .85rem; }
.thread-body { white-space: pre-wrap; line-height: 1.8; }

/* ---------- صفوف الوحدات ---------- */
.module-row {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 16px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.module-row:last-child { border-bottom: 0; }
.module-row input { width: auto; margin-top: 3px; flex: 0 0 auto; }
.module-meta { display: flex; flex-direction: column; gap: 3px; }
.module-title { font-weight: 600; }
.module-desc { color: var(--muted); font-size: .9rem; line-height: 1.7; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td {
    text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th { color: var(--muted); font-weight: 600; font-size: .82rem; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.unread td { background: #fcf6fa; }

/* ---------- شبكة بطاقات إحصائية قابلة للنقر (فلاتر) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat.is-accent .value { color: var(--accent); }
.stat.is-accent .ico { color: var(--accent); }

/* ---------- خيارات نطاق النسخ الاحتياطي ---------- */
.backup-scopes { display: grid; gap: 10px; }
.backup-scope {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
    cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease);
}
.backup-scope:hover { border-color: var(--accent); }
.backup-scope:has(input:checked) { border-color: var(--accent); background: #fcf6fa; }
.backup-scope input { width: auto; margin-top: 3px; flex: 0 0 auto; }
.backup-scope-body { display: flex; flex-direction: column; gap: 3px; }
.backup-scope-body small { font-size: .82rem; line-height: 1.6; }

/* ---------- قائمة تفاصيل مرتّبة (مفتاح/قيمة) ---------- */
.detail-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 24px;
}
.detail-list .item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: right;
    padding: 10px 2px;
    border-bottom: 1px solid var(--line);
}
.detail-list .item.full { grid-column: 1 / -1; }
.detail-list .item .k { color: var(--muted); font-size: .78rem; font-weight: 600; }
.detail-list .item .v { font-weight: 600; word-break: break-word; }
@media (max-width: 560px) {
    .detail-list { grid-template-columns: 1fr; }
}

/* ---------- قائمة الطلبات الأخيرة (لوحة العميل) ---------- */
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--bg); transition: border-color .2s var(--ease), transform .12s var(--ease);
}
.recent-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.recent-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.recent-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8rem; }

/* ---------- الشارات ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .76rem; font-weight: 600;
    padding: 3px 9px; border-radius: 999px;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.muted { background: var(--bg); color: var(--muted); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: .92rem;
    padding: 10px 18px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; background: var(--accent); color: #fff;
    transition: transform .15s var(--ease), background .2s var(--ease), opacity .2s;
}
.btn:hover { background: var(--accent-d); }
.btn:active { transform: scale(.98); }
.btn.full { width: 100%; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--err); }
.btn.danger:hover { background: #97170f; }
.btn.sm { padding: 7px 12px; font-size: .84rem; border-radius: 10px; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- النماذج ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 7px; }
.field input, .field textarea, .field select {
    width: 100%; font: inherit; color: var(--ink);
    padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel); transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(155, 30, 119, .12);
}
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.field .err-msg { color: var(--err); font-size: .82rem; margin-top: 6px; }

/* ---------- التنبيهات ---------- */
.alert {
    border-radius: 12px; padding: 12px 16px; font-size: .92rem; margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert.success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cd; }
.alert.error { background: var(--err-bg); color: var(--err); border-color: #f5c4c0; }
.alert.info { background: #eaf1fb; color: #1d4ed8; border-color: #cfe0f7; }

/* ---------- حالة فارغة ---------- */
.empty {
    text-align: center; padding: 40px 20px; color: var(--muted);
}

.muted { color: var(--muted); }
.section-gap { margin-top: 22px; }
.pagehead { margin-bottom: 18px; }
.pagehead p { color: var(--muted); }

/* ---------- نافذة طبقة جانبية للموبايل ---------- */
.scrim {
    display: none;
    position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 8;
}

@media (max-width: 900px) {
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset-inline-end: 0; top: 0; z-index: 9;
        width: 280px; transform: translateX(100%);
        transition: transform .3s var(--ease);
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .scrim.show { display: block; }
    .burger-admin { display: inline-flex; }
    .grid.cols-4 { grid-template-columns: 1fr; }
}
