/* الهوية الأساسية — مطابقة لتصميم abtech.sa المعتمد */

/* مؤشّر تركيز واضح للتنقّل بلوحة المفاتيح (وصولية) */
:focus-visible {
  outline: 2px solid #2147ae;
  outline-offset: 2px;
  border-radius: 8px;
}

body {
  margin: 0;
  font-family: "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color: #11243b;
  background:
    radial-gradient(circle at 13% 48%, rgba(24,184,201,.13), transparent 25%),
    radial-gradient(circle at 82% 8%, rgba(183,231,75,.08), transparent 31%),
    linear-gradient(135deg, #f8f9fc 0%, #ffffff 52%, #f5f6fa 100%);
  background-attachment: fixed;
  line-height: 1.7;
  text-align: right;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .42;
  background-image:
    linear-gradient(rgba(18,59,76,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18,59,76,.045) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(90deg, transparent, black 45%, transparent);
  mask-image: linear-gradient(90deg, transparent, black 45%, transparent);
}
a { color: #1d3d96; text-decoration: none; }
a:hover { color: #1a388b; }
::selection { background: #dce3f8; }
* { box-sizing: border-box; }

/* ===== هيكل التطبيق ===== */
.layout {
  display: grid; grid-template-columns: 272px minmax(0,1fr);
  min-height: 100vh; gap: 22px; padding: 22px;
  position: relative;
}
.sidebar {
  background: linear-gradient(185deg, #16295e 0%, #0f1f4a 60%, #0c1a40 100%);
  border: 1px solid rgba(255,255,255,.06); border-radius: 22px;
  color: #cbd6ef; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 22px; height: calc(100vh - 44px);
  overflow-y: auto; box-shadow: 0 30px 80px rgba(8,18,46,.28);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 6px; }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand img { width: 38px; height: 42px; object-fit: contain; }
.side-brand-copy { display: grid; line-height: 1.15; min-width: 0; }
.side-brand-copy strong { font-size: 16px; font-weight: 900; color: #fff; white-space: nowrap; }
.side-brand-copy small { color: var(--gold, #C2A24E); margin-top: 3px; font-size: 11px; font-weight: 800; letter-spacing: .4px; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.side-status { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; color: #9fb0d8; }
.side-status i { width: 8px; height: 8px; border-radius: 50%; background: #4fca9a; box-shadow: 0 0 0 3px rgba(79,202,154,.18); }
.workspace { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

/* رأس مجموعة قابلة للطي في القائمة الجانبية */
.nav-group-hdr {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 10px; font-weight: 800; color: #7e93c4; letter-spacing: .5px;
  padding: 14px 12px 5px; text-align: right;
}
.nav-group-hdr:hover { color: #b7c6ec; }
.nav-chev { font-size: 9px; color: #5f74a6; transition: color .15s; }
.nav-group-hdr:hover .nav-chev { color: #b7c6ec; }
.nav-group-items { display: flex; flex-direction: column; gap: 3px; }

.nav-btn {
  position: relative; border: 0; border-radius: 11px; padding: 9px 12px;
  display: flex; align-items: center; gap: 11px; text-align: right;
  font-weight: 700; font-size: 13.5px; font-family: inherit; cursor: pointer;
  min-height: 42px; background: transparent; color: #b9c6e6;
  transition: background .15s, color .15s; width: 100%;
}
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.active {
  background: linear-gradient(90deg, rgba(194,162,78,.20), rgba(194,162,78,.05)); color: #fff;
}
.nav-btn.active::before { content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--gold, #C2A24E); }
.nav-ic { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; color: #8ea3d6; }
.nav-btn:hover .nav-ic { color: #cdd8f2; }
.nav-btn.active .nav-ic { color: var(--gold, #C2A24E); }

/* ===== شريط علوي مصقول (بطاقة المستخدم + إجراءات) ===== */
.topbar-actions { display: flex; gap: 10px; align-items: center; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; position: relative; }
.tb-search { position: relative; display: flex; align-items: center; }
.tb-search svg { position: absolute; inset-inline-start: 14px; width: 16px; height: 16px; color: #9aa9b5; pointer-events: none; }
.tb-search input { width: clamp(180px, 24vw, 280px); border: 1px solid #d7deea; border-radius: 999px; padding: 10px 16px; padding-inline-start: 38px; background: #fff; color: #11243b; font-family: inherit; font-size: 13px; }
.tb-search input:focus { outline: none; border-color: #234bb9; box-shadow: 0 0 0 3px rgba(33,71,174,.1); }
.tb-icon { position: relative; width: 42px; height: 42px; border: 1px solid #e2e7f0; background: #fff; color: #3d4a63; border-radius: 12px; display: grid; place-items: center; cursor: pointer; transition: background .15s, border-color .15s; }
.tb-icon svg { width: 19px; height: 19px; }
.tb-icon:hover { background: #f6f8fc; border-color: #cfd7e6; }
.tb-dot { position: absolute; top: -5px; inset-inline-start: -5px; min-width: 18px; height: 18px; }
.tb-user { display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 12px; border: 1px solid #e2e7f0; background: #fff; border-radius: 999px; cursor: pointer; position: relative; transition: border-color .15s; }
.tb-user:hover { border-color: #cfd7e6; }
.tb-ava { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(145deg, #1f42a1, #16295e); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 15px; flex: 0 0 auto; }
.tb-uc { display: grid; line-height: 1.2; min-width: 0; }
.tb-uc strong { font-size: 13px; font-weight: 800; color: #0b1728; white-space: nowrap; }
.tb-uc small { font-size: 11px; color: #758495; }
@media (max-width: 560px) { .tb-uc { display: none; } .tb-search input { width: 150px; } }
.tb-menu { display: none; position: absolute; top: 52px; inset-inline-end: 0; background: #fff; border: 1px solid #e2e7f0; border-radius: 14px; box-shadow: 0 20px 50px rgba(15,23,41,.16); overflow: hidden; z-index: 60; min-width: 160px; }
.tb-menu.open { display: block; }
.tb-menu button { width: 100%; border: 0; background: #fff; color: #b32318; font-weight: 800; font-size: 13.5px; font-family: inherit; padding: 12px 16px; text-align: right; cursor: pointer; }
.tb-menu button:hover { background: #fdf2f2; }
.nav-badge {
  min-width: 22px; height: 20px; border-radius: 999px; background: #d92d20; color: #fff;
  display: grid; place-items: center; padding: 0 6px; font-size: 11px; font-weight: 800; font-style: normal;
}

/* ===== مكونات مشتركة ===== */
.card {
  background: rgba(255,255,255,.93); border: 1px solid rgba(220,230,237,.9);
  border-radius: 20px; box-shadow: 0 24px 55px rgba(40,83,101,.08);
}
.card-lg {
  background: rgba(255,255,255,.93); backdrop-filter: blur(16px);
  border: 1px solid rgba(195,220,228,.92); border-radius: 24px;
  box-shadow: 0 35px 90px rgba(23,72,93,.13);
}
.btn-primary {
  border: 0; border-radius: 12px; background: linear-gradient(135deg,#d9bd74,#c2a24e);
  color: #152a63; padding: 13px 22px; font-size: 14px; font-weight: 800;
  font-family: inherit; cursor: pointer; box-shadow: 0 13px 28px rgba(194,162,78,.30);
  transition: transform .18s;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; }
.btn-secondary {
  border: 1px solid #cfd4e3; border-radius: 12px; background: #fff; color: #11243b;
  padding: 12px 20px; font-size: 13.5px; font-weight: 800; font-family: inherit; cursor: pointer;
}
.btn-secondary:hover { border-color: rgba(8,166,199,.42); }
.btn-pill {
  border: 1px solid #cfd4e3; background: #fff; color: #12243a; border-radius: 999px;
  padding: 8px 16px; font-size: 12.5px; font-weight: 800; font-family: inherit; cursor: pointer;
}
.btn-pill:hover { border-color: rgba(8,166,199,.42); }

.field { display: grid; gap: 6px; font-size: 13px; font-weight: 800; color: #34495c; }
.field input, .field select, .field textarea {
  border: 1px solid #cfd4e3; border-radius: 12px; padding: 12px 14px;
  font-size: 14px; font-family: inherit; color: #11243b; background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #234bb9; box-shadow: 0 0 0 3px rgba(18,174,202,.12);
}
.req { color: #d92d20; }

.badge {
  display: inline-flex; padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; white-space: nowrap;
}

.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: right; padding: 11px 14px; font-size: 12px; color: #7c8a98;
  font-weight: 800; border-bottom: 1px solid #e8eff4; white-space: nowrap;
  background: #f7f9fc;
}
.tbl thead th:first-child { border-top-right-radius: 10px; }
.tbl thead th:last-child { border-top-left-radius: 10px; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid #eef3f7; font-size: 13px; color: #2a3b4d; }
.tbl tbody tr:nth-child(even) td { background: #fafbfe; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: #eef3fd; }

/* ===== حالات موحّدة (فارغ/بحث/خطأ) ===== */
.state-box {
  display: grid; justify-items: center; text-align: center; gap: 7px;
  padding: 46px 22px; color: #64748b;
}
.state-box .state-ic {
  width: 58px; height: 58px; display: grid; place-items: center;
  border-radius: 16px; background: #f2f5fb; margin-bottom: 4px;
}
.state-box .state-ic svg { width: 30px; height: 30px; }
.state-box strong { font-size: 15px; color: #34495c; font-weight: 900; }
.state-box span { font-size: 13px; color: #94a3b8; max-width: 340px; line-height: 1.6; }

/* ===== تبويبات صفحات التفاصيل (DetailShell) ===== */
.care-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid #e8eff4; margin-bottom: 18px;
}
.care-tab {
  appearance: none; background: none; border: 0; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 800; color: #64748b; padding: 11px 16px;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 7px; transition: color .15s;
}
.care-tab:hover { color: #234bb9; }
.care-tab.active { color: #152a63; border-bottom-color: #c2a24e; }
.care-tab-badge {
  background: #eef2f8; color: #64748b; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 8px; min-width: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.care-tab.active .care-tab-badge { background: #152a63; color: #fff; }
.care-tab-panel[hidden] { display: none; }

/* بطاقة صف بسيطة داخل التبويبات (فروع/جهات اتصال) */
.care-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid #eef2f7; border-radius: 12px;
  background: #fff; margin-bottom: 8px; font-size: 13px;
}
.care-row .care-row-main { display: grid; gap: 2px; min-width: 0; }
.care-row .care-row-main b { font-size: 13.5px; color: #1f3350; font-weight: 800; }
.care-row .care-row-main span { color: #64748b; font-size: 12.5px; }
.care-row .care-row-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* رأس صفحة التفاصيل */
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 4px;
}
.detail-head .dh-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head .dh-title strong { font-size: 21px; font-weight: 900; color: #0b1728; }
.detail-head .dh-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; color: #64748b; font-size: 12.5px; font-weight: 700; }
.detail-head .dh-meta span { display: inline-flex; align-items: center; gap: 5px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; color: #64748b;
  font-size: 12.5px; font-weight: 800; text-decoration: none; margin-bottom: 12px;
}
.back-link:hover { color: #234bb9; }

/* ===== النوافذ المنبثقة (modals) ===== */
.care-modal-back {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(7,17,31,.5); display: grid; place-items: center; padding: 16px;
  animation: mdl-fade .16s ease;
}
.care-modal {
  background: #fff; border-radius: 20px; width: 100%;
  max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(7,17,31,.35);
  animation: mdl-pop .18s cubic-bezier(.2,.7,.3,1);
}
.care-modal-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid #eef3f7;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.care-modal-hd strong { font-size: 16px; font-weight: 900; color: #0b1728; }
.care-modal-body { padding: 20px; }
.care-modal-foot { display: flex; gap: 10px; justify-content: flex-start; padding: 0 20px 20px; }
body.modal-open { overflow: hidden; }
@keyframes mdl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mdl-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .care-modal-back, .care-modal { animation: none; } }

/* ===== هيكل تحميل (شبح) ===== */
.skel-tbl { display: grid; gap: 13px; padding: 12px 4px; }
.skel-row { display: grid; gap: 16px; }
.skel {
  height: 15px; border-radius: 7px;
  background: linear-gradient(90deg, #eef2f8 25%, #e2e8f2 37%, #eef2f8 63%);
  background-size: 400% 100%; animation: skel 1.3s ease-in-out infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

/* ===== تجاوب — شاشات متوسطة ===== */
@media (max-width: 1080px) and (min-width: 861px) {
  .layout { grid-template-columns: 232px minmax(0,1fr); padding: 16px; gap: 14px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ===== تجاوب — الجوال ===== */
.ab-mobilebar { display: none; }
.ab-scrim { display: none; }

@media (max-width: 860px) {
  /* الشريط العلوي الثابت */
  .ab-mobilebar {
    display: flex; position: fixed; top: 0; right: 0; left: 0; z-index: 300;
    align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 14px; min-height: 56px;
    background: rgba(255,255,255,.95); backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(195,220,228,.8);
  }
  .ab-menu-btn {
    border: 1px solid #cfd4e3; background: #fff; color: #11243b;
    border-radius: 12px; width: 42px; height: 40px; display: grid; place-items: center;
    font-family: inherit; cursor: pointer; font-size: 18px; line-height: 1;
  }

  /* التخطيط: عمود واحد مع مساحة للشريط العلوي */
  .layout { grid-template-columns: 1fr; padding: 70px 12px 20px; gap: 14px; }

  /* القائمة الجانبية تتحول لدرج منزلق من اليمين */
  .sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(310px, 86vw); height: 100dvh; z-index: 400;
    border-radius: 0; margin: 0;
    transform: translateX(105%); transition: transform .25s ease;
  }
  .sidebar.open { transform: none; box-shadow: -24px 0 60px rgba(7,17,31,.3); }
  .ab-scrim {
    display: block; position: fixed; inset: 0; z-index: 350;
    background: rgba(7,17,31,.45);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .ab-scrim.show { opacity: 1; pointer-events: auto; }

  /* هيدر الصفحة: عمودي والبحث بعرض كامل */
  #ab-topbar { flex-direction: column; align-items: stretch !important; gap: 12px !important; }
  #ab-topbar > div:last-child { flex-wrap: wrap; }
  #ab-search { width: 100% !important; flex: 1 1 200px; min-width: 0; }
  #ab-topbar h1 { font-size: 22px !important; }

  /* المؤشرات والبطاقات */
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }

  /* الجداول: تمرير أفقي داخل كرتها بدل كسر الصفحة */
  .card:has(.tbl), section:has(.tbl) { overflow-x: auto; }
  .tbl { min-width: 640px; }

  /* أزرار الرأس تلتف ولا تنضغط */
  .btn-primary, .btn-secondary { padding: 12px 16px; font-size: 13px; }

  /* قائمة الجرس لا تتجاوز الشاشة */
  #ab-bell-menu { width: min(360px, calc(100vw - 40px)) !important; left: auto !important; right: -60px; }
}

@media (max-width: 420px) {
  .grid-4 { grid-template-columns: 1fr; }
}

/* ===== الجداول على الجوال: بطاقات مكدّسة بدل التمرير الأفقي ===== */
@media (max-width: 640px) {
  .care-tbl-wrap { overflow-x: visible !important; }
  .tbl-cards { min-width: 0; }
  .tbl-cards thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards tr {
    border: 1px solid #e8eff4; border-radius: 14px; margin-bottom: 12px;
    padding: 4px 2px; background: #fff; box-shadow: 0 3px 10px rgba(21,42,99,.05);
  }
  .tbl-cards tbody tr:nth-child(even) td { background: transparent; }
  .tbl-cards td {
    border: 0; padding: 9px 15px; font-size: 13px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left;
  }
  .tbl-cards td + td { border-top: 1px dashed #eef3f7; }
  .tbl-cards td::before {
    content: attr(data-label); font-weight: 800; color: #7c8a98;
    font-size: 12px; flex: 0 0 auto; text-align: right;
  }
  .tbl-cards td:empty { display: none; }
}
