/* ============================================================
   الفرسان SPKS · التخطيط
   خصائص منطقية فقط — يعمل RTL و LTR بملف واحد
   ============================================================ */

/* ============ شاشة الدخول ============ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

.auth-brand {
  background: var(--grad-primary); color: #fff; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; padding: var(--s7);
}
.auth-brand::before,
.auth-brand::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .07);
}
.auth-brand::before { width: 460px; height: 460px; inset-block-end: -190px; inset-inline-end: -160px; }
.auth-brand::after  { width: 250px; height: 250px; inset-block-start: -90px; inset-inline-start: -70px; }

.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brandmark { display: flex; align-items: center; gap: var(--s3); }
.auth-brand .brandmark img {
  width: 62px; height: 62px; border-radius: 15px; flex: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.auth-brand .brandmark .t { line-height: 1.3; }
.auth-brand .brandmark .t b { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; display: block; }
.auth-brand .brandmark .t span { font-size: var(--fs-sm); opacity: .85; }

.auth-brand .pitch h2 { font-size: clamp(24px, 3vw, 34px); margin-bottom: var(--s3); line-height: 1.35; }
.auth-brand .pitch p { opacity: .88; max-width: 40ch; line-height: 1.85; font-size: var(--fs-md); }
.auth-brand .feats { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s6); }
.auth-brand .feat { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-sm); }
.auth-brand .feat i {
  width: 32px; height: 32px; border-radius: 9px; flex: none; font-style: normal;
  background: rgba(255, 255, 255, .16); display: grid; place-items: center; padding: 8px;
}
.auth-brand .feat i svg { width: 100%; height: 100%; }
.auth-brand .foot { font-size: var(--fs-xs); opacity: .7; }

.auth-form-side { display: grid; place-items: center; padding: var(--s6) var(--s5); background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .mobile-logo { display: none; text-align: center; margin-bottom: var(--s5); }
.auth-card .mobile-logo img { width: 78px; height: 78px; border-radius: 18px; margin-inline: auto; box-shadow: var(--shadow-2); }
.auth-card > header { margin-bottom: var(--s6); }
.auth-card > header h1 { font-size: var(--fs-2xl); margin-bottom: 6px; }
.auth-card > header p { color: var(--muted); font-size: var(--fs-sm); }
.auth-card form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.auth-alert {
  display: flex; align-items: flex-start; gap: var(--s2);
  background: var(--crit-soft); color: var(--crit);
  border-radius: var(--r-sm); padding: 12px var(--s3); font-size: var(--fs-sm); font-weight: 500;
}
/* محتوى كلمة المرور يُكتب LTR دائماً، فيثبت الزر على يمين الحقل في اللغتين */
.pw-wrap { position: relative; direction: ltr; }
.pw-wrap .input { padding-right: 46px; padding-left: 12px; }
.pw-toggle {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  padding: 7px; border-radius: 7px; color: var(--muted); display: grid;
}
.pw-toggle svg { width: 17px; height: 17px; }
.pw-toggle:hover { background: var(--surface-3); color: var(--ink); }
.lang-switch { position: fixed; inset-block-start: var(--s4); inset-inline-end: var(--s4); z-index: 10; }

@media (max-width: 940px) {
  .auth-wrap { grid-template-columns: 1fr; background: var(--surface); }
  .auth-brand { display: none; }
  .auth-card .mobile-logo { display: block; }
}

/* ============ الهيكل العام ============ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.mini { grid-template-columns: var(--sidebar-mini) 1fr; }

/* ---------------- القائمة الجانبية ---------------- */
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  z-index: 60; box-shadow: var(--shadow-1);
}
.sidebar-head {
  height: var(--header-h); display: flex; align-items: center; gap: var(--s3);
  padding-inline: var(--s4); border-bottom: 1px solid var(--line-2); flex: none;
}
.sidebar-head img { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.sidebar-head .name { line-height: 1.25; overflow: hidden; }
.sidebar-head .name b { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); display: block; }
.sidebar-head .name small { display: block; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.shell.mini .sidebar-head { justify-content: center; padding-inline: 0; }
.shell.mini .sidebar-head .name { display: none; }

.nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s3) var(--s4); display: flex; flex-direction: column; gap: 3px; }
.nav::-webkit-scrollbar { width: 5px; }
.nav-group {
  margin-top: var(--s4); padding: 0 var(--s3) 6px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  letter-spacing: .06em; text-transform: uppercase;
}
.nav-group:first-child { margin-top: 2px; }
.shell.mini .nav-group { font-size: 0; text-align: center; padding: 0; }
.shell.mini .nav-group::after { content: "•••"; font-size: 10px; letter-spacing: 1px; }

.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: 10px;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600;
  transition: var(--tr); position: relative; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--primary); text-decoration: none; }
.nav-item.active { background: var(--grad-primary); color: #fff; box-shadow: var(--shadow-blue); }
.nav-item.active:hover { color: #fff; }
.nav-item > svg { width: 19px; height: 19px; flex: none; }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; }
.nav-item .chev { width: 15px; height: 15px; flex: none; transition: transform var(--tr); opacity: .6; }
.nav-item.open .chev { transform: rotate(180deg); }
.nav-item .count {
  font-size: 10.5px; font-family: var(--font-mono);
  background: var(--surface-3); color: var(--muted); padding: 1px 7px; border-radius: var(--r-full);
}
.nav-item.active .count { background: rgba(255, 255, 255, .22); color: #fff; }
.shell.mini .nav-item { justify-content: center; padding-inline: 0; }
.shell.mini .nav-item .label,
.shell.mini .nav-item .chev,
.shell.mini .nav-item .count { display: none; }

/* قائمة فرعية */
.subnav { display: none; flex-direction: column; gap: 2px; margin: 2px 0 4px; padding-inline-start: 30px; }
.subnav.open { display: flex; }
.shell.mini .subnav { display: none !important; }
.subnav a {
  padding: 8px var(--s3); border-radius: 8px; font-size: 12.5px; font-weight: 500;
  color: var(--muted); transition: var(--tr); position: relative;
}
.subnav a::before {
  content: ""; position: absolute; inset-inline-start: -14px; inset-block-start: 50%;
  width: 6px; height: 1px; background: var(--line);
}
.subnav a:hover { background: var(--surface-2); color: var(--primary); text-decoration: none; }
.subnav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }

.sidebar-foot { padding: var(--s3); border-top: 1px solid var(--line-2); flex: none; }
.user-chip {
  display: flex; align-items: center; gap: var(--s3); padding: 9px;
  border-radius: 11px; width: 100%; transition: var(--tr); color: inherit;
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: var(--grad-primary); color: #fff;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 13px;
}
.user-chip .meta { text-align: start; overflow: hidden; min-width: 0; }
.user-chip .meta b { display: block; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta small { color: var(--muted); font-size: 11px; }
.shell.mini .user-chip { justify-content: center; }
.shell.mini .user-chip .meta { display: none; }

/* ---------------- الهيدر ---------------- */
.main-col { display: flex; flex-direction: column; min-width: 0; }
.header {
  height: var(--header-h); flex: none; position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s3); padding-inline: var(--s5);
}
.header .spacer { flex: 1; }

.header-search { flex: 1; max-width: 470px; position: relative; }
.header-search input {
  width: 100%; padding: 11px var(--s4); padding-inline-start: 44px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; font-size: var(--fs-sm); transition: var(--tr); font-family: inherit;
}
.header-search input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
.header-search input::placeholder { color: var(--muted); }
.header-search > svg {
  position: absolute; inset-inline-start: 15px; inset-block-start: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; color: var(--muted);
  display: grid; place-items: center; transition: var(--tr); position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute; inset-block-start: 8px; inset-inline-end: 8px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--r-full);
  background: var(--crit); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface); line-height: 1;
}

/* قائمة منسدلة */
.dd { position: relative; }
.dd-menu {
  position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-3); padding: 6px; z-index: 90; display: none;
  animation: pop .16s ease-out;
}
.dd-menu.open { display: block; }
.dd-menu a, .dd-menu button {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: 9px var(--s3); border-radius: 8px; font-size: var(--fs-sm); font-weight: 500;
  color: var(--ink-2); transition: var(--tr); text-align: start;
}
.dd-menu a:hover, .dd-menu button:hover { background: var(--surface-2); color: var(--primary); text-decoration: none; }
.dd-menu svg { width: 17px; height: 17px; flex: none; }
.dd-menu .sep { height: 1px; background: var(--line-2); margin: 5px 0; }
.dd-menu .danger { color: var(--crit); }
.dd-menu .danger:hover { background: var(--crit-soft); color: var(--crit); }
.dd-head { padding: var(--s3); border-bottom: 1px solid var(--line-2); margin-bottom: 5px; }
.dd-head b { display: block; font-size: var(--fs-sm); font-weight: 700; }
.dd-head small { color: var(--muted); font-size: 11.5px; }

/* بطاقة المستخدم في الهيدر */
.header-user { display: flex; align-items: center; gap: var(--s2); padding: 5px; border-radius: 11px; transition: var(--tr); }
.header-user:hover { background: var(--surface-2); }
.header-user .meta { text-align: start; line-height: 1.3; }
.header-user .meta b { display: block; font-size: 12.5px; font-weight: 700; }
.header-user .meta small { color: var(--muted); font-size: 11px; }
@media (max-width: 720px) { .header-user .meta { display: none; } }

/* ---------------- المحتوى ---------------- */
.content { flex: 1; padding: var(--s5); max-width: 1560px; width: 100%; margin-inline: auto; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap;
}
.page-head h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
.page-head > div > p { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.crumbs a { color: var(--primary); font-weight: 500; }
.crumbs svg { width: 13px; height: 13px; opacity: .6; }
html[dir="rtl"] .crumbs svg { transform: scaleX(-1); }

/* ---------------- الشريط السفلي للجوال ---------------- */
.bottombar { display: none; }

@media (max-width: 900px) {
  .shell, .shell.mini { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: 286px;
    transform: translateX(-110%); transition: transform var(--tr); box-shadow: var(--shadow-3);
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open { transform: translateX(0) !important; }

  .content { padding: var(--s4); padding-block-end: calc(var(--bottombar-h) + var(--s6)); }
  .header { padding-inline: var(--s3); gap: var(--s2); }
  .header-search { max-width: none; }
  .header-search input { padding-block: 9px; }

  .bottombar {
    display: block; position: fixed; inset-block-end: 0; inset-inline: 0; z-index: 70;
    background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding-block-end: env(safe-area-inset-bottom);
  }
  .bottombar .items { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--bottombar-h); }
  .bottombar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; transition: var(--tr); position: relative;
  }
  .bottombar a svg { width: 21px; height: 21px; }
  .bottombar a.active { color: var(--primary); }
  .bottombar a.active::before {
    content: ""; position: absolute; inset-block-start: 0; width: 26px; height: 3px;
    background: var(--primary); border-radius: 0 0 4px 4px;
  }
  .bottombar a:hover { text-decoration: none; }
  .scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); z-index: 55; }
}

/* ---------------- شبكات مساعدة ---------------- */
.grid { display: grid; gap: var(--s4); }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g-4 { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.g-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }

/* تخطيط لوحة المعلومات */
.dash-main { display: grid; grid-template-columns: 1fr 1.35fr 1.1fr; gap: var(--s4); align-items: start; }
.dash-bottom { display: grid; grid-template-columns: 1.7fr 1fr; gap: var(--s4); align-items: start; margin-top: var(--s4); }
@media (max-width: 1280px) {
  .dash-main { grid-template-columns: 1fr 1fr; }
  .dash-main > *:last-child { grid-column: 1 / -1; }
  .dash-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .dash-main { grid-template-columns: 1fr; }
  .dash-main > *:last-child { grid-column: auto; }
}

/* ---------------- زر طيّ القائمة الجانبية ---------------- */
.collapse-btn {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; margin-top: var(--s2); padding: 9px var(--s3);
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
  font-family: var(--font-display); font-size: 12.5px; font-weight: 600;
  transition: var(--tr);
}
.collapse-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.collapse-btn svg { width: 17px; height: 17px; flex: none; transition: transform var(--tr); }
/* السهم يشير لجهة الطيّ: للخارج عند الفتح، وللداخل عند الطيّ */
html[dir="rtl"] .collapse-btn svg { transform: scaleX(-1); }
.collapse-btn.is-mini svg { transform: scaleX(1); }
html[dir="rtl"] .collapse-btn.is-mini svg { transform: scaleX(1); }
.shell.mini .collapse-btn { justify-content: center; padding-inline: 0; }
.shell.mini .collapse-btn .label { display: none; }

@media (max-width: 900px) {
  /* على الجوال يصير الزر «إغلاق القائمة» */
  .collapse-btn svg { transform: scaleX(1) !important; }
}
