/* ZadHub — هوية: كحلي · أخضر · ذهبي */
:root {
  --navy: #0B1738; --green: #065F2C; --gold: #A97C2E; --sand: #F7F3EA;
  --bg: #F5F3EE; --surface: #FFFFFF; --surface-2: #FAF8F3; --text: #0B1738; --muted: #556079;
  --border: #E2DDD1; --primary: #065F2C; --primary-hover: #054D24; --primary-text: #FFFFFF;
  --accent: #A97C2E; --danger: #B3261E; --danger-bg: #FCEDEC; --warning-bg: #FBF3E2; --success-bg: #E7F3EC;
  --info-bg: #EAF0FA; --ring: rgba(6, 95, 44, .28); --shadow: 0 1px 2px rgba(11,23,56,.06), 0 6px 20px rgba(11,23,56,.06);
  --radius: 16px; --radius-sm: 10px;
  --font: "Readex Pro", "Segoe UI", Tahoma, sans-serif; --brand-font: "Lexend", "Readex Pro", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #071026; --surface: #0E1B3A; --surface-2: #12224A; --text: #EEF1F7; --muted: #A3AECA;
  --border: #22355F; --primary: #1E9A52; --primary-hover: #23AE5D; --primary-text: #FFFFFF;
  --accent: #D3A24A; --danger: #F2867E; --danger-bg: #3A1A22; --warning-bg: #3A2F17; --success-bg: #12341F;
  --info-bg: #15264A; --ring: rgba(30, 154, 82, .35); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.75; font-size: 16px;
  -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.brand-text { font-family: var(--brand-font); font-weight: 800; letter-spacing: -.02em; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

/* ---------- الشعار حسب الوضع ---------- */
.only-dark { display: none !important; }
:root[data-theme="dark"] .only-dark { display: inline-block !important; }
:root[data-theme="dark"] .only-light { display: none !important; }

/* ---------- الرأس ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar .container { display: flex; align-items: center; gap: 18px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 40px; width: auto; }
.brand span { font-size: 1.45rem; }
.nav { display: flex; gap: 4px; margin-inline-start: 12px; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); padding: 8px 14px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--success-bg); }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px;
  border: 1px solid var(--border); border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; }
:root[data-theme="dark"] .avatar { background: var(--primary); }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); min-width: 210px; padding: 6px; z-index: 40; }
.menu a, .menu button { display: block; width: 100%; text-align: start; padding: 10px 12px; border-radius: 10px; color: var(--text);
  background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

main { flex: 1; padding: 28px 0 56px; }
.footer { border-top: 1px solid var(--border); padding: 18px 0; color: var(--muted); font-size: .85rem; }
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- الشبكة الزخرفية (من رمز الشعار) ---------- */
.net-bg { position: relative; overflow: hidden; }
.net-bg::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='160' viewBox='0 0 220 160'%3E%3Cg fill='none' stroke='%23A97C2E' stroke-opacity='.35' stroke-width='2'%3E%3Cpath d='M20 130 L80 90 L150 100 L200 40'/%3E%3Cpath d='M80 90 L110 30'/%3E%3C/g%3E%3Cg fill='%23A97C2E' fill-opacity='.45'%3E%3Ccircle cx='20' cy='130' r='4'/%3E%3Ccircle cx='80' cy='90' r='6'/%3E%3Ccircle cx='150' cy='100' r='4'/%3E%3Ccircle cx='200' cy='40' r='4'/%3E%3Ccircle cx='110' cy='30' r='4'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 220px 160px; }
.net-bg > * { position: relative; }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

.hero { background: var(--navy); color: #F7F3EA; border-radius: 22px; padding: 28px; margin-bottom: 26px; }
.hero h1 { color: #fff; margin-bottom: 4px; }
.hero p { color: #C9D1E4; margin: 0; }
.hero .badge { background: rgba(255,255,255,.12); color: #F7F3EA; }

/* ---------- الأزرار ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gold { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- النماذج ---------- */
.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field .hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 140px; resize: vertical; line-height: 1.8; }
textarea.editor { min-height: 420px; font-size: .97rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input.ltr, .ltr input { direction: ltr; text-align: left; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 4px; accent-color: var(--primary); flex: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatches input:checked + span { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text); }
.swatches input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }

/* ---------- التنبيهات ---------- */
.flashes { margin-bottom: 18px; display: grid; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 12px; border: 1px solid transparent; }
.flash.success { background: var(--success-bg); border-color: rgba(6,95,44,.25); }
.flash.error { background: var(--danger-bg); color: var(--danger); border-color: rgba(179,38,30,.25); }
.flash.warning { background: var(--warning-bg); border-color: rgba(169,124,46,.35); }
.flash.info { background: var(--info-bg); }
.flash.link { background: var(--surface-2); border: 1px dashed var(--border); display: flex; gap: 10px; align-items: center; }
.flash.link code { flex: 1; direction: ltr; text-align: left; word-break: break-all; font-size: .85rem; }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem;
  font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--success-bg); color: var(--primary); border-color: transparent; }
.badge.gold { background: var(--warning-bg); color: var(--accent); border-color: transparent; }
.badge.red { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .85rem; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }
.table td.wrap { white-space: normal; }

/* ---------- التطبيقات ---------- */
.section-block { margin-bottom: 28px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-title .bar { width: 6px; height: 22px; border-radius: 4px; }
.section-title h2 { margin: 0; font-size: 1.15rem; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.app-tile { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; min-height: 76px; }
.app-tile:hover { text-decoration: none; border-color: var(--c, var(--primary)); transform: translateY(-2px); }
.app-icon { width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 1.25rem; background: var(--c, var(--primary)); }
.app-meta { min-width: 0; }
.app-name { font-weight: 700; line-height: 1.4; }
.app-desc { color: var(--muted); font-size: .82rem; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-box { max-width: 380px; width: 100%; }

/* ---------- المقالات ---------- */
.articles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.article-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
.article-card:hover { text-decoration: none; border-color: var(--accent); }
.article-card .cover { aspect-ratio: 16/9; background: var(--navy); display: grid; place-items: center; overflow: hidden; }
.article-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.article-card .cover .ph { width: 64px; opacity: .9; }
.article-card .body { padding: 16px 18px 18px; }
.article-card h3 { margin-bottom: 6px; }
.article-card p { color: var(--muted); font-size: .92rem; margin: 0; }
.prose { max-width: 760px; margin: 0 auto; font-size: 1.08rem; line-height: 2; }
.prose h2 { margin-top: 1.6em; } .prose h3 { margin-top: 1.3em; }
.prose img { border-radius: 12px; margin: 12px 0; }
.prose blockquote { margin: 1em 0; padding: 4px 18px; border-inline-start: 4px solid var(--accent); background: var(--surface-2); border-radius: 8px; }
.prose pre { background: var(--surface-2); padding: 14px; border-radius: 10px; overflow-x: auto; direction: ltr; text-align: left; }
.prose code { font-family: Consolas, monospace; font-size: .92em; }
.prose table { border-collapse: collapse; width: 100%; } .prose th, .prose td { border: 1px solid var(--border); padding: 8px; }
.article-cover { border-radius: 18px; overflow: hidden; margin-bottom: 22px; max-height: 420px; }
.article-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- صفحات الدخول ---------- */
.auth-wrap { min-height: calc(100vh - 0px); display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--navy); color: #F7F3EA; display: flex; flex-direction: column; justify-content: center; padding: 56px; }
.auth-side img { width: min(360px, 90%); margin-bottom: 28px; }
.auth-side h2 { color: #fff; font-size: 1.6rem; }
.auth-side p { color: #C9D1E4; max-width: 420px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .mobile-logo { display: none; margin: 0 auto 22px; width: 220px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: .93rem; flex-wrap: wrap; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0;
  color: var(--muted); cursor: pointer; padding: 6px 8px; font: inherit; font-size: .85rem; }
.center-card { max-width: 520px; margin: 40px auto; text-align: center; }
.big-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; margin: 0 auto 16px; font-size: 2rem;
  background: var(--success-bg); color: var(--primary); }
.big-icon svg { width: 36px; height: 36px; }

/* ---------- لوحة التحكم ---------- */
.admin-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 26px; align-items: start; }
.side { position: sticky; top: 86px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
.side a svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.side a:hover { background: var(--surface-2); text-decoration: none; }
.side a.active { background: var(--success-bg); color: var(--primary); }
.side a.active svg { color: var(--primary); }
.side .count { margin-inline-start: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat b { display: block; font-size: 1.9rem; font-family: var(--brand-font); line-height: 1.2; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat.accent { border-top: 4px solid var(--accent); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.admin-app-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.admin-app-row:last-child { border-bottom: 0; }
.admin-app-row .app-icon { width: 40px; height: 40px; font-size: 1.05rem; border-radius: 11px; }
.admin-app-row .grow { flex: 1; min-width: 0; }
.admin-app-row .url { direction: ltr; text-align: right; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.editbox { border: 1px dashed var(--border); border-radius: 12px; padding: 0 14px; margin-top: 12px; }
details.editbox[open] { padding-bottom: 6px; }
details.editbox summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--primary); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .5; margin-bottom: 8px; }
.pager { display: flex; justify-content: space-between; margin-top: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.danger-zone { border-color: rgba(179,38,30,.35); }
.tabs-mobile { display: none; }

/* ---------- الحوار ---------- */
dialog { border: 1px solid var(--border); border-radius: 18px; padding: 24px; background: var(--surface); color: var(--text);
  max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5,10,25,.55); }

/* ---------- الشاشات الصغيرة ---------- */
@media (max-width: 960px) {
  .admin-layout { grid-template-columns: 1fr; }
  .side { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 6px; scrollbar-width: none; }
  .side a { white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card .mobile-logo { display: block; }
}
@media (max-width: 720px) {
  .topbar .container { flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; width: 100%; margin: 0; }
  .brand img { height: 34px; } .brand span { font-size: 1.25rem; }
  .user-menu summary .uname { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .app-tile { flex-direction: column; text-align: center; padding: 14px 8px; }
  .app-desc { display: none; }
  .hero { padding: 22px; border-radius: 18px; }
  main { padding-top: 18px; }
  .card { padding: 18px; }
}

[hidden] { display: none !important; }
.article-card .cover img.ph { width: 76px; height: auto; object-fit: contain; }
:root[data-theme="dark"] .hero { background: var(--surface-2); border: 1px solid var(--border); }
