/* ==========================================================================
   رسوخ العمرانية — base.css
   المتغيرات، التصفير، هيكل التطبيق، الشريط الجانبي، الشريط العلوي
   ========================================================================== */

:root {
  /* الهوية — أزرق شعار «رسوخ العمرانية» (#122f47) + ذهبي */
  --brand: #1b4a72;
  --brand-2: #2a6ba8;
  --brand-dark: #122f47;
  --brand-darker: #0a1c2b;
  --gold: #c9a227;
  --gold-soft: #fbf3d9;

  --bg: #f3f6fa;
  --card: #ffffff;
  --line: #e2e9f1;
  --line-soft: #eef3f8;
  --text: #0f1b26;
  --text-2: #33424f;
  --muted: #6d7d8a;
  --muted-2: #97a6b0;

  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --info: #0284c7;
  --violet: #7c3aed;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(11, 61, 44, .05), 0 6px 18px -10px rgba(11, 61, 44, .18);
  --shadow-lg: 0 12px 40px -14px rgba(11, 61, 44, .32);
  --sidebar-w: 268px;
  --font: "Noto Kufi Arabic", "Segoe UI", "Tahoma", "Dubai", "Cairo", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; line-height: 1.4; }
p { margin: 0 0 .5rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
b, strong { font-weight: 700; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------- هيكل ---------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.view {
  flex: 1;
  padding: 20px 24px 8px;
  min-width: 0;
  animation: fade .28s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* -------------------------------- جانبي -------------------------------- */
.sidebar {
  background: linear-gradient(175deg, var(--brand-dark), var(--brand-darker) 65%);
  color: #e9eef5;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 4px; }

/* ------------------------------ الشعار (الهوية) ------------------------------ */
.brand { padding: 4px 8px 12px; text-align: center; }
.brand-logo {
  display: block;
  width: 100%;
  max-width: 212px;
  height: auto;
  margin: 2px auto 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25));
}
.brand-mark { display: none; width: 42px; height: auto; margin: 2px auto 0; }
.brand-tag {
  display: block;
  color: #9db4c8;
  font-size: 10.5px;
  letter-spacing: .2px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav-sep { font-size: 10.5px; letter-spacing: .5px; color: #6f8ba3; padding: 14px 12px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #d3dfe9;
  cursor: pointer;
  border: 0; background: none; width: 100%; text-align: start;
  font-size: 14px;
  transition: background .16s, color .16s, transform .16s;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-end: -14px; top: 12px; bottom: 12px;
  width: 4px; border-radius: 4px 0 0 4px; background: var(--gold);
}
.nav-ico { font-size: 16px; width: 22px; text-align: center; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--gold); color: #241a00;
  font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.nav-badge.alert { background: var(--danger); color: #fff; }

.sidebar-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }
.license-box {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.license-box small { display: block; color: #9db4c8; font-size: 10.5px; }
.license-box b { color: #fff; font-size: 13px; letter-spacing: .3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 4px rgba(61, 220, 132, .18); flex: 0 0 8px; }
.ghost-btn {
  background: rgba(255, 255, 255, .08); color: #dce6ee; border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; font-size: 13px;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* ------------------------------- شريط علوي ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.page-head { min-width: 150px; }
.page-head h1 { font-size: 19px; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 520px; }
.search-wrap input {
  width: 100%; padding: 10px 38px 10px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fbfdfc;
  transition: border-color .18s, box-shadow .18s;
}
.search-wrap input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(15, 138, 88, .13); background: #fff; }
.search-ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 17px; pointer-events: none; }
.search-wrap kbd {
  position: absolute; inset-inline-end: 9px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--muted-2); background: var(--line-soft);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-family: var(--font);
}
.search-results {
  position: absolute; top: calc(100% + 8px); inset-inline: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; z-index: 40; padding: 6px;
}
.sr-group-title { font-size: 11px; color: var(--muted-2); padding: 8px 10px 4px; font-weight: 700; }
.sr-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.sr-item:hover, .sr-item.active { background: var(--line-soft); }
.sr-item .sr-main { flex: 1; min-width: 0; }
.sr-item .sr-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-item .sr-main small { color: var(--muted); font-size: 11.5px; }
.sr-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 15px; color: var(--text-2);
  transition: background .16s, border-color .16s, transform .16s;
}
.icon-btn:hover { background: var(--line-soft); }
.icon-btn:active { transform: scale(.95); }
#hijriPill {
  width: auto; padding: 0 12px; font-size: 12.5px; color: var(--brand-dark);
  background: var(--gold-soft); border-color: #ecd9a0; font-weight: 600;
}

.quick-add-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 235px; z-index: 45;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; background: none; cursor: pointer;
  border-radius: 9px; text-align: start; font-size: 13.5px;
}
.dropdown-item:hover { background: var(--line-soft); }
.dropdown-sep { height: 1px; background: var(--line); margin: 5px 6px; }

/* --------------------------------- تذييل --------------------------------- */
.app-foot {
  padding: 14px 24px 18px; color: var(--muted-2); font-size: 11.5px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.app-foot b { color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(7, 42, 30, .45); z-index: 50; }

/* ------------------------------- استجابة ------------------------------- */
.only-mobile { display: none !important; }

@media (max-width: 1080px) {
  :root { --sidebar-w: 74px; }
  .nav-label, .nav-badge, .license-box div, .ghost-btn { display: none; }
  .brand { padding-inline: 0; }
  .brand-logo, .brand-tag { display: none; }
  .brand-mark { display: block; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-sep { display: none; }
  .license-box { justify-content: center; padding: 10px 0; }
  .sidebar-foot { justify-items: center; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 250px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-end: 0; width: 250px;
    transform: translateX(105%); transition: transform .26s ease; z-index: 60;
  }
  html[dir="rtl"] .sidebar { transform: translateX(-105%); }
  body.menu-open .sidebar { transform: none; }
  .nav-label, .nav-badge, .license-box div, .ghost-btn { display: revert; }
  .brand { padding: 4px 8px 12px; }
  .brand-logo, .brand-tag { display: block; }
  .brand-mark { display: none; }
  .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .only-mobile { display: grid !important; }
  .only-desktop { display: none !important; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .view { padding: 14px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .page-head { flex: 1; }
}
