/* ══ نظام ERC المتكامل — إطار الصفحة (القائمة الجانبية + الشريط العلوي) ══
   الأزرار هون (.topbar-btn/.icon-btn) خاصة بالإطار حتى يقدر يشتغل جنب صفحات لسا ما انتقلت لـbase.css. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: var(--fs-14); font-weight: var(--fw-regular); line-height: var(--lh); color: var(--text); background: var(--bg); direction: rtl; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { width: var(--icon); height: var(--icon); flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell.app { height: 100vh; min-height: 0; }
.shell.app .main { height: 100vh; overflow-y: auto; }

.sidebar { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; height: 100vh; overflow: hidden; border-inline-end: 1px solid var(--side-border); }
.sidebar-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-bottom: 1px solid var(--side-border); color: var(--side-strong); }
.sidebar-head img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.sidebar-title { font-size: var(--fs-14); font-weight: var(--fw-semibold); line-height: 1.3; }
.sidebar-sub { font-size: var(--fs-12); color: var(--side-dim); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) 0 var(--s-4); }
.nav-group { padding: var(--s-4) var(--s-4) var(--s-1); font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--side-dim); }
.nav-item { position: relative; display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 8px var(--s-4); background: transparent; border: 0; color: var(--side-text); font-family: var(--font); font-size: var(--fs-14); font-weight: var(--fw-regular); text-align: start; text-decoration: none; cursor: pointer; }
.nav-item .icon { color: var(--side-dim); }
.nav-item:hover { background: var(--side-hover); color: var(--side-strong); }
.nav-item:hover .icon { color: var(--side-text); }
.nav-item.active { background: var(--side-active-bg); color: var(--side-strong); font-weight: var(--fw-medium); }
.nav-item.active::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--brand); }
.nav-item.active .icon { color: var(--side-strong); }
.sidebar-foot { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--side-border); display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--fs-12); color: var(--side-dim); }
.sidebar-foot .row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.sidebar-foot .conn { color: var(--side-text); }
.foot-link { display: inline-flex; align-items: center; gap: 6px; color: var(--side-text); text-decoration: none; font-size: var(--fs-12); }
.foot-link:hover { color: var(--side-strong); }
.foot-link .icon { color: inherit; width: 16px; height: 16px; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-6); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-start { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.breadcrumb { font-size: var(--fs-12); color: var(--text-2); min-height: 18px; }
.page-title { font-size: var(--fs-20); font-weight: var(--fw-semibold); color: var(--text); line-height: 1.3; }
.topbar-btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: var(--font); font-size: var(--fs-13); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap; }
.topbar-btn:hover, .icon-btn:hover { background: var(--hover); border-color: var(--gray-400); }
.topbar-btn .icon, .icon-btn .icon { color: inherit; width: 16px; height: 16px; }
.icon-btn { width: 32px; padding: 0; }
.hamburger { display: none; }
.content { padding: var(--s-6); max-width: 1800px; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(28, 28, 26, .5); z-index: 90; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 1024px) { .shell { grid-template-columns: 200px minmax(0, 1fr); } }
@media (max-width: 768px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .hamburger { display: inline-flex; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; max-width: 82vw; height: 100%; z-index: 95; transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow-float); }
  .sidebar.open { transform: translateX(0); }
  .content { padding: var(--s-4); }
  .topbar { padding: var(--s-3) var(--s-4); }
}

/* ── استجابة الشاشات الصغيرة: أقسام قديمة بتستعمل style="" مباشر (شبكات بعرض ثابت وصفوف flex بدون لفّ) ── */
@media (max-width: 1100px) {
  .content [style*="grid-template-columns:400px"] { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 768px) {
  .content [style*="display:flex"] { flex-wrap: wrap; }
  .content select[style*="width:"], .content input[style*="width:"] { max-width: 100%; }
}
@media (max-width: 560px) {
  .content [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
}
