/*
  Styled after xelADashboard: "Discord-native" surfaces. Cards are embeds with a
  coloured bar on the left, the page header is a channel header, buttons are Discord buttons.
  Colour values mirror xelADashboard/src/vars.scss.
*/

@font-face { font-family: Figtree; src: url("../fonts/Figtree-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/Figtree-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/Figtree-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: Figtree; src: url("../fonts/Figtree-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --nav-height: 80px;
  --primary: #14bae4;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --orange: #f26522;
  --red: #e74c3c;

  /* Chart series */
  --ws: #2ecc71;
  --rest: #f1c40f;
  --discord: #7289da;
}

:root[data-theme="dark"] {
  --bg-page: #303030;
  --bg-card: #212121;
  --bg-card-hover: #292929;
  --bg-deep: #181818;
  --bg-tooltip: #181818;
  --text: #d9d9d9;
  --text-strong: #fff;
  --text-muted: rgba(255, 255, 255, .55);
  --text-faint: rgba(255, 255, 255, .45);
  --bar: #4e5058;
  --grid: rgba(255, 255, 255, .06);
  --pill: #4e5058;
  --pill-hover: #5d606a;
  --footer-text: #8c8c8c;
  --nav-bg: rgba(33, 33, 33, .75);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-page: #f5f5f5;
  --bg-card: #fff;
  --bg-card-hover: #fafafa;
  --bg-deep: #d9d9d9;
  --bg-tooltip: #fff;
  --text: #181818;
  --text-strong: #000;
  --text-muted: rgba(0, 0, 0, .55);
  --text-faint: rgba(0, 0, 0, .45);
  --bar: #d4d7dc;
  --grid: rgba(0, 0, 0, .07);
  --pill: #6d6f78;
  --pill-hover: #5f616a;
  --footer-text: #696969;
  --nav-bg: rgba(236, 236, 236, .92);
  --discord: #5865f2;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--bg-page);
  color: var(--text);
  font-family: Figtree, sans-serif;
  font-size: 1em;
  line-height: 1.4;
}

/* The page scrolls inside this instead of the window, same as the dashboard. It spans the
   full height so content scrolls under the translucent navbar, while the scrollbar track
   starts below it (see ::-webkit-scrollbar-track) */
.page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--nav-height);
  overflow-y: auto;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Montserrat, sans-serif;
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  -webkit-user-drag: none;
}

a:hover { text-decoration: underline; }

code {
  font-family: "Source Code Pro", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .9em;
  border-radius: 3px;
  padding: 2px 5px;
  background-color: var(--bg-deep);
  white-space: pre;
}

a code { color: var(--primary); }

/* ── Navbar ─────────────────────────────────────────────────────────────── */

/* Sticky, translucent and blurred like the dashboard navbar, content scrolls under it */
.navbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 25px 0 15px;
  background-color: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--text-strong);
  font-family: Montserrat, sans-serif;
  font-size: 22px;
  font-weight: 700;
}

.brand img {
  height: 56px;
  width: 56px;
  border-radius: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  margin-left: 25px;
}

.nav-links a {
  display: flex;
  align-items: center;
  color: inherit;
  font-size: 18px;
}

/* Diamond separators, same as the dashboard navbar */
.nav-links a + a { margin-left: 10px; }

.nav-links a + a::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 3px;
  transform: rotate(45deg);
  background-color: #d9d9d9;
}

.external-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  opacity: .7;
}

[data-theme="light"] .nav-links a + a::before { background-color: #303030; }

.theme-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}

.theme-toggle:hover {
  background-color: var(--bg-page);
  color: var(--text-strong);
}

.theme-toggle svg { width: 22px; height: 22px; }
[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun { display: none; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.container {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 40px 60px;
}

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── Page header (Discord channel header) ──────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}


.page-text { flex: 1; min-width: 0; }

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-strong);
}

.hash {
  margin-right: 8px;
  font-weight: 500;
  color: var(--text-faint);
}

.page-subtitle {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.page-subtitle b { color: var(--text); font-weight: 600; }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* Grey secondary Discord button */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 3px;
  background-color: var(--pill);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
  transition: background-color .15s;
}

.pill:hover {
  background-color: var(--pill-hover);
  text-decoration: none;
}

/* ── Category label (Discord channel category) ─────────────────────────── */

.category {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 28px 0 12px;
  font-family: Figtree, sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-faint);
}

.category::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin: 0 4px 3px 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

/* ── Cards (Discord embeds) ────────────────────────────────────────────── */

.card {
  padding: 20px;
  border-radius: 4px;
  background-color: var(--bg-card);
  border-left: 4px solid var(--bar);
}

[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

.card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

.card-desc + .card-desc { margin-top: 8px; }
.card-desc b { color: var(--text); font-weight: 600; }

/* Status banner */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.banner + .banner { margin-top: 12px; }
.banner .dot { margin-top: 4px; }
.banner[data-impact="minor"] { --bar: var(--yellow); }
.banner[data-impact="major"] { --bar: var(--orange); }
.banner[data-impact="critical"] { --bar: var(--red); }

.badge {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background-color: var(--bar);
  color: #181818;
}

.badge-grey {
  background-color: var(--pill);
  color: #fff;
}

/* Health dot, glows while things are fine */
.dot {
  flex-shrink: 0;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--text-faint);
}

.dot[data-state="good"] { background-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 204, 113, .2); }
.dot[data-state="okay"] { background-color: var(--yellow); box-shadow: 0 0 0 3px rgba(241, 196, 15, .2); }
.dot[data-state="bad"],
.dot[data-state="down"] { background-color: var(--red); box-shadow: 0 0 0 3px rgba(231, 76, 60, .2); }

/* Stat tiles */
.stat { display: flex; flex-direction: column; }

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-faint);
}

.stat-value {
  margin-top: 6px;
  font-family: Montserrat, sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  margin-left: 4px;
  font-family: Figtree, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-sub b { color: var(--text); font-weight: 600; }

.stat-small { padding: 16px 20px; }
.stat-small .stat-value { font-size: 22px; margin-top: 4px; }

/* Charts */
.charts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-box {
  position: relative;
  height: 220px;
}

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

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: none;
  border-radius: 3px;
  background-color: var(--bg-deep);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

[data-theme="light"] .legend-item { background-color: #f0f0f0; }

.legend-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background-color: var(--swatch);
}

.legend-item.off { opacity: .4; }
.legend-item.off .swatch { background-color: var(--text-faint); }

/* ── Footer ────────────────────────────────────────────────────────────── */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 20px;
  min-height: 48px;
  padding: 10px 15px;
  font-size: 14px;
  background-color: var(--bg-deep);
  color: var(--footer-text);
}

[data-theme="light"] .footer { background-color: #d9d9d9; }

.footer > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.footer > div > * + * {
  display: flex;
  align-items: center;
  margin-left: 5px;
}

.footer > div > * + *::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 3px;
  transform: rotate(45deg);
  background-color: var(--bg-page);
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-corner { background-color: transparent; }

::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track {
  border: 4px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb { background-color: var(--bg-deep); min-height: 40px; }
::-webkit-scrollbar-track { background-color: var(--bg-card); margin: var(--nav-height) 0 8px; }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media screen and (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 800px) {
  .container { padding: 20px 16px 40px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .nav-links { display: none; }
}

@media screen and (max-width: 600px) {
  :root { --nav-height: 64px; }
  .brand img { height: 44px; width: 44px; }
  .page-header { flex-wrap: wrap; }
  .page-actions { width: 100%; }
  .chart-box { height: 200px; }
  .footer { flex-direction: column; align-items: flex-start; }
}
