/*
 * BlackWall theme
 * A reusable visual layer built on Tabler v1.4.0.
 */

:root {
  --ns-color-brand: #071c33;
  --ns-color-brand-soft: #124c77;
  --ns-color-action: #0c78c9;
  --ns-color-action-hover: #0967ad;
  --ns-color-accent: #22b8cf;
  --ns-color-success: #2fb344;
  --ns-color-warning: #f59f00;
  --ns-color-danger: #d63939;
  --ns-color-neutral: #98a2b3;
  --ns-color-text: #172b4d;
  --ns-color-text-muted: #66788a;
  --ns-color-border: #dfe7ef;
  --ns-color-surface: #ffffff;
  --ns-color-surface-subtle: #f9fbfd;
  --ns-color-page: #f3f6fa;
  --ns-radius-card: 12px;
  --ns-shadow-card: 0 8px 25px rgba(23, 43, 77, 0.045);
  --ns-shadow-card-hover: 0 13px 30px rgba(23, 43, 77, 0.08);
  --ns-header-height: 64px;
}

/* Horizontal clipping lives here, on the document scroller, and deliberately
   NOT on body: overflow-x on body makes body a scroll container, and a
   position: sticky child then sticks to a box that never scrolls, so the
   header silently stops sticking. clip is preferred because it does not
   create a scrollport at all; hidden is the fallback for older engines. */
html {
  max-width: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-x: clip;
  /* Anchor targets would otherwise land underneath the sticky header. */
  scroll-padding-top: calc(var(--ns-header-height) + 1rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

body.app-page {
  /* dvh tracks the shrinking/growing mobile toolbar; vh is the fallback and
     overshoots the visible area on phones, forcing a small phantom scroll. */
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
  color: var(--ns-color-text);
  background:
    radial-gradient(circle at 90% -10%, #dff5fb 0, transparent 30rem),
    var(--ns-color-page);
}

a {
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid rgba(12, 120, 201, 0.3);
  outline-offset: 2px;
}

.app-page main,
.app-page .container-xl,
.app-page .row > *,
.app-page .card,
.app-page .card-header > *,
.app-page .d-flex > * {
  min-width: 0;
}

.app-page .form-control,
.app-page .form-select,
.app-page .input-icon,
.app-page .card-actions {
  max-width: 100%;
}

.app-page .card-header,
.evidence-dialog__header,
.evidence-dialog__footer {
  flex-wrap: wrap;
}

.page-title,
.page-intro,
.card-title,
.card-subtitle,
.list-group-item {
  overflow-wrap: anywhere;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: var(--ns-header-height);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(7, 28, 51, 0.08);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ns-color-brand) !important;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 5px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--ns-color-brand), var(--ns-color-brand-soft));
  box-shadow: 0 5px 12px rgba(7, 28, 51, 0.18);
}

.brand-mark span {
  display: block;
  width: 3px;
  border-radius: 3px;
  background: #fff;
}

.brand-mark span:nth-child(1) { height: 7px; opacity: 0.6; }
.brand-mark span:nth-child(2) { height: 15px; }
.brand-mark span:nth-child(3) { height: 11px; opacity: 0.8; }

.app-header .nav-link {
  border-radius: 8px;
  color: #4a6178;
  font-weight: 500;
}

.app-header .nav-link:hover,
.app-header .nav-link.active {
  color: var(--ns-color-action);
  background: #edf7ff;
}

.app-header .nav-link.active {
  box-shadow: inset 0 -2px 0 var(--ns-color-action);
}

.page-heading {
  padding: 2rem 0 1rem;
}

.overline {
  margin-bottom: 0.35rem;
  color: #54718b;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  color: var(--ns-color-brand);
  font-size: clamp(1.55rem, 3vw, 1.9rem);
  letter-spacing: -0.035em;
}

.page-intro {
  max-width: 64ch;
  color: var(--ns-color-text-muted);
}

.btn-primary {
  --tblr-btn-bg: var(--ns-color-action);
  --tblr-btn-border-color: var(--ns-color-action);
  --tblr-btn-hover-bg: var(--ns-color-action-hover);
  --tblr-btn-hover-border-color: var(--ns-color-action-hover);
}

.app-page .card {
  border: 1px solid rgba(7, 28, 51, 0.08);
  border-radius: var(--ns-radius-card);
  box-shadow: var(--ns-shadow-card);
}

.metric-card {
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ns-shadow-card-hover);
}

.health-summary {
  overflow: hidden;
  background: linear-gradient(120deg, #fff 40%, #eefaff);
}

.health-summary__indicator {
  display: inline-block;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 7px rgba(255, 255, 255, 0.48),
    0 0 0 1px rgba(7, 28, 51, 0.08),
    0 8px 24px currentColor;
}

.health-summary__indicator--healthy { color: rgba(47, 179, 68, 0.2); background: var(--ns-color-success); }
.health-summary__indicator--warning { color: rgba(245, 159, 0, 0.2); background: var(--ns-color-warning); }
.health-summary__indicator--critical { color: rgba(214, 57, 57, 0.2); background: var(--ns-color-danger); }
.health-summary__indicator--unknown { color: rgba(152, 162, 179, 0.2); background: var(--ns-color-neutral); }

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot--healthy { background: var(--ns-color-success); }
.status-dot--warning { background: var(--ns-color-warning); }
.status-dot--critical { background: var(--ns-color-danger); }
.status-dot--unknown { background: var(--ns-color-neutral); }

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--ns-color-border);
  border-radius: 999px;
  background: #fff;
  color: #4a6178;
  font-size: 0.8rem;
}

.live-status__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ns-color-accent);
  box-shadow: 0 0 0 0 rgba(34, 184, 207, 0.5);
  animation: live-status-pulse 2s infinite;
}

@keyframes live-status-pulse {
  70% { box-shadow: 0 0 0 8px rgba(34, 184, 207, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 184, 207, 0); }
}

.metric-card__value {
  color: var(--ns-color-brand);
  font-size: 1.65rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}

.metric-sparkline {
  width: 100%;
  height: 48px;
}

.metric-sparkline path,
.evidence-chart__line {
  fill: none;
  stroke: var(--ns-color-action);
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.metric-sparkline__area {
  fill: rgba(12, 120, 201, 0.1);
  stroke: none;
}

.evidence-chart {
  position: relative;
  overflow: hidden;
  min-height: 310px;
}

.evidence-chart--large {
  min-height: 390px;
}

.evidence-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.evidence-chart__grid {
  stroke: #e3eaf1;
  stroke-width: 1;
}

.evidence-chart__axis {
  fill: #75879a;
  font-size: 10px;
}

.evidence-chart__area {
  fill: rgba(12, 120, 201, 0.08);
  stroke: none;
}

.evidence-chart__expected-range {
  fill: rgba(34, 184, 207, 0.15);
  stroke: rgba(34, 184, 207, 0.45);
}

.evidence-chart__warning-region {
  fill: rgba(245, 159, 0, 0.11);
  stroke: rgba(245, 159, 0, 0.45);
}

.evidence-chart__critical-region {
  fill: rgba(214, 57, 57, 0.12);
  stroke: rgba(214, 57, 57, 0.48);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  color: var(--ns-color-text-muted);
  font-size: 0.78rem;
}

.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 8px;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: 1px;
}

.chart-legend__swatch--observed { border-top: 2px solid var(--ns-color-action); }
.chart-legend__swatch--expected { border: 1px solid rgba(34, 184, 207, 0.5); background: rgba(34, 184, 207, 0.2); }
.chart-legend__swatch--warning { background: rgba(245, 159, 0, 0.18); }
.chart-legend__swatch--unavailable { background: #e5e9ee; }

.analysis-filters {
  position: sticky;
  top: calc(var(--ns-header-height) + 0.75rem);
  z-index: 10;
}

.finding-item--warning {
  border-left: 3px solid var(--ns-color-warning) !important;
}

.finding-item--critical {
  border-left-color: var(--ns-color-danger) !important;
}

.finding-item--info {
  border-left-color: var(--ns-color-action) !important;
}

.export-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.export-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.export-status--complete { color: #218838; }
.export-status--expiring { color: #b36b00; }
.export-status--failed { color: #c92a2a; }
.export-status--preparing { color: var(--ns-color-action); }

.records-table thead th {
  color: #54718b;
  font-size: 0.69rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.records-table tbody tr:hover {
  background: #f7fbfe;
}

.app-page .table-responsive {
  max-width: 100%;
  contain: inline-size paint;
}

.evidence-dialog {
  width: min(760px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(7, 28, 51, 0.28);
  /* The body scrolls, not the dialog, so the title and the close button in the
     header and footer stay reachable however long the content is. */
  overflow: hidden;
}

/* Scoped to [open] on purpose. Declaring display on the bare .evidence-dialog
   selector would beat the UA's `dialog:not([open]) { display: none }` and leave
   closed dialogs visible on the page. */
.evidence-dialog[open] {
  display: flex;
  flex-direction: column;
}

.evidence-dialog::backdrop {
  background: rgba(7, 28, 51, 0.55);
  backdrop-filter: blur(3px);
}

.evidence-dialog__header,
.evidence-dialog__footer {
  display: flex;
  /* Pinned: only the body between them scrolls. */
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5ebf1;
}

.evidence-dialog__footer {
  border-top: 1px solid #e5ebf1;
  border-bottom: 0;
}

.evidence-dialog__body {
  flex: 1 1 auto;
  /* Without min-height: 0 a flex item refuses to shrink below its content
     height, so the overflow would escape the dialog instead of scrolling. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem;
}

.auth-layout {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.6), rgba(217, 239, 248, 0.5));
}

.auth-layout::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(12, 120, 201, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 120, 201, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
  content: "";
}

.auth-layout__brand {
  position: absolute;
  z-index: 2;
  top: 1.5rem;
  left: 2rem;
}

.auth-panel {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, 420px);
}

.auth-intro__accent {
  width: 42px;
  height: 3px;
  margin-bottom: 1rem;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ns-color-action), var(--ns-color-accent));
}

@media (max-width: 767px) {
  .app-header .navbar-collapse {
    padding: 0.75rem 0 1rem;
  }

  .app-header .nav-link.active {
    box-shadow: inset 3px 0 0 var(--ns-color-action);
  }

  .page-heading { padding-top: 1.25rem; }
  .health-summary__indicator { width: 44px; height: 44px; }
  .analysis-filters { position: static; }
  .evidence-chart, .evidence-chart--large { min-height: 260px; }
  .auth-layout__brand { top: 1rem; left: 1rem; }

  .evidence-dialog {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .evidence-dialog__header,
  .evidence-dialog__footer,
  .evidence-dialog__body { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live-status__indicator { animation: none; }
  .metric-card { transition: none; }
}
