:root {
  --bg: #080a0e;
  --bg-gradient: linear-gradient(165deg, #080a0e 0%, #0c0f14 35%, #0e1118 70%, #0a0c10 100%);
  --surface: #12161e;
  --surface-hover: #181d26;
  --surface2: #1a1f2a;
  --border: #2a3142;
  --border-subtle: #1c222e;
  --text: #eaecef;
  --text-muted: #9098a8;
  --text-dim: #6b7280;
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --accent-glow: rgba(34, 211, 238, 0.25);
  --danger: #f87171;
  --danger-hover: #ef4444;
  --ok: #34d399;
  --warn: #fbbf24;
  --liquidsoap: #a78bfa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background: var(--bg-gradient);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ========== Login ========== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 70% at 50% -10%, rgba(34, 211, 238, 0.12) 0%, transparent 55%);
  pointer-events: none;
}

.login-box {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: inline-block;
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 14px var(--accent-glow));
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem 0;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-form input::placeholder {
  color: var(--text-dim);
}

.login-file-warning {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid var(--warn);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0 0 1.25rem 0;
}

.login-file-warning code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  background: var(--surface2);
  border-radius: 4px;
}

.login-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
}

.btn-login {
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-login:hover {
  background: var(--accent-hover);
}

.btn-login:active {
  transform: scale(0.99);
}

/* ========== App (Admin & User) ========== */
.app {
  max-width: 1024px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3.5rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.06) 0%, rgba(26, 31, 42, 0.6) 50%, var(--surface) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.header .logo {
  font-size: 2.35rem;
  color: var(--accent);
  line-height: 1;
  filter: drop-shadow(0 0 14px var(--accent-glow));
}

.header h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem 0;
}

.tagline {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.user-badge {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--accent);
  padding: 0.45rem 0.9rem;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 999px;
}

.btn-logout {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-logout:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--surface2);
}

/* ========== Cards (Admin & User) ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 70%);
  opacity: 0.5;
}

.card:hover {
  border-color: var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.card h2 {
  font-size: 1.22rem;
  font-weight: 600;
  margin: 0 0 0.9rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.01em;
}

.card-icon {
  font-size: 1.3rem;
  opacity: 0.95;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.section-head h2 { margin: 0; }

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

/* Leere Listen (Streams, DJs, User) – einheitlicher Look */
.stream-list .hint,
.dj-list .hint,
.user-list .hint {
  padding: 1.5rem 1.25rem;
  background: var(--surface2);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  text-align: center;
  margin: 0;
}

/* ========== Buttons ========== */
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 2px 10px rgba(34, 211, 238, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 3px 14px rgba(34, 211, 238, 0.35);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-small {
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  margin-left: 0.5rem;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* ========== Stream list (Admin & User) ========== */
.stream-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stream-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.4rem;
  align-items: center;
  padding: 1.35rem 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  border-left: 3px solid transparent;
}

.stream-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  border-left-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.stream-item .info {
  min-width: 0;
}

.stream-item .name {
  font-weight: 600;
  font-size: 1.08rem;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.stream-item .meta {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stream-item .stream-nowplaying {
  margin-top: 0.35rem;
  color: var(--text-dim);
  font-style: italic;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-top: 0.4rem;
  font-family: var(--font-sans);
}

.badge-liquidsoap {
  background: rgba(167, 139, 250, 0.2);
  color: var(--liquidsoap);
  border: 1px solid rgba(167, 139, 250, 0.4);
}

.stream-item .status {
  text-align: right;
  font-size: 0.85rem;
}

.stream-item .status.online {
  color: var(--ok);
}

.stream-item .status.online::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--ok);
}

.stream-item .status.offline {
  color: var(--text-muted);
}

.stream-item .status .listeners {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.stream-item .actions {
  display: flex;
  gap: 0.5rem;
}

.dj-item {
  grid-template-columns: 1fr auto;
  border-left: 3px solid transparent;
}
.dj-item:hover { border-left-color: var(--liquidsoap); }
.dj-item .name { margin-bottom: 0; }


/* ========== SSL / Nginx ========== */
.ssl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.nginx-preview,
.certbot-help {
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.nginx-preview pre,
.certbot-help pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ========== Settings row (Admin) ========== */
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
  padding: 0.75rem 0;
}

.settings-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 6rem;
}

.input-domain {
  flex: 1;
  min-width: 180px;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s;
}

.input-domain:focus {
  outline: none;
  border-color: var(--accent);
}

/* ========== Modal ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

/* Stream-Form-Modal: scrollbar, damit Speichern/Abbrechen immer sichtbar sind */
#modal .modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content.modal-wide {
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.08) 0%, transparent 100%);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

#stream-form {
  padding: 1.35rem;
}

.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-group {
  margin-bottom: 0.5rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.form-actions .btn-primary {
  min-width: 100px;
}

/* DJ / Stream-DJs / Playlist modals */
.modal-content .hint {
  margin: 0 1.35rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stream-djs-assigned,
#stream-djs-assigned {
  margin: 0 1.35rem 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  min-height: 60px;
}
.stream-djs-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stream-djs-row:last-child { border-bottom: none; }
.stream-djs-row .priority { font-weight: 600; color: var(--accent); min-width: 1.2rem; }
.stream-djs-row .name { flex: 1; }
.stream-djs-row .priority-input { width: 4rem; padding: 0.35rem; text-align: center; }
.stream-djs-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0 1.35rem 1rem;
}
.stream-djs-add select { flex: 1; min-width: 140px; }
.stream-djs-add input[type="number"] { width: 5rem; }
#modal-stream-djs .form-actions,
#modal-dj form .form-actions { padding: 1rem 1.35rem; margin: 0; }
#modal-dj #dj-form { padding: 1.35rem; }

.playlist-path.hint { margin-bottom: 0.5rem; }
.playlist-toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0 1.35rem 1rem;
}
.playlist-toolbar input { flex: 1; min-width: 0; }
.playlist-entries {
  list-style: none;
  margin: 0 1.35rem 1rem;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.playlist-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}
.playlist-entry:last-child { border-bottom: none; }
.playlist-entry .playlist-index { color: var(--accent); font-weight: 600; min-width: 1.5rem; }
.playlist-entry .playlist-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modal-playlist .form-actions { padding: 1rem 1.35rem; margin: 0; }

.btn-small { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

/* Benutzerbereich: gleiche Cards, weniger Sektionen – nutzt dieselben .card/.stream-item Styles */
.section-users .card-icon { filter: drop-shadow(0 0 6px rgba(52, 211, 57, 0.3)); }

.password-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.password-display input.readonly {
  flex: 1;
  min-width: 200px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

input.readonly {
  background: var(--surface2);
  color: var(--text-muted);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.lautfm-password-row .form-hint { margin-left: 0; display: block; margin-top: 0.25rem; }

/* ========== Liquidsoap / Form sections ========== */
.form-section {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.form-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  color: var(--text);
}

.form-section-hint {
  margin-bottom: 0.85rem;
  display: block;
}

.form-row-inline {
  margin-bottom: 0.85rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.liquidsoap-dj-port-row .btn-small {
  margin-left: 0.5rem;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.user-streams-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  max-height: 12rem;
  overflow-y: auto;
}

.user-streams-checkboxes .checkbox-label {
  margin-bottom: 0;
}

.user-list .stream-item {
  grid-template-columns: 1fr auto;
  border-left: 3px solid transparent;
}
.user-list .stream-item:hover { border-left-color: var(--accent); }

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    width: 100%;
    justify-content: flex-end;
  }
  .stream-item {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .stream-item .status { text-align: left; }
  .stream-item .actions { justify-content: flex-start; }
}
