/* ================================================================
   Project-specific CSS supplement for Bootstrap 5.3
   Clean monitoring dashboard aesthetic, mobile-friendly.
   ================================================================ */

/* ----------------------------------------------------------------
   Custom colour tokens
   ---------------------------------------------------------------- */
:root {
  --fapg-accent:       #16a34a;
  --fapg-accent-soft:  #e4f3ea;
  --fapg-danger:       #dc2626;
  --fapg-danger-soft:  #fee4e2;
  --fapg-warn:         #d97706;
  --fapg-warn-soft:    #fff4d6;
  --fapg-unknown:      #64748b;
  --fapg-unknown-soft: #f1f5f9;
  --fapg-surface:      #ffffff;
  --fapg-border:       #e2e8f0;
  --fapg-text:         #1e293b;
  --fapg-text-muted:   #64748b;
  --navbar-height:     3.5rem;
}

/* ----------------------------------------------------------------
   Global font
   ---------------------------------------------------------------- */
html {
  overflow-x: clip;
}

body {
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  overflow-x: clip;
}

/* Toolbar graph controls — scroll horizontally without causing page overflow */
.graph-control-scroll {
  max-width: 100%;
}

#toolbar {
  max-width: 100%;
  position: sticky;
  top: var(--navbar-height);
  z-index: 1015;
  background: var(--bs-body-bg, #fff);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.sticky-controls {
  position: sticky;
  top: var(--navbar-height);
  z-index: 1015;
  background: var(--bs-body-bg, #fff);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* Info toggle button in insight card headers */
.info-toggle {
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.info-toggle:hover,
.info-toggle:focus-visible,
.info-toggle[aria-expanded="true"] {
  opacity: 1;
}

#toolbar .toolbar-items {
  min-width: 0;
}

.range-control {
  flex-wrap: nowrap;
}

.range-control .range-label {
  white-space: nowrap;
}

/* ----------------------------------------------------------------
   Section and page titles — prominent, accented left border
   ---------------------------------------------------------------- */
.card-header h1,
.card-header h2 {
  letter-spacing: -0.01em;
}

.card-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fapg-text);
}

.card-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
}

section > .h4,
section > h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--fapg-text);
  letter-spacing: -0.02em;
}

section > .h6,
section > h2 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--fapg-text-muted);
}

/* ----------------------------------------------------------------
   Cards — clean with defined borders, subtle shadow
   ---------------------------------------------------------------- */
.card {
  border-color: var(--fapg-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-header {
  background-color: #f8fafc;
  border-bottom-color: var(--fapg-border);
}

/* ----------------------------------------------------------------
   Header LED status indicator
   ---------------------------------------------------------------- */
.header-status-link {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
}

.header-status-link:focus-visible {
  outline: 2px solid var(--fapg-accent);
  outline-offset: 0.25rem;
}

.header-status-led {
  width: 0.85rem;
  height: 0.85rem;
  border: 1px solid rgba(23, 33, 27, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff 0 8%, #98a2b3 18%, #475467 70%);
  box-shadow:
    inset 0 -1px 2px rgba(23, 33, 27, 0.45),
    0 0 0.35rem rgba(71, 84, 103, 0.45);
}

.header-status-link.is-healthy .header-status-led {
  background: radial-gradient(circle at 32% 28%, #ffffff 0 8%, #86efac 18%, #16a34a 68%, #14532d 100%);
  animation: led-green 1.35s ease-in-out infinite;
}

.header-status-link.is-warning .header-status-led {
  background: radial-gradient(circle at 32% 28%, #ffffff 0 8%, #fca5a5 18%, #dc2626 68%, #7f1d1d 100%);
  animation: led-red 1s ease-in-out infinite;
}

@keyframes led-green {
  0%, 100% {
    box-shadow:
      inset 0 -1px 2px rgba(23, 33, 27, 0.45),
      0 0 0.3rem rgba(22, 163, 74, 0.45);
    opacity: 0.78;
  }
  50% {
    box-shadow:
      inset 0 -1px 2px rgba(23, 33, 27, 0.45),
      0 0 0.85rem rgba(22, 163, 74, 0.95),
      0 0 1.25rem rgba(134, 239, 172, 0.45);
    opacity: 1;
  }
}

@keyframes led-red {
  0%, 100% {
    box-shadow:
      inset 0 -1px 2px rgba(23, 33, 27, 0.45),
      0 0 0.35rem rgba(220, 38, 38, 0.5);
    opacity: 0.75;
  }
  50% {
    box-shadow:
      inset 0 -1px 2px rgba(23, 33, 27, 0.45),
      0 0 0.9rem rgba(220, 38, 38, 1),
      0 0 1.35rem rgba(252, 165, 165, 0.5);
    opacity: 1;
  }
}

/* ----------------------------------------------------------------
   Status pill — coloured badge for online/offline/unknown states.
   ---------------------------------------------------------------- */
.status-pill {
  white-space: nowrap;
  font-size: 0.78rem;
}

.status-pill.is-healthy,
.status-pill.is-online {
  background-color: var(--fapg-accent-soft) !important;
  color: var(--fapg-accent) !important;
}

.status-pill.is-stale,
.status-pill.is-probe-error {
  background-color: var(--fapg-warn-soft) !important;
  color: var(--fapg-warn) !important;
}

.status-pill.is-offline,
.status-pill.is-unreachable {
  background-color: var(--fapg-danger-soft) !important;
  color: var(--fapg-danger) !important;
}

.status-pill.is-unknown {
  background-color: var(--fapg-unknown-soft) !important;
  color: var(--fapg-unknown) !important;
}

/* ----------------------------------------------------------------
   Status node marker — LED dot on the status page
   ---------------------------------------------------------------- */
.status-node-marker {
  width: 1.25rem;
  height: 1.25rem;
  border: 0.3rem solid var(--fapg-unknown-soft);
  border-radius: 50%;
  background: var(--fapg-unknown);
  flex-shrink: 0;
}

.status-node-marker.is-online,
.status-node-marker.is-healthy {
  border-color: var(--fapg-accent-soft);
  background: var(--fapg-accent);
}

.status-node-marker.is-stale,
.status-node-marker.is-probe-error {
  border-color: var(--fapg-warn-soft);
  background: var(--fapg-warn);
}

.status-node-marker.is-offline,
.status-node-marker.is-unreachable {
  border-color: var(--fapg-danger-soft);
  background: var(--fapg-danger);
}

/* ----------------------------------------------------------------
   Reading range bar (home page quick-reading cards)
   ---------------------------------------------------------------- */
.reading-quick-link {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: var(--bs-card-border-radius);
  cursor: pointer;
}

.reading-quick-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.reading-quick-item {
  --range-gradient: linear-gradient(90deg, var(--fapg-border), var(--fapg-border));
}

.reading-quick-item.is-stale {
  opacity: 0.6;
  border-color: var(--fapg-border) !important;
}

.reading-range-labels {
  grid-template-columns: 1fr auto 1fr;
}

.reading-range {
  position: relative;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--range-gradient);
}

.reading-range-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--fapg-unknown);
  box-shadow: 0 1px 4px rgba(23, 33, 27, 0.35);
  transform: translate(-50%, -50%);
}

/* Status node detail-list term labels */
.status-node-dt {
  font-size: 0.7rem;
}

/* ----------------------------------------------------------------
   Chart canvas sizing
   ---------------------------------------------------------------- */
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
  aspect-ratio: 16 / 9;
}

@media (max-width: 575.98px) {
  .chart-wrap {
    aspect-ratio: 4 / 3;
    min-height: 250px;
  }
}

/* All chart cards flex their body so info collapses squish evenly */
.row > [class*="col"] > .card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.row > [class*="col"] > .card > .card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.row > [class*="col"] > .card > .card-body > .chart-wrap {
  flex: 1;
  min-height: 0;
}

/* Probes grid — flex charts within cards */
.probes-grid .card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.probes-grid .tab-panel.is-active {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.probes-grid .chart-wrap {
  flex: 1;
  min-height: 0;
}

/* ----------------------------------------------------------------
   Tab panel visibility (JS-driven)
   ---------------------------------------------------------------- */
.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

/* ----------------------------------------------------------------
   Timeframe control active state
   ---------------------------------------------------------------- */
.timeframe-button.is-active {
  background-color: var(--fapg-accent) !important;
  border-color: var(--fapg-accent) !important;
  color: #fff !important;
  font-weight: 600;
}

/* ----------------------------------------------------------------
   Insights page — section anchor nav with scroll spy
   ---------------------------------------------------------------- */
.insights-nav .nav-link {
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fapg-text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
}

.insights-nav .nav-link.active {
  background-color: var(--fapg-accent) !important;
  color: #fff !important;
}

.insight-theme {
  scroll-margin-top: 5rem;
}
