/* status.css
 * Minimal helpers on top of Tailwind classes.
 * Keep behavior in status.js.
 */

:root {
  color-scheme: light;

  --sp-header-bg: #1f2230;
  --sp-header-border: rgba(255, 255, 255, 0.10);
  --sp-header-text: rgba(255, 255, 255, 0.96);
  --sp-header-sub: rgba(214, 221, 230, 0.86);

  --sp-nav-bg: rgba(31, 34, 48, 0.80);
  --sp-nav-border: rgba(255, 255, 255, 0.10);

  --sp-bar-track: rgba(148, 163, 184, 0.22);
  --sp-bar-track-hover: rgba(148, 163, 184, 0.28);

  --sp-green: rgba(102, 196, 77, 1);            /* 100% */
  --sp-green-soft: rgb(153 225 134);            /* >=98% */
  --sp-orange: rgba(255, 171, 93, 1);           /* >=95% */
  --sp-red: rgba(255, 61, 61, 0.85);            /* <95% */


  /* Radar waves (used by `.sp-radar`)
   * - speed (how fast a wave expands):        --sp-radar-duration
   * - frequency (how often a wave starts):    --sp-radar-stagger
   * - range (how far it expands):             --sp-radar-scale
   */
  --sp-radar-duration: 2.2s;
  --sp-radar-stagger: 1.1s;
  --sp-radar-scale: 2.65;
  --sp-radar-border: 2px;
  --sp-radar-opacity: 0.55;
  --sp-radar-opacity-mid: 0.18;
}

html.dark {
  color-scheme: dark;

  --sp-header-bg: rgba(27, 27, 29, 0.78);
  --sp-header-border: rgba(255, 255, 255, 0.10);
  --sp-header-text: rgba(255, 255, 255, 0.92);
  --sp-header-sub: rgba(148, 163, 184, 0.90);

  --sp-nav-bg: rgba(27, 27, 29, 0.55);
  --sp-nav-border: rgba(255, 255, 255, 0.08);

  --sp-bar-track: rgba(148, 163, 184, 0.12);
  --sp-bar-track-hover: rgba(148, 163, 184, 0.16);
}

/* Layout */
.sp-container {
  max-width: 1000px;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Header / nav */
.sp-header {
  border-bottom: 1px solid var(--sp-header-border);
  background: var(--sp-header-bg);
  color: var(--sp-header-text);
}

.sp-nav {
  border-bottom: 1px solid var(--sp-nav-border);
  background: var(--sp-nav-bg);
  color: var(--sp-header-text);
}

#last-updated-label {
  color: rgba(255, 255, 255, 0.86);
}

#sp-subtitle {
  color: var(--sp-header-sub);
}

#sp-logo-wrap {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* Stale data mode */
body.sp-stale #overall-status {
  opacity: 0.95;
}
body.sp-stale #services {
  opacity: 0.92;
}

/* Reserve some space while overall title is loading to reduce layout shift */
#overall-status {
  min-height: 2.35rem;
}

/* MOTD */
.sp-motd {
  border-radius: 0.4rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(249, 250, 251, 0.65);
  padding: 0.75rem;
}
html.dark .sp-motd {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 16, 0.55);
}

.sp-motd-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(107, 114, 128, 0.95);
  font-weight: 800;
}
html.dark .sp-motd-label {
  color: rgba(148, 163, 184, 0.90);
}

.sp-motd-body {
  margin-top: 0.35rem;
  max-height: 100px;
  overflow: auto;
  white-space: pre-line;
  font-size: 0.875rem;
  line-height: 1.35;
}

/* Custom scrollbar (WebKit) */
.sp-motd-body::-webkit-scrollbar {
  width: 10px;
}
.sp-motd-body::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 9999px;
}
.sp-motd-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.40);
  border-radius: 9999px;
}
html.dark .sp-motd-body::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.12);
}
html.dark .sp-motd-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.34);
}

/* Firefox */
.sp-motd-body {
  scrollbar-color: rgba(148, 163, 184, 0.40) rgba(148, 163, 184, 0.18);
  scrollbar-width: thin;
}
html.dark .sp-motd-body {
  scrollbar-color: rgba(148, 163, 184, 0.34) rgba(148, 163, 184, 0.12);
}

/* --- Cards / borders (small radius, subtle border) --- */
.sp-card {
  border-radius: 0.4rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}
html.dark .sp-card {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(27, 27, 29, 0.90);
}

/* --- Buttons --- */
.sp-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 800;
  border: 1px solid transparent;
  user-select: none;
}

.sp-btn:focus-visible {
  outline: 2px solid rgba(91, 115, 232, 0.55);
  outline-offset: 2px;
}

.sp-btn-ghost {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(15, 23, 42, 0.10);
  color: rgba(15, 23, 42, 0.86);
}
html.dark .sp-btn-ghost {
  background: rgba(27, 27, 29, 0.55);
  border-color: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.92);
}

.sp-btn-ghost:hover {
  background: rgba(243, 244, 246, 0.90);
}
html.dark .sp-btn-ghost:hover {
  background: rgba(42, 42, 45, 0.75);
}

/* Light theme header needs contrast; use dedicated button styling */
.sp-header .sp-btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
}
.sp-header .sp-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sp-btn-solid {
  background: rgba(91, 115, 232, 1);
  border-color: rgba(91, 115, 232, 1);
  color: rgba(255, 255, 255, 0.98);
}
.sp-btn-solid:hover {
  background: rgba(71, 94, 211, 1);
  border-color: rgba(71, 94, 211, 1);
}

.sp-btn-on {
  background: rgba(91, 115, 232, 0.16) !important;
  border-color: rgba(91, 115, 232, 0.35) !important;
  color: rgba(91, 115, 232, 1) !important;
}
html.dark .sp-btn-on {
  background: rgba(91, 115, 232, 0.20) !important;
  border-color: rgba(91, 115, 232, 0.32) !important;
  color: rgba(147, 197, 253, 1) !important;
}

/* Nav links */
.sp-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
  border-radius: 0.35rem;
  font-weight: 800;
  color: rgba(55, 65, 81, 0.90);
}
html.dark .sp-nav-link {
  color: rgba(229, 231, 235, 0.92);
}
.sp-nav-link:hover {
  background: rgba(243, 244, 246, 0.90);
}
html.dark .sp-nav-link:hover {
  background: rgba(42, 42, 45, 0.60);
}

/* Nav on dark header (both themes) */
.sp-nav .sp-nav-link {
  color: rgba(255, 255, 255, 0.92);
}
.sp-nav .sp-nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* --- Status dots --- */
.sp-status-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 9999px;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}
html.dark .sp-status-dot {
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.25);
}

/* Dot colors + ring color for radar waves */
.sp-dot-ok { background: #10b981; --sp-ring: rgba(16, 185, 129, 0.40); }
.sp-dot-warn { background: #f59e0b; --sp-ring: rgba(245, 158, 11, 0.40); }
.sp-dot-degraded { background: #f59e0b; --sp-ring: rgba(245, 158, 11, 0.40); }
.sp-dot-partial { background: #fb923c; --sp-ring: rgba(251, 146, 60, 0.40); }
.sp-dot-down { background: #ef4444; --sp-ring: rgba(239, 68, 68, 0.42); }
.sp-dot-critical { background: #dc2626; --sp-ring: rgba(220, 38, 38, 0.42); }
.sp-dot-maintenance { background: #3b82f6; --sp-ring: rgba(59, 130, 246, 0.40); }
.sp-dot-paused { background: #9ca3af; --sp-ring: rgba(156, 163, 175, 0.36); }
.sp-dot-unknown { background: #94a3b8; --sp-ring: rgba(148, 163, 184, 0.34); }

/* --- Radar waves (reusable) ---
 *
 * Attach `.sp-radar` to any dot to enable the wave effect.
 * Adjust speed / range / frequency via the --sp-radar-* variables in :root.
 */
.sp-radar {
  position: relative;
  isolation: isolate;
}

.sp-radar::before,
.sp-radar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  border: var(--sp-radar-border, 2px) solid var(--sp-ring, rgba(148, 163, 184, 0.35));
  animation: spRadar var(--sp-radar-duration, 2.2s) ease-out infinite;
  pointer-events: none;
}

.sp-radar::after {
  animation-delay: var(--sp-radar-stagger, 1.1s);
}

@keyframes spRadar {
  0% { transform: translate(-50%, -50%) scale(1); opacity: var(--sp-radar-opacity, 0.55); }
  70% { opacity: var(--sp-radar-opacity-mid, 0.18); }
  100% { transform: translate(-50%, -50%) scale(var(--sp-radar-scale, 2.65)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-radar::before,
  .sp-radar::after { animation: none; }
}

/* Overall dot: bigger (pair with `.sp-dot-overall`) */
.sp-dot-overall {
  width: 1.35rem;
  height: 1.35rem;
  box-shadow: none;
  flex: 0 0 auto;
  margin-bottom: 15px;
  margin-right: 0.5rem;
}

/* Live indicator */
.sp-live-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 9999px;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
  animation: spPulse 1.6s ease-out infinite;
}
.sp-live-dot.sp-live-stale {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}
.sp-live-dot.sp-live-offline {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
  animation: none;
}

@keyframes spPulse {
  0% { transform: scale(1); opacity: 1; }
  60% { transform: scale(1.35); opacity: 0.72; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-live-dot { animation: none; }
}

/* --- Uptime bars (percent-based, configurable days) --- */
.sp-uptime-bars {
  --sp-bars: 90;

  /* Base look (wide screens): 6px bars + a visually pleasing gap.
   * Small screens: reduce the gap first, then scale bar width down as needed.
   *
   * Latest (newest) day is on the right edge.
   */
  --sp-bar-base: 6px;
  --sp-gap-min: 1px;
  --sp-gap-max: 6px;

  /* Gap that would keep bars at --sp-bar-base while filling the row. */
  --sp-gap-ideal: calc((100% - (var(--sp-bars) * var(--sp-bar-base))) / (var(--sp-bars) - 1));
  --sp-gap: clamp(var(--sp-gap-min), var(--sp-gap-ideal), var(--sp-gap-max));

  /* Bar width that fits with the selected gap. */
  --sp-bar-w: calc((100% - ((var(--sp-bars) - 1) * var(--sp-gap))) / var(--sp-bars));

  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--sp-bar-w);
  gap: var(--sp-gap);
  align-items: end;

  /* If sub-pixel rounding causes leftover space, pin the newest bar to the right edge. */
  justify-content: end;
}

.sp-uptime-bars .sp-bar {
  position: relative;
  height: 26px;
  border-radius: 9999px;
  background: var(--sp-bar-track);
  overflow: hidden;
}

.sp-uptime-bars .sp-bar:hover {
  opacity: 0.80;
  background: var(--sp-bar-track-hover);
}

.sp-uptime-bars .sp-bar[data-nodata="1"] {
  opacity: 0.35;
}

.sp-uptime-bars .sp-bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--sp-p, 0) * 1%);
  border-radius: 9999px;
}

/* Uptime label next to service name */
.sp-uptime-pct {
  margin-left: 0.45rem;
  font-size: 0.875rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  transition: opacity 120ms ease-out;
}

details:hover .sp-uptime-pct {
  opacity: 0.90;
}

/* --- Pills --- */
.sp-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 900;
  border-radius: 9999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.70);
  color: rgba(55, 65, 81, 0.95);
}
html.dark .sp-pill {
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(17, 17, 18, 0.35);
  color: rgba(255, 255, 255, 0.92);
}

/* API error card */
.sp-api-error {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(254, 242, 242, 0.75);
}
html.dark .sp-api-error {
  border-color: rgba(239, 68, 68, 0.26);
  background: rgba(127, 29, 29, 0.16);
}

/* Powered by footer */
.sp-powered {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  color: rgba(75, 85, 99, 0.82);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
}

.sp-powered:hover {
  color: rgba(75, 85, 99, 0.82);
}

html.dark .sp-powered {
  color: rgba(203, 213, 225, 0.74);
}

html.dark .sp-powered:hover {
  color: rgba(203, 213, 225, 0.74);
}

.sp-powered-copy {
  white-space: nowrap;
}

.sp-powered-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  color: rgba(75, 85, 99, 0.92);
  font-size: 0.92rem;
  font-weight: 500;
}

html.dark .sp-powered-brand {
  color: rgba(203, 213, 225, 0.86);
}

.sp-powered-logo {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  border-radius: 0.35rem;
  filter: grayscale(1);
  opacity: 0.58;
  transition: filter 120ms ease-out, opacity 120ms ease-out;
}

.sp-powered:hover .sp-powered-logo,
.sp-powered:focus-visible .sp-powered-logo {
  filter: grayscale(0);
  opacity: 1;
}

@media (max-width: 420px) {
  .sp-powered {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }
}

/* API doc code block */
.sp-code {
  border-radius: 0.4rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(249, 250, 251, 0.75);
  padding: 0.75rem;
  overflow: auto;
}
html.dark .sp-code {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 16, 0.55);
}

/* --- Monitor details (inline) --- */
.sp-details {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}
html.dark .sp-details {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.sp-loc-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.65);
}
.sp-loc-dot[data-ok="1"] { background: rgba(16, 185, 129, 0.90); }
.sp-loc-dot[data-ok="0"] { background: rgba(239, 68, 68, 0.90); }

/* Hide default disclosure marker for details/summary */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* --- Loading skeleton (prevents jumping while initial data loads) --- */
#monitor-list[data-loading="1"] {
  min-height: 260px;
}

.sp-skeleton {
  position: relative;
  border-radius: 0.4rem;
  animation: spSkeletonPulse 1.4s ease-in-out infinite;
}

.sp-skeleton-line {
  display: inline-block;
  height: 0.75rem;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.30);
}
html.dark .sp-skeleton-line {
  background: rgba(148, 163, 184, 0.18);
}

.sp-skeleton-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.30);
}
html.dark .sp-skeleton-dot {
  background: rgba(148, 163, 184, 0.18);
}

.sp-skeleton-bars {
  height: 22px;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.16);
}
html.dark .sp-skeleton-bars {
  background: rgba(148, 163, 184, 0.10);
}

.sp-skeleton-w-40 { width: 10rem; }
.sp-skeleton-w-20 { width: 5rem; }
.sp-skeleton-w-14 { width: 3.5rem; }

@keyframes spSkeletonPulse {
  0% { opacity: 0.65; }
  50% { opacity: 1; }
  100% { opacity: 0.65; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-skeleton { animation: none; }
}
