/* Fablabs Manager — habillage de l'administration technique Django.
   Repose sur les variables de thème de l'admin (clair, sombre, automatique) : aucune règle ne casse son fonctionnement. */

@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

/* ------------------------------------------------------------------ jetons */
html[data-theme="light"],
:root {
  --fm-orange: #ff7900;
  --fm-orange-strong: #c2410c;
  --fm-orange-soft: #fff7ed;
  --fm-surface: #ffffff;
  --fm-canvas: #f4f4f5;
  --fm-ring: rgb(0 0 0 / 0.08);
  --fm-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.03);
  --fm-radius: 12px;

  --primary: #c2410c;
  --secondary: #18181b;
  --accent: #fb923c;
  --primary-fg: #ffffff;
  --body-fg: #27272a;
  --body-bg: #f4f4f5;
  --body-quiet-color: #71717a;
  --body-medium-color: #52525b;
  --body-loud-color: #09090b;
  --header-color: #e4e4e7;
  --header-branding-color: #ffffff;
  --header-bg: #0c0c0e;
  --header-link-color: #e4e4e7;
  --breadcrumbs-fg: #71717a;
  --breadcrumbs-link-fg: #3f3f46;
  --breadcrumbs-bg: #ffffff;
  --link-fg: #c2410c;
  --link-hover-color: #9a3412;
  --link-selected-fg: #9a3412;
  --hairline-color: #e4e4e7;
  --border-color: #d4d4d8;
  --error-fg: #b91c1c;
  --message-success-bg: #ecfdf3;
  --message-warning-bg: #fffbeb;
  --message-error-bg: #fef2f2;
  --darkened-bg: #fafafa;
  --selected-bg: #fff7ed;
  --selected-row: #fff7ed;
  --button-fg: #ffffff;
  --button-bg: #c2410c;
  --button-hover-bg: #9a3412;
  --default-button-bg: #18181b;
  --default-button-hover-bg: #3f3f46;
  --close-button-bg: #71717a;
  --close-button-hover-bg: #3f3f46;
  --delete-button-bg: #dc2626;
  --delete-button-hover-bg: #b91c1c;
  --object-tools-fg: #ffffff;
  --object-tools-bg: #3f3f46;
  --object-tools-hover-bg: #18181b;
  --font-family-primary: "InterVariable", "Inter", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fm-surface: #18181b;
    --fm-canvas: #0c0c0e;
    --fm-ring: rgb(255 255 255 / 0.08);
    --fm-orange-soft: rgb(255 121 0 / 0.1);
    --primary: #ea580c;
    --body-fg: #e4e4e7;
    --body-bg: #0c0c0e;
    --body-quiet-color: #a1a1aa;
    --body-medium-color: #d4d4d8;
    --body-loud-color: #fafafa;
    --breadcrumbs-bg: #18181b;
    --breadcrumbs-link-fg: #d4d4d8;
    --link-fg: #fb923c;
    --link-hover-color: #fdba74;
    --link-selected-fg: #fdba74;
    --hairline-color: #27272a;
    --border-color: #3f3f46;
    --error-fg: #f87171;
    --message-success-bg: #052e16;
    --message-warning-bg: #3a2a05;
    --message-error-bg: #3b0d0d;
    --darkened-bg: #111113;
    --selected-bg: rgb(255 121 0 / 0.12);
    --selected-row: rgb(255 121 0 / 0.12);
    --default-button-bg: #3f3f46;
    --default-button-hover-bg: #52525b;
  }
}
html[data-theme="dark"] {
  --fm-surface: #18181b;
  --fm-canvas: #0c0c0e;
  --fm-ring: rgb(255 255 255 / 0.08);
  --fm-orange-soft: rgb(255 121 0 / 0.1);
  --primary: #ea580c;
  --body-fg: #e4e4e7;
  --body-bg: #0c0c0e;
  --body-quiet-color: #a1a1aa;
  --body-medium-color: #d4d4d8;
  --body-loud-color: #fafafa;
  --breadcrumbs-bg: #18181b;
  --breadcrumbs-link-fg: #d4d4d8;
  --link-fg: #fb923c;
  --link-hover-color: #fdba74;
  --link-selected-fg: #fdba74;
  --hairline-color: #27272a;
  --border-color: #3f3f46;
  --error-fg: #f87171;
  --message-success-bg: #052e16;
  --message-warning-bg: #3a2a05;
  --message-error-bg: #3b0d0d;
  --darkened-bg: #111113;
  --selected-bg: rgb(255 121 0 / 0.12);
  --selected-row: rgb(255 121 0 / 0.12);
  --default-button-bg: #3f3f46;
  --default-button-hover-bg: #52525b;
}

/* --------------------------------------------------------------- en-tête */
body { -webkit-font-smoothing: antialiased; }
#header {
  min-height: 64px; padding: 0 24px; gap: 16px;
  background: var(--header-bg);
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}
#site-name { display: flex; align-items: center; gap: 12px; margin: 0; }
#site-name a.fm-brand, #site-name a.fm-brand:visited { display: flex; align-items: center; gap: 12px; color: #fff; }
.fm-brand-mark {
  display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #fb923c, #c2410c); box-shadow: 0 6px 16px -6px rgb(234 88 12 / 0.7);
}
.fm-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.fm-brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.fm-brand-sub { font-size: 11px; font-weight: 400; color: #a1a1aa; }
.fm-env { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em; }
.fm-env-dev { background: rgb(251 191 36 / 0.15); color: #fbbf24; box-shadow: inset 0 0 0 1px rgb(251 191 36 / 0.3); }
.fm-env-prod { background: rgb(74 222 128 / 0.12); color: #4ade80; box-shadow: inset 0 0 0 1px rgb(74 222 128 / 0.3); }
#user-tools { font-size: 12px; letter-spacing: 0; text-transform: none; color: #a1a1aa; }
#user-tools a { border-bottom: 0; color: #e4e4e7; }
#user-tools a:hover { color: #fb923c; text-decoration: none; }
#user-tools a.fm-back { color: #fb923c; font-weight: 600; }
#logout-form button { color: #e4e4e7; font-size: 12px; text-transform: none; letter-spacing: 0; }
#logout-form button:hover { color: #fb923c; text-decoration: none; }
.theme-toggle svg.theme-icon-when-auto, .theme-toggle svg.theme-icon-when-dark, .theme-toggle svg.theme-icon-when-light { fill: #a1a1aa; color: #a1a1aa; }

/* ------------------------------------------------------- fil d'Ariane */
div.breadcrumbs {
  padding: 12px 24px; font-size: 13px; color: var(--breadcrumbs-fg);
  background: var(--breadcrumbs-bg); border-bottom: 1px solid var(--hairline-color);
}
div.breadcrumbs a { color: var(--breadcrumbs-link-fg); }
div.breadcrumbs a:hover { color: var(--link-fg); }

/* ------------------------------------------------------- mise en page */
#main { background: var(--fm-canvas); }
#content { padding: 24px 32px; }
#content h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; color: var(--body-loud-color); margin-bottom: 16px; }
#content h2.subhead { color: var(--body-quiet-color); }

/* Barre latérale de navigation */
#nav-sidebar { background: var(--fm-surface); border-right: 1px solid var(--hairline-color); padding-top: 8px; }
#nav-sidebar .module th, #nav-sidebar .module caption { font-size: 13px; }
#nav-filter { border-radius: 8px; border: 1px solid var(--border-color); background: var(--body-bg); margin: 8px 10px 12px; width: calc(100% - 20px); padding: 8px 10px; }
#nav-sidebar .current-app .section:link, #nav-sidebar .current-app .section:visited { color: var(--link-fg); font-weight: 600; }
#nav-sidebar .current-model { background: var(--selected-row); }
.toggle-nav-sidebar { background: var(--fm-surface); border-right: 1px solid var(--hairline-color); color: var(--body-quiet-color); }

/* ------------------------------------------------------- modules / cartes */
.module {
  background: var(--fm-surface); border-radius: var(--fm-radius); overflow: hidden;
  box-shadow: var(--fm-shadow), 0 0 0 1px var(--fm-ring); margin-bottom: 20px;
}
.module h2, .module caption, .inline-group h2 {
  background: transparent; color: var(--body-loud-color); font-size: 13px; font-weight: 600;
  letter-spacing: 0; text-transform: none; padding: 14px 16px; border-bottom: 1px solid var(--hairline-color);
}
.module caption a.section, .module h2 a.section { color: var(--body-loud-color); }
.module caption a.section:hover { color: var(--link-fg); }
.app-list .module table { width: 100%; }
#content-main .app-list .module th, #nav-sidebar .module th { padding: 9px 16px; font-weight: 500; }
.module tr:hover th a, .module tr:hover td a { color: var(--link-fg); }
a.addlink, a.changelink, a.viewlink { font-size: 12px; font-weight: 500; }

/* Tables de listes */
#changelist .results { border-radius: var(--fm-radius); overflow-x: auto; box-shadow: var(--fm-shadow), 0 0 0 1px var(--fm-ring); background: var(--fm-surface); }
#result_list { width: 100%; border-collapse: collapse; }
#result_list thead th {
  background: var(--darkened-bg); color: var(--body-quiet-color); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 1px solid var(--hairline-color); padding: 10px 12px;
}
#result_list thead th a { color: var(--body-quiet-color); }
#result_list tbody td, #result_list tbody th { padding: 11px 12px; border-bottom: 1px solid var(--hairline-color); vertical-align: middle; font-size: 13px; }
#result_list tbody tr:last-child td, #result_list tbody tr:last-child th { border-bottom: 0; }
#result_list tbody tr:hover td, #result_list tbody tr:hover th { background: var(--darkened-bg); }
#result_list tbody th a { font-weight: 600; }
#changelist table thead th.sorted .text a { color: var(--body-loud-color); }

/* Barre d'outils, recherche, actions */
#changelist #toolbar { background: transparent; padding: 0 0 14px; border: 0; }
#changelist #toolbar form input[type="text"], #searchbar {
  border-radius: 8px; border: 1px solid var(--border-color); padding: 8px 12px; min-width: 280px; background: var(--fm-surface);
}
#changelist #toolbar form input[type="submit"] { border-radius: 8px; padding: 8px 14px; }
#changelist .actions { background: var(--fm-surface); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; box-shadow: 0 0 0 1px var(--fm-ring); border: 0; color: var(--body-quiet-color); }
#changelist .actions select { border-radius: 8px; }
.paginator { border: 0; padding: 14px 4px; color: var(--body-quiet-color); font-size: 13px; }
.paginator a:link, .paginator a:visited, .paginator .this-page { border-radius: 6px; padding: 4px 9px; }
.paginator a:link, .paginator a:visited { background: var(--fm-surface); box-shadow: 0 0 0 1px var(--fm-ring); color: var(--body-fg); }
.paginator .this-page { background: var(--primary); color: #fff; }

/* Filtres latéraux */
#changelist-filter {
  background: var(--fm-surface); border-radius: var(--fm-radius); box-shadow: var(--fm-shadow), 0 0 0 1px var(--fm-ring);
  overflow: hidden; border: 0;
}
#changelist-filter h2 { background: transparent; color: var(--body-loud-color); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 14px 16px; border-bottom: 1px solid var(--hairline-color); }
#changelist-filter h3 { color: var(--body-quiet-color); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin: 16px 16px 6px; }
#changelist-filter ul { padding: 0 8px 8px; border-bottom: 0; }
#changelist-filter li { margin: 0; }
#changelist-filter li a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--body-medium-color); }
#changelist-filter li a:hover { background: var(--darkened-bg); color: var(--body-loud-color); }
#changelist-filter li.selected a { background: var(--fm-orange-soft); color: var(--link-fg); font-weight: 600; border: 0; margin: 0; padding-left: 8px; }
#changelist-filter details summary { padding: 0 16px; }
.changelist-filter-clear a { padding: 0 16px; }

/* Hiérarchie de dates */
.xfull, .date-hierarchy { font-size: 13px; }

/* ------------------------------------------------------- formulaires */
fieldset.module { padding: 0; }
fieldset.module h2 { margin: 0; }
.form-row { padding: 14px 16px; border-bottom: 1px solid var(--hairline-color); }
.form-row:last-child { border-bottom: 0; }
.aligned label { color: var(--body-medium-color); font-weight: 500; }
.required label, label.required { color: var(--body-loud-color); font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=tel],
textarea, select, .vTextField, .vDateField, .vTimeField, .vIntegerField, .vBigIntegerField, .vForeignKeyRawIdAdminField {
  border-radius: 8px; border: 1px solid var(--border-color); padding: 7px 10px; background: var(--fm-surface); color: var(--body-fg);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--fm-orange); box-shadow: 0 0 0 3px rgb(255 121 0 / 0.2);
}
:focus-visible { outline: 2px solid var(--fm-orange); outline-offset: 2px; }
div.help, p.help, .help { color: var(--body-quiet-color); font-size: 12px; }
.errornote { border-radius: 10px; border: 1px solid rgb(220 38 38 / 0.3); background: var(--message-error-bg); color: var(--error-fg); }
ul.errorlist li { border-radius: 8px; background: var(--error-fg); }
.selector .selector-available h2, .selector .selector-chosen h2 { border-radius: 8px 8px 0 0; }
.selector-chosen h2 { background: var(--primary); }
.inline-group .tabular tr.has_original td { padding-top: 10px; }
fieldset.collapse summary, .module details summary { cursor: pointer; }

/* Boutons */
.button, input[type=submit], input[type=button], .submit-row input, a.button {
  border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px; letter-spacing: 0;
  transition: background .15s, box-shadow .15s;
}
.button.default, input[type=submit].default, .submit-row input.default { background: var(--button-bg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); }
.button.default:hover, input[type=submit].default:hover { background: var(--button-hover-bg); }
.submit-row {
  background: var(--fm-surface); border: 0; border-radius: var(--fm-radius); padding: 14px 16px;
  box-shadow: var(--fm-shadow), 0 0 0 1px var(--fm-ring); gap: 10px; margin: 16px 0;
}
.submit-row a.deletelink, .submit-row a.deletelink:visited { border-radius: 8px; padding: 9px 16px; height: auto; line-height: 1.4; }
.object-tools a:link, .object-tools a:visited {
  border-radius: 8px; padding: 7px 14px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none;
  background: var(--fm-surface); color: var(--body-fg); box-shadow: 0 0 0 1px var(--border-color);
}
.object-tools a:hover { background: var(--darkened-bg); color: var(--link-fg); }
.object-tools a.addlink { background: var(--primary); color: #fff; box-shadow: none; }
.object-tools a.addlink:hover { background: var(--button-hover-bg); color: #fff; }

/* Messages */
ul.messagelist li {
  border-radius: 10px; margin: 0 0 10px; padding: 12px 16px 12px 42px; font-size: 13px;
  box-shadow: 0 0 0 1px var(--fm-ring); background-position: 14px 13px;
}

/* ------------------------------------------------------- connexion */
body.login { background: radial-gradient(1200px 600px at 100% -10%, rgb(234 88 12 / 0.18), transparent 60%), var(--fm-canvas); }
body.login #container {
  border-radius: 16px; border: 0; overflow: hidden; margin-top: 10vh;
  box-shadow: 0 20px 50px -20px rgb(0 0 0 / 0.35), 0 0 0 1px var(--fm-ring); background: var(--fm-surface);
}
body.login #header { padding: 18px 24px; }
body.login #content { padding: 24px 28px 28px; }
body.login .form-row { border: 0; padding: 6px 0; }
body.login .form-row input { width: 100%; box-sizing: border-box; padding: 10px 12px; }
body.login .submit-row { box-shadow: none; padding: 12px 0 0; margin: 0; }
body.login .submit-row input { width: 100%; padding: 11px; }

/* ------------------------------------------------------- tableau de bord */
.dashboard #content { max-width: 1400px; width: auto; margin: 0 auto; }
.dashboard .colMS { margin-right: 0; }
.dashboard #content-main { float: none; width: auto; }
.dashboard #content > h1 { display: none; }
.fm-apps .module table { width: 100%; table-layout: auto; }
.fm-apps .module th { width: 60%; }
.fm-apps .module td { white-space: nowrap; text-align: right; padding-right: 16px; }
.fm-hero {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px 28px; margin-bottom: 20px; border-radius: 16px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(600px 200px at 100% 0%, rgb(251 146 60 / 0.35), transparent 70%), linear-gradient(120deg, #0c0c0e, #27272a);
}
.fm-eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #fdba74; }
#content .fm-hero-title { color: #fff; font-size: 24px; margin: 0; }
.fm-hero-text { margin: 8px 0 0; max-width: 640px; color: #d4d4d8; font-size: 13px; line-height: 1.55; }
a.fm-hero-cta, a.fm-hero-cta:visited {
  flex-shrink: 0; padding: 10px 16px; border-radius: 10px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #fb923c, #c2410c); box-shadow: 0 8px 20px -8px rgb(234 88 12 / 0.8);
}
a.fm-hero-cta:hover { color: #fff; filter: brightness(1.05); }

.fm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
a.fm-stat, a.fm-stat:visited {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--fm-radius);
  background: var(--fm-surface); box-shadow: var(--fm-shadow), 0 0 0 1px var(--fm-ring); color: var(--body-fg);
  border-top: 3px solid var(--fm-tone, #a1a1aa); transition: transform .15s, box-shadow .15s;
}
a.fm-stat:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -12px rgb(0 0 0 / 0.25), 0 0 0 1px var(--fm-ring); color: var(--body-fg); }
.fm-stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--body-quiet-color); }
.fm-stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; color: var(--body-loud-color); font-variant-numeric: tabular-nums; }
.fm-stat-hint { font-size: 12px; color: var(--body-quiet-color); }
.fm-tone-primary { --fm-tone: #ff7900; }
.fm-tone-info { --fm-tone: #2563eb; }
.fm-tone-success { --fm-tone: #16a34a; }
.fm-tone-warning { --fm-tone: #d97706; }
.fm-tone-danger { --fm-tone: #dc2626; }
.fm-tone-neutral { --fm-tone: #a1a1aa; }

.fm-alerts { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.fm-alert { margin: 0; border-radius: 10px; padding: 10px 14px; font-size: 13px; background: var(--fm-surface);
  box-shadow: inset 3px 0 0 var(--fm-tone), 0 0 0 1px var(--fm-ring); }
.fm-alert a { color: var(--body-loud-color); font-weight: 500; }

.fm-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.fm-apps .module { margin-bottom: 16px; }
.fm-panel h2 { margin: 0; }
.fm-feed { list-style: none; margin: 0; padding: 6px 0; }
.fm-feed li { display: flex; flex-direction: column; gap: 2px; padding: 8px 16px; border-bottom: 1px solid var(--hairline-color); list-style: none; }
.fm-feed li:last-child { border-bottom: 0; }
.fm-feed-action { font-size: 13px; font-weight: 500; color: var(--body-loud-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-feed-meta { font-size: 12px; color: var(--body-quiet-color); display: flex; align-items: center; gap: 6px; }
.fm-dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; }
.fm-dot-ok { background: #16a34a; }
.fm-dot-ko { background: #dc2626; }
.fm-muted { color: var(--body-quiet-color); font-size: 13px; }
.fm-panel-link { margin: 0; padding: 10px 16px; border-top: 1px solid var(--hairline-color); font-size: 12px; font-weight: 600; }

@media (max-width: 1024px) {
  .fm-grid { grid-template-columns: 1fr; }
  #content { padding: 16px; }
  #searchbar { min-width: 0; width: 100%; }
}
@media (max-width: 767px) {
  #header { padding: 10px 16px; }
  .fm-brand-sub, .fm-env { display: none; }
  .fm-hero { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
