/* ==========================================================
   بوابة مجموعة الكندي — تصميم فاتح وهادئ
   بطاقات بيضاء بحدود رمادية خفيفة، لون أخضر واحد للتفاعل، ومسافات واسعة
   ========================================================== */

:root {
  color-scheme: light;

  /* الأسطح */
  --bg: #ffffff;
  --bg-soft: #f8faf9;
  --surface: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d2d6db;

  /* الحبر */
  --ink: #161616;
  --ink-2: #384250;
  --ink-3: #5f6672;

  /* اللون الأساسي */
  --accent: #1b8354;
  --accent-ink: #146c43;
  --accent-50: #f3fcf6;
  --accent-100: #dff6e7;
  --focus: #1b8354;

  /* الوسوم */
  --tag-beta: #8a5300;
  --tag-beta-bg: #fff4e0;
  --tag-move: #1d5a96;
  --tag-move-bg: #eef5fd;
  --tag-soon: #4d5761;
  --tag-soon-bg: #f3f4f6;

  /* متغيرات تستخدمها صفحة الإعدادات */
  --glass: var(--surface);
  --glass-hi: var(--surface);
  --glass-row-hover: #f6f8f7;
  --badge: var(--accent-50);
  --hair: var(--line);
  --chip-on-bg: var(--accent);
  --chip-on-ink: #ffffff;
  --spec: transparent;
  --spec-soft: transparent;
  --rim-low: var(--line);
  --sat: 100%;
  --sheen: transparent;

  --shadow-hover: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -6px rgba(16, 24, 40, .08);

  --r-card: 14px;
  --r-panel: 16px;
  --r-row: 10px;
  --r-badge: 50%;
  --r-tag: 999px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
  --wrap: 1200px;
  --gutter: 32px;
}

/* ---------- أساسيات ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
search { display: block; }
.scene { display: none; }

/* صندوق أبيض بحدود — يستخدمه الإعدادات أيضاً */
.glass { position: relative; background: var(--surface); border: 1px solid var(--line); }

.wrap { width: min(var(--wrap), 100%); margin-inline: auto; padding-inline: var(--gutter); }
.page { min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; }

/* ---------- الترويسة ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead { display: flex; align-items: center; gap: 12px; height: 72px; }
.gear {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; margin-inline-start: auto;
  border-radius: 10px;
  font-size: 20px; color: var(--ink-3);
  transition: color .2s, background-color .2s;
}
.gear:hover { color: var(--accent); background: var(--accent-50); }
.logo { display: block; height: 40px; width: auto; flex: none; }
.org { padding-inline-start: 14px; border-inline-start: 1px solid var(--line); }
.org { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.org-ar { font-size: 17px; font-weight: 700; }
.org-en { font-size: 12.5px; color: var(--ink-3); }

/* ---------- منطقة البحث ---------- */
.finder-band { background: var(--bg-soft); border-bottom: 1px solid var(--line); padding-block: 36px 28px; }
.lens {
  display: flex; align-items: center; gap: 12px;
  height: 58px; padding-inline: 18px 12px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface);
  cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.lens:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(27, 131, 84, .14); }
.lens-icon { font-size: 21px; color: var(--ink-3); }
.lens input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 17px; color: var(--ink);
}
.lens input::placeholder { color: #8a929c; opacity: 1; }
.lens input::-webkit-search-cancel-button { display: none; }
.clear {
  display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-3); cursor: pointer; font-size: 18px;
}
.clear:hover { background: var(--bg-soft); color: var(--ink); }
.clear[hidden] { display: none; }
.kbd {
  display: grid; place-items: center;
  min-width: 28px; height: 28px; padding-inline: 8px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 7px;
  font: 500 13px/1 var(--font); color: var(--ink-3); background: var(--surface);
}
.lens:focus-within .kbd { visibility: hidden; }

.filters { margin-top: 18px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding-inline: 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-size: 14.5px; white-space: nowrap;
  color: var(--ink-2); background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 500; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px #fff; }
.dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }

/* ---------- الأقسام ---------- */
.results { display: flex; flex-direction: column; gap: 56px; padding-block: 44px 64px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.panel-head::before {
  content: ""; flex: none;
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--c);
}
.panel-title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.3; }
.panel-sub { font-size: 14px; color: var(--ink-3); }

.items {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
}
.items > li { display: flex; }

/* ---------- البطاقة ---------- */
.item {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 188px;
  padding: 22px 22px 18px;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--surface);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
a.item:hover { border-color: #b7dfc6; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
a.item:focus-visible { outline-offset: 3px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.badge {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: var(--r-badge);
  font-size: 21px;
  color: var(--accent); background: var(--accent-50);
}
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.name { font-size: 17px; font-weight: 600; line-height: 1.45; }
.desc { display: block; margin-top: 6px; font-size: 14.5px; line-height: 1.75; color: var(--ink-3); }
.note {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; font-size: 13px; color: var(--ink-2);
}
.note svg { font-size: 15px; color: var(--ink-3); }
.go {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: auto; padding-top: 16px;
  font-size: 14.5px; font-weight: 600; color: var(--accent);
}
.go svg { font-size: 16px; transition: transform .2s var(--ease); }
a.item:hover .go svg { transform: translate(-2px, -2px); }
.soon-text { margin-top: auto; padding-top: 16px; font-size: 14px; color: var(--ink-3); }

.tag {
  display: inline-block;
  padding: 2px 10px 3px;
  border-radius: var(--r-tag);
  font-size: 12.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
}
.tag.beta { color: var(--tag-beta); background: var(--tag-beta-bg); }
.tag.move { color: var(--tag-move); background: var(--tag-move-bg); }
.tag.soon { color: var(--tag-soon); background: var(--tag-soon-bg); }

/* عنصر بلا رابط: يظهر معطلاً لا مكسوراً */
.item.is-soon { background: var(--bg-soft); }
.item.is-soon .badge { color: #8a929c; background: #eef0f2; }
.item.is-soon .name { color: var(--ink-2); }

mark { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }

/* ---------- لا نتائج / خطأ ---------- */
.empty { border-radius: var(--r-panel); padding: 32px 28px; }
.empty h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.empty p { margin: 0; color: var(--ink-2); font-size: 15px; }
.empty .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  height: 42px; padding-inline: 18px; border: 0; border-radius: 10px; cursor: pointer;
  font-size: 14.5px; font-weight: 600;
  background: var(--accent); color: #fff;
  transition: background-color .2s;
}
.btn:hover { background: var(--accent-ink); }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.ghost:hover { background: var(--bg-soft); }
.empty code { font-family: inherit; direction: ltr; unicode-bidi: isolate; padding: 0 5px; border-radius: 4px; background: var(--bg-soft); border: 1px solid var(--line); }

/* ---------- التذييل ---------- */
.foot { border-top: 1px solid var(--line); padding-block: 22px; font-size: 13.5px; color: var(--ink-3); text-align: center; }

/* ---------- بطاقة تفتح نافذة (دليل الموظفين) ---------- */
button.item { font: inherit; color: inherit; text-align: start; cursor: pointer; width: 100%; }
button.item:hover { border-color: #b7dfc6; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
button.item:focus-visible { outline-offset: 3px; }

/* ---------- دليل الموظفين ---------- */
.people-box { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); padding: 4px 22px 8px; }
.people-group + .people-group { margin-top: 22px; }
.people-title { margin: 16px 0 4px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.people-head, .person {
  display: grid; align-items: center; gap: 16px;
  grid-template-columns: minmax(0, 1.25fr) 96px minmax(0, 1fr) minmax(0, 1.5fr);
}
.people-head { padding: 8px 0; font-size: 12.5px; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.people { list-style: none; margin: 0; padding: 0; }
.person { padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.p-main { min-width: 0; }
.p-name { font-size: 15.5px; font-weight: 600; }
.p-label { display: none; }
.p-ext strong { font-size: 17px; font-weight: 700; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.p-cell { min-width: 0; }
.p-link {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  font-size: 14.5px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.p-link:hover { color: var(--accent); }
.p-link svg { font-size: 15px; color: var(--ink-3); }
.p-none { color: #9aa1aa; }
.p-mob { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; }
.wa {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 17px; color: #1fa855; background: #eaf8ef;
  transition: background-color .2s, color .2s;
}
.wa:hover { background: #1fa855; color: #fff; }

.dir-dlg {
  width: min(1000px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(16, 24, 40, .3);
}
.dir-dlg[open] { display: flex; flex-direction: column; }
.dir-dlg::backdrop { background: rgba(16, 24, 40, .35); }
.dir-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 12px; }
.dir-title { margin: 0; font-size: 20px; font-weight: 700; }
.dir-find {
  display: flex; align-items: center; gap: 10px;
  margin: 0 24px 6px; height: 46px; padding-inline: 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-3);
}
.dir-find:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(27, 131, 84, .14); }
.dir-search { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15.5px; color: var(--ink); }
.dir-search::-webkit-search-cancel-button { display: none; }
.dir-body { overflow-y: auto; padding: 0 24px 22px; }
.dir-empty { padding: 20px 0; color: var(--ink-3); }

@media (max-width: 640px) {
  .people-box { padding: 2px 14px 6px; }
  .people-head { display: none; }
  .person {
    gap: 4px 12px; padding: 12px 0;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name ext" "mobile mobile" "email email";
  }
  .p-main { grid-area: name; }
  .p-ext { grid-area: ext; display: flex; align-items: baseline; gap: 6px; }
  .p-ext .p-label { display: inline; font-size: 12px; color: var(--ink-3); }
  .p-mobile { grid-area: mobile; }
  .p-email { grid-area: email; }
  .p-mobile .p-none, .p-email .p-none { display: none; }
  .dir-dlg { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .dir-top { padding: 16px 16px 10px; }
  .dir-find { margin: 0 16px 4px; }
  .dir-body { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
}

/* ---------- الجوال ---------- */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .masthead { height: 64px; gap: 10px; }
  .org-ar { font-size: 15px; }
  .org-en { font-size: 12px; }
  .logo { height: 32px; }
  .org { padding-inline-start: 10px; }
  .finder-band { padding-block: 22px 18px; }
  .lens { height: 52px; padding-inline: 14px 8px; }
  .lens input { font-size: 16px; }
  .kbd { display: none; }
  .filters { margin-inline: calc(var(--gutter) * -1); }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-inline: var(--gutter); }
  .chips::-webkit-scrollbar { display: none; }
  .chip { height: 36px; padding-inline: 14px; font-size: 14px; }
  .results { gap: 40px; padding-block: 28px 44px; }
  .panel-title { font-size: 19px; }
  .panel-head { margin-bottom: 16px; }
  .panel-head::before { width: 18px; height: 18px; }
  .panel-sub:lang(en) { display: none; }
  .items { gap: 10px; }
  /* على الجوال: بطاقة أفقية مضغوطة، والبطاقة كلها قابلة للضغط */
  .item {
    min-height: 0;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    grid-template-areas: "icon name tags" "icon desc desc" "icon note note";
    column-gap: 14px; align-items: start;
    padding: 14px 16px;
  }
  .card-top { display: contents; }
  .badge { grid-area: icon; width: 40px; height: 40px; font-size: 18px; }
  .tags { grid-area: tags; padding-top: 1px; }
  .name { grid-area: name; font-size: 16px; }
  .desc { grid-area: desc; margin-top: 2px; font-size: 14px; line-height: 1.65; }
  .note { grid-area: note; margin-top: 6px; }
  .go { display: none; }
}
@media (hover: none) { .kbd { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .item, .go svg, .chip, .lens { transition: none; }
  a.item:hover { transform: none; }
}

@media print {
  .finder-band, .gear { display: none; }
  .item { break-inside: avoid; }
}
