/* ==========================================================================
   LIS — base theme (Bootstrap 5 RTL aware, light/dark)
   ========================================================================== */

/* ---- Arabic web font (Tajawal), vendored for offline use ----------------- */
@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Regular.d11e9f3094b8.ttf") format("truetype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Medium.3876865bd2f3.ttf") format("truetype");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "Tajawal";
  src: url("../fonts/Tajawal-Bold.ef7c3dc2a2b8.ttf") format("truetype");
  font-weight: 700; font-display: swap;
}

:root {
  --lis-sidebar-width: 264px;
  --lis-navbar-height: 60px;
  --lis-font: "Tajawal", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --lis-primary: #2563eb;
  --lis-primary-700: #1d4ed8;
  --lis-radius: .85rem;
  --lis-shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --lis-shadow-lg: 0 12px 40px rgba(16,24,40,.12);
}

html, body { height: 100%; }
body {
  font-family: var(--lis-font);
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* Brand-tinted primary across Bootstrap. */
[data-bs-theme="light"] {
  --bs-primary: var(--lis-primary);
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: var(--lis-primary);
  --bs-link-hover-color: var(--lis-primary-700);
  --bs-body-bg: #ffffff;
  --bs-tertiary-bg: #f4f6fb;
}
.btn-primary {
  --bs-btn-bg: var(--lis-primary); --bs-btn-border-color: var(--lis-primary);
  --bs-btn-hover-bg: var(--lis-primary-700); --bs-btn-hover-border-color: var(--lis-primary-700);
  --bs-btn-active-bg: var(--lis-primary-700);
}

/* ---- Layout -------------------------------------------------------------- */
.lis-layout { display: flex; min-height: 100vh; }
.lis-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.lis-content { padding: 1.6rem 1.75rem; flex: 1 1 auto; }

/* ---- Sidebar ------------------------------------------------------------- */
.lis-sidebar {
  width: var(--lis-sidebar-width);
  flex: 0 0 var(--lis-sidebar-width);
  background: var(--bs-body-bg);
  border-inline-end: 1px solid var(--bs-border-color);
  display: flex; flex-direction: column;
  transition: margin .2s ease;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.lis-sidebar.collapsed { margin-inline-start: calc(-1 * var(--lis-sidebar-width)); }

.lis-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.05rem 1.15rem; font-weight: 700; font-size: 1.08rem;
  border-bottom: 1px solid var(--bs-border-color);
  color: var(--lis-primary);
}
.lis-brand i { font-size: 1.55rem; }
.lis-brand-logo { height: 36px; width: auto; }

.lis-nav { padding: .7rem .6rem; }
.lis-nav-section {
  display: block; padding: .85rem .85rem .35rem; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color);
}
.lis-nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .85rem; margin-bottom: .12rem; border-radius: .6rem;
  color: var(--bs-body-color); text-decoration: none; font-size: .93rem; font-weight: 500;
  transition: background .12s, color .12s;
}
.lis-nav-link i { font-size: 1.15rem; width: 1.35rem; text-align: center; opacity: .85; }
.lis-nav-link:hover { background: var(--bs-tertiary-bg); }
.lis-nav-link.active {
  background: linear-gradient(135deg, var(--lis-primary), var(--lis-primary-700));
  color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.lis-nav-link.active i { opacity: 1; }
.lis-nav-link.disabled { opacity: .4; pointer-events: none; }

/* ---- Navbar -------------------------------------------------------------- */
.lis-navbar {
  height: var(--lis-navbar-height);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky; top: 0; z-index: 20;
}
.lis-navbar-title { font-weight: 700; font-size: 1.02rem; }
.lis-navbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .45rem; }
.btn-icon {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--bs-border-color); background: var(--bs-body-bg);
  color: var(--bs-body-color); border-radius: .55rem; padding: .35rem .6rem;
  transition: background .12s;
}
.btn-icon:hover { background: var(--bs-tertiary-bg); }

/* ---- Cards (global polish) ----------------------------------------------- */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--lis-radius);
  box-shadow: var(--lis-shadow);
}
.card-header { background: transparent; font-weight: 600; border-bottom: 1px solid var(--bs-border-color); }

/* ---- Stat cards ---------------------------------------------------------- */
.lis-stat-card {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
  border-radius: var(--lis-radius); padding: 1.15rem 1.25rem; height: 100%;
  box-shadow: var(--lis-shadow); transition: transform .15s, box-shadow .15s;
}
.lis-stat-card:hover { transform: translateY(-3px); box-shadow: var(--lis-shadow-lg); }
.lis-stat-icon {
  width: 52px; height: 52px; border-radius: .8rem; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.lis-stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.lis-stat-label { font-size: .82rem; color: var(--bs-secondary-color); font-weight: 500; }

/* ---- Tables -------------------------------------------------------------- */
.table > :not(caption) > * > * { padding: .6rem .7rem; }
.table thead th { font-size: .82rem; text-transform: none; color: var(--bs-secondary-color); font-weight: 600; }

/* Card that wraps a data table (search + table + pager). */
.lis-table-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
  border-radius: var(--lis-radius); box-shadow: var(--lis-shadow); overflow: hidden; }
.lis-table-card > .dataTable-wrapper { padding: 0; }

/* ---- simple-datatables theming (RTL + brand) ----------------------------- */
.dataTable-wrapper .dataTable-top,
.dataTable-wrapper .dataTable-bottom {
  padding: .85rem 1rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.dataTable-wrapper .dataTable-bottom { border-top: 1px solid var(--bs-border-color); }
.dataTable-wrapper .dataTable-top { border-bottom: 1px solid var(--bs-border-color); background: var(--bs-tertiary-bg); }
.dataTable-search { margin-inline-start: auto; }
.dataTable-input {
  padding: .45rem .8rem; border: 1px solid var(--bs-border-color); border-radius: .55rem;
  background: var(--bs-body-bg); color: var(--bs-body-color); min-width: 220px; font-family: inherit;
}
.dataTable-input:focus { outline: none; border-color: var(--lis-primary); box-shadow: 0 0 0 .2rem rgba(37,99,235,.15); }
.dataTable-selector { padding: .4rem .6rem; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: var(--bs-body-bg); color: var(--bs-body-color); }
.dataTable-table { width: 100%; margin: 0; border-collapse: collapse; }
.dataTable-table th, .dataTable-table td { padding: .65rem .8rem; border-bottom: 1px solid var(--bs-border-color); text-align: start; vertical-align: middle; }
.dataTable-table thead th {
  background: var(--bs-tertiary-bg); font-size: .82rem; font-weight: 700;
  color: var(--bs-secondary-color); white-space: nowrap; border-bottom: 2px solid var(--bs-border-color);
}
.dataTable-table tbody tr { transition: background .1s; }
.dataTable-table tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--bs-tertiary-bg) 45%, transparent); }
.dataTable-table tbody tr:hover { background: var(--bs-primary-bg-subtle); }
/* Sort arrows on the start side (RTL aware). */
.dataTable-sorter { position: relative; padding-inline-end: 18px; display: inline-block; cursor: pointer; }
.dataTable-sorter::before, .dataTable-sorter::after {
  content: ""; position: absolute; inset-inline-end: 4px; border-inline-start: 4px solid transparent;
  border-inline-end: 4px solid transparent; opacity: .35;
}
.dataTable-sorter::before { border-top: 5px solid currentColor; bottom: 2px; }
.dataTable-sorter::after { border-bottom: 5px solid currentColor; top: 2px; }
.asc .dataTable-sorter::after, .desc .dataTable-sorter::before { opacity: 1; color: var(--lis-primary); }
.dataTable-pagination { display: flex; gap: .25rem; margin-inline-start: auto; list-style: none; padding: 0; margin-bottom: 0; }
.dataTable-pagination li a {
  display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center;
  padding: 0 .5rem; border-radius: .5rem; text-decoration: none; color: var(--bs-body-color);
  border: 1px solid transparent;
}
.dataTable-pagination li a:hover { background: var(--bs-tertiary-bg); }
.dataTable-pagination li.active a { background: var(--lis-primary); color: #fff; }
.dataTable-info { color: var(--bs-secondary-color); font-size: .85rem; }

/* ---- Messages ------------------------------------------------------------ */
.lis-messages { position: fixed; top: 1rem; inset-inline-end: 1rem; z-index: 1080; max-width: 380px; }
.lis-messages .alert { box-shadow: var(--lis-shadow-lg); border: 0; border-radius: .7rem; }

/* ---- Login --------------------------------------------------------------- */
.lis-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(37,99,235,.18), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(14,165,233,.16), transparent 55%),
    linear-gradient(160deg, #eef2ff 0%, #f8fafc 55%, #eff6ff 100%);
}
.lis-login-card {
  width: 100%; max-width: 410px; background: #fff;
  border: 1px solid rgba(16,24,40,.06); border-radius: 1.25rem;
  padding: 0; overflow: hidden;
  box-shadow: 0 24px 60px rgba(37,99,235,.18), 0 8px 24px rgba(16,24,40,.08);
}
.lis-login-head {
  background: linear-gradient(135deg, var(--lis-primary), #0ea5e9);
  color: #fff; text-align: center; padding: 2rem 2rem 1.5rem;
}
.lis-login-head .lis-login-logo {
  width: 68px; height: 68px; margin: 0 auto .75rem;
  background: rgba(255,255,255,.18); border-radius: 1rem;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.25);
}
.lis-login-head .lis-login-logo i { font-size: 2.1rem; color: #fff; }
.lis-login-head img { max-height: 64px; margin-bottom: .5rem; }
.lis-login-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.lis-login-head p { margin: .25rem 0 0; opacity: .9; font-size: .9rem; }
.lis-login-body { padding: 1.75rem 2rem 2rem; }
.lis-login-body .form-label { font-weight: 600; font-size: .9rem; }
.lis-login-body .form-control { padding: .65rem .9rem; border-radius: .65rem; }
.lis-login-body .form-control:focus { border-color: var(--lis-primary); box-shadow: 0 0 0 .2rem rgba(37,99,235,.18); }
.lis-login-body .btn-primary { padding: .7rem; border-radius: .65rem; font-weight: 600; }
.lis-login-foot { text-align: center; margin-top: 1.1rem; }

/* ---- Color-coded category sections (results entry) ----------------------- */
.lis-cat { border-inline-start: 5px solid var(--c, #888); overflow: hidden; }
.lis-cat > .card-header {
  background: color-mix(in srgb, var(--c) 12%, var(--bs-body-bg));
  color: var(--c); font-weight: 700;
  border-bottom: 1px solid color-mix(in srgb, var(--c) 28%, var(--bs-border-color));
  display: flex; align-items: center; gap: .5rem;
}
.lis-cat > .card-header::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c);
  display: inline-block; flex: 0 0 10px;
}
.lis-cat.c0 { --c: #2563eb; } /* blue   */
.lis-cat.c1 { --c: #059669; } /* emerald*/
.lis-cat.c2 { --c: #7c3aed; } /* violet */
.lis-cat.c3 { --c: #d97706; } /* amber  */
.lis-cat.c4 { --c: #e11d48; } /* rose   */
.lis-cat.c5 { --c: #0891b2; } /* cyan   */
.lis-cat.c6 { --c: #c026d3; } /* fuchsia*/
.lis-cat.c7 { --c: #65a30d; } /* lime   */
.lis-cat.c8 { --c: #4f46e5; } /* indigo */
.lis-cat.c9 { --c: #ea580c; } /* orange */

/* ---- Critical/abnormal value helpers (Phase 7+) -------------------------- */
.val-high { color: var(--bs-danger); font-weight: 700; }
.val-low { color: #d97706; font-weight: 700; }
.val-critical { color: #fff; background: var(--bs-danger); padding: 0 .4rem; border-radius: .35rem; font-weight: 700; }

/* ---- Dark mode tweaks ---------------------------------------------------- */
[data-bs-theme="dark"] { --bs-tertiary-bg: #0b1220; }
[data-bs-theme="dark"] .lis-login { background: linear-gradient(160deg, #0b1220, #111827); }
[data-bs-theme="dark"] .lis-login-card { background: #111827; border-color: rgba(255,255,255,.08); }
