/* DA Forge : noir + braise rouge néon. Page de test minimaliste. */
:root {
  --bg: #0c0c0e;
  --card: #16161a;
  --border: #2a2a30;
  --text: #ececf0;
  --muted: #9a9aa5;
  --ember: #ff3b2f;
  --ok: #2ecc71;
  --warn: #f1c40f;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over element display rules below
   (e.g. `.btn { display: block }`), otherwise JS toggling `el.hidden` has no
   visible effect and elements like the "request license" button stay shown. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1c0f0e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 0 0 1px rgba(255, 59, 47, 0.06), 0 24px 60px rgba(0, 0, 0, 0.5);
}

h1 { margin: 0; font-size: 28px; }
.subtitle { margin: 4px 0 24px; color: var(--muted); font-size: 14px; }

#g_id_signin { margin-top: 16px; }

.profile { display: grid; gap: 10px; margin-bottom: 20px; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.row span { color: var(--muted); font-size: 13px; }
.row strong { font-weight: 600; text-align: right; }

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.banner.ok { border-color: rgba(46, 204, 113, 0.4); color: var(--ok); background: rgba(46, 204, 113, 0.08); }
.banner.warn { border-color: rgba(241, 196, 15, 0.4); color: var(--warn); background: rgba(241, 196, 15, 0.08); }

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  background: var(--ember);
  color: #fff;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }

.error {
  margin-top: 16px;
  color: var(--ember);
  font-size: 13px;
}

.setup {
  border: 1px solid rgba(241, 196, 15, 0.4);
  background: rgba(241, 196, 15, 0.06);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}
.setup strong { color: var(--warn); }
.setup ol { margin: 8px 0 0; padding-left: 18px; }
.setup li { margin-bottom: 4px; }
.setup code {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.setup .hint { color: var(--muted); margin: 10px 0 0; }

/* ── Console d'administration (admin.html) ──────────────────────────────── */
/* Full-page layout once signed in: the login view keeps the centered card,
   but the console itself fills the whole viewport instead of looking like a
   modal. `console-open` is toggled on <body> by admin.js. */
body.console-open {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}
.admin-card {
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 24px 32px;
}
/* The tables grow with the page; keep them scrolling inside the view. */
.admin-card #users-panel,
.admin-card #admins-panel { flex: 1; min-height: 0; }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
.admin-header h1 { font-size: 22px; }
.admin-header .subtitle { margin-bottom: 0; }
.admin-header-actions { display: flex; gap: 8px; }

/* Compact inline buttons (the base .btn is a full-width block). */
.btn.small {
  display: inline-block;
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 0;
}
.btn.danger {
  background: transparent;
  border: 1px solid rgba(255, 59, 47, 0.5);
  color: var(--ember);
}
.btn:disabled { opacity: 0.5; cursor: wait; filter: none; }

.banner.err {
  border-color: rgba(255, 59, 47, 0.4);
  color: var(--ember);
  background: rgba(255, 59, 47, 0.08);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--ember); }

.table-scroll { overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cell-muted { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(46, 204, 113, 0.4); background: rgba(46, 204, 113, 0.08); }
.badge.warn { color: var(--warn); border-color: rgba(241, 196, 15, 0.4); background: rgba(241, 196, 15, 0.08); }
.badge.err { color: var(--ember); border-color: rgba(255, 59, 47, 0.4); background: rgba(255, 59, 47, 0.08); }
.badge.off { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions select {
  background: #000;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
}

/* Creation row pinned at the top of the users table. */
.user-add { display: flex; gap: 8px; }
.user-add select {
  background: #000;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  max-width: 260px;
}
/* ─── MCP tab: catalog / distribution sub-views ────────────────────────────── */
/* Pill-style secondary tabs, visually lighter than the main tab bar. */
.subtabs { display: flex; gap: 8px; margin-bottom: 16px; }
.subtab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.subtab.active { color: var(--text); border-color: var(--ember); }

/* Distribution view: two clearly-titled blocks (every workspace / one). */
.dist-block { margin-bottom: 26px; }
.dist-title { font-size: 15px; margin: 0 0 4px; }
.dist-sub { margin: 0 0 10px; max-width: 640px; }
#mcp-dist-view .user-add { margin-bottom: 10px; }

/* Workspace rows unfold their MCP editor in place (accordion). */
.ws-row { cursor: pointer; }
.ws-row:hover td { background: rgba(255, 255, 255, 0.03); }
.ws-row.open td { background: rgba(255, 255, 255, 0.04); }
.ws-caret { display: inline-block; width: 14px; color: var(--muted); }
.ws-mcp-summary { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-detail-row td.ws-detail-cell {
  padding: 14px 12px 18px 26px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--ember);
}
#ws-mcp-editor .user-add { margin-bottom: 10px; }

/* Catalog "Distribué" column: badges may stack (common + per-workspace). */
.badge-stack { display: flex; flex-wrap: wrap; gap: 4px; }
.user-add input {
  flex: 1;
  max-width: 460px;
  background: #000;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.admin-add { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-add input {
  flex: 1;
  background: #000;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}

/* ─── MCP library tab ────────────────────────────────────────────────────── */
.mcp-toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.mcp-toolbar .subtitle { margin: 0; max-width: 640px; }

.mcp-form {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcp-form h2 { margin: 0; font-size: 15px; }
.mcp-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.mcp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.mcp-form label.mcp-f-check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.mcp-form input[type="text"],
.mcp-form textarea {
  background: #000;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}
.mcp-form textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; resize: vertical; }
.mcp-form input:disabled { opacity: 0.6; }
