/* BotFactory2 - Apple-inspiriertes Design, hell und dunkel.
   Alles ohne externe Abhaengigkeiten: keine Webfonts, keine Frameworks. */

:root {
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9f0a;

  --bg: #f5f5f7;
  --bg-grad-a: #eef1f7;
  --bg-grad-b: #f8f6f4;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: rgba(0, 0, 0, 0.035);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 16px 40px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1), 0 32px 80px rgba(0, 0, 0, 0.14);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "Inter", system-ui, sans-serif;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-grad-a: #10131a;
    --bg-grad-b: #1a1420;
    --surface: rgba(28, 28, 30, 0.72);
    --surface-solid: #1c1c1e;
    --surface-2: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --accent: #0a84ff;
    --accent-hover: #339cff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-grad-a: #10131a;
  --bg-grad-b: #1a1420;
  --surface: rgba(28, 28, 30, 0.72);
  --surface-solid: #1c1c1e;
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #0a84ff;
  --accent-hover: #339cff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

/* Weiche Farbverlaeufe im Hintergrund - typisch Apple. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60rem 40rem at 12% -10%, var(--bg-grad-a), transparent 60%),
    radial-gradient(50rem 36rem at 95% 0%, var(--bg-grad-b), transparent 55%),
    var(--bg);
}

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

h1, h2, h3 { letter-spacing: -0.02em; margin: 0 0 0.4em; font-weight: 650; }
h1 { font-size: 2rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }

/* --- Kopfzeile ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  font-size: 1.05rem;
}
.brand svg { width: 24px; height: 24px; }

.topnav { display: flex; gap: 0.25rem; margin-left: 0.75rem; flex-wrap: wrap; }
.topnav a {
  padding: 0.35rem 0.75rem;
  border-radius: 980px;
  color: var(--text-2);
  font-size: 0.9rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }

.spacer { flex: 1; }

.userchip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  border-radius: 980px;
  background: var(--surface-2);
  font-size: 0.88rem;
}
.userchip img { width: 26px; height: 26px; border-radius: 50%; }

/* --- Layout -------------------------------------------------------------- */

.wrap { max-width: 1120px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.wrap.wide { max-width: 1400px; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0; }

.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 0.35rem; }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }

/* --- Karten -------------------------------------------------------------- */

.card {
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card.hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card-head h2, .card-head h3 { margin: 0; }

.stat { text-align: left; }
.stat .value {
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat .label { color: var(--text-2); font-size: 0.85rem; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 980px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease),
    opacity 0.2s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--border); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #ff5147; }
.btn.success { background: var(--green); }
.btn.small { padding: 0.32rem 0.8rem; font-size: 0.83rem; }
.btn.block { width: 100%; }

/* --- Formulare ----------------------------------------------------------- */

label { display: block; font-size: 0.88rem; font-weight: 550; margin-bottom: 0.35rem; }
.field { margin-bottom: 1.1rem; }
.field .hint { color: var(--text-2); font-size: 0.82rem; margin-top: 0.35rem; }

input[type="text"], input[type="password"], input[type="search"],
textarea, select {
  width: 100%;
  padding: 0.62rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
select { appearance: none; padding-right: 2rem; background-image: none; }

.switch { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 46px; height: 28px; border-radius: 980px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.25s var(--ease);
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 980px;
  border: 1px solid var(--border);
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.9rem;
  border-radius: 980px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.segmented button.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.7rem;
  border-radius: 980px;
  font-size: 0.78rem;
  font-weight: 550;
  background: var(--surface-2);
  color: var(--text-2);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.on { background: rgba(52, 199, 89, 0.15); color: #248a3d; }
.badge.off { background: var(--surface-2); color: var(--text-3); }
.badge.warn { background: rgba(255, 159, 10, 0.16); color: #b26b00; }
.badge.err { background: rgba(255, 59, 48, 0.15); color: var(--red); }
:root[data-theme="dark"] .badge.on { color: #30d158; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.on { color: #30d158; }
  :root:not([data-theme="light"]) .badge.warn { color: #ffd60a; }
}
.badge.on .dot { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* --- Tabellen ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left;
  font-weight: 550;
  color: var(--text-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

/* --- Konsole / Logs ------------------------------------------------------ */

.console {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  background: #0b0d10;
  color: #d6dae0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scroll-behavior: smooth;
}
.console.tall { height: 60vh; }
.console::-webkit-scrollbar { width: 10px; }
.console::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
}

/* --- KI-Chat ------------------------------------------------------------- */

.chat { display: flex; flex-direction: column; gap: 0.9rem; max-height: 55vh; overflow-y: auto; padding-right: 0.3rem; }
.msg { display: flex; gap: 0.7rem; animation: rise 0.35s var(--ease); }
.msg .bubble {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  max-width: min(46rem, 88%);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.ai .bubble { border-bottom-left-radius: 6px; }
.msg .who {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.thinking { display: inline-flex; gap: 4px; align-items: center; }
.thinking i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: bounce 1.2s infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.prompt-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 980px;
  padding: 0.28rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chip:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.filechange {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-top: 0.3rem;
}
.filechange.bad { background: rgba(255, 59, 48, 0.12); color: var(--red); }
.filechange.good { color: var(--text-2); }

/* --- Dateimanager -------------------------------------------------------- */

.fm { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 900px) { .fm { grid-template-columns: 1fr; } }

.filelist { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.filelist li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s var(--ease);
}
.filelist li:hover { background: var(--surface-2); }
.filelist li.active { background: var(--accent-soft); color: var(--accent); }
.filelist .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .size { color: var(--text-3); font-size: 0.75rem; }
.filelist svg { width: 16px; height: 16px; flex: none; color: var(--text-3); }
.filelist li.active svg { color: var(--accent); }

.crumbs { display: flex; gap: 0.3rem; align-items: center; font-size: 0.85rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.crumbs button {
  background: none; border: none; font: inherit; color: var(--accent);
  cursor: pointer; padding: 0.1rem 0.2rem; border-radius: 6px;
}
.crumbs span { color: var(--text-3); }

.editor-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.editor-wrap {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0b0d10;
}
.editor-wrap pre, .editor-wrap textarea {
  margin: 0;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  border: 0;
}
.editor-wrap pre {
  pointer-events: none;
  color: #d6dae0;
  min-height: 55vh;
  overflow: auto;
}
.editor-wrap textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  overflow: auto;
}
.editor-wrap textarea:focus { outline: none; box-shadow: none; border: 0; }

/* Syntax-Highlighting */
.tok-kw { color: #ff7ab2; }
.tok-str { color: #8fd88f; }
.tok-com { color: #6c7a89; font-style: italic; }
.tok-num { color: #d0a0ff; }
.tok-fn { color: #7bc8ff; }
.tok-dec { color: #ffc46b; }

/* --- Terminal ------------------------------------------------------------ */

.term {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.45;
  background: #0b0d10;
  color: #d6dae0;
  border-radius: var(--radius);
  padding: 1rem;
  height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.term-input {
  display: flex; gap: 0.5rem; margin-top: 0.7rem; align-items: center;
}
.term-input span { font-family: var(--mono); color: var(--text-2); }
.term-input input { font-family: var(--mono); }

/* --- Toasts -------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}
.toast {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  max-width: 24rem;
  animation: slidein 0.35s var(--ease);
}
.toast.err { border-color: rgba(255, 59, 48, 0.4); }
.toast.ok { border-color: rgba(52, 199, 89, 0.4); }
@keyframes slidein {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* --- Dialog -------------------------------------------------------------- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: 30rem;
  width: calc(100% - 2rem);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); }

/* --- Login --------------------------------------------------------------- */

.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  text-align: center;
}
.hero .card { max-width: 28rem; padding: 2.5rem 2rem; animation: rise 0.6s var(--ease); }
.hero h1 { font-size: 2.4rem; margin-bottom: 0.4rem; }
.hero .logo {
  width: 68px; height: 68px; margin: 0 auto 1.2rem;
  display: grid; place-items: center;
  border-radius: 20px;
  background: linear-gradient(140deg, var(--accent), #8a5cf6);
  box-shadow: var(--shadow);
}
.hero .logo svg { width: 36px; height: 36px; color: #fff; }
.btn.discord { background: #5865f2; }
.btn.discord:hover { background: #6b76f5; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs button {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text-2);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane { display: none; animation: rise 0.3s var(--ease); }
.tabpane.active { display: block; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.2rem; font-size: 0.9rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 0.85rem; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}
pre code { display: block; padding: 0.9rem 1rem; overflow-x: auto; background: var(--surface-2); }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.4rem 0; }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-2);
}
.empty svg { width: 44px; height: 44px; color: var(--text-3); margin-bottom: 0.8rem; }

@media (max-width: 640px) {
  .wrap { padding: 1.2rem 1rem 3rem; }
  .topbar { padding: 0.55rem 0.9rem; }
  .topnav { margin-left: 0; }
  .userchip span { display: none; }
  h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
