:root {
  --bg: #0a0c11;
  --bg-soft: #0e1117;
  --surface: #13161e;
  --surface-2: #191d27;
  --surface-3: #21262f;
  --hover: #262b36;
  --text: #e8eaf0;
  --muted: #929aab;
  --faint: #626b7c;
  --accent: #6672ff;
  --accent-soft: rgba(102, 114, 255, 0.15);
  --accent-hover: #7a85ff;
  --green: #2fb67c;
  --green-soft: #26895f;
  --danger: #f2585f;
  --border: #232733;
  --border-soft: #1c202a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --sidebar-w: 252px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(102, 114, 255, 0.16), transparent 70%),
    var(--bg);
}
.login-box {
  background: var(--surface);
  padding: 40px 36px 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  width: 380px;
  max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.login-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 10px 28px -8px rgba(102, 114, 255, 0.5);
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-box h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-box p { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
}
.login-box input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.login-box button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(140deg, var(--accent), #8a5cff);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s, box-shadow 0.2s;
  box-shadow: 0 8px 20px -8px rgba(102, 114, 255, 0.6);
}
.login-box button:hover { filter: brightness(1.08); box-shadow: 0 10px 26px -8px rgba(102, 114, 255, 0.75); }
.login-box button:active { transform: scale(0.98); }
.error { color: #ff8a8a; margin-top: 14px; font-size: 13.5px; min-height: 18px; }

/* ── App-Shell ─────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Seitenleiste ──────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 20px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  overflow: hidden;
  background: transparent;
  flex: none;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.3px; }
.feature-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
  margin: 0 -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.feature-nav::-webkit-scrollbar { width: 8px; }
.feature-nav::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: #fff;
  border-color: rgba(102, 114, 255, 0.25);
}
.nav-emoji { font-size: 15px; width: 20px; text-align: center; flex: none; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot {
  padding: 12px 10px 4px;
  font-size: 11px;
  color: var(--faint);
  border-top: 1px solid var(--border-soft);
}
/* Nav ausgrauen, solange kein Server gewählt ist */
.sidebar:not(.nav-ready) .feature-nav { opacity: 0.35; pointer-events: none; }

/* ── Inhalt ────────────────────────────────────────── */
.content { flex: 1; min-width: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 34px;
  background: rgba(10, 12, 17, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-title { display: flex; flex-direction: column; gap: 3px; }
.header-kicker { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.header-sub { font-size: 13px; color: var(--muted); }
.header-right { display: flex; gap: 12px; align-items: center; }

select, input, textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
select { cursor: pointer; }
select:hover, input:hover, textarea:hover { border-color: #333a49; }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface-3);
}
textarea { resize: vertical; width: 100%; line-height: 1.5; }
#guild-select { min-width: 190px; font-weight: 600; }

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: #333a49; }

/* ── Layout Hauptbereich ───────────────────────────── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 34px 34px 150px;
}
.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 100px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.placeholder-icon { font-size: 46px; opacity: 0.9; margin-bottom: 6px; }
.placeholder-title { font-size: 19px; font-weight: 700; color: var(--text); }
.placeholder-text { font-size: 14px; }

/* ── Karten ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  scroll-margin-top: 90px;
  transition: border-color 0.2s;
}
.card:hover { border-color: #313848; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 13px;
}
.card-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 19px;
  flex: none;
  border: 1px solid var(--border);
}
.card-title { line-height: 1.2; }
.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-body > label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.card-body label.check {
  flex-direction: row;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  padding: 2px 0;
}
.card-body label.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}
.row { display: flex; gap: 14px; }
.row label { flex: 1; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.6; }
.hint strong { color: var(--text); }
.hint code {
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--mono);
  color: #b9c0ff;
  border: 1px solid var(--border-soft);
}

.card.disabled { opacity: 0.7; }
.card.disabled .card-body { opacity: 0.45; pointer-events: none; }

/* ── Selbstrollen- / Autoresponder-Zeilen ──────────── */
.selfrole-row, .ar-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.selfrole-row .sr-role { flex: 2; min-width: 0; }
.selfrole-row .sr-label { flex: 2; min-width: 0; }
.selfrole-row .sr-emoji { width: 72px; flex: none; text-align: center; }
.selfrole-row .sr-remove, .ar-row .ar-remove { padding: 10px 13px; flex: none; }
.ar-row .ar-trigger { flex: 1; min-width: 0; }
.ar-row .ar-response { flex: 2; min-width: 0; }
#selfrole-add, #autoresponder-add, #ticket-type-add, #app-type-add { margin-top: 2px; align-self: flex-start; }

/* ── Arten-Editor (Tickets / Bewerbungen) ──────────── */
.sep { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }
.type-block {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.type-block label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.type-block textarea, .type-block select { font-weight: 400; color: var(--text); }
.type-head { display: flex; gap: 8px; align-items: center; }
.type-head .tt-emoji, .type-head .at-emoji { width: 64px; flex: none; text-align: center; font-size: 16px; }
.type-head .tt-name, .type-head .at-name { flex: 1; min-width: 0; font-weight: 600; }
.type-head .btn-ghost { flex: none; padding: 10px 13px; }

/* ── Toggle-Switch ─────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #3a404e;
  border-radius: 26px;
  transition: 0.25s;
}
.switch span::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.switch input:checked + span { background: linear-gradient(135deg, var(--green), var(--green-soft)); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ── Speicher-Leiste ───────────────────────────────── */
.save-bar {
  position: fixed;
  bottom: 24px;
  left: calc(50% + var(--sidebar-w) / 2);
  transform: translateX(-50%);
  width: min(720px, calc(100% - var(--sidebar-w) - 60px));
  background: rgba(25, 29, 39, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 14px 14px 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  z-index: 30;
  animation: slideUp 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.save-bar span { color: var(--text); font-size: 14px; font-weight: 500; }
#save-btn {
  background: linear-gradient(135deg, var(--green), var(--green-soft));
  color: #fff;
  border: none;
  padding: 11px 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 8px 20px -8px rgba(47, 182, 124, 0.6);
}
#save-btn:hover { filter: brightness(1.1); }
#save-btn:active { transform: scale(0.98); }
#save-btn:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

/* ── Responsiv ─────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .save-bar { left: 50%; width: min(720px, calc(100% - 40px)); }
  main { padding: 24px 18px 150px; }
  header { padding: 16px 18px; }
}
@media (max-width: 560px) {
  .row { flex-direction: column; }
  header { flex-direction: column; gap: 12px; align-items: stretch; }
  .header-right { flex-wrap: wrap; }
  #guild-select { flex: 1; }
  .selfrole-row, .ar-row { flex-wrap: wrap; }
}

/* ── Primär-Button (Bots) ──────────────────────────── */
.btn-primary {
  background: linear-gradient(140deg, var(--accent), #8a5cff);
  border: none;
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 8px 20px -10px rgba(102, 114, 255, 0.7);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 520px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; }

.bots-list { display: flex; flex-direction: column; gap: 10px; }
.bots-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px; }
.bot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.bot-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.bot-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bot-dot.off { background: var(--faint); }
.bot-info { flex: 1; min-width: 0; }
.bot-name { font-weight: 700; font-size: 14px; }
.bot-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }

.bot-add {
  border-top: 1px solid var(--border-soft);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bot-add h3 { margin: 0; font-size: 15px; font-weight: 700; }
.bot-add-status { font-size: 13px; color: var(--muted); min-height: 18px; }
