/* PlasmaStatus — "professional" theme.
   Classic status page layout: header bar, solid status banner, one bordered list of
   components grouped by category, footer bar. Deliberately different from "simple".
   --primary / --primary-rgb are injected from PageSettings.ThemeColor by index.ejs. */

:root {
  --bg: #141414;
  --bar: #0d0d0d;
  --surface: #1b1b1b;
  --surface-2: #232323;
  --line: #2c2c2c;
  --line-strong: #3a3a3a;
  --text: #ededed;
  --text-2: #b0b0b0;
  --text-3: #808080;
  --online: #2ea44f;
  --partial: #d29922;
  --offline: #d1453b;
  --maintenance: #3f7fd9;
  --radius: 4px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

[x-cloak] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }

/* status color helpers */
.online { --sc: var(--online); }
.partial { --sc: var(--partial); }
.offline { --sc: var(--offline); }
.maintenance { --sc: var(--maintenance); }
.placeholder { --sc: var(--surface-2); }
.kw { color: inherit; }

.container { max-width: 1000px; margin: 0 auto; padding: 0 24px; }
.page { flex: 1; padding: 36px 0 56px; }

/* ---------- Header bar ---------- */
.appbar { background: var(--bar); border-bottom: 1px solid var(--line); }
.appbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.appbar__brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.appbar__logo { height: 28px; width: auto; }
.appbar__name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar__nav { display: flex; align-items: center; gap: 24px; font-size: 14px; }

/* ---------- Announcement ---------- */
.announcement {
  display: flex; align-items: center; gap: 12px;
  max-width: 952px; margin: 20px auto 0; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.announcement__icon { color: var(--maintenance); }
.announcement--warning .announcement__icon { color: var(--partial); }
.announcement--success .announcement__icon { color: var(--online); }
.announcement--error .announcement__icon { color: var(--offline); }
.announcement__msg { flex: 1; }
.announcement__close { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 4px; border-radius: var(--radius); }
.announcement__close:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Status banner ---------- */
.banner {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px; border-radius: var(--radius);
  background: var(--sc, var(--online)); color: #fff;
}
.banner__icon { font-size: 18px; width: 18px; text-align: center; }
.banner__title { font-size: 20px; font-weight: 600; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 40px 0 14px; }
.toolbar__title { font-size: 22px; font-weight: 600; color: var(--text); }
.toolbar__sub { margin-top: 4px; font-size: 13px; color: var(--text-3); }
.search {
  width: 240px; padding: 7px 10px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
.search::placeholder { color: var(--text-3); }
.search:focus { border-color: var(--primary); }

/* ---------- Component list ---------- */
.services { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.services__empty { padding: 28px 22px; color: var(--text-2); text-align: center; }
.category + .category { border-top: 1px solid var(--line); }
.category__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 22px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.category:first-child .category__head { border-radius: var(--radius) var(--radius) 0 0; }
.category__name { font-size: 15px; font-weight: 600; color: var(--text); }
.category__count { font-size: 13px; color: var(--text-3); }

.service { padding: 18px 22px 16px; }
.service + .service { border-top: 1px solid var(--line); }
.service__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.service__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.service__dot { display: none; }
.service__name { font-size: 15px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service__stats { display: flex; align-items: baseline; gap: 18px; flex-shrink: 0; }
.metric { display: inline-flex; align-items: baseline; gap: 4px; font-size: 13px; color: var(--text-3); }
.metric--uptime { display: none; }
.metric__value { color: var(--text-2); }
.service__badge { font-size: 14px; color: var(--sc); white-space: nowrap; }

/* ---------- 90-day history ---------- */
.history__bars { display: flex; gap: 2px; height: 32px; }
.bar { position: relative; flex: 1 1 0; min-width: 0; border-radius: 1px; background: var(--sc, var(--surface-2)); cursor: default; }
.bar.online { opacity: .75; }
.bar:hover { opacity: 1; z-index: 2; }
.history__axis { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--text-3); }
.history__axis > span:nth-child(2) { flex: 1; display: flex; align-items: center; gap: 12px; white-space: nowrap; color: var(--text-2); }
.history__axis > span:nth-child(2)::before,
.history__axis > span:nth-child(2)::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  min-width: 160px; padding: 10px 12px; background: var(--bar); color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  opacity: 0; visibility: hidden; z-index: 50; pointer-events: none;
}
.bar:hover .tooltip { opacity: 1; visibility: visible; }
.bar:nth-child(-n+8) .tooltip { left: 0; transform: none; }
.bar:nth-last-child(-n+8) .tooltip { left: auto; right: 0; transform: none; }
.tooltip__head { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.tooltip__dot { width: 8px; height: 8px; border-radius: 1px; background: var(--sc, var(--text-3)); }
.tooltip__date { font-weight: 600; font-size: 13px; color: var(--text); }
.tooltip__row { display: flex; justify-content: space-between; gap: 14px; font-size: 12.5px; line-height: 1.7; }
.tooltip__label { color: var(--text-3); }
.tooltip__value { color: var(--text); }

/* ---------- Links ---------- */
.refresh-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; background: none; border: 0;
  font: inherit; color: var(--text-2); cursor: pointer;
}
.refresh-link i { font-size: .85em; }
.refresh-link:hover { color: var(--text); }
.refresh-link:disabled { cursor: default; color: var(--text-3); }
.refresh-link.is-spinning i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.footer-link { color: var(--text-2); text-decoration: none; }
.footer-link:hover { color: var(--text); }

/* ---------- Footer bar ---------- */
.sitefoot { background: var(--bar); border-top: 1px solid var(--line); }
.sitefoot__inner { padding-top: 20px; padding-bottom: 20px; font-size: 13px; color: var(--text-3); }

/* ---------- Toast ---------- */
.toast { position: fixed; top: 76px; right: 20px; max-width: 340px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); z-index: 60; }
.toast__head { display: flex; align-items: center; gap: 8px; }
.toast__icon { display: none; }
.toast__title { color: var(--text); font-weight: 600; font-size: 14px; }
.toast__msg { color: var(--text-2); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .container { padding: 0 16px; }
  .announcement { margin-left: 16px; margin-right: 16px; }
  .page { padding-top: 24px; }
  .banner { padding: 14px 18px; }
  .banner__title { font-size: 17px; }
  .toolbar { flex-direction: column; align-items: stretch; margin-top: 30px; }
  .search { width: 100%; }
  .category__head, .service { padding-left: 16px; padding-right: 16px; }
  .metric--resp { display: none; }
  .history__bars { gap: 1px; height: 26px; }
  .history__axis { font-size: 12px; gap: 8px; }
  .history__axis > span:nth-child(2) { gap: 8px; }
}

/* ---------- Incidents ---------- */
.incident--none { --tone: var(--text-3); }
.incident--minor { --tone: var(--partial); }
.incident--major { --tone: #e8743b; }
.incident--critical { --tone: var(--offline); }
.incident--maintenance { --tone: var(--maintenance); }
.incident--resolved { --tone: var(--online); }

.incidents { margin: 28px 0; }
.incidents__headrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.incidents__headrow .incidents__title { margin-bottom: 0; }
.incidents__title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.incidents__none { color: var(--text-3); font-size: 14px; padding: 4px 0; }
.incidents--past { margin-top: 40px; }

.incident {
  position: relative; padding: 16px 18px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--tone);
  border-radius: var(--radius);
}
.incident__head { display: flex; align-items: center; gap: 10px; }
.incident__icon { color: var(--tone); width: 16px; text-align: center; flex-shrink: 0; }
.incident__title { flex: 1; min-width: 0; color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; }
.incident__title:hover { text-decoration: underline; }
.incident__status {
  flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--tone);
  padding: 2px 9px; border: 1px solid var(--tone); border-radius: 999px; white-space: nowrap;
}
.incident__msg { margin-top: 8px; color: var(--text-2); font-size: 14px; white-space: pre-wrap; word-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.incident__meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; color: var(--text-3); }
.incident__meta i { margin-right: 3px; }
.incident__eta { color: var(--text-2); }
.incident__affected { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.incidents--past .incident { padding: 12px 16px; }
.incidents--past .incident__title { font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px;
  background: var(--surface-2); border-radius: 999px; font-size: 12.5px; color: var(--text);
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sc, var(--text-3)); flex-shrink: 0; display: inline-block; }
.chip__status { color: var(--sc); font-weight: 500; }

.service__incident { color: var(--sc, var(--text-3)); font-size: 13px; text-decoration: none; }
.service__incident:hover { filter: brightness(1.2); }

/* ---------- Incident detail page ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 18px; color: var(--text-2); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--text); }
.incident-page { padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--tone); border-radius: var(--radius); }
.incident-page__kicker { font-size: 13px; color: var(--tone); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.incident-page__title { margin-top: 6px; font-size: 24px; line-height: 1.25; color: var(--text); }
.incident-page__status { margin-top: 10px; }
.incident-facts { display: flex; flex-wrap: wrap; gap: 14px 36px; margin: 18px 0 0; }
.incident-facts dt { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.incident-facts dd { margin: 2px 0 0; color: var(--text); font-size: 14px; }
.incident-facts__eta dd { color: var(--tone); font-weight: 600; }

.incident-block { margin-top: 28px; }
.incident-block__title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.affected-table { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.affected-table li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; }
.affected-table li + li { border-top: 1px solid var(--line); }
.affected-table__name { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 500; min-width: 0; }
.affected-table__status { color: var(--sc); font-size: 13px; font-weight: 600; white-space: nowrap; }

.resolution { padding: 18px 22px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--online); border-radius: var(--radius); }
.resolution .incident-block__title i { color: var(--online); }
.resolution h3 { margin: 14px 0 4px; font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.resolution h3:first-of-type { margin-top: 0; }
.resolution p { color: var(--text); white-space: pre-wrap; word-wrap: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { position: relative; padding: 0 0 24px 28px; }
.timeline__item::before { content: ''; position: absolute; left: 6px; top: 18px; bottom: 0; width: 2px; background: var(--line-strong); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item:last-child::before { display: none; }
.timeline__item::after { content: ''; position: absolute; left: 0; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text-3); }
.timeline__item.is-latest::after { border-color: var(--tone, var(--primary)); background: var(--tone, var(--primary)); }
.timeline__item.is-final::after { border-color: var(--online); background: var(--online); }
.timeline__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.timeline__status { font-weight: 600; color: var(--text); }
.timeline__time { font-size: 13px; color: var(--text-3); }
.timeline__msg { margin-top: 4px; color: var(--text-2); white-space: pre-wrap; word-wrap: break-word; }
.timeline__aff { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }

.history-title { font-size: 24px; color: var(--text); margin-bottom: 8px; }


@media (max-width: 640px) {
  .incident { padding: 14px; }
  .incident-page { padding: 18px; }
  .incident-page__title { font-size: 20px; }
}
