/* ===== Tokens ===== */
:root {
  --bg: #0F1115;
  --surface: #171a21;
  --surface-alt: #1f232c;
  --border: #2a2f3a;
  --text: #E7E9EE;
  --text-dim: #9aa1ad;
  --accent: #FFB454;
  --accent-dim: #7c5a26;
  --success: #6FCF97;
  --danger: #EB5757;
  --radius: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 .4em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ===== Layout ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.user-chip img {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border);
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 61px);
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ===== Sidebar / module rack ===== */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px 14px;
}

.sidebar .server-name {
  font-family: var(--font-display);
  font-size: 16px;
  padding: 0 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.rack-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
  transition: background .15s ease, color .15s ease;
}

.rack-item:hover { background: var(--surface-alt); color: var(--text); }
.rack-item.active { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

.led {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
  background: #4b5160;
}
.led.on { background: var(--success); box-shadow: 0 0 6px var(--success); }
.led.warn { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.rack-item .module-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #565d6b;
  margin-left: auto;
}

/* ===== Main content ===== */
.content { padding: 32px 36px; max-width: 880px; }

.module-header { margin-bottom: 28px; }
.module-header .eyebrow { display: block; margin-bottom: 6px; }
.module-header p { color: var(--text-dim); margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h3 { font-size: 15px; margin-bottom: 16px; }

/* ===== Forms ===== */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: #6b7280; margin-top: 5px; }

input[type=text], input[type=number], textarea, select {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
}

textarea { min-height: 90px; resize: vertical; font-family: var(--font-mono); }

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

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.toggle-row .label { font-size: 14px; }
.toggle-row .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.switch {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.switch input:checked + .slider { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .slider::before { background: var(--accent); transform: translate(18px, -50%); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: #3a4150; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1a1306; font-weight: 600; }
.btn-accent:hover { background: #ffc473; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(235,87,87,.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Tables / lists ===== */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface-alt);
}
.list-row .name { font-weight: 600; }
.list-row .meta { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); }
.list-row .actions { display: flex; gap: 8px; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag.success { color: var(--success); border-color: var(--success); }

.info-note {
  background: rgba(255, 180, 84, .08);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ===== Server grid (home) ===== */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 32px 36px;
}
.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s ease, transform .15s ease;
}
.server-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.server-card img {
  width: 48px; height: 48px; border-radius: 50%;
  margin-bottom: 14px; border: 1px solid var(--border);
}
.server-card .server-card-name { font-family: var(--font-display); font-size: 15px; }

/* ===== Login page ===== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  text-align: center;
}
.login-shell .dot-grid {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.login-shell .dot-grid span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--border);
}
.login-shell .dot-grid span:nth-child(2) { background: var(--accent); }
.login-shell h1 { font-size: 28px; }
.login-shell p { color: var(--text-dim); max-width: 360px; }

.flash {
  background: rgba(235,87,87,.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
}

/* ===== Aperçu d'embed façon Discord ===== */
.preview-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.discord-preview {
  background: #313338;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 12px;
  position: sticky;
  top: 24px;
}

.discord-preview-bar {
  width: 4px;
  border-radius: 4px;
  background: #5865F2;
  flex-shrink: 0;
}

.discord-preview-body { min-width: 0; flex: 1; }

.discord-preview-title {
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.discord-preview-desc {
  color: #dbdee1;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.discord-preview-image {
  margin-top: 10px;
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  display: none;
  object-fit: cover;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-row input[type=color] {
  width: 44px; height: 36px;
  padding: 2px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.color-row code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.form-with-preview {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) {
  .form-with-preview { grid-template-columns: 1fr; }
  .discord-preview { position: static; }
}

.placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.placeholder-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--accent);
  background: var(--surface-alt);
}

/* ===== Auto-rôles : arbre de catégories ===== */
.autorole-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.autorole-toolbar form { margin: 0; }

.autorole-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.autorole-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  padding-left: calc(14px + min(var(--depth), 20) * 22px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  position: relative;
}

.autorole-node::before {
  content: "";
  position: absolute;
  left: calc(14px + min(var(--depth), 20) * 22px - 12px);
  top: 0;
  bottom: 0;
  border-left: 1px solid #343a47;
  opacity: calc(min(var(--depth), 1));
}

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

.autorole-node-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  flex-shrink: 0;
}

.autorole-node .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.autorole-node form { margin: 0; }

@media (max-width: 800px) {
  .autorole-node {
    align-items: flex-start;
    flex-direction: column;
    padding-left: calc(12px + min(var(--depth), 8) * 12px);
  }
  .autorole-node .actions { width: 100%; }
}

/* ===== Profil du bot par serveur ===== */
.bot-profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.bot-profile-preview-card {
  position: sticky;
  top: 20px;
}

.bot-profile-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

.bot-profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 76px;
  background: #171a20;
}

.bot-profile-name {
  color: #f4f5f7;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.bot-badge {
  display: inline-flex;
  align-items: center;
  min-height: 17px;
  padding: 0 4px;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  vertical-align: 2px;
}

.bot-profile-current {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.bot-profile-form h3:not(:first-child) {
  margin-top: 24px;
}

.bot-profile-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 0 0;
  color: var(--text);
  cursor: pointer;
}

.bot-profile-check input {
  width: auto;
  margin-top: 2px;
}

.bot-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.bot-profile-reset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
}

.bot-profile-reset h3,
.bot-profile-reset p {
  margin-top: 0;
}

.bot-profile-reset p {
  margin-bottom: 0;
}

.bot-profile-error {
  border-color: #6f3030;
}

@media (max-width: 900px) {
  .bot-profile-layout {
    grid-template-columns: 1fr;
  }

  .bot-profile-preview-card {
    position: static;
  }

  .bot-profile-reset {
    align-items: flex-start;
    flex-direction: column;
  }
}
