/* ============================================================================
   Obsidian — shared design system for the TAP Beta Portal.
   Faithfully mirrors the in-game UIFoundry theme:
     palette      TAP/Skins.lua:148-155  (obsidian skin)
     accentHeader TAP/Theme.lua:95-107   (min(1, c*1.3+0.30))
     type scale   TAP/Headings.lua:15-29
     shell dims   TAP/Window.lua         (920x600, 44/210/22, 8px radius, 1px border)
   Used verbatim by BOTH the Wails client frontend and the server download portal,
   so the desktop app and the web page are visually identical to /tap in-game.
   The font is expected next to this file at ./fonts/Ubuntu.ttf.
   ========================================================================== */

@font-face {
  font-family: "Ubuntu";
  src: url("fonts/Ubuntu.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* palette */
  --bg: #08080A;
  --sidebar: #0D0D0F;
  --panel: #121315;
  --card: #1A1B1E;
  --hover: #26282D;
  --border: #33353B;
  --text: #EBEDF1;
  --subtext: #8A8F99;
  --accent: #6685B3;
  --accent-header: #D1F9FF;  /* brightened accent for highlights/headers */

  /* status */
  --neutral: #4C5466;
  --success: #218754;
  --warning: #B87833;
  --danger: #8C3338;
  --info: #0D8CBF;
  --danger-btn: #521F26;
  --danger-btn-hover: #803839;
  --danger-btn-text: #FFB8B8;

  /* shape */
  --radius: 8px;
  --border-size: 1px;

  /* accent tints (mix() equivalents used in-game) */
  --accent-08: rgba(102, 133, 179, 0.08);
  --accent-12: rgba(102, 133, 179, 0.12);
  --accent-18: rgba(102, 133, 179, 0.18);
  --accent-30: rgba(102, 133, 179, 0.30);
  --accent-50: rgba(102, 133, 179, 0.50);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Ubuntu", "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---- type scale (mirrors HEADING_ROLES) ---- */
.t-display  { font-size: 28px; color: var(--text); }
.t-h1       { font-size: 22px; color: var(--text); }
.t-h2       { font-size: 18px; color: var(--text); }
.t-h3       { font-size: 16px; color: var(--text); }
.t-h4       { font-size: 14px; color: var(--text); }
.t-h5       { font-size: 13px; color: var(--accent); }
.t-title    { font-size: 16px; color: var(--text); }
.t-subtitle { font-size: 12px; color: var(--subtext); }
.t-overline { font-size: 10px; color: var(--subtext); text-transform: uppercase; letter-spacing: 0.08em; }
.t-caption  { font-size: 11px; color: var(--subtext); }
.t-label    { font-size: 12px; color: var(--subtext); }
.t-body     { font-size: 12px; color: var(--text); }
.accent     { color: var(--accent); }
.accent-hl  { color: var(--accent-header); }
.muted      { color: var(--subtext); }

/* ============================ WINDOW SHELL ============================ */
.window {
  display: grid;
  grid-template-rows: 44px 1fr 22px;
  grid-template-columns: 210px 1fr;
  grid-template-areas:
    "header header"
    "sidebar content"
    "footer footer";
  height: 100vh;
  background: var(--bg);
  border: var(--border-size) solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* header (drag handle) */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  padding: 0 8px 0 16px;
  background: var(--panel);
  border-bottom: var(--border-size) solid var(--border);
  --wails-draggable: drag;      /* Wails: makes the header move the window */
  -webkit-app-region: drag;
  user-select: none;
}
.header .logo {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--accent);
  -webkit-mask: radial-gradient(circle at 50% 42%, transparent 22%, #000 24%) ;
  flex: 0 0 auto;
}
.header .title { font-size: 15px; color: var(--text); margin-left: 8px; font-weight: 500; }
.header .title b { color: var(--accent-header); font-weight: 600; }
.header .spacer { flex: 1; }
.header .winbtn {
  -webkit-app-region: no-drag;
  --wails-draggable: no-drag;
  width: 28px; height: 28px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--subtext);
  cursor: pointer; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.header .winbtn:hover { background: var(--hover); color: var(--text); }
.header .winbtn.close:hover { background: var(--danger-btn); color: var(--danger-btn-text); }

/* sidebar nav */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar);
  border-right: var(--border-size) solid var(--border);
  padding: 6px 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.nav-cat {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--subtext); padding: 10px 16px 4px;
}
.nav-row {
  position: relative;
  height: 30px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; margin: 0 6px; border-radius: 6px;
  color: var(--subtext); cursor: pointer; user-select: none;
  font-size: 13px;
}
.nav-row .ico { width: 16px; text-align: center; opacity: 0.9; }
.nav-row:hover { background: var(--accent-12); color: var(--text); }
.nav-row.active { background: var(--accent-18); color: #FAFCFF; }
.nav-row.active::before {   /* 3px accent bar on active */
  content: ""; position: absolute; left: 0; top: 5px; bottom: 5px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.sidebar .grow { flex: 1; }
.sidebar .side-btn {
  margin: 6px 12px 4px; height: 28px; border-radius: 6px;
  background: var(--accent); color: #FAFCFF; border: none; cursor: pointer;
  font-size: 12px; font-family: inherit;
}
.sidebar .side-btn:hover { filter: brightness(1.12); }

/* content */
.content {
  grid-area: content;
  background: var(--bg);
  overflow-y: auto;
  padding: 20px 22px;
}
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 18px; color: var(--text); margin: 0 0 14px; }

/* footer */
.footer {
  grid-area: footer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--panel);
  border-top: var(--border-size) solid var(--border);
  font-size: 11px;
}
.footer .name { color: var(--text); }
.footer .ver { color: var(--accent); }

/* custom scrollbar (accent thumb / faint track, like the in-game 8px bar) */
.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track, .content::-webkit-scrollbar-track { background: rgba(26,27,30,0.6); }
.sidebar::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb {
  background: var(--accent); border-radius: 4px; min-height: 24px;
}

/* ============================ COMPONENTS ============================ */

/* card — bordered container, optional 3px left accent bar */
.card {
  position: relative;
  background: var(--card);
  border: var(--border-size) solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.card.accent { border-color: color-mix(in srgb, var(--border) 65%, var(--accent) 35%); }
.card.accent::before {
  content: ""; position: absolute; left: 1px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.card.danger { border-color: var(--danger); }
.card.danger::before { background: var(--danger); }
.card.success::before { background: var(--success); }
.card-title { font-size: 14px; color: var(--text); margin: 0 0 4px; padding-left: 8px; }
.card-body { padding-left: 8px; }

/* stat tile — overline label above a big colored value */
.tile {
  position: relative;
  background: var(--card);
  border: var(--border-size) solid color-mix(in srgb, var(--border) 65%, var(--accent) 35%);
  border-radius: var(--radius);
  padding: 12px 12px 12px 15px;
  min-width: 150px;
}
.tile::before {
  content: ""; position: absolute; left: 1px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.tile .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--subtext); }
.tile .v { font-size: 22px; color: var(--text); margin-top: 4px; }
.tile .v.accent { color: var(--accent-header); }
.tile .d { font-size: 11px; color: var(--subtext); margin-top: 2px; }
.tile .d.up { color: var(--success); }
.tile .d.down { color: var(--danger-btn-text); }
.tile-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* buttons */
.btn {
  font-family: inherit; font-size: 12px;
  height: 26px; padding: 0 14px;
  border-radius: 8px; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text); background: var(--card);
}
.btn:hover { background: color-mix(in srgb, var(--accent) 35%, #000 65%); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: #FAFCFF; }
.btn.primary:hover { filter: brightness(1.14); background: var(--accent); }
.btn.ghost { background: var(--bg); }
.btn.ghost:hover { background: var(--accent-30); }
.btn.danger { background: var(--danger-btn); color: var(--danger-btn-text); }
.btn.danger:hover { background: var(--danger-btn-hover); }
.btn.lg { height: 32px; padding: 0 18px; font-size: 13px; }

/* toggle switch (38x18 track, 14x14 knob) */
.switch { position: relative; width: 38px; height: 18px; flex: 0 0 auto; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  position: absolute; inset: 0; border-radius: 9px; background: var(--border);
  transition: background 0.12s;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 7px; background: var(--text); transition: left 0.12s, background 0.12s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .knob { left: 22px; background: #0D0F14; }

/* input / editbox */
.input {
  font-family: inherit; font-size: 12px; color: var(--text);
  height: 26px; padding: 0 7px; width: 100%;
  background: var(--bg); border: var(--border-size) solid var(--border);
  border-radius: 6px; outline: none;
}
.input:focus { border-color: var(--accent); }

/* section header + divider */
.section { margin: 20px 0 0; }
.section > .lbl { font-size: 12px; color: var(--accent); }
.section > .rule { height: 1px; background: rgba(51,53,59,0.8); margin-top: 6px; }

/* form row */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 8px; border-radius: 6px;
}
.row:hover { background: rgba(38,40,45,0.6); }
.row .row-main { flex: 1; min-width: 0; }
.row .row-main .rt { font-size: 13px; color: var(--text); }
.row .row-main .rs { font-size: 11px; color: var(--subtext); margin-top: 2px; }

/* zebra list rows (Builder:Row) */
.list { border-radius: 6px; overflow: hidden; }
.list .lrow {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; font-size: 12px;
}
.list .lrow:nth-child(odd) { background: rgba(26,27,30,0.02); }
.list .lrow:nth-child(even) { background: rgba(26,27,30,0.07); }
.list .lrow:hover { background: rgba(38,40,45,0.6); }
.list .lrow:hover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent);
}

/* badge */
.badge {
  display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 10px; color: #FAFCFF;
}
.badge.accent { background: var(--accent); }
.badge.neutral { background: var(--neutral); }
.badge.success { background: var(--success); }
.badge.warning { background: var(--warning); }
.badge.danger { background: var(--danger); }
.badge.info { background: var(--info); }

/* banner (update-available callout) */
.banner {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: var(--accent-08);
  border: var(--border-size) solid color-mix(in srgb, var(--border) 60%, var(--accent) 40%);
  border-radius: var(--radius); padding: 12px 14px 12px 16px; margin-bottom: 14px;
}
.banner::before {
  content: ""; position: absolute; left: 1px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 2px; background: var(--accent);
}
.banner .bmain { flex: 1; }
.banner .bt { font-size: 13px; color: var(--accent-header); }
.banner .bs { font-size: 11px; color: var(--subtext); margin-top: 2px; }
.banner.ok { background: rgba(33,135,84,0.08); border-color: color-mix(in srgb, var(--border) 60%, var(--success) 40%); }
.banner.ok::before { background: var(--success); }
.banner.ok .bt { color: #7FD9A6; }

/* status dot */
.dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; }
.dot.ok { background: var(--success); }
.dot.warn { background: var(--warning); }
.dot.err { background: var(--danger); }

/* mono path chip */
.path-chip {
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12px;
  color: var(--text); background: var(--bg);
  border: var(--border-size) solid var(--border); border-radius: 6px;
  padding: 6px 10px; word-break: break-all;
}
.path-chip.unset { color: var(--danger-btn-text); border-color: var(--danger); }

/* spinner */
.spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
