/* Launch Your Project — thèmes clair / sombre / système + layout sidebar + responsive */

/* ----- Variables : mode clair (défaut) ----- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --bg-elevated: #ffffff;
  --fg: #14151a;
  --muted: #5c5f6b;
  --border: #d8dae3;
  --sidebar-bg: #1e293b;
  --sidebar-fg: #f1f5f9;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: #334155;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --error: #b91c1c;
  --notice: #0369a1;
  --shadow: rgba(15, 23, 42, 0.08);
}

/* ----- Mode sombre explicite ----- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-elevated: #181b26;
  --fg: #eef0f7;
  --muted: #9ca3b8;
  --border: #2d3348;
  --sidebar-bg: #0c0e14;
  --sidebar-fg: #f1f5f9;
  --sidebar-muted: #8b95a8;
  --sidebar-hover: #252a3a;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --error: #f87171;
  --notice: #38bdf8;
  --shadow: rgba(0, 0, 0, 0.35);
}

/* ----- Thème « système » : suit le réglage OS ----- */
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    color-scheme: light;
    --bg: #f4f5f8;
    --bg-elevated: #ffffff;
    --fg: #14151a;
    --muted: #5c5f6b;
    --border: #d8dae3;
    --sidebar-bg: #1e293b;
    --sidebar-fg: #f1f5f9;
    --sidebar-muted: #94a3b8;
    --sidebar-hover: #334155;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --error: #b91c1c;
    --notice: #0369a1;
    --shadow: rgba(15, 23, 42, 0.08);
  }
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    color-scheme: dark;
    --bg: #0f1117;
    --bg-elevated: #181b26;
    --fg: #eef0f7;
    --muted: #9ca3b8;
    --border: #2d3348;
    --sidebar-bg: #0c0e14;
    --sidebar-fg: #f1f5f9;
    --sidebar-muted: #8b95a8;
    --sidebar-hover: #252a3a;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --error: #f87171;
    --notice: #38bdf8;
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}

/* ========== App : sidebar gauche ========== */
.landing-block {
  margin: 2rem 0;
  max-width: 44rem;
}
.landing-block-title-full {
  grid-column: 1 / -1;
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.landing-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
.landing-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.layout-app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  border-right: 1px solid var(--border);
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem 0;
  overflow-y: auto;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 1.25rem 0.85rem;
}

.sidebar-brand-row .sidebar-logo {
  padding: 0;
  flex: 1;
  min-width: 0;
}

.sidebar-avatar img {
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.18);
  display: block;
}

.sidebar-logo {
  display: block;
  padding: 0 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sidebar-fg) !important;
  text-decoration: none;
}

.sidebar-inner > .sidebar-brand-row + .sidebar-nav {
  padding-top: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
  flex: 1;
}

.sidebar-link {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--sidebar-fg) !important;
  text-decoration: none;
  font-size: 0.95rem;
}

.sidebar-link:hover,
.sidebar-link:focus-visible {
  background: var(--sidebar-hover);
  outline: none;
}

.sidebar-link--muted {
  color: var(--sidebar-muted) !important;
  font-size: 0.875rem;
}

/* Bloc « Mes projets » + favoris imbriqués */
.sidebar-nav-group--projects {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0.25rem;
}

.sidebar-favorites {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.25rem 0 0;
  padding: 0.35rem 0 0.35rem 0.65rem;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.sidebar-link--favorite {
  font-size: 0.88rem;
  padding-left: 1.1rem;
  position: relative;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link--favorite::before {
  content: "★";
  position: absolute;
  left: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  opacity: 0.85;
  color: #fbbf24;
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

.sidebar-prefs {
  display: flex;
  flex-direction: column;
}

.sidebar-theme-label {
  display: block;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin-bottom: 0.35rem;
}

.sidebar-theme-select {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--sidebar-hover);
  color: var(--sidebar-fg);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.app-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

.app-main {
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* Parcours module : pleine largeur de la zone principale */
.app-main:has(.workspace-shell) {
  max-width: none;
  width: 100%;
  margin: 0;
  padding-left: clamp(1rem, 2vw, 2rem);
  padding-right: clamp(1rem, 2vw, 2rem);
}

/* Édition module : hauteur fixée à la fenêtre, pas de scroll sur la page (scroll dans colonnes) */
body.layout-app:has(.workspace-shell > form.workspace-form) {
  height: 100vh;
  overflow: hidden;
}

body.layout-app:has(.workspace-shell > form.workspace-form) .app-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-main:has(.workspace-shell > form.workspace-form) {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

/* Bouton menu mobile */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 250;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  align-items: center;
  justify-content: center;
}

.sidebar-toggle::before {
  content: "";
  width: 20px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.45);
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

@media (max-width: 900px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px var(--shadow);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-content {
    margin-left: 0;
    padding-top: 0;
  }

  .app-main {
    padding-top: 3.5rem;
  }

  /* Petit écran : la page peut défiler (en-tête + colonnes empilées) */
  body.layout-app:has(.workspace-shell > form.workspace-form) {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  body.layout-app:has(.workspace-shell > form.workspace-form) .app-content {
    overflow: visible;
    display: block;
    flex: none;
    min-height: 0;
  }

  .app-main:has(.workspace-shell > form.workspace-form) {
    overflow: visible;
    display: block;
    flex: none;
    min-height: 0;
  }

  .workspace-shell:has(> form.workspace-form) {
    overflow: visible;
    display: block;
    flex: none;
    min-height: 0;
  }

  .workspace-shell > form.workspace-form {
    overflow: visible;
    display: block;
    flex: none;
    min-height: 0;
  }
}

/* ========== Pages publiques (sans compte) ========== */
.layout-public .public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.public-logo {
  font-weight: 700;
  color: var(--fg) !important;
  text-decoration: none;
}

.public-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.public-nav a {
  color: var(--accent);
  text-decoration: none;
}

.public-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

@media (max-width: 480px) {
  .public-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ----- Composants ----- */
.hero { text-align: center; padding: 2rem 0; }
.lead { font-size: 1.15rem; color: var(--muted); }
.grid { display: grid; gap: 1rem; }

@media (min-width: 600px) {
  .modules-preview { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .modules-preview { grid-template-columns: repeat(3, 1fr); }
}

.modules-preview article {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
}
.btn:hover { background: var(--accent-hover); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.1rem; }
.btn-secondary { background: var(--muted); }
.btn-primary {
  background: var(--accent);
}
.btn-danger {
  background: #b91c1c;
}
.btn-danger:hover {
  background: #991b1b;
}
.btn-muted {
  background: var(--border);
  color: var(--fg) !important;
}
.btn-muted:hover {
  filter: brightness(0.95);
}
[data-theme="dark"] .btn-muted {
  color: var(--fg) !important;
}

.form label { display: block; margin-bottom: 1rem; }
.form input, .form textarea, .form select {
  width: 100%;
  max-width: 520px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--fg);
}

.inline-form {
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.error { color: var(--error); }
.notice { color: var(--notice); }
.muted { color: var(--muted); font-size: 0.9rem; }

.project-list { list-style: none; padding: 0; }
.project-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.project-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.project-list-item .project-favorite-form {
  flex-shrink: 0;
  margin: 0;
}
.project-favorite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fbbf24;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.project-favorite-btn:hover,
.project-favorite-btn:focus-visible {
  background: color-mix(in srgb, #fbbf24 18%, transparent);
  outline: none;
}
.project-list-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}
.project-list-item .project-delete-form {
  margin-left: auto;
}
.project-danger-zone {
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.modules-grid {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}
@media (min-width: 640px) {
  .modules-grid { grid-template-columns: repeat(2, 1fr); }
}

.module-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px var(--shadow);
}
.module-card .status { font-size: 0.85rem; text-transform: capitalize; }

.conversation {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 10px;
  margin: 1rem 0;
  background: var(--bg-elevated);
}
.msg { margin-bottom: 1rem; }
.msg.user { border-left: 3px solid var(--accent); padding-left: 0.5rem; }
.msg.assistant { border-left: 3px solid var(--muted); padding-left: 0.5rem; }

.breadcrumb { font-size: 0.9rem; margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); }

#chat-messages {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
  font-size: 0.95rem;
  background: var(--bg-elevated);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

.table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

.exports {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ----- Admin : onglets ----- */
.admin-page-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1.25rem;
  padding: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.nav-tab {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.nav-tab:hover {
  color: var(--fg);
  background: var(--bg);
}

.nav-tab.is-active {
  color: var(--fg);
  background: var(--bg);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}

.tab-panel {
  padding: 0.25rem 0 1.5rem;
}

.tab-panel h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.admin-alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.admin-alert--ok {
  background: rgba(5, 150, 105, 0.12);
  color: var(--notice);
}
.admin-alert--err {
  background: rgba(185, 28, 28, 0.1);
  color: var(--error);
}
.admin-alert--notice {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ----- Admin : statistiques ----- */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.admin-stat-card {
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.admin-stat-card__label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.admin-stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ----- Page compte RGPD ----- */
.account-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.account-section:last-of-type {
  border-bottom: none;
}

/* ----- Admin : plans en tuiles + utilisateurs ----- */
.admin-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.admin-lead {
  margin: 0 0 1.25rem;
  max-width: 52rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.admin-subsection-title {
  margin: 2rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.admin-form-narrow {
  max-width: 36rem;
}

.admin-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.admin-plan-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.admin-plan-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--shadow);
}

.admin-plan-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.admin-plan-card__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  max-width: 60%;
}
.admin-pill--notice {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
}
[data-theme="dark"] .admin-pill--notice {
  background: rgba(96, 165, 250, 0.15);
}
.admin-plan-card__code {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.admin-plan-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}
.admin-plan-card__desc {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
  flex: 1;
}
.admin-plan-card__stats {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.82rem;
}
.admin-plan-card__stats li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.admin-plan-card__stats span {
  color: var(--muted);
  font-size: 0.75rem;
}
.admin-plan-card__stats strong {
  font-size: 0.9rem;
}
.admin-plan-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.admin-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-pill--ok {
  background: rgba(5, 150, 105, 0.15);
  color: var(--notice);
}
.admin-pill--warn {
  background: rgba(180, 83, 9, 0.15);
  color: #b45309;
}
[data-theme="dark"] .admin-pill--warn {
  color: #fbbf24;
}
.admin-pill--muted {
  background: var(--bg);
  color: var(--muted);
}

.admin-inline-form {
  display: inline;
}
.admin-inline-form button {
  vertical-align: middle;
}

.table--actions .table-actions {
  white-space: normal;
  min-width: 220px;
}
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.table-row-muted {
  opacity: 0.72;
}
.admin-code {
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.admin-form-wide .form-check,
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.form-check input {
  width: auto;
  max-width: none;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 720px;
}
@media (max-width: 640px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}
.form-checks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-bottom: 0.25rem;
}
.admin-details {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  max-width: 720px;
}
.admin-details summary {
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.admin-plan-flags {
  max-width: 720px;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.admin-plan-flags__intro {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}
.admin-plan-flags .form-check {
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.admin-plan-flags .form-check:last-child {
  margin-bottom: 0;
}
.admin-plan-flags .form-check input {
  margin-top: 0.2rem;
}
.admin-plan-flags .form-check span {
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ----- Admin : formulaire fournisseur IA ----- */
.form-ai-provider .ai-model-row {
  display: grid;
  gap: 1rem;
  max-width: 720px;
  margin-bottom: 1rem;
}
.form-ai-provider #ai-model-preset {
  max-width: 100%;
}
.form-ai-provider .ai-model-custom-label input {
  max-width: 100%;
}

/* ----- Module workspace : aide + chargement IA ----- */
.module-guidance {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 40rem;
  margin: 0 0 1.35rem;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--bg-elevated);
  border-radius: 0 12px 12px 0;
  box-shadow: 0 1px 3px var(--shadow);
}

.ai-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
}
[data-theme="dark"] .ai-loading-overlay {
  background: rgba(0, 0, 0, 0.45);
}
.ai-loading-overlay[hidden] {
  display: none !important;
}
.ai-loading-overlay__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px var(--shadow);
}
.ai-loading-overlay__box p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg);
}
.ai-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ai-spin 0.75s linear infinite;
}
@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== Workspace modules (parcours projet) ========== */
.workspace-shell {
  width: 100%;
  max-width: none;
  margin: 0;
}

.workspace-shell:has(> form.workspace-form) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.workspace-shell > form.workspace-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Un peu moins de marge en haut pour que la grille tienne mieux en hauteur */
.workspace-shell:has(> form.workspace-form) > .breadcrumb {
  margin-bottom: 0.5rem;
}

.workspace-shell:has(> form.workspace-form) > .breadcrumb,
.workspace-shell:has(> form.workspace-form) > .workspace-project-identity,
.workspace-shell:has(> form.workspace-form) > .workspace-header,
.workspace-shell:has(> form.workspace-form) > .module-guidance,
.workspace-shell:has(> form.workspace-form) > .error,
.workspace-shell:has(> form.workspace-form) > .notice {
  flex-shrink: 0;
}

.workspace-shell:has(> form.workspace-form) > .workspace-header {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
}

.workspace-shell:has(> form.workspace-form) > .module-guidance {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
}

/* Aperçu identité : logo (ou initiale), nom, tonalité, pastilles #hex dans le texte « couleurs » */
.workspace-project-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px var(--shadow);
  flex-shrink: 0;
}

.workspace-shell:has(> form.workspace-form) > .workspace-project-identity {
  margin-bottom: 0.65rem;
}

.workspace-project-identity__brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.workspace-project-identity__download {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.workspace-project-identity__download:hover,
.workspace-project-identity__download:focus-visible {
  text-decoration: underline;
  outline: none;
}

.workspace-project-identity__logo-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.workspace-project-identity__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.workspace-project-identity__logo-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  border-radius: inherit;
  line-height: 0;
}

.workspace-project-identity__logo-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fenêtre plein écran pour voir le logo en grand (clic sur la miniature) */
.workspace-logo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.workspace-logo-lightbox[hidden] {
  display: none !important;
}

.workspace-logo-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  cursor: pointer;
}

[data-theme="dark"] .workspace-logo-lightbox__backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.workspace-logo-lightbox__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: min(94vw, 1200px);
  max-height: min(92vh, 900px);
  width: 100%;
  padding: 0.75rem 1rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.workspace-logo-lightbox__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.workspace-logo-lightbox__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.workspace-logo-lightbox__close {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.workspace-logo-lightbox__close:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

.workspace-logo-lightbox__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.workspace-logo-lightbox__img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.workspace-logo-lightbox__img {
  max-width: 100%;
  max-height: min(78vh, 760px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.workspace-project-identity__monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

@supports not (background: color-mix(in srgb, white, black)) {
  .workspace-project-identity__monogram {
    background: rgba(37, 99, 235, 0.1);
  }
}

[data-theme="dark"] .workspace-project-identity__monogram {
  background: rgba(96, 165, 250, 0.12);
}

.workspace-project-identity__text {
  flex: 1;
  min-width: min(100%, 14rem);
}

.workspace-project-identity__name {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--fg);
}

.workspace-project-identity__tone {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

.workspace-project-identity__tone--muted {
  font-style: italic;
}

.workspace-project-identity__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;
}

.workspace-project-identity__swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--swatch, var(--border));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.workspace-help--tight-top {
  margin-top: -0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.86rem;
}

.workspace-logo-prompt-label {
  display: block;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
}

.workspace-readonly-prompt {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.75rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  min-height: 6rem;
}

.workspace-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.workspace-header__main {
  flex: 1;
  min-width: min(100%, 18rem);
}

.workspace-header__aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem 0.85rem;
}

.workspace-header-btn-ai,
.workspace-header-btn-complete {
  font-size: 0.875rem;
  padding: 0.42rem 0.95rem;
  white-space: nowrap;
}

.workspace-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--fg);
}

.workspace-lead {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 36rem;
}

.workspace-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--muted);
}

.workspace-badge--not_started {
  border-color: var(--border);
  color: var(--muted);
}

.workspace-badge--in_progress {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
}

[data-theme="dark"] .workspace-badge--in_progress {
  background: rgba(96, 165, 250, 0.12);
}

.workspace-badge--completed {
  border-color: rgba(5, 150, 105, 0.45);
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

[data-theme="dark"] .workspace-badge--completed {
  color: #34d399;
}

.workspace-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 2rem 0 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.workspace-section-title--sub {
  font-size: 0.98rem;
  margin-top: 1.35rem;
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.workspace-fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin: 1rem 0 1.25rem;
  background: var(--bg-elevated);
}

.workspace-fieldset .form-check {
  display: block;
  margin: 0.4rem 0;
}

.workspace-layout__fields > .workspace-section-title:first-of-type,
.workspace-layout__fields > fieldset + .workspace-section-title {
  margin-top: 0;
}

.workspace-section-title--chat {
  margin-top: 2.25rem;
  border-bottom: none;
  padding-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.workspace-section-title--chat::before {
  content: "";
  width: 4px;
  height: 1.15em;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
}

.workspace-help {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 40rem;
}

/* Champs : cartes */
.workspace-form label:not(.form-check) {
  display: block;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 3px var(--shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
}

.workspace-form label:not(.form-check):focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25), 0 6px 20px var(--shadow);
}

[data-theme="dark"] .workspace-form label:not(.form-check):focus-within {
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.35), 0 6px 24px var(--shadow);
}

.workspace-form input[type="text"],
.workspace-form input[type="url"],
.workspace-form input[type="email"],
.workspace-form textarea,
.workspace-form select {
  width: 100%;
  max-width: none;
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  line-height: 1.5;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.workspace-form textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.workspace-form label:not(.form-check):has(textarea[name="summary"]) {
  border-left: 4px solid var(--accent);
  padding-left: calc(1.15rem - 4px);
  background: linear-gradient(
    135deg,
    var(--bg-elevated) 0%,
    color-mix(in srgb, var(--bg-elevated) 92%, var(--accent)) 100%
  );
}

@supports not (background: color-mix(in srgb, white, black)) {
  .workspace-form label:not(.form-check):has(textarea[name="summary"]) {
    background: var(--bg-elevated);
  }
}

.workspace-form label:not(.form-check):has(textarea[name="summary"]) textarea {
  min-height: 10rem;
}

/* Parcours brainstorm : radios */
.workspace-form fieldset.brainstorm-mode {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px var(--shadow);
}

.workspace-form fieldset.brainstorm-mode legend {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 0.35rem;
  color: var(--fg);
}

.workspace-form label.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  padding: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-weight: 500;
}

.workspace-form label.form-check:last-child {
  margin-bottom: 0;
}

.workspace-form label.form-check input {
  width: auto;
  max-width: none;
  margin-top: 0.2rem;
}

/* Grille : assistant IA à gauche, champs à droite (desktop) */
.workspace-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: stretch;
  min-height: 0;
}

@media (min-width: 900px) {
  .workspace-layout {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(0, 1.65fr);
    gap: 1.5rem;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .workspace-layout__chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .workspace-layout__fields {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 0 0.5rem 0 1.25rem;
    margin: 0;
    border-left: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 899px) {
  .workspace-layout__fields {
    padding: 0;
    border-left: none;
  }

  .workspace-layout__chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: min(400px, 52vh);
  }

  .workspace-layout__chat,
  .workspace-chat-panel {
    min-height: 0;
  }
}

/* Panneau conversation IA (colonne gauche) */
.workspace-chat-panel {
  margin-top: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(
    165deg,
    var(--bg-elevated) 0%,
    color-mix(in srgb, var(--bg-elevated) 94%, var(--accent)) 120%
  );
  box-shadow: 0 4px 20px var(--shadow);
}

@supports not (background: color-mix(in srgb, white, black)) {
  .workspace-chat-panel {
    background: var(--bg-elevated);
  }
}

.workspace-chat-panel__head {
  flex-shrink: 0;
}

.workspace-chat-panel__head .workspace-section-title--chat {
  margin-top: 0;
  margin-bottom: 0.45rem;
}

.workspace-chat-panel__head .workspace-help {
  margin-bottom: 0.65rem;
  max-width: none;
}

.workspace-chat-panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.workspace-chat-panel__scroll .conversation {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  max-height: none;
  overflow: visible;
}

.workspace-chat-panel__footer {
  flex-shrink: 0;
  padding-top: 0.85rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.workspace-chat-panel__footer .workspace-form-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.conversation__empty {
  margin: 0;
  font-style: italic;
}

.workspace-ai-actions {
  margin-bottom: 1.15rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--bg);
}

.workspace-ai-actions__hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.workspace-ai-actions__hint strong {
  color: var(--fg);
}

.workspace-field-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.workspace-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.workspace-form .workspace-form-actions .btn {
  min-width: 12rem;
}

.workspace-form-actions--logo {
  margin-top: 0.35rem;
  padding-top: 0.75rem;
  border-top: none;
}

/* Champs dans le panneau IA : plus léger que le reste du formulaire */
.workspace-form .workspace-chat-panel label:not(.form-check) {
  background: var(--bg);
  box-shadow: none;
}

.workspace-form .workspace-chat-panel label:not(.form-check):focus-within {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

/* Bulles messages */
.workspace-chat-panel .msg {
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  max-width: 100%;
}

.workspace-chat-panel .msg:last-child {
  margin-bottom: 0;
}

.workspace-chat-panel .msg__role {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.workspace-chat-panel .msg__body {
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.workspace-chat-panel .msg--user {
  margin-left: 0;
  margin-right: 2rem;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

[data-theme="dark"] .workspace-chat-panel .msg--user {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.22);
}

.workspace-chat-panel .msg--assistant {
  margin-left: 2rem;
  margin-right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* Formulaire « complété » : uniquement CSRF, bouton dans l’en-tête (form="workspace-complete-form") */
.workspace-complete-form-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .workspace-header {
    flex-direction: column;
    align-items: stretch;
  }
  .workspace-badge {
    align-self: flex-start;
  }
  .workspace-chat-panel .msg--user {
    margin-right: 0;
  }
  .workspace-chat-panel .msg--assistant {
    margin-left: 0;
  }
}

/* ----- Centre de notifications ----- */
.notification-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.notification-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.notification-list__item:not(.notification-list__item--read) {
  border-left: 4px solid var(--accent);
}

.notification-list__item time {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.notification-list__item p {
  margin: 0.35rem 0 0;
  flex: 1 1 100%;
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Bouton support flottant */
.fab-support {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff !important;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 3rem;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 4px 18px var(--shadow);
}

.fab-support:hover,
.fab-support:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.account-avatar-preview {
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.landing-html {
  max-width: 52rem;
}

.landing-html p {
  margin: 0.65rem 0;
}

.admin-textarea-code {
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
}
