/* 10-providers.css — /Admin/Providers only (Pages/Admin/Providers/*; /Providers until task 129). Linked last in _Layout.cshtml; no other page uses these
   classes. Moved out of 09-analytics.css by task 041.

   The app has no full dark theme (its dark @media only restyles a few status chips; the surface/text tokens
   stay light), so this page deliberately has NO dark overrides — otherwise it became a dark island on the
   otherwise-light page under a dark OS setting. It always uses the light surface tokens. */

.provider-status-page {
  display: grid;
  /* minmax(0, …): a grid track otherwise grows to the table's 860 px min-width and widens the page at 390 px. */
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.provider-status-page h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 700;
}

/* Header: title and the period switch on one line */
.provider-status-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.provider-status-head h1 {
  margin: 0 0 4px;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.provider-status-head p {
  margin: 0;
  color: var(--muted);
}

.provider-status-period {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.provider-status-period a {
  padding: 8px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.provider-status-period a:hover { color: var(--text); background: var(--surface-2); }
.provider-status-period a[aria-current="page"] { color: var(--accent-contrast); background: var(--accent); }

/* Summary strip */
.provider-status-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.provider-status-summary__health { display: inline-flex; align-items: center; gap: 6px; }
.provider-status-summary__sep { width: 1px; height: 18px; background: var(--border); }

.provider-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #94a3b8;
}

.provider-dot.provider-health--bad { background: #dc2626; }
.provider-dot.provider-health--warn { background: #d97706; }
.provider-dot.provider-health--ok { background: #16a34a; }

/* Health pill: shared by the action cards and the table */
.provider-health-pill {
  display: inline-flex;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.provider-health-pill.provider-health--bad { color: var(--down); background: var(--down-bg); border-color: #fca5a5; }
.provider-health-pill.provider-health--warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, var(--surface-1)); }
.provider-health-pill.provider-health--ok { color: var(--up); background: var(--up-bg); border-color: color-mix(in srgb, var(--up) 35%, var(--surface-1)); }
.provider-health-pill.provider-health--unknown { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
/* A provider asleep after days of blocks (task 083): grey, not red — probed once a day, nothing to do here. */
.provider-health-pill.provider-health--asleep { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }

/* "Потребують дії" */
.provider-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}

.provider-action-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--down) 35%, var(--surface-1));
  border-radius: 12px;
}

.provider-action-card header { display: flex; align-items: center; gap: 10px; }
.provider-action-card header strong { flex-grow: 1; font-size: 1.05rem; }

.provider-action-card__cause { display: flex; flex-direction: column; gap: 2px; }
.provider-action-card__cause span { color: var(--muted); font-size: 0.88rem; }

.provider-action-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.provider-action-card dt { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.provider-action-card dd { margin: 0; font-weight: 700; }

.provider-action-card__state {
  margin: auto 0 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.88rem;
}

.provider-status-allclear {
  margin: 0;
  padding: 14px 18px;
  background: var(--up-bg);
  border: 1px solid color-mix(in srgb, var(--up) 35%, var(--surface-1));
  border-radius: 12px;
  color: var(--up);
}

/* "Усі провайдери": the wrapper scrolls so the page never does. position: relative contains the pills' absolutely
   positioned .visually-hidden reasons (task 143), as .assets-table-wrap does (task 134: they widened the page). */
.provider-status-table-wrap {
  position: relative;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.provider-status-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.provider-status-table th,
.provider-status-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.provider-status-table thead th { color: var(--muted); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.provider-status-table tbody tr:last-child > * { border-bottom: 0; }
.provider-status-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.provider-status-table tbody th { font-weight: 600; white-space: nowrap; }
.provider-status-table__problem { color: var(--muted); max-width: 280px; }
/* «Скинути» and «Скинуто о HH:mm» (task 104) */
.provider-status-table__reset { white-space: nowrap; }
.provider-status-table__reset small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8rem; }
.provider-status-section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.provider-status-reset-note { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; }

.provider-retry--hot {
  display: block;
  color: var(--warn);
  font-weight: 700;
}

/* Detail tabs. Without .is-ready (no JS) the strip is hidden and every panel shows its own heading. */
.provider-tabs {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.provider-tabs__list {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
}

.provider-tabs.is-ready .provider-tabs__list { display: flex; }
.provider-tabs.is-ready .provider-tabs__heading { display: none; }

.provider-tabs__list [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.provider-tabs__list [role="tab"][aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.provider-tabs__list [role="tab"]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

.provider-tabs__count {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
}

.provider-tabs__heading {
  margin: 0;
  padding: 14px 18px 4px;
  font-size: 1.05rem;
}

.provider-tabs__panel + .provider-tabs__panel { border-top: 1px solid var(--border); }
.provider-tabs.is-ready .provider-tabs__panel + .provider-tabs__panel { border-top: 0; }

.provider-list { margin: 0; padding: 0; list-style: none; }

.provider-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.provider-list__item--running { box-shadow: inset 3px 0 0 var(--accent); }
.provider-list__item--bad { box-shadow: inset 3px 0 0 #dc2626; }

.provider-list__title { flex: 0 1 300px; min-width: 0; font-weight: 600; text-decoration: none; }
.provider-list__meta { flex: 1 1 200px; min-width: 0; color: var(--muted); font-size: 0.88rem; }

.provider-list__detail {
  display: inline-block;
  max-width: min(420px, 100%);
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The start of an answer the client could not read (task 136), folded under its failure. */
.provider-list__excerpt { flex: 1 1 100%; min-width: 0; color: var(--muted); font-size: 0.8rem; }
.provider-list__excerpt > summary { cursor: pointer; }
.provider-list__excerpt > pre {
  max-height: 16rem;
  margin: 6px 0 0;
  padding: 8px 10px;
  overflow: auto;
  border-radius: 6px;
  background: var(--surface-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.provider-list-empty { margin: 0; padding: 14px 18px; color: var(--muted); }

.provider-list-more > summary {
  padding: 12px 18px;
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.provider-list-more[open] > summary { border-bottom: 1px solid var(--border); }

/* The phone (task 105). ≤ 900 px: the period links and the reset buttons a finger's 44 px, a set's title 24 px.
   ≤ 640 px: «Усі провайдери» is a card per provider — the name and its health pill on the first line, the figures two
   by two under their data-label, the last problem and «Скинути» across the card — instead of 860 px behind a scroll. */
@media (max-width: 900px) {
  .provider-status-period a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
  }

  .provider-list__title {
    min-height: 24px;
  }
}

@media (max-width: 640px) {
  .provider-status-table-wrap {
    overflow: visible;
  }

  .provider-status-table {
    min-width: 0;
  }

  .provider-status-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .provider-status-table,
  .provider-status-table tbody {
    display: block;
  }

  .provider-status-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .provider-status-table tbody tr:last-child {
    border-bottom: 0;
  }

  .provider-status-table tbody th,
  .provider-status-table tbody td {
    display: block;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .provider-status-table tbody th {
    align-self: center;
  }

  .provider-status-table tbody .num {
    text-align: left;
  }

  .provider-status-table tbody td:first-of-type {
    justify-self: end;
    align-self: center;
  }

  .provider-status-table td[data-label]:not(:first-of-type)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
  }

  .provider-status-table__problem,
  .provider-status-table__reset {
    grid-column: 1 / -1;
  }

  .provider-status-table__reset form {
    display: inline;
  }
}
