/* ============================================================
   Design tokens — Sentinel "ops console" dark theme
   ============================================================ */

:root {
  --sentinel-ink: #0a0e1a; /* app background, near-black navy */
  --sentinel-surface: #131a2b; /* card/table surface, dark slate-navy */
  --sentinel-surface-2: #1a2338; /* raised surface / hover / thead */
  --sentinel-line: #26314a; /* borders/dividers */
  --sentinel-text: #e7ebf3; /* primary off-white text */
  --sentinel-text-muted: #8d96ad; /* secondary text */
  --sentinel-accent: #22d3ee; /* signal cyan — links, active nav, focus, posture accents */
  --sentinel-accent-rgb: 34, 211, 238;
  --sentinel-critical: #f43f5e; /* rose-red */
  --sentinel-critical-bg: rgba(244, 63, 94, 0.14);
  --sentinel-warning: #f59e0b; /* amber */
  --sentinel-warning-bg: rgba(245, 158, 11, 0.14);
  --sentinel-healthy: #10b981; /* emerald */
  --sentinel-healthy-bg: rgba(16, 185, 129, 0.14);
  --sentinel-unknown: #64748b; /* neutral slate for "no data" */
  --sentinel-unknown-bg: rgba(100, 116, 139, 0.14);
  --font-display: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* Re-point Bootstrap's own color variables so any utility class we haven't
     explicitly overridden (.text-body, .border, etc.) still resolves to the
     dark theme instead of Bootstrap's light-theme defaults. */
  --bs-body-bg: var(--sentinel-ink);
  --bs-body-bg-rgb: 10, 14, 26;
  --bs-body-color: var(--sentinel-text);
  --bs-body-color-rgb: 231, 235, 243;
  --bs-border-color: var(--sentinel-line);
  --bs-border-color-translucent: var(--sentinel-line);
  --bs-link-color: var(--sentinel-accent);
  --bs-link-color-rgb: var(--sentinel-accent-rgb);
  --bs-link-hover-color: var(--sentinel-accent);
  --bs-link-hover-color-rgb: var(--sentinel-accent-rgb);
}

/* ============================================================
   Global element + Bootstrap component overrides
   ============================================================ */

body {
  background: var(--sentinel-ink);
  color: var(--sentinel-text);
  font-family: var(--font-display);
}

h1, h2, h3, h4, h5, h6, .display-6 {
  font-weight: 600;
}

a {
  color: var(--sentinel-accent);
}
a:hover {
  color: var(--sentinel-accent);
  filter: brightness(1.2);
}

.text-muted {
  color: var(--sentinel-text-muted) !important;
}

.card {
  background-color: var(--sentinel-surface);
  color: var(--sentinel-text);
  border: 1px solid var(--sentinel-line);
}
.card-header {
  background-color: transparent;
  border-color: var(--sentinel-line);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--sentinel-text);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
  --bs-table-hover-color: var(--sentinel-text);
  --bs-table-border-color: var(--sentinel-line);
}

.modal-content {
  background-color: var(--sentinel-surface);
  color: var(--sentinel-text);
  border: 1px solid var(--sentinel-line);
}
.modal-header,
.modal-footer {
  border-color: var(--sentinel-line);
}
.btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
}

.form-control,
.form-select {
  background-color: var(--sentinel-surface-2);
  color: var(--sentinel-text);
  border-color: var(--sentinel-line);
}
.form-control:focus,
.form-select:focus {
  background-color: var(--sentinel-surface-2);
  color: var(--sentinel-text);
  border-color: var(--sentinel-accent);
  box-shadow: 0 0 0 0.2rem rgba(var(--sentinel-accent-rgb), 0.25);
}
.form-control::placeholder {
  color: var(--sentinel-text-muted);
  opacity: 1;
}
.form-select option {
  background: var(--sentinel-surface);
  color: var(--sentinel-text);
}

.dropdown-menu {
  background-color: var(--sentinel-surface);
  border-color: var(--sentinel-line);
}
.dropdown-item {
  color: var(--sentinel-text);
}
.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--sentinel-surface-2);
  color: var(--sentinel-text);
}

.alert {
  --bs-alert-bg: var(--sentinel-surface);
  --bs-alert-color: var(--sentinel-text);
  --bs-alert-border-color: var(--sentinel-line);
}
.alert-success { --bs-alert-bg: var(--sentinel-healthy-bg); --bs-alert-color: var(--sentinel-text); --bs-alert-border-color: var(--sentinel-healthy); }
.alert-danger { --bs-alert-bg: var(--sentinel-critical-bg); --bs-alert-color: var(--sentinel-text); --bs-alert-border-color: var(--sentinel-critical); }
.alert-warning { --bs-alert-bg: var(--sentinel-warning-bg); --bs-alert-color: var(--sentinel-text); --bs-alert-border-color: var(--sentinel-warning); }
.alert-info { --bs-alert-bg: rgba(var(--sentinel-accent-rgb), 0.14); --bs-alert-color: var(--sentinel-text); --bs-alert-border-color: var(--sentinel-accent); }
.alert .btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
}

/* ============================================================
   App Navbar
   ============================================================ */

.app-navbar {
  background: var(--sentinel-ink);
  border-bottom: 1px solid rgba(var(--sentinel-accent-rgb), 0.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.app-navbar .navbar-brand {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  color: #f1f5f9 !important;
}

.app-navbar .navbar-brand .bi {
  font-size: 1.15rem;
  color: var(--sentinel-accent);
}

.app-navbar .nav-link {
  color: #94a3b8 !important;
  font-size: 0.82rem;
  padding: 0.4rem 0.65rem !important;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}

.app-navbar .nav-link:hover {
  color: #e2e8f0 !important;
  background: rgba(255, 255, 255, 0.07);
}

.app-navbar .nav-link.active {
  color: var(--sentinel-accent) !important;
  background: rgba(var(--sentinel-accent-rgb), 0.1);
}

.app-navbar .nav-signout {
  color: #64748b !important;
  font-size: 0.8rem;
}

.app-navbar .nav-signout:hover {
  color: #cbd5e1 !important;
}

/* ============================================================
   Project-wide utilities
   ============================================================ */

.alert-debug {
  color: var(--sentinel-text);
  background-color: var(--sentinel-surface);
  border-color: var(--sentinel-line);
}

.alert-error {
  color: var(--sentinel-text);
  background-color: var(--sentinel-critical-bg);
  border-color: var(--sentinel-critical);
}

/* ============================================================
   Home Page
   ============================================================ */

.home-hero {
  min-height: calc(100vh - 56px);
  background: var(--sentinel-ink);
}

.home-hero-icon {
  font-size: 4rem;
  color: var(--sentinel-accent);
}

.home-header {
  background: linear-gradient(135deg, #0a0e1a 0%, #101a2e 60%, #0f2436 100%);
  border-bottom: 1px solid var(--sentinel-line);
}

/* ============================================================
   Inventory Section
   ============================================================ */

/* Inventory page wrapper — full dark canvas below the header */
.inv-page {
  background: var(--sentinel-ink);
  min-height: calc(100vh - 50px);
}

/* Dark header strip at the top of inventory pages */
.inv-header {
  background: linear-gradient(135deg, #0a0e1a 0%, #101a2e 60%, #0f2436 100%);
  border-bottom: 1px solid var(--sentinel-line);
}

/* Filter pill tabs inside the header */
.inv-filter-pills .nav-link {
  color: #94a3b8;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  padding: 0.6rem 1rem 0.5rem;
  font-size: 0.85rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.inv-filter-pills .nav-link:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border-bottom-color: #475569;
}
.inv-filter-pills .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-bottom-color: var(--sentinel-accent);
  font-weight: 600;
}

/* Breadcrumb inside dark header */
.inv-breadcrumb {
  color: #94a3b8;
  font-size: 0.8rem;
}
.inv-breadcrumb a {
  color: #7ab3e8;
  text-decoration: none;
}
.inv-breadcrumb a:hover {
  color: #93c5fd;
}

/* ---- Metric cards ---- */
.metric-card {
  border: none;
  border-left: 4px solid var(--sentinel-unknown);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.15s, transform 0.15s;
}
.metric-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transform: translateY(-2px);
}
.metric-card.metric-ok { border-left-color: var(--sentinel-healthy); }
.metric-card.metric-warn { border-left-color: var(--sentinel-warning); }
.metric-card.metric-danger { border-left-color: var(--sentinel-critical); }
.metric-card.metric-info { border-left-color: var(--sentinel-accent); }

/* ---- Slim summary bar (Project List) ---- */
.summary-bar {
  padding: 0.85rem 1.1rem;
  background: var(--sentinel-surface);
  border: 1px solid var(--sentinel-line);
  border-radius: 0.5rem;
}
.summary-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--sentinel-text);
}
.summary-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}
.summary-stat-label {
  font-size: 0.78rem;
  color: var(--sentinel-text-muted);
}
.summary-stat-danger .summary-stat-value { color: var(--sentinel-critical); }
.summary-stat-warn .summary-stat-value { color: var(--sentinel-warning); }

/* ---- Project health hero ---- */
.health-hero {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  border-left: 6px solid var(--sentinel-unknown);
  background: var(--sentinel-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.health-hero-synopsis {
  color: var(--sentinel-text-muted);
  font-size: 0.9rem;
}
.health-hero-critical {
  border-left-color: var(--sentinel-critical);
  background: var(--sentinel-critical-bg);
}
.health-hero-critical i { color: var(--sentinel-critical); }
.health-hero-warning {
  border-left-color: var(--sentinel-warning);
  background: var(--sentinel-warning-bg);
}
.health-hero-warning i { color: var(--sentinel-warning); }
.health-hero-healthy {
  border-left-color: var(--sentinel-healthy);
  background: var(--sentinel-healthy-bg);
}
.health-hero-healthy i { color: var(--sentinel-healthy); }

/* ---- Posture strip (signature component) ---- */
.posture-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.posture-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: default;
}
.posture-strip-sm .posture-node {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
}
.posture-strip-lg .posture-node {
  width: 2.15rem;
  height: 2.15rem;
  font-size: 1rem;
}
.posture-node.posture-critical { background: var(--sentinel-critical-bg); color: var(--sentinel-critical); }
.posture-node.posture-warning { background: var(--sentinel-warning-bg); color: var(--sentinel-warning); }
.posture-node.posture-healthy { background: var(--sentinel-healthy-bg); color: var(--sentinel-healthy); }
.posture-node.posture-unknown { background: var(--sentinel-unknown-bg); color: var(--sentinel-unknown); }

/* ---- App-wide posture hero + live pulse (Home) ---- */
.app-posture-hero {
  padding: 1.25rem 1.5rem;
  border-radius: 0.65rem;
  border-left: 6px solid var(--sentinel-unknown);
  background: var(--sentinel-surface);
}
.app-posture-hero.health-hero-critical { border-left-color: var(--sentinel-critical); background: var(--sentinel-critical-bg); }
.app-posture-hero.health-hero-warning { border-left-color: var(--sentinel-warning); background: var(--sentinel-warning-bg); }
.app-posture-hero.health-hero-healthy { border-left-color: var(--sentinel-healthy); background: var(--sentinel-healthy-bg); }

.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--sentinel-text-muted);
}
.live-pulse-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--sentinel-accent);
}
@media (prefers-reduced-motion: no-preference) {
  .live-pulse-dot {
    animation: live-pulse-ping 2s ease-in-out infinite;
  }
}
@keyframes live-pulse-ping {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--sentinel-accent-rgb), 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(var(--sentinel-accent-rgb), 0); }
}

/* ---- "Projects needing attention" cards (Home) ---- */
.attention-card {
  background: var(--sentinel-surface);
  border: 1px solid var(--sentinel-line);
  border-left: 4px solid var(--sentinel-unknown);
  border-radius: 0.5rem;
  transition: box-shadow 0.15s, transform 0.15s;
}
.attention-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transform: translateY(-2px);
}
.attention-card.status-critical { border-left-color: var(--sentinel-critical); }
.attention-card.status-warning { border-left-color: var(--sentinel-warning); }
.attention-card-synopsis {
  color: var(--sentinel-text-muted);
  font-size: 0.85rem;
}

/* ---- Server table ---- */
.table-inventory thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--sentinel-surface-2);
  color: var(--sentinel-text);
  border-color: var(--sentinel-line);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.7rem 0.75rem;
}

.table-inventory tbody td {
  vertical-align: middle;
  padding: 0.55rem 0.75rem;
}

.table-inventory tbody tr:hover td {
  background: rgba(var(--sentinel-accent-rgb), 0.06);
}

/* Row status colouring */
tr.status-critical td { background: var(--sentinel-critical-bg); }
tr.status-warning td { background: var(--sentinel-warning-bg); }
tr.status-critical:hover td { background: rgba(244, 63, 94, 0.22) !important; }
tr.status-warning:hover td { background: rgba(245, 158, 11, 0.22) !important; }

/* ---- Progress bars ---- */
.progress.progress-sm {
  height: 6px;
  border-radius: 3px;
  background-color: var(--sentinel-line);
}

/* ---- Server hostname link ---- */
.server-link {
  color: var(--sentinel-accent);
}
.server-link:hover {
  color: var(--sentinel-accent);
  filter: brightness(1.2);
  text-decoration: underline !important;
}

/* ---- Monospace for technical values ---- */
.text-mono {
  font-family: var(--font-mono), monospace;
  font-size: 0.825em;
  color: var(--sentinel-text-muted);
}

/* ---- Table column minimum widths ---- */
.col-eol { min-width: 130px; }
.col-disk,
.col-mem { min-width: 140px; }
.col-load { min-width: 180px; }

/* ---- Inline stat label width ---- */
.stat-label { min-width: 3rem; }

/* ---- Chart height cap ---- */
.chart-300 { max-height: 300px; }

/* ---- Home page ---- */
.hero-desc { max-width: 420px; }
.home-content {
  background: var(--sentinel-ink);
  min-height: calc(100vh - 110px);
}

/* ---- Repos page ---- */
.select-project { min-width: 140px; }
.repo-search { width: 240px; }

/* ---- Repos page: project filter combobox ---- */
.repo-project-combo { position: relative; }
.repo-project-combo-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  margin-top: 0.25rem;
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--sentinel-surface);
  border: 1px solid var(--sentinel-line);
  border-radius: 0.375rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 0.4rem;
}
.repo-project-combo-list { display: flex; flex-direction: column; }
.repo-project-combo-item {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  color: var(--sentinel-text);
  text-decoration: none;
}
.repo-project-combo-item:hover,
.repo-project-combo-item.highlighted {
  background: var(--sentinel-surface-2);
}
.repo-project-combo-item.active {
  background: var(--sentinel-accent);
  color: #04141a;
}
