/* ===== Shared UI kit: page headers, table cards, status pills, avatars, icon buttons, empty states, filter bars, pager =====
   Builds on the tokens of site.css (--accent-1, --accent-2, --grad). Logical properties are used throughout so the same
   markup works in RTL (Persian) and LTR (English). */

:root {
  --ui-border: #e6eaf5;
  --ui-border-soft: #eef1f8;
  --ui-muted: #64748b;
  --ui-ink: #0f172a;
  --ui-soft: #f7f9fd;
  --ui-shadow: 0 .25rem 1rem rgba(15, 23, 42, .05);
  --tone-indigo: linear-gradient(135deg, #4f46e5, #06b6d4);
  --tone-cyan: linear-gradient(135deg, #0891b2, #22d3ee);
  --tone-green: linear-gradient(135deg, #16a34a, #4ade80);
  --tone-amber: linear-gradient(135deg, #d97706, #fbbf24);
  --tone-rose: linear-gradient(135deg, #e11d48, #fb7185);
  --tone-violet: linear-gradient(135deg, #7c3aed, #a78bfa);
  --tone-slate: linear-gradient(135deg, #475569, #94a3b8);
}

/* ---------- page header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header-main { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.page-header-icon {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #fff;
  background: var(--tone-indigo);
  box-shadow: 0 .5rem 1.2rem rgba(79, 70, 229, .25);
}
.page-header-icon.tone-cyan { background: var(--tone-cyan); box-shadow: 0 .5rem 1.2rem rgba(8, 145, 178, .25); }
.page-header-icon.tone-green { background: var(--tone-green); box-shadow: 0 .5rem 1.2rem rgba(22, 163, 74, .25); }
.page-header-icon.tone-amber { background: var(--tone-amber); box-shadow: 0 .5rem 1.2rem rgba(217, 119, 6, .25); }
.page-header-icon.tone-rose { background: var(--tone-rose); box-shadow: 0 .5rem 1.2rem rgba(225, 29, 72, .25); }
.page-header-icon.tone-violet { background: var(--tone-violet); box-shadow: 0 .5rem 1.2rem rgba(124, 58, 237, .25); }
.page-header-icon.tone-slate { background: var(--tone-slate); box-shadow: 0 .5rem 1.2rem rgba(71, 85, 105, .25); }
.page-header-text h1 { font-size: 1.55rem; font-weight: 800; margin: 0; line-height: 1.3; color: var(--ui-ink); }
.page-header-text p { margin: .2rem 0 0; color: var(--ui-muted); font-size: .92rem; line-height: 1.7; max-width: 52rem; }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
@media (max-width: 575.98px) {
  .page-header-icon { width: 2.75rem; height: 2.75rem; font-size: 1.25rem; border-radius: .85rem; }
  .page-header-text h1 { font-size: 1.3rem; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1 1 auto; }
}

/* ---------- panels / table cards ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 1.1rem;
  box-shadow: var(--ui-shadow);
}
.table-card {
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 1.1rem;
  box-shadow: var(--ui-shadow);
  overflow: hidden;
}
.table-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--ui-border);
}
.table-card-title { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ui-ink); }
.table-card-title > i { color: var(--accent-1); font-size: 1.1rem; }
.count-pill {
  background: #eef1fa;
  color: #4338ca;
  border-radius: 999px;
  padding: .05rem .7rem;
  font-size: .78rem;
  font-weight: 700;
}

/* ---------- data table ---------- */
.data-table { margin: 0; --bs-table-bg: transparent; --bs-table-hover-bg: #f9faff; }
.data-table thead th {
  background: var(--ui-soft);
  color: var(--ui-muted);
  font-size: .76rem;
  font-weight: 700;
  border-bottom: 1px solid var(--ui-border);
  padding: .8rem 1rem;
  white-space: nowrap;
}
html[dir="ltr"] .data-table thead th { text-transform: uppercase; letter-spacing: .04em; }
.data-table tbody td { padding: .85rem 1rem; border-color: var(--ui-border-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color .15s ease; }
.data-table tbody tr:hover > * { background: #f9faff; }
.data-table tr.is-muted-row > * { opacity: .55; }
.data-table .cell-title { font-weight: 600; color: var(--ui-ink); }
.data-table .cell-sub { color: var(--ui-muted); font-size: .8rem; display: flex; align-items: center; gap: .3rem; }
.data-table .cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; direction: ltr; unicode-bidi: embed; }
.data-table .cell-actions { text-align: end; white-space: nowrap; width: 1%; }

/* ---------- identity tiles (server / user / institute) ---------- */
.avatar-tile {
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: .85rem;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: var(--tone-indigo);
}
.avatar-tile.is-round { border-radius: 50%; }
.avatar-tile.tone-cyan { background: var(--tone-cyan); }
.avatar-tile.tone-green { background: var(--tone-green); }
.avatar-tile.tone-amber { background: var(--tone-amber); }
.avatar-tile.tone-rose { background: var(--tone-rose); }
.avatar-tile.tone-violet { background: var(--tone-violet); }
.avatar-tile.tone-slate { background: var(--tone-slate); }
.avatar-tile.is-sm { width: 2.1rem; height: 2.1rem; font-size: .85rem; border-radius: .7rem; }
.identity { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.identity > div { min-width: 0; }

/* ---------- status pills ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .22rem .7rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: #eef1fa;
  color: #475569;
  white-space: nowrap;
}
.status-pill.has-dot::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.status-pill.is-success { background: rgba(34, 197, 94, .14); color: #15803d; }
.status-pill.is-danger { background: rgba(239, 68, 68, .13); color: #b91c1c; }
.status-pill.is-warning { background: rgba(245, 158, 11, .17); color: #b45309; }
.status-pill.is-info { background: rgba(6, 182, 212, .13); color: #0e7490; }
.status-pill.is-brand { background: rgba(79, 70, 229, .12); color: #4338ca; }
.status-pill.is-muted { background: #f1f5f9; color: #64748b; }
.status-pill.is-live::before { animation: ui-pulse 1.6s ease-in-out infinite; }
@keyframes ui-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.7); } }

/* ---------- icon buttons ---------- */
.row-actions { display: inline-flex; gap: .35rem; align-items: center; }
.row-actions form { display: inline; margin: 0; }
.btn-icon {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: .65rem;
  border: 1px solid var(--ui-border);
  background: #fff;
  color: #475569;
  font-size: .95rem;
  line-height: 1;
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}
.btn-icon:hover { background: #eef1fa; color: var(--accent-1); border-color: #c7d2fe; transform: translateY(-1px); }
.btn-icon.is-danger:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-icon.is-warning:hover { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.btn-icon.is-success:hover { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.btn-icon.is-primary { background: var(--grad); color: #fff; border-color: transparent; }
.btn-icon.is-primary:hover { color: #fff; filter: brightness(1.06); }

/* ---------- filter bar ---------- */
.filter-bar { padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.filter-bar .form-label { font-size: .78rem; font-weight: 600; color: var(--ui-muted); margin-bottom: .3rem; }
.filter-bar .input-group-text { background: var(--ui-soft); border-color: var(--ui-border); color: var(--ui-muted); }
.filter-bar .form-control, .filter-bar .form-select { border-color: var(--ui-border); }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 3.25rem 1.5rem; color: var(--ui-muted); }
.empty-state-icon {
  width: 4.75rem;
  height: 4.75rem;
  margin: 0 auto 1.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  color: var(--accent-1);
  background: linear-gradient(135deg, rgba(79, 70, 229, .12), rgba(6, 182, 212, .12));
}
.empty-state h3 { font-size: 1.05rem; font-weight: 700; color: var(--ui-ink); margin-bottom: .35rem; }
.empty-state p { max-width: 30rem; margin: 0 auto 1rem; line-height: 1.8; font-size: .92rem; }

/* ---------- pager ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.25rem;
  flex-wrap: wrap;
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--ui-border);
  background: #fbfcff;
}
.pager.is-standalone { border: 1px solid var(--ui-border); border-radius: 1rem; margin-top: 1.25rem; }
.pager-info { color: var(--ui-muted); font-size: .85rem; }
.pager-info strong { color: var(--ui-ink); }
.pager-pages { display: flex; gap: .3rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; justify-content: center; }
.pager-pages a, .pager-pages span {
  min-width: 2.15rem;
  height: 2.15rem;
  display: inline-grid;
  place-items: center;
  padding: 0 .55rem;
  border-radius: .65rem;
  font-size: .86rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  border: 1px solid var(--ui-border);
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
}
.pager-pages a:hover { background: #eef1fa; color: var(--accent-1); border-color: #c7d2fe; }
.pager-pages .is-active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 .25rem .75rem rgba(79, 70, 229, .3);
}
.pager-pages .is-disabled { opacity: .4; pointer-events: none; }
.pager-pages .is-gap { border-color: transparent; background: transparent; min-width: 1.4rem; padding: 0; }
.pager-size { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ui-muted); }
.pager-size a, .pager-size span.is-current {
  padding: .2rem .6rem;
  border-radius: .55rem;
  text-decoration: none;
  color: #475569;
  background: #fff;
  border: 1px solid var(--ui-border);
  font-weight: 600;
}
.pager-size a:hover { background: #eef1fa; color: var(--accent-1); }
.pager-size span.is-current { background: #eef1fa; color: #4338ca; border-color: #c7d2fe; }
@media (max-width: 767.98px) {
  .pager { justify-content: center; }
  .pager-info, .pager-size { width: 100%; justify-content: center; text-align: center; }
}

/* ---------- small helpers ---------- */
.import-cols li { padding: .3rem 0; line-height: 1.7; }
.import-cols i { margin-inline-end: .35rem; }
.text-nowrap-cell { white-space: nowrap; }
.kbd-hint { font-family: ui-monospace, Menlo, Consolas, monospace; background: #eef1fa; border-radius: .4rem; padding: .05rem .4rem; font-size: .82em; direction: ltr; unicode-bidi: embed; }

/* ---------- session activity tiles ---------- */
.activity-label i { margin-inline-end: .3rem; color: var(--accent-1); }
.activity-item.activity-warn .activity-label i { color: #b45309; }

/* ---------- layout fixes ---------- */
/* site.css sets `.page-wrap { padding: 7.5rem 0 3rem }`, which also wiped the container's side gutters on small screens. */
.page-wrap { padding-inline: calc(var(--bs-gutter-x, 1.5rem) * .5); }
@media (max-width: 575.98px) {
  .page-wrap { padding-top: 5.75rem; }
}
.data-table td .identity { min-width: 11rem; }

/* ---------- live server cards (analytics) ---------- */
.server-status-grid { grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1.15rem; }
.srv-card {
  --srv-accent: #94a3b8;
  --srv-tint: rgba(148, 163, 184, .12);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 1.25rem;
  box-shadow: var(--ui-shadow);
  overflow: hidden;
  isolation: isolate;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.srv-card.is-online { --srv-accent: #22c55e; --srv-tint: rgba(34, 197, 94, .12); }
.srv-card.is-offline { --srv-accent: #ef4444; --srv-tint: rgba(239, 68, 68, .1); }
/* coloured edge + soft glow in the corner make the state readable from across the room */
.srv-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: .28rem;
  background: var(--srv-accent);
  opacity: .9;
}
.srv-card::after {
  content: "";
  position: absolute;
  inset-inline-end: -3.5rem;
  top: -3.5rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--srv-tint), transparent);
  z-index: -1;
  pointer-events: none;
}
.srv-card:hover { transform: translateY(-3px); box-shadow: 0 1rem 2rem rgba(15, 23, 42, .1); border-color: #d6dcf0; }

.srv-card-top { display: flex; align-items: center; gap: .8rem; }
.srv-card-icon {
  flex: 0 0 auto;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: .95rem;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  color: #fff;
  background: var(--tone-indigo);
  box-shadow: 0 .4rem .9rem rgba(79, 70, 229, .25);
}
.srv-card.is-online .srv-card-icon { background: var(--tone-green); box-shadow: 0 .4rem .9rem rgba(22, 163, 74, .28); }
.srv-card.is-offline .srv-card-icon { background: var(--tone-rose); box-shadow: 0 .4rem .9rem rgba(225, 29, 72, .25); }
.srv-card.is-disabled .srv-card-icon { background: var(--tone-slate); box-shadow: 0 .4rem .9rem rgba(71, 85, 105, .22); }
.srv-card-id { flex: 1 1 auto; min-width: 0; }
.srv-card-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--ui-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.srv-card-inst {
  margin: .1rem 0 0;
  display: flex;
  align-items: center;
  gap: .3rem;
  min-width: 0;
  font-size: .8rem;
  color: var(--ui-muted);
}
.srv-card-inst span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-card-top .status-pill { flex: 0 0 auto; }

/* the two big numbers (also buttons that open the list modal) */
.srv-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.srv-stat {
  position: relative;
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
  padding: .7rem .8rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 1rem;
  background: var(--ui-soft);
  text-align: start;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.srv-stat:hover { background: #fff; border-color: #c7d2fe; box-shadow: 0 .4rem 1rem rgba(79, 70, 229, .14); }
.srv-stat:active { transform: scale(.98); }
.srv-stat:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 2px; }
.srv-stat-icon {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: .7rem;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  color: #fff;
  background: var(--tone-indigo);
}
.srv-stat.tone-indigo .srv-stat-icon { background: linear-gradient(135deg, #4f46e5, #818cf8); }
.srv-stat.tone-cyan .srv-stat-icon { background: var(--tone-cyan); }
.srv-stat-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.srv-stat-value { font-size: 1.45rem; font-weight: 800; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.srv-stat-label { font-size: .72rem; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-stat-go {
  position: absolute;
  inset-inline-end: .55rem;
  top: .5rem;
  font-size: .8rem;
  color: var(--accent-1);
  opacity: 0;
  transition: opacity .15s ease;
}
.srv-stat:hover .srv-stat-go, .srv-stat:focus-visible .srv-stat-go { opacity: .8; }
.srv-stat.is-idle { opacity: .6; }
.srv-stat.is-idle .srv-stat-value { color: var(--ui-muted); }
.srv-stat.is-idle:hover { opacity: 1; }
.srv-card.is-offline .srv-stat, .srv-card.is-disabled .srv-stat { opacity: .55; }

.srv-card-actions { display: flex; gap: .5rem; }
.srv-card-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border-radius: .75rem; }
.srv-card-actions .btn-grad { flex: 1 1 auto; }
.srv-card-actions .btn-outline-secondary { flex: 0 0 auto; border-color: var(--ui-border); color: #475569; }
.srv-card-actions .btn-outline-secondary:hover { background: #eef1fa; color: var(--accent-1); border-color: #c7d2fe; }

.srv-card-foot {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: auto;
  padding-top: .65rem;
  border-top: 1px dashed var(--ui-border);
  font-size: .74rem;
  color: var(--ui-muted);
}
@media (max-width: 575.98px) {
  .server-status-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .srv-card, .srv-stat { transition: none; }
  .srv-card:hover { transform: none; }
}

/* ---------- user ⇄ server assignment ---------- */
.server-access {
  border: 1px solid var(--ui-border);
  border-radius: 1rem;
  background: var(--ui-soft);
  padding: 1rem 1.1rem;
}
.server-access-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.server-access [hidden] { display: none !important; }
.srv-pick-list {
  display: grid;
  gap: .45rem;
  max-height: 19rem;
  overflow-y: auto;
  padding: .15rem;
}
.srv-pick {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 0;
  padding: .55rem .75rem;
  border: 1px solid var(--ui-border);
  border-radius: .85rem;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.srv-pick[hidden] { display: none !important; }
.srv-pick:hover { border-color: #c7d2fe; }
.srv-pick.is-selected, .srv-pick:has(input:checked) {
  border-color: #818cf8;
  background: rgba(79, 70, 229, .06);
  box-shadow: 0 0 0 .15rem rgba(79, 70, 229, .08);
}
.srv-pick .form-check-input { flex: 0 0 auto; margin: 0; float: none; }
.srv-pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.35; }
.srv-pick-text strong { font-size: .92rem; color: var(--ui-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-pick-text small { color: var(--ui-muted); font-size: .76rem; display: flex; align-items: center; gap: .3rem; }
.srv-pick.is-muted-row { opacity: .65; }
