/* SelfRemote - Oberflaeche
 *
 * Bewusst dunkel gehalten: das Werkzeug zeigt fremde Bildschirme, und alles um
 * das Bild herum soll zuruecktreten statt zu blenden. Keine Fremd-Frameworks,
 * alles wird mit dem Server ausgeliefert.
 */

:root {
  --bg: #0e1116;
  --bg-raised: #161b22;
  --bg-sunken: #0a0d12;
  --line: #232b36;
  --line-soft: #1b222c;

  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7885;

  --accent: #35d0a5;
  --accent-dim: #1d7a62;
  --amber: #e3a13c;
  --red: #e06c6c;

  --radius: 10px;
  --radius-sm: 6px;

  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  --fast: 130ms cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--text-dim); }
.small { font-size: 0.86em; }
.nowrap { white-space: nowrap; }

/* --- Kopfleiste --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 58px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(53 208 165 / 0.15);
}
.brand-name { font-size: 16px; letter-spacing: 0.2px; }
.brand-name b { font-weight: 650; }

.topnav { display: flex; gap: 20px; margin-right: auto; }
.topnav a { color: var(--text-dim); font-size: 14px; padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--accent-dim); }

.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who-name { color: var(--text-dim); }

.tag {
  font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: var(--line); color: var(--text-dim);
}
.tag-admin { background: rgb(53 208 165 / 0.14); color: var(--accent); }

.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-faint); font: inherit; font-size: 14px;
}
.linkbtn:hover { color: var(--text); }

/* --- Grundgeruest --- */

.wrap { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }

.head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; margin-bottom: 8px; flex-wrap: wrap;
}

h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }

.lede { color: var(--text-dim); max-width: 68ch; margin: 4px 0 28px; }

.foot {
  padding: 24px; text-align: center;
  color: var(--text-faint); font-size: 12px;
  border-top: 1px solid var(--line-soft);
}

/* --- Meldungen --- */

.notice, .error {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 24px; font-size: 14px;
  border-left: 3px solid var(--accent);
  background: rgb(53 208 165 / 0.08);
}
.error { border-left-color: var(--red); background: rgb(224 108 108 / 0.09); }

/* --- Formulare --- */

input[type="text"], input[type="password"], select {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color var(--fast), box-shadow var(--fast);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgb(53 208 165 / 0.12);
}
input::placeholder { color: var(--text-faint); }

label { display: block; font-size: 13px; color: var(--text-dim); }
label input, label select { display: block; width: 100%; margin-top: 6px; }

.stack { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { min-width: 240px; }

.row-form {
  display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
}
.row-form label { flex: 1 1 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 9px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-raised); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
.btn:hover { background: #1c2430; border-color: #2d3846; text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06231c; font-weight: 600; }
.btn-primary:hover { background: #45e0b4; border-color: #45e0b4; }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger:hover { color: var(--red); border-color: rgb(224 108 108 / 0.4); }

.btn-disabled { opacity: 0.35; cursor: not-allowed; }
.btn-wide { width: 100%; padding: 11px; }

button { font-family: inherit; }

/* --- Anmeldeseiten --- */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 32px 36px;
  box-shadow: var(--shadow);
}
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.gate-card h1 { font-size: 20px; margin-bottom: 4px; }

/* --- Geraeteliste --- */

.devices { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 10px; }

.device {
  display: grid;
  grid-template-columns: 4px 1fr auto auto;
  align-items: center;
  gap: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 16px 0;
  transition: border-color var(--fast), background var(--fast);
}
.device:hover { border-color: #2d3846; }

.device-state {
  width: 4px; height: 44px; border-radius: 0 3px 3px 0;
  background: var(--line);
}
.device.is-online .device-state {
  background: var(--accent);
  box-shadow: 0 0 12px rgb(53 208 165 / 0.5);
}

.device-main h2 { font-size: 16px; margin: 0 0 3px; }
.device-meta {
  margin: 0; font-size: 12.5px; color: var(--text-faint);
  display: flex; gap: 7px; flex-wrap: wrap;
}

.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-faint); white-space: nowrap;
}
.pill-on { color: var(--accent); background: rgb(53 208 165 / 0.1); }

.device-actions { display: flex; align-items: center; gap: 8px; }

.empty {
  margin-top: 40px; padding: 48px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty p { margin: 0 0 6px; }

/* --- Token-Karte --- */

.token-card {
  background: linear-gradient(180deg, rgb(53 208 165 / 0.07), transparent 70%), var(--bg-raised);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
  margin-bottom: 30px;
}
.token-card p { margin: 0 0 14px; font-size: 13.5px; }
.token {
  display: block; font-family: var(--mono); font-size: 14px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  word-break: break-all; color: var(--accent);
}
.cmd-hint { margin: 16px 0 6px !important; font-size: 12.5px; color: var(--text-faint); }
.cmd {
  display: block; font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-sunken); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text-dim); word-break: break-all;
}

/* --- Tabellen --- */

.panel {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px 24px; margin-bottom: 30px;
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faint); padding: 0 14px 10px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:hover td { background: rgb(255 255 255 / 0.015); }
.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.row-actions input { min-width: 150px; }

.table-log td { padding: 9px 14px; font-size: 13px; }
.ev {
  font-size: 12px; padding: 2px 8px; border-radius: 4px;
  background: var(--line); color: var(--text-dim);
}
.ev-angemeldet, .ev-verbunden { color: var(--accent); background: rgb(53 208 165 / 0.1); }
.ev-verweigert, .ev-anmeldung { color: var(--red); background: rgb(224 108 108 / 0.1); }

/* --- Betrachter --- */

.viewer { display: flex; flex-direction: column; height: 100vh; background: var(--bg-sunken); }

.viewer-bar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 52px; flex: 0 0 auto;
  background: var(--bg-raised); border-bottom: 1px solid var(--line);
}
.back { font-size: 18px; color: var(--text-dim); padding: 0 6px; }
.back:hover { color: var(--text); text-decoration: none; }
.viewer-title { display: flex; flex-direction: column; line-height: 1.25; }
.viewer-title strong { font-size: 14px; }
.viewer-status {
  margin-left: auto; font-size: 13px; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.viewer-status.live { color: var(--accent); }
.viewer-status.dead { color: var(--red); }
.viewer-tools { display: flex; align-items: center; gap: 10px; }
.quality { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.quality select { margin: 0; padding: 5px 8px; }

.stage { position: relative; flex: 1 1 auto; display: grid; place-items: center; overflow: hidden; }
#screen { max-width: 100%; max-height: 100%; cursor: crosshair; background: #000; }
#screen:focus { outline: 2px solid var(--accent-dim); outline-offset: -2px; }

.overlay {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: 16px; justify-items: center;
  background: rgb(10 13 18 / 0.85); color: var(--text-dim); font-size: 14px;
}
.overlay.hidden { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.viewer-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 8px 18px; flex: 0 0 auto;
  background: var(--bg-raised); border-top: 1px solid var(--line);
  font-size: 12px;
}

@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 14px; }
  .topnav { gap: 12px; }
  .wrap { padding: 26px 14px 60px; }
  .device { grid-template-columns: 4px 1fr; row-gap: 12px; padding-bottom: 18px; }
  .device-status, .device-actions { grid-column: 2; }
  .inline-form input { min-width: 0; }
  .viewer-tools .quality { display: none; }
}
