/* Multibot Dashboard — Discord-artiges Dark Theme, Vanilla CSS, keine externen Ressourcen. */

:root {
  --bg-deepest: #1e1f22;
  --bg-deep: #2b2d31;
  --bg-base: #313338;
  --bg-hover: #383a40;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --gold: #f0b232;
  --text: #f2f3f5;
  --text-muted: #b5bac1;
  --text-faint: #949ba4;
  --border: #3f4147;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg-base);
  color: var(--text);
  font-family: "gg sans", "Segoe UI", "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button { font-family: inherit; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  background: var(--bg-deepest);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: flex;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.lang-switch button:hover { color: var(--text); }

.lang-switch button.active {
  background: var(--accent);
  color: #fff;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.user-box img,
.user-box .avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}

.user-box a {
  color: var(--text-faint);
  text-decoration: none;
  font-size: 12px;
}

.user-box a:hover { color: var(--text); text-decoration: underline; }

.user-name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------------------------------------------- app */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 13px; }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

/* ------------------------------------------------------------------ login */
.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}

.login-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card .brand-logo {
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
}

.login-card p {
  color: var(--text-muted);
  margin: 8px 0 24px;
}

.login-error {
  background: rgba(242, 63, 67, 0.12);
  border: 1px solid rgba(242, 63, 67, 0.5);
  color: #fca7a9;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

/* ----------------------------------------------------------------- guilds */
.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.guild-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  width: 100%;
}

.guild-card:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.guild-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.guild-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  overflow: hidden;
}

.guild-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.guild-card-body { min-width: 0; }

.guild-card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guild-card-sub {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------- guild view */
.guild-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.sidebar {
  width: 240px;
  flex: 0 0 auto;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  position: sticky;
  top: 76px;
}

.sidebar-guild {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  min-width: 0;
}

.sidebar-guild .guild-icon { width: 36px; height: 36px; font-size: 14px; }

.sidebar-guild-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 8px 6px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item .star { margin-left: auto; }

.sidebar-back { margin-top: 12px; width: 100%; }

.main-panel {
  flex: 1 1 auto;
  min-width: 0;
}

.panel-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.panel-head {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ------------------------------------------------------------------ forms */
.field {
  padding: 14px 0;
  border-bottom: 1px solid rgba(63, 65, 71, 0.6);
}

.field:last-of-type { border-bottom: 0; }

.field-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field-label {
  font-weight: 600;
  font-size: 14.5px;
}

.field-help {
  color: var(--text-faint);
  font-size: 13px;
  margin: 3px 0 8px;
}

.field.locked { opacity: 0.62; }

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(240, 178, 50, 0.14);
  border: 1px solid rgba(240, 178, 50, 0.45);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 8px;
}

.locked-hint {
  color: var(--gold);
  font-size: 12.5px;
  margin-top: 6px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  max-width: 480px;
  background: var(--bg-deepest);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

textarea { resize: vertical; min-height: 88px; }

input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--accent);
}

input:disabled, textarea:disabled, select:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

select { cursor: pointer; }
select:disabled { cursor: not-allowed; }

/* toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: #80848e;
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { cursor: not-allowed; opacity: 0.6; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* tag editor (stringlist) */
.tag-editor {
  max-width: 480px;
  background: var(--bg-deepest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-editor.disabled { opacity: 0.7; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  font-size: 13px;
  max-width: 100%;
}

.tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.tag button {
  border: 0;
  background: var(--bg-hover);
  color: var(--text-muted);
  width: 17px;
  height: 17px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tag button:hover { background: var(--red); color: #fff; }

.tag-editor input {
  flex: 1 1 120px;
  min-width: 120px;
  border: 0;
  background: transparent;
  padding: 5px 6px;
  max-width: none;
}

.tag-editor input:focus-visible { border: 0; outline: none; }

/* save bar */
.save-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- premium */
.tier-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: var(--bg-deepest);
}

.tier-banner.premium {
  border-color: rgba(240, 178, 50, 0.5);
  background: rgba(240, 178, 50, 0.08);
}

.tier-pill {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 12px;
  background: var(--bg-hover);
  color: var(--text-muted);
  flex: 0 0 auto;
}

.tier-pill.premium { background: var(--gold); color: #2b2100; }

.compare-wrap { overflow-x: auto; }

.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 420px;
}

.compare th, .compare td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.compare th {
  color: var(--text-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compare td:nth-child(2), .compare th:nth-child(2),
.compare td:nth-child(3), .compare th:nth-child(3) {
  text-align: center;
  white-space: nowrap;
}

.compare .col-premium { color: var(--gold); font-weight: 600; }

.upgrade-hint {
  margin-top: 18px;
  background: var(--bg-deepest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Stripe-Kauf-Button — nur sichtbar wenn Stripe konfiguriert + Free-Tarif */
.subscribe-cta { margin: -4px 0 24px; }

.btn-premium {
  background: var(--gold);
  color: #2b2100;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(240, 178, 50, 0.28);
}

.btn-premium:hover { background: #f7c14e; }

/* --------------------------------------------------------------- commands */
.nav-slash {
  font-weight: 700;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  color: var(--text-faint);
  flex: 0 0 auto;
}

.nav-item.active .nav-slash { color: #fff; }

.commands-intro {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 6px;
}

.commands-counter {
  color: var(--text-faint);
  font-size: 12.5px;
  margin-bottom: 6px;
}

.command-group { margin-top: 20px; }

.command-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.command-group-head h3 {
  margin: 0;
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn-mini {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-mini:hover { background: var(--bg-hover); color: var(--text); }

.command-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(63, 65, 71, 0.6);
}

.command-row:last-child { border-bottom: 0; }

.command-row .switch { margin-top: 1px; }

.command-info { min-width: 0; flex: 1 1 auto; }

.command-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cmd-name {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  background: var(--bg-deepest);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  color: var(--text);
}

.command-name-line .star,
.command-name-line .protected-hint {
  font-size: 13px;
  cursor: help;
}

.command-desc {
  color: var(--text-faint);
  font-size: 13px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* Editierbares Namensfeld in Code-Optik (wie .cmd-name, nur als Input) */
.cmd-name-edit {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: var(--bg-deepest);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px 1px 8px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  transition: border-color 0.15s ease;
}

.cmd-name-edit:focus-within { border-color: var(--accent); }
.cmd-name-edit.invalid { border-color: var(--red); }

.cmd-name-edit .cmd-slash {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}

.cmd-name-edit input[type="text"].cmd-name-input {
  width: 8ch;
  max-width: 100%;
  min-width: 4ch;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 2px 1px;
}

.cmd-name-edit input[type="text"].cmd-name-input:focus-visible { border: 0; outline: none; }

.cmd-name-hint {
  color: var(--red);
  font-size: 12px;
  margin-top: 3px;
}

.cmd-alias-note {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 3px;
}

/* display:flex würde das hidden-Attribut aushebeln → explizit ausblenden */
.cmd-alias-note[hidden],
.cmd-name-hint[hidden] { display: none; }

.cmd-alias-reset {
  border: 0;
  background: var(--bg-hover);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}

.cmd-alias-reset:hover { background: var(--red); color: #fff; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--bg-deepest);
  border: 1px solid var(--green);
  color: var(--text);
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(92vw, 480px);
}

.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--border); }

/* ---------------------------------------------------------------- loading */
.loading {
  color: var(--text-faint);
  text-align: center;
  padding: 48px 0;
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 820px) {
  .guild-layout { flex-direction: column; }

  .sidebar {
    position: static;
    width: 100%;
  }

  .app { padding: 16px 10px 80px; }
  .panel-card { padding: 16px; }
  input[type="text"], input[type="number"], textarea, select, .tag-editor { max-width: none; }
  .subscribe-cta .btn { width: 100%; }
}

@media (max-width: 480px) {
  .brand-title { font-size: 14px; }
  .user-name { display: none; }
}
