/*
 * next.css — the new interface (js/next/), in the style of altamusinc.com:
 * a white header with the page links, a navy hero with a yellow eyebrow and a
 * bold headline, then white cards with soft shadows on a light page.
 *
 * Every class here starts with `nx-`, except `.interface-switch` (the button
 * in either header that switches interface). Colours come from the tokens of
 * altamus.css, so both themes work; the hero is navy in both, like the login
 * page's.
 *
 * 1. Interface switch   2. Shell   3. Hero   4. Content and sections
 * 5. Needs attention    6. Cards and lanes   7. Site page   8. Phones
 */

/* ============================================================ 1. Interface switch */

.interface-switch {
  margin-right: 8px;
  white-space: nowrap;
}

@media (max-width: 899.98px) {
  .interface-switch {
    min-width: 44px;
    min-height: 44px;
    margin-right: 0;
    padding: 4px 12px;
  }

  .interface-switch .btn__label {
    display: none;
  }
}

/* ============================================================ 2. Shell */

.nx-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--color-bg);
}

.nx-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex: none;
  align-items: center;
  gap: 28px;
  height: 72px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.nx-header .icon-btn {
  width: 44px;
  height: 44px;
}

.nx-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

/* The two dots of the website's eyebrows. */
.nx-brand__mark,
.nx-eyebrow__dots {
  position: relative;
  flex: none;
  width: 18px;
  height: 8px;
}

.nx-brand__mark::before,
.nx-brand__mark::after,
.nx-eyebrow__dots::before,
.nx-eyebrow__dots::after {
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  content: '';
  border-radius: 50%;
}

.nx-brand__mark::before,
.nx-eyebrow__dots::before {
  left: 0;
  background: var(--orange);
}

.nx-brand__mark::after,
.nx-eyebrow__dots::after {
  left: 10px;
  background: var(--yellow);
}

.nx-brand__name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-heading);
}

.nx-nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 100%;
}

.nx-nav__link {
  position: relative;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-heading);
  background: none;
  border: 0;
  cursor: pointer;
}

.nx-nav__link:hover {
  color: var(--color-accent-text);
}

.nx-nav__link.is-selected {
  color: var(--color-accent-text);
}

.nx-nav__link.is-selected::after {
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 3px;
  content: '';
  background: var(--color-accent);
  border-radius: 3px 3px 0 0;
}

.nx-header__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nx-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.nx-bottom-nav {
  display: none;
}

.nx-page {
  min-height: 100%;
}

.nx-page__state:empty {
  display: none;
}

/* ============================================================ 3. Hero */

/* Navy in both themes: the controls inside take the dark theme's values. */
.nx-hero {
  --color-surface: #111f35;
  --color-surface-raised: #1a2b47;
  --color-surface-sunken: #0b1526;
  --color-border: rgba(255, 255, 255, 0.18);
  --color-border-strong: rgba(255, 255, 255, 0.4);
  --color-text: #dce3ee;
  --color-text-muted: #b6c2d4;
  --color-heading: #ffffff;
  --color-accent-text: #c9b9ff;
  --color-accent-tint: rgba(124, 77, 255, 0.35);
  --color-accent-tint-hover: rgba(124, 77, 255, 0.45);
  --color-on-accent-tint: #ffffff;
  --color-hover: rgba(255, 255, 255, 0.08);
  --color-accent-hover: rgba(255, 255, 255, 0.08);
  --color-focus: #ffffff;
  --color-field-fill: rgba(255, 255, 255, 0.06);
  --color-field-outline: rgba(255, 255, 255, 0.4);

  padding: 44px clamp(16px, 4vw, 40px) 40px;
  color: #ffffff;
  background:
    radial-gradient(900px 380px at 88% 0%, rgba(124, 77, 255, 0.28), transparent 70%),
    radial-gradient(700px 320px at 0% 100%, rgba(255, 110, 64, 0.12), transparent 70%),
    linear-gradient(135deg, var(--navy-900), var(--navy) 55%, var(--navy-700));
}

.nx-hero--site {
  padding-top: 24px;
}

.nx-hero__inner {
  max-width: 1200px;
  margin: 0 auto;
}

.nx-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-accent-text);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.nx-eyebrow--light {
  color: var(--yellow);
}

.nx-hero__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.nx-hero__title {
  max-width: 22ch;
  margin: 0;
  font-size: clamp(28px, 4.2vw, 40px);
  font-weight: 800;
  line-height: 1.12;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.nx-hero--site .nx-hero__title {
  max-width: none;
}

.nx-hero__lead {
  max-width: 62ch;
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.85);
}

.nx-hero__lead:empty {
  display: none;
}

.nx-hero__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 24px;
}

.nx-hero__refresh {
  min-height: 36px;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.nx-hero__updated {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.nx-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 28px 0 0;
}

.nx-stat {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-card);
}

.nx-stat dt {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nx-stat dd {
  margin: 6px 0 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: #ffffff;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.nx-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px 0 0;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  background: none;
  border: 0;
  cursor: pointer;
}

.nx-back:hover {
  color: #ffffff;
}

/* ============================================================ 4. Content and sections */

.nx-content {
  display: flex;
  flex-direction: column;
  gap: 44px;
  max-width: 1280px;
  padding: 36px clamp(16px, 4vw, 40px) 72px;
  margin: 0 auto;
}

.nx-section[hidden] {
  display: none;
}

.nx-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.nx-section__title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-heading);
  letter-spacing: -0.02em;
}

.nx-section__count {
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-accent-text);
  letter-spacing: 0;
  background: var(--color-accent-tint);
  border-radius: var(--radius-pill);
}

.nx-section__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.nx-section__actions:empty {
  display: none;
}

.nx-search {
  width: 240px;
  max-width: 100%;
}

/* ============================================================ 5. Needs attention */

.nx-queue {
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.nx-queue__item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 12px 20px 12px 22px;
  text-align: left;
  color: var(--color-text);
  background: none;
  border: 0;
  cursor: pointer;
}

.nx-queue__item + .nx-queue__item {
  border-top: 1px solid var(--color-border);
}

.nx-queue__item::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  content: '';
  background: var(--nx-item-color, var(--status-unknown));
}

.nx-queue__item:hover {
  background: var(--color-row-hover);
}

.nx-queue__icon {
  display: grid;
  width: 44px;
  height: 44px;
  font-size: 20px;
  color: var(--nx-item-color, var(--status-unknown));
  background: color-mix(in srgb, var(--nx-item-color, var(--status-unknown)) 14%, transparent);
  border-radius: 12px;
  place-items: center;
}

.nx-queue__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nx-queue__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-heading);
}

.nx-queue__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: color-mix(in srgb, var(--nx-item-color, var(--status-unknown)) 18%, transparent);
  border-radius: var(--radius-pill);
}

.nx-queue__tag::before {
  width: 8px;
  height: 8px;
  content: '';
  background: var(--nx-item-color, var(--status-unknown));
  border-radius: 50%;
}

.nx-queue__detail {
  font-size: 14px;
  color: var(--color-text-muted);
}

.nx-queue__action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent-text);
  white-space: nowrap;
}

.nx-queue__empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  font-size: 15px;
  color: var(--color-text);
}

.nx-queue__empty .bi {
  font-size: 22px;
  color: var(--status-ok);
}

/* ============================================================ 6. Cards and lanes */

.nx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.nx-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 16px;
}

.nx-grid__empty {
  grid-column: 1 / -1;
  margin: 0;
}

.nx-site-card,
.nx-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 20px;
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}

.nx-site-card:hover,
.nx-card:not(:disabled):hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.nx-card:disabled {
  cursor: default;
  box-shadow: none;
}

.nx-site-card {
  position: relative;
  gap: 12px;
  overflow: hidden;
}

/* The status as a bar on top of the card, besides the tag that names it. */
.nx-site-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  content: '';
  background: var(--color-border);
}

.nx-site-card--healthy::before {
  background: var(--status-ok);
}

.nx-site-card--info::before {
  background: var(--status-info);
}

.nx-site-card--warning::before {
  background: var(--status-warning);
}

.nx-site-card--error::before {
  background: var(--status-error);
}

.nx-site-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.nx-site-card__name,
.nx-card__title {
  min-width: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-heading);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.nx-site-card__facts,
.nx-card__muted {
  font-size: 14px;
  color: var(--color-text-muted);
}

.nx-site-card__lanes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 10px;
}

.nx-site-card__more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent-text);
}

.nx-lane {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.nx-lane__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nx-lane__cells {
  display: flex;
  gap: 1px;
  height: 16px;
}

.nx-cell {
  flex: 1;
  min-width: 0;
  background: var(--color-lane-empty);
  border-radius: 2px;
}

.nx-cell--healthy {
  background: color-mix(in srgb, var(--status-ok) 45%, transparent);
}

.nx-cell--info {
  background: var(--status-info);
}

.nx-cell--warning {
  background: var(--status-warning);
}

.nx-cell--error {
  background: var(--status-error);
}

.nx-lane__bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  background: var(--color-lane-empty);
  border-radius: var(--radius-pill);
}

.nx-lane__span {
  position: absolute;
  top: 0;
  bottom: 0;
}

.nx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.nx-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nx-legend .nx-cell {
  flex: none;
  width: 12px;
  height: 12px;
}

.nx-skeleton {
  height: 14px;
  background: var(--color-skeleton);
  border-radius: 6px;
}

.nx-skeleton + .nx-skeleton {
  width: 70%;
}

/* ============================================================ 7. Site page */

.nx-card__kicker {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-accent-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nx-card__figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.nx-card__value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-heading);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.nx-card__unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.nx-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nx-card--scanner {
  border-left: 4px solid var(--nx-item-color, var(--status-unknown));
}

.nx-tree {
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* ============================================================ 8. Phones */

@media (max-width: 899.98px) {
  .nx-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 719.98px) {
  .nx-header {
    gap: 12px;
    height: 60px;
  }

  .nx-nav {
    display: none;
  }

  .nx-bottom-nav {
    display: flex;
    flex: none;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
  }

  .nx-bottom-nav__item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: none;
    border: 0;
    cursor: pointer;
  }

  .nx-bottom-nav__item .bi {
    font-size: 20px;
  }

  .nx-bottom-nav__item.is-selected {
    color: var(--color-accent-text);
  }

  .nx-hero {
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .nx-content {
    gap: 32px;
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .nx-section__title {
    font-size: 22px;
  }

  .nx-search {
    width: 100%;
  }

  .nx-queue__item {
    grid-template-columns: 44px minmax(0, 1fr);
    padding-right: 14px;
  }

  .nx-queue__action {
    display: none;
  }
}

@media (max-width: 379.98px) {
  .nx-brand .tag {
    display: none;
  }

  .nx-stat dd {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nx-site-card,
  .nx-card {
    transition: none;
  }

  .nx-site-card:hover,
  .nx-card:not(:disabled):hover {
    transform: none;
  }
}
