* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #14161a;
  color: #e6e6e6;
}

header {
  padding: 1.2rem 2rem;
  background: #1b1e24;
  border-bottom: 1px solid #2a2e37;
}

header h1 { margin: 0; font-size: 1.4rem; }
.subtitle { margin: 0.2rem 0 0; color: #9aa1ac; font-size: 0.9rem; }

.layout { display: flex; min-height: calc(100vh - 70px); }

aside {
  width: 260px;
  background: #1b1e24;
  border-right: 1px solid #2a2e37;
  padding: 1rem;
}

aside h2 { font-size: 1rem; text-transform: uppercase; color: #9aa1ac; }

#hosts { list-style: none; padding: 0; margin: 0 0 1rem; }

#hosts li {
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
  background: #22262e;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#hosts li.active { background: #2f6fed; }
#hosts li .status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
#hosts li .host-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hosts li .host-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.status.online { background: #35d07f; }
.status.offline { background: #d0353f; }

.host-remove {
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  font-size: 0.95rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#addHostForm { display: flex; flex-direction: column; gap: 0.4rem; }
#addHostForm input, #addHostForm button {
  padding: 0.4rem;
  border-radius: 4px;
  border: 1px solid #333842;
  background: #22262e;
  color: #e6e6e6;
}
#addHostForm button { cursor: pointer; background: #2f6fed; border: none; }

main { flex: 1; padding: 1.5rem 2rem; }

section { margin-bottom: 2rem; background: #1b1e24; border: 1px solid #2a2e37; border-radius: 8px; padding: 1.2rem; }

.hidden { display: none; }

#bulkHostCheckboxes { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
#bulkHostCheckboxes label { background: #22262e; padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.9rem; }

.bulk-form, .add-asset .row { display: flex; gap: 0.5rem; margin-bottom: 0.7rem; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=number], input[type=file], textarea {
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #333842;
  background: #22262e;
  color: #e6e6e6;
}

textarea { width: 100%; font-family: monospace; }

button {
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  border: none;
  background: #2f6fed;
  color: white;
  cursor: pointer;
}
button.danger { background: #d0353f; }
button:hover { opacity: 0.9; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #2a2e37; font-size: 0.9rem; }
th { color: #9aa1ac; font-weight: 500; }

/* Upload-/Verarbeitungs-Fortschritt */

.upload-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: -0.2rem 0 0.7rem;
  font-size: 0.85rem;
  color: #9aa1ac;
}

/* .hidden (oben, "display:none") und .upload-progress (hier, "display:flex")
   haben dieselbe Spezifitaet (je ein einzelner Klassen-Selektor) - ohne
   diese Regel wuerde bei gleichzeitig gesetzten Klassen einfach die Regel
   gewinnen, die spaeter im Stylesheet steht (hier also .upload-progress),
   und der Balken bliebe dauerhaft sichtbar statt zu verschwinden. Der
   Selektor mit zwei Klassen hat eine hoehere Spezifitaet und gewinnt
   deshalb unabhaengig von der Reihenfolge im Stylesheet.
*/
.upload-progress.hidden {
  display: none;
}

.upload-progress-bar {
  position: relative;
  width: 160px;
  height: 8px;
  border-radius: 4px;
  background: #22262e;
  overflow: hidden;
  flex-shrink: 0;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: #2f6fed;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

/* Unbestimmter Fortschritt (kein Prozentwert bekannt, z.B. waehrend der
   Pi das Video/Bild verarbeitet oder ein YouTube-Video herunterlaedt) -
   ein wandernder Balken statt einer Prozentzahl. */
.upload-progress-bar.indeterminate::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: #2f6fed;
  border-radius: 4px;
  animation: indeterminate-slide 1.1s ease-in-out infinite;
}

.upload-progress-bar.small {
  width: 40px;
  height: 6px;
}

@keyframes indeterminate-slide {
  0%   { left: -40%; }
  100% { left: 100%; }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.status-badge.ok { background: rgba(53, 208, 127, 0.15); color: #35d07f; }
.status-badge.off { background: rgba(154, 161, 172, 0.15); color: #9aa1ac; }
.status-badge.error { background: rgba(208, 53, 63, 0.15); color: #ff6b74; cursor: help; }
.status-badge.processing { background: rgba(47, 111, 237, 0.15); color: #6fa1ff; }

/* Login/Setup-Seiten */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-box {
  width: 340px;
  background: #1b1e24;
  border: 1px solid #2a2e37;
  border-radius: 8px;
  padding: 1.6rem;
}

.auth-box h1 { margin: 0 0 0.2rem; font-size: 1.3rem; }
.auth-box .subtitle { margin: 0 0 1rem; }
.auth-hint { color: #9aa1ac; font-size: 0.85rem; margin: 0 0 1rem; }

.auth-box form { display: flex; flex-direction: column; gap: 0.8rem; }
.auth-box label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: #9aa1ac; }
.auth-box input { padding: 0.5rem; border-radius: 4px; border: 1px solid #333842; background: #22262e; color: #e6e6e6; }
.auth-box button { margin-top: 0.4rem; }

.auth-error {
  background: rgba(208, 53, 63, 0.15);
  color: #ff6b74;
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Auth-aware Header */

.header-inner { display: flex; align-items: center; justify-content: space-between; }
.user-box { display: flex; align-items: center; gap: 0.7rem; font-size: 0.9rem; color: #9aa1ac; }
.user-box .role-badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(47, 111, 237, 0.15);
  color: #6fa1ff;
}
.user-box a { color: #9aa1ac; }

/* Rollenbasierte Sichtbarkeit: wird per JS anhand von /api/me umgeschaltet */
body:not(.is-admin) .admin-only { display: none !important; }

/* Asset-Gruppen (Aktiv/Inaktiv), Drag & Drop, Zeitplan */

h3.group-title { margin: 1.4rem 0 0.4rem; font-size: 0.95rem; color: #9aa1ac; text-transform: uppercase; }
h3.group-title:first-of-type { margin-top: 0.6rem; }

tr.asset-row-draggable { cursor: grab; }
tr.asset-row-draggable.dragging { opacity: 0.4; }
tr.drag-over { box-shadow: inset 0 2px 0 #2f6fed; }

.drag-handle { cursor: grab; color: #666d7a; padding-right: 0.4rem; user-select: none; }

.schedule-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #22262e;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #9aa1ac;
  cursor: pointer;
  border: none;
}
.schedule-badge:hover { opacity: 0.85; }

tr.schedule-editor-row td {
  background: #171a1f;
  padding: 0.8rem;
}

.weekday-picker { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.weekday-picker label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: #22262e;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.schedule-time-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; flex-wrap: wrap; }
.schedule-time-row input[type=time] { padding: 0.35rem; border-radius: 4px; border: 1px solid #333842; background: #22262e; color: #e6e6e6; }

.action-icons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.action-icons button { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
button.secondary { background: #333842; }

/* Panels (System Info / Integrations / Benutzerverwaltung) */

.panel-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.panel-tabs button { background: #22262e; }
.panel-tabs button.active { background: #2f6fed; }

pre.raw-json {
  background: #12141a;
  border: 1px solid #2a2e37;
  border-radius: 6px;
  padding: 0.8rem;
  overflow: auto;
  font-size: 0.82rem;
  max-height: 420px;
}

#userTable td, #userTable th { vertical-align: middle; }
.user-form { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.user-form select { padding: 0.5rem; border-radius: 4px; border: 1px solid #333842; background: #22262e; color: #e6e6e6; }

/* Remote-Player (Pull-Modus) */

#addHostForm select { padding: 0.4rem; border-radius: 4px; border: 1px solid #333842; background: #22262e; color: #e6e6e6; }

.token-box {
  margin-top: 0.7rem;
  padding: 0.8rem;
  background: #171a1f;
  border: 1px solid #2a2e37;
  border-radius: 6px;
}
.token-box p { margin: 0 0 0.5rem; font-size: 0.85rem; }
.raw-json.small { font-size: 0.72rem; max-height: none; white-space: pre-wrap; word-break: break-all; }

.host-mode-badge {
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(154, 161, 172, 0.15);
  color: #9aa1ac;
  margin-left: 0.3rem;
}
.host-last-seen { font-size: 0.72rem; color: #666d7a; display: block; margin-top: 0.1rem; }

body:not(.current-host-remote) .remote-only { display: none !important; }
body.current-host-remote .direct-only { display: none !important; }

.queued-hint { color: #9aa1ac; font-size: 0.82rem; margin: -0.4rem 0 0.8rem; }

#queuePanel { margin-bottom: 1.2rem; }
#queuePanel h3 { margin-bottom: 0.5rem; }
#queueList { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
#queueList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #22262e;
  border-radius: 6px;
  font-size: 0.85rem;
}
.queue-action { color: #e6e6e6; }
.queue-right { display: flex; align-items: center; gap: 0.5rem; }
.queue-cancel-btn {
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  border-radius: 4px;
}
.host-mode-badge.pending { background: rgba(47, 111, 237, 0.15); color: #6fa1ff; }
