/* IPTV Auth admin interface.
   One stylesheet, no framework, no external fonts: this UI has to work on an
   isolated network and while the thing it manages is broken. */

/* Alteox brand palette, from the press kit. Kept as its own layer so the
   semantic variables below can be read against it, and so nothing has to guess
   at a hex code twice. */
:root {
  --brand-light-blue: #92DAEB;
  --brand-medium-blue: #6ABDD8;
  --brand-blue: #3880BB;
  --brand-bright-blue: #107CB5;
  --brand-purple: #293C9F;
  --brand-pink-purple: #8D63EE;
  --brand-dark-blue: #062535;
  --brand-dark: #060D11;
}

/* Semantic layer, matching alteox.com: white ground, near-black body text,
   brand blue for headings and links, and the dark navy reserved for the one
   primary action on a page -- the same role "Contact Us" plays on the site. */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f6f9;
  --border: #dfe7ed;
  --text: #171717;
  --muted: #5c6f7c;

  /* Links, headings and the active navigation item. */
  --accent: var(--brand-blue);
  /* The primary button. */
  --cta: var(--brand-dark-blue);
  --cta-text: #ffffff;
  --accent-text: #ffffff;

  --ok: #1a7f4b;
  --ok-bg: #e6f5ec;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --err: #b5262f;
  --err-bg: #fdeaec;

  --radius: 12px;
  /* Buttons and chips are pills on the site, so they are pills here. */
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(6, 37, 53, .04), 0 8px 24px rgba(6, 37, 53, .05);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* The site sets "creato"; Creato Display is the licensed family name. Neither
     is bundled -- this UI loads no external fonts, because it has to work on an
     isolated network -- so both are named ahead of the system stack. */
  --sans: "Creato Display", creato, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Built up from the brand darks rather than a neutral grey, so the dark
       theme reads as the same family as the light one. */
    --bg: var(--brand-dark);
    --panel: #0c1a23;
    --panel-2: #12252f;
    --border: #1d3a49;
    --text: #e6eef2;
    --muted: #8fa5b1;
    --accent: var(--brand-medium-blue);
    --accent-text: var(--brand-dark);
    /* On a dark ground the navy CTA would disappear, so the light blue carries
       it instead and the text goes dark. */
    --cta: var(--brand-medium-blue);
    --cta-text: var(--brand-dark);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --ok: #56d68f;
    --ok-bg: #14301f;
    --warn: #e5b567;
    --warn-bg: #33280f;
    --err: #ef8a92;
    --err-bg: #38191c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: linear-gradient(180deg, #f3f8fb 0%, var(--bg) 420px);
  background-repeat: no-repeat;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  body { background-image: linear-gradient(180deg, #0b1c26 0%, var(--bg) 420px); }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.brand:hover { text-decoration: none; }

/* The logo is used as supplied and never recoloured or rearranged, per the brand
   guidelines, so it is sized by height alone and left to keep its own ratio. */
.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

/* "Auth" names this tool next to the company mark, rather than being set into
   the logo itself. */
.brand-sub {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--muted);
}

/* The supplied light variant is greyscale, so on a dark background the full
   colour mark is kept and only lifted slightly off the panel. */
@media (prefers-color-scheme: dark) {
  .brand-logo { filter: saturate(1.1) brightness(1.12); }
}

.nav { list-style: none; margin: 0; padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav li { margin: 1px 0; }
.nav a {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  color: var(--text);
  font-weight: 500;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent); color: var(--accent-text); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.who { display: block; margin-bottom: 8px; color: var(--text); }
.who:hover { text-decoration: none; }
.who-name {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.content { flex: 1; padding: 24px 28px 60px; min-width: 0; max-width: 1400px; }

.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ------------------------------------------------------------------ header */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h1 {
  font-size: 24px;
  margin: 0 0 4px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--accent);
}
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
h3 { font-weight: 700; }
.subtitle { color: var(--muted); margin: 0; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.panel-tight { padding: 0; overflow: hidden; }
.panel h2 { margin-top: 0; }
.panel-note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-value { color: var(--accent); }
.stat-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.badge.role { text-transform: capitalize; }
/* Server kind next to a mapping, so "which of these is MediaMTX" is readable
   without knowing the naming convention someone used for their servers. */
.badge.kind { font-family: var(--mono); font-weight: 500; font-size: 10px; }

/* ------------------------------------------------------------------- forms */

label { display: block; font-weight: 550; margin-bottom: 4px; font-size: 13px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 3px; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 70px; resize: vertical; font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; }
.field-inline { display: flex; gap: 8px; align-items: center; }
.field-inline input[type=checkbox] { width: auto; margin: 0; }
.field-inline label { margin: 0; font-weight: 500; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }

.checklist {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--panel);
}
.checklist label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-weight: 450;
  padding: 3px 0;
  margin: 0;
}
.checklist input { width: auto; margin: 0; }
.checklist .meta { color: var(--muted); font-size: 12px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--cta); border-color: var(--cta); color: var(--cta-text); }
.btn-primary:hover { filter: brightness(1.12); background: var(--cta); }
.btn-danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn-danger:hover { background: var(--err-bg); }
.btn-quiet { color: var(--muted); font-weight: 500; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.btn-row .spacer { flex: 1; }

/* ------------------------------------------------------------------ alerts */

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-err { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------------------ filters */

.filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters input[type=search] { min-width: 220px; }
.filters select { min-width: 130px; }

/* ------------------------------------------------------------- bulk actions */

.bulkbar {
  display: none;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.bulkbar.on { display: flex; }
.bulkbar .count { font-weight: 600; }
.bulkbar select, .bulkbar input { width: auto; }

/* -------------------------------------------------------------- code blocks */

pre.snippet {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  margin: 0 0 10px;
  white-space: pre;
}
.secret-once {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.secret-once code {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 6px;
  overflow-wrap: anywhere;
  user-select: all;
}

/* ------------------------------------------------------------------- login */

.login-card { width: 100%; max-width: 360px; }
/* The sign-in card is the one place with room to give the mark some presence, so
   it is centred and larger than the sidebar copy. */
.login-card .brand {
  border: none;
  padding: 0 0 18px;
  justify-content: center;
}
.login-card .brand-logo { height: 38px; }

/* -------------------------------------------------------------- pagination */

.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 14px; }
.pager .info { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { display: flex; flex-wrap: wrap; }
  .nav-sep { display: none; }
  .content { padding: 16px; }
}
