/* Remote management pages: the login page, the list of recyclers and each
 * recycler's site page. Styled like the operator UI: its tokens (values from
 * diagnostics/frontend/src/static/operator-ui/tokens.css), font, logo, header,
 * raised cards for anything you can press and the green accent. The theme
 * follows the browser's light or dark setting.
 */

:root {
  color-scheme: light;

  --surface-page: #e9ebed;
  --surface-card: #ffffff;
  --surface-panel: #f2f4f6;
  --surface-inset: #f2f4f6;
  --surface-raised: #f7f8fa;

  --border: #dde1e6;
  --border-strong: #c4cad2;

  --text-strong: #1c2127;
  --text-1: #23282e;
  --text-body: #3d454e;
  --text-2: #5b6470;
  --text-3: #8a929c;
  --text-dim: #9aa3ad;

  --tint-base: #ffffff;
  --press-shade: #000000;

  --accent: #178a55;
  --accent-ink: #ffffff;
  --accent-brand: #1d9e63;

  --status-fault: #c9352c;
  --status-fault-tint: color-mix(in srgb, var(--status-fault) 12%, var(--tint-base));
  --status-warning: #a86f0c;
  --status-warning-tint: color-mix(in srgb, var(--status-warning) 14%, var(--tint-base));

  --radius-panel: 14px;
  --radius-card: 10px;
  --radius-control: 10px;
  --shadow-card: 0 1px 2px rgba(16, 24, 32, 0.06);
  --shadow-raised: 0 1px 3px rgba(16, 24, 32, 0.08);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 10px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 24px;
  --touch-min: 52px;

  --font-family: "Source Sans Pro", sans-serif;
  /* The operator UI's type scale, a size up: these pages are read on
     ordinary screens from further away than its panel */
  --type-label: 13px;
  --type-label-tracking: 0.08em;
  --type-body-small: 16px;
  --type-body: 17px;
  --type-base: 18px;
  --type-title: 22px;
  --type-header: 20px;
  --weight-regular: 400;
  --weight-semibold: 600;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --surface-page: #14171b;
    --surface-card: #1e2226;
    --surface-panel: #23282e;
    --surface-inset: #181c20;
    --surface-raised: #262b31;

    --border: #30363d;
    --border-strong: #3d454e;

    --text-strong: #f2f4f6;
    --text-1: #e6e9ed;
    --text-body: #c9d0d8;
    --text-2: #a4adb8;
    --text-3: #889199;
    --text-dim: #737c86;

    --tint-base: var(--surface-card);
    --press-shade: #ffffff;

    --accent-brand: #3dbf83;

    --status-fault: #ea6a62;
    --status-warning: #e8b23a;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-raised: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

@font-face {
  font-family: "Source Sans Pro";
  font-weight: 400;
  src: local("Source Sans Pro"), url(SourceSansPro-Regular.ttf) format("truetype");
}

@font-face {
  font-family: "Source Sans Pro";
  font-weight: 600;
  src: local("Source Sans Pro Semibold"), local("SourceSansPro-Semibold"),
    url(SourceSansPro-Semibold.ttf) format("truetype");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Rules that set display, such as .notice, would otherwise show hidden
   elements (the login page's "Wrong username or password") */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: var(--space-4);
  background: var(--surface-page);
  color: var(--text-1);
  font-family: var(--font-family);
  font-size: var(--type-base);
  line-height: 1.4;
}

.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

/* The logo file is black ink on transparent; the dark theme inverts it. */
.logo {
  display: block;
  height: 20px;
}

@media (prefers-color-scheme: dark) {
  .logo {
    filter: invert(1);
  }
}

/* ── Header, as in the operator UI ─────────────────────────────────────────── */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

header .header-divider {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
}

header h1 {
  min-width: 0;
  margin: 0;
  font-size: var(--type-header);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-left: auto;
}

/* On a phone: logo, then the title, then the buttons on one row */
@media (max-width: 640px) {
  header .header-divider {
    display: none;
  }

  header h1 {
    flex-basis: 100%;
  }

  header nav {
    margin-left: calc(-1 * var(--space-3));
    gap: 0;
  }

  header nav .btn {
    padding: 0 var(--space-3);
  }
}

/* ── Label (eyebrow) ───────────────────────────────────────────────────────── */
.label {
  display: block;
  margin: var(--space-6) 0 var(--space-2);
  color: var(--text-2);
  font-size: var(--type-label);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--type-label-tracking);
  text-transform: uppercase;
}

main > .label:first-child {
  margin-top: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--text-1);
  box-shadow: var(--shadow-card);
  font: var(--weight-semibold) var(--type-body) var(--font-family);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:active {
  background: var(--surface-inset);
}

.btn:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent-brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:active {
  background: color-mix(in srgb, var(--accent) 85%, var(--press-shade));
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}

/* ── Cards: raised, with a chevron, so they read as touchable ──────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-3);
}

.card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 80px;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  color: var(--text-1);
  text-decoration: none;
}

.card:active {
  background: var(--surface-inset);
}

.card > .icon {
  color: var(--accent-brand);
}

.card > .card-text {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.card .card-title {
  font-size: var(--type-base);
  font-weight: var(--weight-semibold);
}

.card .card-sub {
  color: var(--text-2);
  font-size: var(--type-body-small);
}

.card > .chevron {
  color: var(--text-dim);
}

.empty {
  color: var(--text-2);
}

/* ── Notices ───────────────────────────────────────────────────────────────── */
.notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  font-size: var(--type-body);
}

.notice-warning {
  background: var(--status-warning-tint);
  color: var(--status-warning);
}

.notice-fault {
  background: var(--status-fault-tint);
  color: var(--status-fault);
}

/* ── Pages of all cameras ──────────────────────────────────────────────────── */
.cameras {
  display: grid;
  gap: var(--space-4);
  justify-items: center;
}

/* All cameras in one row (--cameras is their number); one column on a phone */
.cameras.side-by-side {
  grid-template-columns: repeat(var(--cameras), minmax(0, 1fr));
}

@media (max-width: 640px) {
  .cameras.side-by-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cameras img {
  display: block;
  width: 100%;
  max-width: 900px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-inset);
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 380px;
  margin: 12vh auto 0;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface-card);
  box-shadow: var(--shadow-raised);
}

.login h1 {
  margin: 0;
  font-size: var(--type-title);
  font-weight: var(--weight-semibold);
}

.login .label {
  margin: 0 0 var(--space-1);
}

.login input[type="text"],
.login input[type="password"] {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-inset);
  color: var(--text-1);
  font: var(--type-base) var(--font-family);
}

.login input:focus {
  outline: 2px solid var(--accent-brand);
  outline-offset: 1px;
}

.login .notice {
  margin: 0;
}

.login .btn {
  width: 100%;
}

.login .help {
  margin: 0;
  color: var(--text-2);
  font-size: var(--type-body-small);
}
