/* Internal Health screen — DRK-7893.
   Purpose-built dashboard. Reuses the mdds semantic color tokens so it stays on-palette
   in light/dark without inheriting the legacy screens' layout. */

.health-page {
  padding: 24px 28px;
  color: var(--md-content-primary);
  background: var(--md-background-secondary);
  min-height: 100%;
  box-sizing: border-box;
}

.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.health-header__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--md-content-primary);
}

.health-header__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--md-content-secondary);
}

.health-refresh {
  border: 1px solid var(--md-border-brand);
  background: var(--md-background-brand);
  color: var(--md-content-primary-inverse);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
}

.health-refresh:hover {
  background: var(--md-background-brand-hover);
}

/* Overall status pill */
.health-overall {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

.health-status--up {
  background: var(--md-background-positive-subtle);
  color: var(--md-content-positive-bold);
}

.health-status--down {
  background: var(--md-background-negative-subtle);
  color: var(--md-content-negative-bold);
}

.health-status--unknown {
  background: var(--md-background-caution-subtle);
  color: var(--md-content-caution-bold);
}

/* Attention items */
.health-attention {
  margin-bottom: 24px;
}

.health-attention__empty {
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--md-background-positive-subtle);
  color: var(--md-content-positive-bold);
  font-size: 14px;
}

.health-attention__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--md-background-primary);
  border: 1px solid var(--md-border-subtle);
  border-left-width: 4px;
  border-radius: 6px;
}

.health-attention__msg {
  flex: 1;
  font-size: 14px;
}

.health-attention__section {
  font-size: 12px;
  color: var(--md-content-tertiary);
  text-transform: capitalize;
}

.health-severity {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
}

.health-severity--critical {
  background: var(--md-background-negative-subtle);
  color: var(--md-content-negative-bold);
  border-left-color: var(--md-background-negative);
}

.health-severity--high {
  background: var(--md-background-caution-subtle);
  color: var(--md-content-caution-bold);
}

.health-severity--medium {
  background: var(--md-background-notice-subtle);
  color: var(--md-content-notice-bold);
}

.health-severity--low {
  background: var(--md-background-info-subtle);
  color: var(--md-content-info-bold);
}

.health-attention__item.health-severity--critical { border-left-color: var(--md-background-negative); }
.health-attention__item.health-severity--high { border-left-color: var(--md-background-caution); }
.health-attention__item.health-severity--medium { border-left-color: var(--md-background-notice); }
.health-attention__item.health-severity--low { border-left-color: var(--md-background-info); }

/* Section grid */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.health-card {
  background: var(--md-background-primary);
  border: 1px solid var(--md-border-subtle);
  border-radius: 8px;
  padding: 16px 18px;
}

.health-card__title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--md-content-primary);
  border-bottom: 1px solid var(--md-border-subtle);
  padding-bottom: 8px;
}

.health-kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--md-border-subtle);
}

.health-kv:last-child {
  border-bottom: none;
}

.health-kv__key {
  color: var(--md-content-secondary);
}

.health-kv__val {
  color: var(--md-content-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

/* Service status badge */
.health-badge {
  display: inline-block;
  min-width: 54px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.health-badge.health-status--up { background: var(--md-background-positive-subtle); color: var(--md-content-positive-bold); }
.health-badge.health-status--down { background: var(--md-background-negative-subtle); color: var(--md-content-negative-bold); }
.health-badge.health-status--unknown { background: var(--md-background-caution-subtle); color: var(--md-content-caution-bold); }

.health-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.health-table th,
.health-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--md-border-subtle);
  color: var(--md-content-primary);
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Recent schema changes: give the long changeset id room, keep author/date tight */
.health-table--changes col.health-col-id { width: 58%; }
.health-table--changes col.health-col-author { width: 26%; }
.health-table--changes col.health-col-date { width: 16%; }

.health-table th {
  color: var(--md-content-secondary);
  font-weight: 600;
}

.health-state {
  padding: 40px;
  text-align: center;
  font-size: 15px;
  color: var(--md-content-secondary);
}

.health-state--error { color: var(--md-content-negative-bold); }

/* Per-block progressive-load indicator */
.health-block-loading {
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--md-content-secondary);
}
.health-block-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid var(--md-border-secondary);
  border-top-color: var(--md-content-brand-primary);
  border-radius: 50%;
  vertical-align: -2px;
  animation: health-spin 0.8s linear infinite;
}
@keyframes health-spin { to { transform: rotate(360deg); } }

/* Section titles */
.health-section-title {
  margin: 22px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--md-content-primary);
}

/* Summary tiles */
.health-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.health-tile {
  background: var(--md-background-primary);
  border: 1px solid var(--md-border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.health-tile__num {
  font-size: 26px;
  font-weight: 700;
  color: var(--md-content-brand-primary);
  line-height: 1.1;
}

.health-tile__lbl {
  font-size: 12px;
  color: var(--md-content-secondary);
}

/* nvd3 charts sit inside a card and must not overflow it */
.health-card nvd3 {
  display: block;
  width: 100%;
}

/* Detail tables span the full grid width */
.health-card--wide { grid-column: 1 / -1; }

/* Uniform detail cards: identical height, long content scrolls inside its own body */
.health-grid--uniform .health-card {
  height: 320px;
  display: flex;
  flex-direction: column;
}

.health-grid--uniform .health-card .health-card__title {
  flex: 0 0 auto;
}

.health-card__body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.health-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--md-content-tertiary);
}

/* Drill-down: selector + search + reusable a3w-table */
.health-drill {
  background: var(--md-background-primary);
  border: 1px solid var(--md-border-subtle);
  border-radius: 8px;
  padding: 16px 18px;
}

.health-drill__controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.health-drill__toggle {
  align-self: center;
}

.health-drill__select,
.health-drill__search {
  max-width: 280px;
}

.health-drill__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--md-border-subtle);
}

.health-drill__filter {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 150px;   /* share the row; wrap only when there is no room */
  min-width: 140px;
}

.health-drill__filter-empty {
  font-size: 12px;
  color: var(--md-content-tertiary);
  padding: 4px 0;
}

/* Date-range filter: two compact date inputs side by side */
.health-drill__filter:has(.health-drill__daterange) {
  flex: 2 1 240px;
}
.health-drill__daterange {
  display: flex;
  gap: 6px;
}
.health-drill__daterange input {
  min-width: 0;
  flex: 1 1 0;
}

.health-drill__filter-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--md-content-secondary);
  margin: 0;
}

/* Filter chips (drill-down) */
.health-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.health-chip {
  border: 1px solid var(--md-border-secondary);
  background: var(--md-background-secondary);
  color: var(--md-content-secondary);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  cursor: pointer;
}

.health-chip:hover { background: var(--md-background-secondary-hover); }

.health-chip--on {
  background: var(--md-background-brand);
  color: var(--md-content-primary-inverse);
  border-color: var(--md-border-brand);
}

.health-chip--clear {
  color: var(--md-content-negative-bold);
  border-color: var(--md-border-negative);
}

.health-card .nvd3 text {
  fill: var(--md-content-secondary);
}
