/* Watchdog base styles: Notion dark tokens (DESIGN §9), typography, layout shell and the
   shared controls. Page-specific styles live in ui.css (UI) and auth.css (sign-in pages). */

:root {
  color-scheme: dark;
  --bg: #191919;
  --sidebar: #202020;
  --surface: #252525;
  --surface-2: #2c2c2c;
  --hover: rgba(255, 255, 255, .055);
  --active: rgba(255, 255, 255, .09);
  --border: rgba(255, 255, 255, .094);
  --text: rgba(255, 255, 255, .81);
  --text-2: rgba(255, 255, 255, .55);
  --text-3: rgba(255, 255, 255, .35);
  --accent: #2383E2;
  --accent-hover: #0F75D9;
  --focus: rgba(35, 131, 226, .57);

  /* Notion colors: text / background */
  --gray: #9B9B9B;    --gray-bg: #2F2F2F;
  --brown: #BA856F;   --brown-bg: #4A3228;
  --orange: #C77D48;  --orange-bg: #5C3B23;
  --yellow: #CA9849;  --yellow-bg: #564328;
  --green: #529E72;   --green-bg: #243D30;
  --blue: #5E87C9;    --blue-bg: #143A4E;
  --purple: #9D68D3;  --purple-bg: #3C2D49;
  --pink: #D15796;    --pink-bg: #4E2C3C;
  --red: #DF5452;     --red-bg: #522E2A;

  --font: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 4px;
  --sidebar-w: 240px;
  --peek-w: 520px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- typography ---------- */
h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.3; margin: 1.4em 0 .4em; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: .4em 0 .8em; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--text); }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 85%; }
code { background: var(--surface-2); color: var(--red); padding: .15em .35em; border-radius: 3px; }
pre { background: var(--surface); padding: 12px 16px; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; color: inherit; padding: 0; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px; padding: 0 .35em; color: var(--text-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
blockquote { margin: 8px 0; padding-left: 14px; border-left: 3px solid var(--text); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.small { font-size: 12px; }
.page-icon { font-size: 64px; line-height: 1; margin: 0 0 8px; }
.page-title { font-size: 40px; font-weight: 700; margin: 0 0 12px; }
.breadcrumb { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 3px; }
::selection { background: rgba(35, 131, 226, .35); }
[hidden] { display: none !important; }

/* ---------- layout shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  font-size: 14px; color: var(--text-2);
}
.sidebar:empty, body.bare .sidebar { display: none; }
.main { flex: 1 1 auto; min-width: 0; }
.page { max-width: 960px; margin: 0 auto; padding: 48px 96px 96px; }
/* max-width includes the padding (border-box), so bare pages drop the 96px app gutters. */
body.bare .page { max-width: 512px; padding: 12vh 16px 64px; }
.peek {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--peek-w); max-width: 100vw;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .35); overflow-y: auto; z-index: 40;
  padding: 24px 32px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1; text-decoration: none;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s ease;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--active); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: rgba(223, 84, 82, .45); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 28px; height: 28px; padding: 0; justify-content: center; border-color: transparent; color: var(--text-2); }
.btn-icon:hover { color: var(--text); }

/* ---------- form controls ---------- */
label { display: block; color: var(--text-2); font-size: 12px; font-weight: 500; margin: 12px 0 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="datetime-local"], input[type="date"], input[type="time"],
select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 14px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--focus); }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 10px 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 180px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ---------- tables (Notion table view) ---------- */
.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2);
  padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--hover); }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tags (Notion select options) ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 6px; border-radius: 3px;
  font-size: 12px; line-height: 1; white-space: nowrap;
  background: var(--gray-bg); color: var(--text);
}
.tag-default { background: rgba(255, 255, 255, .055); color: var(--text); }
.tag-gray { background: var(--gray-bg); color: var(--gray); }
.tag-brown { background: var(--brown-bg); color: var(--brown); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-purple { background: var(--purple-bg); color: var(--purple); }
.tag-pink { background: var(--pink-bg); color: var(--pink); }
.tag-red { background: var(--red-bg); color: var(--red); }
.text-gray { color: var(--gray); } .text-brown { color: var(--brown); } .text-orange { color: var(--orange); }
.text-yellow { color: var(--yellow); } .text-green { color: var(--green); } .text-blue { color: var(--blue); }
.text-purple { color: var(--purple); } .text-pink { color: var(--pink); } .text-red { color: var(--red); }

/* ---------- status pills (core.templating.status_pill): icon + label, never color alone ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 6px; border-radius: 3px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.pill-icon { font-size: 11px; }
.pill-ok { background: var(--green-bg); color: var(--green); }
.pill-warn { background: var(--yellow-bg); color: var(--yellow); }
.pill-down { background: var(--red-bg); color: var(--red); }
.pill-silent { background: var(--purple-bg); color: var(--purple); }
.pill-unknown { background: var(--gray-bg); color: var(--gray); }
.pill-disabled { background: var(--gray-bg); color: var(--gray); }
.pill-retired { background: var(--brown-bg); color: var(--brown); }
.pill-muted, .pill-acknowledged, .pill-snoozed { background: transparent; color: var(--text-2); border: 1px solid var(--border); font-weight: 400; }

/* status dots (sidebar tree, strips) */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: 0 0 8px; }
.dot-ok { background: var(--green); } .dot-warn { background: var(--yellow); } .dot-down { background: var(--red); }
.dot-silent { background: var(--purple); } .dot-unknown, .dot-disabled { background: var(--gray); }
.dot-retired { background: var(--brown); }

/* severity tags */
.sev-critical { background: var(--red-bg); color: var(--red); }
.sev-high { background: var(--orange-bg); color: var(--orange); }
.sev-warn { background: var(--yellow-bg); color: var(--yellow); }
.sev-info { background: var(--blue-bg); color: var(--blue); }

/* ---------- properties block (Notion page properties) ---------- */
.props { margin: 4px 0 24px; }
.prop { display: flex; gap: 8px; min-height: 32px; align-items: baseline; padding: 4px 0; }
.prop-key { flex: 0 0 160px; color: var(--text-2); font-size: 14px; }
.prop-val { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* ---------- callout ---------- */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin: 8px 0;
}
.callout-icon { font-size: 18px; line-height: 1.3; flex: 0 0 auto; }
.callout-body { flex: 1 1 auto; min-width: 0; }
.callout-red { background: var(--red-bg); }
.callout-orange { background: var(--orange-bg); }
.callout-yellow { background: var(--yellow-bg); }
.callout-green { background: var(--green-bg); }
.callout-blue { background: var(--blue-bg); }
.callout-purple { background: var(--purple-bg); }
.callout-gray { background: var(--gray-bg); }

/* ---------- toggle (Notion toggle block, <details class="toggle">) ---------- */
details.toggle { margin: 2px 0; }
details.toggle > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 3px 4px; border-radius: var(--radius); font-weight: 600; user-select: none;
}
details.toggle > summary::-webkit-details-marker { display: none; }
details.toggle > summary::before {
  content: "▸"; display: inline-block; width: 16px; text-align: center;
  color: var(--text-2); transition: transform .12s ease;
}
details.toggle[open] > summary::before { transform: rotate(90deg); }
details.toggle > summary:hover { background: var(--hover); }
details.toggle > .toggle-body { padding-left: 22px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  font-size: 14px; max-width: min(90vw, 480px);
}
.toast-error { border-color: rgba(223, 84, 82, .5); }
.toast-ok { border-color: rgba(82, 158, 114, .5); }

/* ---------- misc ---------- */
.muted-block { color: var(--text-3); font-style: italic; }
.empty { background: var(--surface); color: var(--text-2); border-radius: var(--radius); padding: 24px; text-align: center; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: wd-shimmer 1.4s ease infinite; border-radius: var(--radius); min-height: 14px; }
@keyframes wd-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }
.error-page { text-align: center; }
.error-code { font-size: 64px; font-weight: 700; color: var(--text-3); line-height: 1; margin-bottom: 8px; }

/* ---------- phones / narrow windows ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: 8px 0 24px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: none; }
  .page { padding: 56px 16px 64px; }
  body.bare .page { padding-top: 8vh; }
  .page-title { font-size: 30px; }
  .page-icon { font-size: 48px; }
  .peek { width: 100vw; padding: 16px; }
  .prop { flex-direction: column; gap: 0; }
  .prop-key { flex-basis: auto; font-size: 12px; }
}
