/* Badges, empty states, spinners, skeletons, toasts, tabs - everything that tells the user what is
   happening rather than showing them data. */

/* ---- Badge --------------------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.badge[data-variant="neutral"] {
  background-color: var(--color-neutral-subtle);
  color: var(--color-fg-muted);
}

.badge[data-variant="accent"] {
  background-color: var(--color-accent-subtle);
  color: var(--color-accent-fg);
}

.badge[data-variant="success"] {
  background-color: var(--color-success-subtle);
  color: var(--color-success-fg);
}

.badge[data-variant="attention"] {
  background-color: var(--color-attention-subtle);
  color: var(--color-attention-fg);
}

.badge[data-variant="danger"] {
  background-color: var(--color-danger-subtle);
  color: var(--color-danger-fg);
}

/* A void or cancelled record. Outlined rather than filled: it is a record that no longer counts,
   and a filled badge would give it the same weight as a live one. */
.badge[data-variant="void"] {
  background-color: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-fg-subtle);
}

.badge[data-size="small"] {
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 6px;
}

/* ---- Empty state ---------------------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 44px 24px;
  color: var(--color-fg-muted);

  & .empty-state-glyph {
    font-size: 26px;
    opacity: 0.55;
    margin-bottom: 10px;
  }

  & h3 {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--color-fg-default);
  }

  & p {
    font-size: 12.5px;
    max-width: 46ch;
    margin-bottom: 0;
  }

  & .empty-state-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
  }
}

/* A route whose screen is not built yet. Distinct from an empty state on purpose - "nothing here
   yet" and "we have not built this yet" are different messages, and conflating them makes an
   unbuilt screen look like a broken one. */
.planned-state {
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  background-color: var(--color-canvas-subtle);

  & h3 {
    font-family: var(--font-display);
    font-size: 17px;
    margin-bottom: 6px;
  }

  & p {
    color: var(--color-fg-muted);
    font-size: 13px;
    max-width: 60ch;
    margin: 0 auto 14px;
  }

  & .planned-endpoints {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--color-fg-subtle);
    background-color: var(--color-canvas-default);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 9px 12px;
  }
}

/* ---- Loading ---------------------------------------------------------------------------------------- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border-default);
  border-top-color: var(--color-accent-emphasis);
  border-radius: 50%;
  animation: spinner-spin 0.6s linear infinite;
}

.spinner[data-size="large"] {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

@keyframes spinner-spin {
  to { transform: rotate(360deg); }
}

.spinner-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--color-fg-muted);
  font-size: 13px;
}

.skeleton {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--color-neutral-subtle) 25%,
    var(--color-canvas-inset) 37%,
    var(--color-neutral-subtle) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.3s ease infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .skeleton { animation: none; }
}

/* ---- Toast ------------------------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-default);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  background-color: var(--color-canvas-overlay);
  box-shadow: var(--shadow-overlay);
  font-size: 13px;
  animation: toast-in 0.16s ease;

  & .toast-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  & .toast-title {
    font-weight: 600;
    margin-bottom: 1px;
  }

  & .toast-dismiss {
    border: 0;
    background: transparent;
    color: var(--color-fg-subtle);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;

    &:hover { color: var(--color-fg-default); }
  }
}

.toast[data-severity="success"] { border-left-color: var(--color-success-emphasis); }
.toast[data-severity="error"] { border-left-color: var(--color-danger-emphasis); }
.toast[data-severity="warning"] { border-left-color: var(--color-attention-emphasis); }
.toast[data-severity="info"] { border-left-color: var(--color-accent-emphasis); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

/* ---- Notification centre ----------------------------------------------------------------------------- */

.notification-list {
  width: min(380px, 90vw);
  max-height: 420px;
  overflow-y: auto;

  & .notification-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid var(--color-border-muted);
    background: transparent;
    cursor: pointer;
    font-size: 12.5px;

    &:hover { background-color: var(--color-neutral-subtle); }

    &[data-unread="true"] {
      background-color: var(--color-accent-subtle);

      & .notification-title { font-weight: 600; }
    }

    & .notification-title { margin-bottom: 2px; }

    & .notification-meta {
      font-size: 11px;
      color: var(--color-fg-subtle);
    }
  }
}

/* ---- Tabs ---------------------------------------------------------------------------------------------- */

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--color-border-default);
  margin-bottom: 14px;
  overflow-x: auto;

  & .tab {
    position: relative;
    border: 0;
    background: transparent;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--color-fg-muted);
    cursor: pointer;
    white-space: nowrap;
    border-radius: var(--radius-md) var(--radius-md) 0 0;

    &:hover {
      color: var(--color-fg-default);
      background-color: var(--color-neutral-subtle);
    }

    &[aria-selected="true"] {
      color: var(--color-fg-default);
      font-weight: 600;

      /* Sits on the container's border rather than adding a border to the tab, so switching tabs
         never shifts the row by a pixel. */
      &::after {
        content: "";
        position: absolute;
        left: 8px;
        right: 8px;
        bottom: -1px;
        height: 2px;
        background-color: var(--color-accent-emphasis);
      }
    }

    & .tab-count {
      margin-left: 6px;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--color-fg-subtle);
    }
  }
}

/* ---- Licence banner ---------------------------------------------------------------------------------------- */

/* The API answers 402 when a licence has lapsed. That is a standing condition, not a transient
   failure, so it gets a persistent bar rather than a toast that scrolls away. */
.license-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  background-color: var(--color-attention-subtle);
  color: var(--color-attention-fg);
  border-bottom: 1px solid var(--color-attention-emphasis);

  &[data-severity="danger"] {
    background-color: var(--color-danger-subtle);
    color: var(--color-danger-fg);
    border-bottom-color: var(--color-danger-emphasis);
  }
}
