/* ==========================================================================
   Contilium — design system
   Basé sur CHARTE_GRAPHIQUE.html (racine du repo). Toute évolution visuelle
   du produit doit passer par ce fichier plutôt que par des styles ad-hoc
   dans les templates (CONVENTIONS_DEV.md §5).
   ========================================================================== */

:root {
  /* ---- Palette charte ------------------------------------------------- */
  --ink:        #16233D;
  --ink-soft:   #2C3B58;
  --paper:      #EAEEEC;
  --paper-dark: #DFE4DF;
  --paper-deep: #D3D9D2;
  --seal:       #9C2B22;
  --seal-dark:  #7A2019;
  --ribbon:     #B98F46;
  --slate:      #55606D;
  --validated:  #2F6B4F;
  --rejected:   #9C2B22;
  --pending:    #B98F46;

  /* ---- Alias sémantiques utilisés par les composants ci-dessous -------- */
  --brand:          var(--seal);
  --brand-dark:     var(--seal-dark);
  --brand-accent:   var(--ribbon);
  --brand-light:    rgba(156,43,34,0.08);
  --secondary:      var(--ribbon);
  --secondary-light:rgba(185,143,70,0.14);
  --surface:        var(--paper);
  --surface-subtle: var(--paper-dark);
  --surface-raised: #FFFFFF;
  --border:         rgba(22,35,61,0.14);
  --border-mid:     rgba(22,35,61,0.24);
  --text:           var(--ink);
  --text-mid:       var(--ink-soft);
  --text-muted:     var(--slate);
  --success:        var(--validated);
  --error:          var(--seal);
  --warning:        var(--pending);

  /* ---- Typo ------------------------------------------------------------ */
  --font-display: 'IBM Plex Serif', Georgia, serif;
  --font-body:    'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

  /* ---- Forme : coins nets, esthétique "document officiel" --------------- */
  --radius:    3px;
  --radius-lg: 4px;
  --shadow:    0 4px 24px rgba(22,35,61,0.08);
  --shadow-lg: 0 18px 50px rgba(22,35,61,0.14);

  /* ---- Dimensions de layout (shell applicatif) -------------------------- */
  --nav-h:     56px;
  --bottom-h:  64px;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  margin: 0;
}

.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand); margin: 0 0 12px;
}

.ref-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  padding: 6px 12px; border: 1px solid var(--border-mid);
  border-radius: 2px; background: var(--paper-dark);
}
.ref-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--validated); }

.ribbon-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; }
.ribbon-divider .line { flex: 1; height: 1px; background: var(--border); }
.ribbon-divider .knot { width: 9px; height: 9px; background: var(--ribbon); transform: rotate(45deg); flex-shrink: 0; }

/* ---- Sceau (logo) -------------------------------------------------------- */
.seal-mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.seal-mark svg circle.ring-outer { stroke: var(--seal); }
.seal-mark svg circle.ring-inner { stroke: rgba(156,43,34,0.5); }
.seal-mark svg path.corner-fill { fill: var(--paper); }
.seal-mark svg path.corner-edge { stroke: var(--seal); }
.seal-mark svg text.mono { fill: var(--ink); font-family: var(--font-display); }

.seal-mark.on-ink { background: var(--ink); border-radius: 50%; }
.seal-mark.on-ink svg circle.ring-outer,
.seal-mark.on-ink svg circle.ring-inner,
.seal-mark.on-ink svg path.corner-edge { stroke: var(--paper); }
.seal-mark.on-ink svg path.corner-fill { fill: var(--ink); }
.seal-mark.on-ink svg text.mono { fill: var(--paper); }

.seal-mark.on-seal { background: var(--seal); border-radius: 50%; }
.seal-mark.on-seal svg circle.ring-outer,
.seal-mark.on-seal svg circle.ring-inner,
.seal-mark.on-seal svg path.corner-edge { stroke: var(--paper); }
.seal-mark.on-seal svg path.corner-fill { fill: var(--seal); }
.seal-mark.on-seal svg text.mono { fill: var(--paper); }

.brand-lockup { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 19px; color: var(--text); text-decoration: none; }

/* ---- Tampons de statut ---------------------------------------------------- */
.stamp {
  width: 84px; height: 84px; border-radius: 50%;
  border: 2px solid var(--seal); position: relative;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-8deg); flex-shrink: 0;
}
.stamp::before {
  content: ""; position: absolute; inset: 5px; border-radius: 50%;
  border: 1px dashed rgba(156,43,34,0.55);
}
.stamp span {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--seal); text-align: center; line-height: 1.4;
}
.stamp.pending { border-color: var(--pending); }
.stamp.pending::before { border-color: rgba(185,143,70,0.55); }
.stamp.pending span { color: var(--pending); }
.stamp.validated { border-color: var(--validated); }
.stamp.validated::before { border-color: rgba(47,107,79,0.55); }
.stamp.validated span { color: var(--validated); }

/* ==========================================================================
   Composants partagés (shell applicatif + IAM + profil)
   ========================================================================== */

.lose-top-bottom { margin-top: 15px; margin-bottom: 15px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600; font-size: 0.875rem;
  border: none; cursor: pointer;
  transition: filter 0.15s;
  text-decoration: none;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(0.93); }
.btn:active { filter: brightness(0.86); transform: scale(0.98); }
.btn-primary   { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--secondary-light); color: var(--brand-dark); }
.btn-danger    { background: var(--seal); color: #fff; }
.btn-success   { background: var(--validated); color: #fff; }
.btn-warning   { background: var(--pending); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-mid); border: 1px solid var(--border-mid); }
.btn-outline   { background: transparent; color: var(--brand); border: 1.5px solid var(--border-mid); }
.btn-outline:hover { border-color: var(--brand); background: var(--brand-light); }
.btn-lg { padding: 13px 20px; font-size: 1rem; min-height: 52px; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; min-height: 36px; }
.btn-full { width: 100%; justify-content: center; }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-title {
  font-family: var(--font-mono);
  font-size: 0.75rem; font-weight: 600; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.card-surface { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); }

.field { margin-bottom: 1rem; }
.field label, .form-label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
.field input, .field select, .field textarea,
.form-input {
  width: 100%; padding: 12px 14px; height: auto;
  border: 1.5px solid var(--border-mid); border-radius: var(--radius);
  font-size: 1rem; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color 0.15s;
  -webkit-appearance: none;
}
select.form-input { padding: 10px; cursor: pointer; }
.field input:focus, .field select:focus, .field textarea:focus, .form-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(156,43,34,0.12);
}
.field .help  { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.field .error, .errorlist { font-size: 0.78rem; color: var(--error); margin-top: 4px; list-style: none; padding: 0; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--error); }
.field input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }
.field input[type="checkbox"]:checked { background-color: var(--brand); border-color: var(--brand); }
input[type="file"] { border: 1px solid var(--border); background-color: var(--ink-soft); color: #fff; padding: 8px; }
input[type="date"] { padding: 10px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.72rem; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap;
}
.badge-blue   { background: rgba(22,35,61,0.08); color: var(--ink); }
.badge-green  { background: rgba(47,107,79,0.12); color: var(--validated); }
.badge-yellow { background: rgba(185,143,70,0.16); color: #8a6b32; }
.badge-red    { background: rgba(156,43,34,0.10); color: var(--seal); }
.badge-gray   { background: rgba(22,35,61,0.06); color: var(--slate); }
.badge-orange { background: rgba(185,143,70,0.16); color: var(--ribbon); }
.role-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  background: var(--brand-light); color: var(--brand); border: 1px solid var(--border-mid);
}

.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 1.2rem; font-size: 0.85rem; display: flex; align-items: flex-start; gap: 10px; }
.alert-error   { background: rgba(156,43,34,0.06); border: 1px solid rgba(156,43,34,0.25); color: var(--seal-dark); }
.alert-success { background: rgba(47,107,79,0.08); border: 1px solid rgba(47,107,79,0.25); color: var(--validated); }
.alert-info    { background: var(--paper-dark); border: 1px solid var(--border-mid); color: var(--text-mid); }
.alert-warning { background: rgba(185,143,70,0.10); border: 1px solid rgba(185,143,70,0.3); color: #8a6b32; }

.divider { display: flex; align-items: center; gap: 12px; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-mid); }
.divider span { font-size: 0.78rem; color: var(--text-muted); opacity: 0.8; white-space: nowrap; }
.link { color: var(--brand); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 10px 12px; text-align: left;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
td { padding: 12px; font-size: 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface); }

.stat-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.stat-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 500; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

.page-header { background: #fff; border-bottom: 1px solid var(--border); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-header-left { min-width: 0; }
.breadcrumb { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.page-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-subtitle { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 2rem; line-height: 1.6; }

.content { padding: 16px; }
@media (min-width: 769px) { .content { padding: 24px; } }
.text-muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.35; }
.empty-state p { font-size: 0.9rem; }
.confirm-box { background: rgba(156,43,34,0.05); border: 1.5px solid rgba(156,43,34,0.3); border-radius: var(--radius); padding: 1rem; }

/* ---- Toasts -------------------------------------------------------------- */
#toast-container { position: fixed; top: calc(var(--nav-h) + 10px); right: 12px; left: 12px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius); font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow); pointer-events: all; animation: toastIn 0.25s ease-out;
  max-width: 420px; margin-left: auto;
}
.toast-success { background: rgba(47,107,79,0.06); border: 1px solid rgba(47,107,79,0.35); color: var(--validated); }
.toast-error   { background: rgba(156,43,34,0.05); border: 1px solid rgba(156,43,34,0.3); color: var(--seal-dark); }
.toast-warning { background: #fffbeb; border: 1px solid rgba(185,143,70,0.4); color: #8a6b32; }
.toast-info    { background: var(--paper-dark); border: 1px solid var(--border-mid); color: var(--text-mid); }
.toast-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: 0.5; font-size: 16px; padding: 0 2px; }
@keyframes toastIn { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

/* ---- Shell applicatif : topnav / sidebar / bottom-nav -------------------- */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  background: rgba(234,238,236,0.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; z-index: 60;
}
.app-sidebar {
  width: var(--sidebar-w); background: var(--surface-raised); border-right: 1px solid var(--border);
  position: fixed; top: var(--nav-h); bottom: 0; left: 0; z-index: 40;
  display: flex; flex-direction: column; overflow-y: auto; transition: transform 0.25s ease;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(22,35,61,0.4); z-index: 39; }
.app-main { margin-top: var(--nav-h); margin-left: var(--sidebar-w); min-height: calc(100vh - var(--nav-h)); }

.snav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 1px 8px;
  border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
  color: var(--text-mid); text-decoration: none; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.snav-link:hover, .snav-link.active { background: var(--brand-light); color: var(--brand); }
.snav-link.active { font-weight: 600; }
.snav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.snav-section {
  padding: 16px 20px 6px; font-family: var(--font-mono);
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}

.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-h);
  background: var(--surface-raised); border-top: 1px solid var(--border); z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-items { display: flex; height: 100%; align-items: center; }
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-muted); text-decoration: none; font-size: 0.6rem; font-weight: 500;
  padding: 6px 4px; border-radius: 8px; transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bnav-item.active { color: var(--brand); }
.bnav-item svg { width: 22px; height: 22px; }

.nav-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 240px;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: 100;
}
.nav-dropdown.open { display: block; animation: dropIn 0.15s ease-out; }
@keyframes dropIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  font-size: 0.85rem; color: var(--text-mid); text-decoration: none; transition: background 0.12s;
  cursor: pointer; background: none; border: none; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--brand-light); color: var(--brand); }
.dropdown-danger { color: var(--seal); }
.dropdown-danger:hover { background: rgba(156,43,34,0.06); color: var(--seal-dark); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-header { padding: 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-user { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.not-activated { font-size: 0.7rem; padding: 2px 8px; border-radius: 20px; background: rgba(185,143,70,0.16); color: #8a6b32; font-weight: 600; border: 1px solid rgba(185,143,70,0.4); }

@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); top: 0; z-index: 50; }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .app-main { margin-left: 0; padding-bottom: var(--bottom-h); }
  .bottom-nav { display: block; }
  .sidebar-nav-st { margin-top: 70px; margin-bottom: 70px; }
}

/* ==========================================================================
   Pages d'authentification (login, signup, mot de passe, 2FA)
   ========================================================================== */

.auth-left {
  width: 44%; min-height: 100vh; background: var(--ink);
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: 2.8rem 3rem; overflow: hidden;
}
.auth-left::before {
  content: ''; position: absolute; top: -140px; right: -140px; width: 420px; height: 420px;
  border-radius: 50%; border: 1px dashed rgba(234,238,236,0.15);
}
.auth-left::after {
  content: ''; position: absolute; bottom: -120px; left: -120px; width: 320px; height: 320px;
  border-radius: 50%; border: 1px dashed rgba(156,43,34,0.35);
}
.auth-brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.auth-brand-name { font-family: var(--font-display); font-size: 1.35rem; color: var(--paper); line-height: 1.1; }
.auth-brand-name span {
  display: block; font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: rgba(234,238,236,0.55); margin-top: 6px;
}
.auth-left-content { position: relative; z-index: 1; }
.auth-left-tagline {
  font-family: var(--font-display); font-weight: 500; font-size: 2.6rem; line-height: 1.15;
  color: var(--paper); margin-bottom: 1.5rem;
}
.auth-left-tagline em { color: var(--ribbon); font-style: italic; }
.auth-left-desc { font-size: 1rem; line-height: 1.8; color: rgba(234,238,236,0.7); max-width: 420px; }
.auth-features { display: flex; flex-direction: column; gap: 16px; margin-top: 2.8rem; }
.auth-feature { display: flex; gap: 14px; align-items: flex-start; }
.auth-feature-icon {
  width: 40px; height: 40px; border-radius: 2px; background: rgba(234,238,236,0.06);
  border: 1px solid rgba(234,238,236,0.14); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--ribbon); font-size: 18px;
}
.auth-feature-text strong { display: block; color: rgba(234,238,236,0.94); font-size: 0.9rem; margin-bottom: 4px; font-weight: 600; }
.auth-feature-text span { font-size: 0.8rem; line-height: 1.5; color: rgba(234,238,236,0.55); }
.auth-left-footer { position: relative; z-index: 1; color: rgba(234,238,236,0.4); font-family: var(--font-mono); font-size: 0.75rem; }

.auth-right {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem;
  background: var(--surface);
}
.auth-card {
  width: 100%; max-width: 460px; background: var(--surface-raised);
  border-radius: var(--radius-lg); padding: 2.7rem; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.input-wrap { position: relative; }
.input-wrap i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); opacity: 0.7; font-size: 17px; }
.auth-card .form-input { padding-left: 44px; height: 50px; }
.auth-card .btn-primary, .auth-card .btn-outline { width: 100%; height: 48px; font-family: var(--font-body); }

@media (max-width: 900px) {
  .auth-left { display: none; }
  .auth-right { padding: 1.2rem; }
}
@media (max-width: 480px) {
  .auth-card { padding: 2rem 1.4rem; }
  .page-title { font-size: 1.6rem; }
}
