/* system_dashboard.css — System Dashboard (Phase 1) view.
   Feature-scoped, matching the project's per-view CSS convention. Reuses the
   shared .view-container / .view-info-band / .attendance-table classes; only
   the dashboard-specific bits live here. */

#dashboard-view {
  /* Hidden by default like #monthly-view / #daily-view; switchToView() reveals
     it with display:flex. Without this it inherits .view-container's
     display:flex and renders split-screen with the active view, because
     switchToView('request') early-returns at init and never runs hide-all. */
  display: none;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

#dashboard-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#dashboard-online-count {
  font-weight: 600;
}

.dashboard-header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-autorefresh {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

#dashboard-autorefresh-interval {
  cursor: pointer;
}

.dashboard-last-updated {
  font-size: 0.85em;
  color: #6c757d;
}

#dashboard-refresh-now {
  cursor: pointer;
}

/* Match #attendance-table (multi_view_main.css) so the dashboard reads like the
   other views: 13px, #ced4da grid, #dee2e6 header, zebra + hover. */
#dashboard-table-wrap {
  overflow: auto;
  width: 100%;
  border: 1px solid #ced4da;
  background-color: #fff;
}

#dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#dashboard-table th,
#dashboard-table td {
  border: 1px solid #ced4da;
  padding: 6px;
  text-align: left;     /* left, not centred — cells hold long text/history */
  vertical-align: top;
}

#dashboard-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: #dee2e6;
  font-weight: bold;
}

#dashboard-table tbody tr:nth-child(even) {
  background-color: #f1f3f5;
}

#dashboard-table tbody tr:hover {
  background-color: #e2e6ea;
}

.dash-online,
.dash-idle {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Secondary in-cell info: IP after the OUCare ID, login wall-clock after the
   Online-for duration. Muted to match the other de-emphasized text. */
.dash-ip,
.dash-since {
  color: #6c757d;
}

/* Idle cue — muted; scoped under tbody + :hover so it overrides zebra/hover. */
#dashboard-table tbody tr.dashboard-row-idle,
#dashboard-table tbody tr.dashboard-row-idle:hover {
  color: #868e96;
  background-color: #f1f3f5;
}

/* Logged-out row: muted (the "logout Xm Ys" indicator shows in the Idle cell). */
#dashboard-table tbody tr.dashboard-row-logout,
#dashboard-table tbody tr.dashboard-row-logout:hover {
  color: #868e96;
  background-color: #f3eeee;
}

/* Logged-out indicator: light/muted to read as an inactive past state. */
.dash-logout {
  color: #b0b4ba;
  font-style: italic;
  font-weight: normal;
  white-space: nowrap;
}

/* Sortable column headers. */
#dashboard-table th.dash-sortable {
  cursor: pointer;
  user-select: none;
}

#dashboard-table th.dash-sortable:hover {
  background: #f3f4f6;
}

#dashboard-table th.dash-sortable.sorted::after {
  content: " ↓";
  color: #2563eb;
}

/* The scroll cap must live on an inner block — max-height/overflow are ignored
   on table cells. At most two lines (2 × 1.5em), scrollbar when there are more. */
.dash-queries-scroll {
  line-height: 1.5;
  max-height: 3em;
  overflow-y: auto;
}

/* "Online for" login history: current login on top, past logins below (newest
   first). Capped at two lines (2 × 1.5em) like Current View / Recent queries;
   scrollbar for the rest up to the server's LOGIN_HISTORY_MAX. */
.dash-online-scroll {
  line-height: 1.5;
  max-height: 3em;
  overflow-y: auto;
}

.dash-online-item {
  white-space: nowrap;
}

/* Current View history: most-recent-first list, capped at two lines + scroll. */
.dash-view-scroll {
  line-height: 1.5;
  max-height: 3em;
  overflow-y: auto;
}

.dash-view-item {
  white-space: nowrap;
}

/* Current (first) view reads as normal text like the other cells; older
   history entries are de-emphasized. */
.dash-view-item:not(:first-child) {
  color: #868e96;
}

.dash-query {
  white-space: nowrap;
}

.dash-count {
  color: #6c757d;
}

.dash-muted {
  color: #adb5bd;
}

.dashboard-empty {
  padding: 24px;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* ── Mobile (≤ 768px): the dashboard is the fourth bottom-nav tab (gated to
   can_update). The wide table scrolls horizontally like the other mobile
   tables; the header band wraps so its controls don't overflow. ── */
@media (max-width: 768px) {
  #dashboard-info {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .dashboard-header-controls {
    margin-left: 0;     /* don't push off-screen; sits under the title on its own line */
    flex-wrap: wrap;
    gap: 8px;
  }

  #dashboard-table th,
  #dashboard-table td {
    white-space: nowrap;   /* keep cells single-line; the wrap scrolls horizontally */
  }
}
