/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: #f0f2f5; color: #1a1a2e; min-height: 100vh; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* SIDEBAR LAYOUT                                                               */
/* ═══════════════════════════════════════════════════════════════════════════ */

:root { --sb-width: 240px; --sb-collapsed: 60px; }

/* ── Sidebar shell ────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sb-width);
  background: linear-gradient(180deg, #001f6b 0%, #003399 40%, #002580 100%);
  border-right: 1px solid rgba(255,204,0,.2);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width .22s ease;
  overflow: hidden;
}

/* ── Logo ── */
.sb-logo { padding: 1.1rem 1rem .9rem; border-bottom: 1px solid rgba(255,204,0,.15); flex-shrink: 0; }
.sb-logo-link { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.sb-logo-link:hover { text-decoration: none; }
.sb-logo-img  { height: 30px; width: 30px; object-fit: contain; flex-shrink: 0; border-radius: 4px; }
.sb-logo-text { color: #fff; font-size: 1rem; font-weight: 800; white-space: nowrap; overflow: hidden; }

/* ── Nav ── */
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .5rem 0; scrollbar-width: thin; scrollbar-color: rgba(255,204,0,.2) transparent; }

/* ── Item direct (Dashboard) ── */
.sb-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem; margin: .1rem .5rem; border-radius: 8px;
  color: rgba(255,255,255,.75); font-size: .875rem; font-weight: 500;
  text-decoration: none; transition: all .14s; white-space: nowrap; overflow: hidden;
}
.sb-item:hover  { background: rgba(255,204,0,.12); color: #ffcc00; text-decoration: none; }
.sb-item.active { background: rgba(255,204,0,.18); color: #ffcc00; font-weight: 700; border-left: 3px solid #ffcc00; padding-left: calc(1rem - 3px); }

/* ── Group (accordéon) ── */
.sb-group { margin: .1rem .5rem; }
.sb-group-trigger {
  width: 100%; display: flex; align-items: center; gap: .75rem;
  padding: .55rem .6rem; border-radius: 8px; border: none; background: transparent;
  color: rgba(255,255,255,.75); font-size: .875rem; font-weight: 500;
  cursor: pointer; text-align: left; transition: all .14s; white-space: nowrap; overflow: hidden;
}
.sb-group-trigger:hover  { background: rgba(255,204,0,.12); color: #ffcc00; }
.sb-group-trigger.active { color: #ffcc00; font-weight: 700; }
.sb-chevron { margin-left: auto; font-size: .8rem; transition: transform .2s; flex-shrink: 0; opacity: .6; }
.sb-group.open .sb-chevron { transform: rotate(90deg); }

/* ── Sub-items ── */
.sb-group-items {
  display: none; padding: .2rem 0 .3rem .5rem; overflow: hidden;
}
.sb-group.open .sb-group-items { display: block; }
.sb-subitem {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem .4rem 1.25rem; border-radius: 6px; margin: .05rem 0;
  color: rgba(255,255,255,.62); font-size: .82rem; font-weight: 400;
  text-decoration: none; transition: all .12s; white-space: nowrap; overflow: hidden;
  border-left: 2px solid transparent;
}
.sb-subitem:hover  { background: rgba(255,204,0,.1); color: #ffcc00; text-decoration: none; }
.sb-subitem.active { color: #ffcc00; font-weight: 600; border-left-color: #ffcc00; background: rgba(255,204,0,.08); }
.sb-sep { height: 1px; background: rgba(255,204,0,.1); margin: .3rem .5rem; }

/* ── Icon only (partagé item + trigger) ── */
.sb-icon { font-size: 1.05rem; flex-shrink: 0; width: 20px; text-align: center; }

/* ── Tooltip (mode icônes) ── */
.sidebar[data-collapsed] .sb-item[data-tooltip]:hover::after,
.sidebar[data-collapsed] .sb-group-trigger[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(var(--sb-collapsed) + 8px); top: 50%; transform: translateY(-50%);
  background: #1e293b; color: #f8fafc; font-size: .8rem; font-weight: 600;
  padding: .3rem .65rem; border-radius: 6px; white-space: nowrap; z-index: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

/* ── Footer sidebar ── */
.sb-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255,204,0,.15); flex-shrink: 0; }
.sb-user { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; overflow: hidden; }
.sb-role-badge { flex-shrink: 0; }
.sb-username { font-size: .78rem; color: rgba(255,255,255,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-footer-actions { display: flex; align-items: center; gap: .5rem; }
.sb-lang-btn {
  font-size: .75rem; font-weight: 700; color: rgba(255,204,0,.8);
  padding: .25rem .5rem; border-radius: 5px; border: 1px solid rgba(255,204,0,.3);
  transition: all .14s; white-space: nowrap; flex-shrink: 0;
}
.sb-lang-btn:hover { background: rgba(255,204,0,.15); color: #ffcc00; text-decoration: none; }
.sb-logout-btn {
  display: flex; align-items: center; gap: .4rem; flex: 1;
  padding: .3rem .6rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  color: rgba(255,255,255,.6); transition: all .14s; white-space: nowrap; overflow: hidden;
}
.sb-logout-btn:hover { background: rgba(220,38,38,.25); color: #fca5a5; text-decoration: none; }
.sb-logout-row {
  margin-top: .4rem;
  padding-top: .4rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sb-logout-row .sb-logout-btn {
  width: 100%;
  justify-content: center;
  background: rgba(220,38,38,.12);
  border-radius: 6px;
  font-weight: 700;
  color: rgba(255,180,180,.85);
}
.sb-logout-row .sb-logout-btn:hover {
  background: rgba(220,38,38,.3);
  color: #fca5a5;
}

/* ── Page wrapper (décalé de la sidebar) ── */
.page-wrapper {
  margin-left: var(--sb-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .22s ease;
}

/* ── Main content ── */
.main-content { flex: 1; padding: 2rem 2.5rem; max-width: 100%; }
.page-header  { margin-bottom: 1.75rem; }
.page-title   { font-size: 1.6rem; font-weight: 800; color: #111827; letter-spacing: -.02em; }
.page-sub     { color: #64748b; font-size: .9rem; margin-top: .4rem; }

/* ── Footer page ── */
.page-footer {
  text-align: center; padding: 1rem; font-size: .75rem; color: #94a3b8;
  border-top: 1px solid #e2e8f0; margin-top: 3rem;
}
.page-footer a { color: #94a3b8; }

/* ── Hamburger (visible uniquement mobile) ── */
.sb-hamburger {
  display: none; position: fixed; top: .75rem; left: .75rem; z-index: 300;
  background: #003399; border: none; border-radius: 8px; padding: .5rem;
  cursor: pointer; flex-direction: column; gap: 4px;
}
.sb-hamburger span { display: block; width: 20px; height: 2px; background: #ffcc00; border-radius: 2px; }
.sb-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190;
}
.sb-overlay.visible { display: block; }

/* ── Navbar (compatibilité pages qui utilisent encore .navbar) ── */
.navbar { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE — tablet ≤900px : sidebar icônes seules                          */
/* ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) and (min-width: 601px) {
  .sidebar { width: var(--sb-collapsed); }
  .page-wrapper { margin-left: var(--sb-collapsed); }

  /* Masquer les textes, garder les icônes */
  .sb-label, .sb-chevron, .sb-username, .sb-logo-text, .sb-subitem, .sb-sep { display: none; }
  .sb-group-items { display: none !important; }
  .sb-logo { padding: .9rem .6rem; justify-content: center; }
  .sb-logo-link { justify-content: center; }
  .sb-item, .sb-group-trigger {
    justify-content: center; padding: .6rem;
    margin: .1rem .3rem; position: relative;
  }
  .sb-icon { width: auto; }
  .sb-footer { padding: .5rem .3rem; }
  .sb-footer-actions { flex-direction: column; gap: .3rem; }
  .sb-lang-btn { font-size: .65rem; padding: .2rem .3rem; }
  .sb-logout-btn { justify-content: center; padding: .3rem; }
  .sb-user { justify-content: center; }
  .sb-username { display: none; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .g2,.g3,.g4 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE — mobile ≤600px : sidebar masquée + hamburger                    */
/* ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .page-wrapper { margin-left: 0; }
  .sb-hamburger { display: flex; }
  .main-content { padding: 1rem 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .g2,.g3,.g4 { grid-template-columns: 1fr; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card         { background: #fff; border-radius: 10px; padding: 1.5rem;
                box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04); }
.card + .card { margin-top: 1.25rem; }

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stats-grid   { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card    { background: #fff; border-radius: 10px; padding: 1.25rem 1.5rem;
                box-shadow: 0 1px 3px rgba(0,0,0,.08); border-left: 4px solid #2563eb; }
.stat-card.red    { border-color: #dc2626; }
.stat-card.green  { border-color: #16a34a; }
.stat-card.orange { border-color: #d97706; }
.stat-card.purple { border-color: #7c3aed; }
.stat-num   { font-size: 2rem; font-weight: 700; line-height: 1; color: #1a1a2e; }
.stat-label { font-size: .78rem; color: #64748b; margin-top: .3rem; font-weight: 500; }

/* ── Grilles ──────────────────────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ── Sections formulaire ──────────────────────────────────────────────────── */
.section-title { font-size: 1rem; font-weight: 700; color: #1e3a5f; margin: 2rem 0 1rem;
                 padding-bottom: .5rem; border-bottom: 2px solid #2563eb; }
.section-sub   { font-size: .875rem; font-weight: 600; color: #374151;
                 margin: 1.25rem 0 .75rem; }
.s4-block      { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px;
                 padding: 1.5rem; margin-top: 1rem; }
.s4-block .section-title { color: #dc2626; border-color: #dc2626; }

/* ── Form controls ────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 1.1rem; }
.form-label   { display: block; font-size: .875rem; font-weight: 600; color: #374151;
                margin-bottom: .4rem; }
.form-label .req { color: #dc2626; }
.form-control { width: 100%; padding: .6rem .9rem; border: 1.5px solid #d1d5db;
                border-radius: 8px; font-size: .95rem; font-family: inherit;
                transition: border .15s, box-shadow .15s; background: #fff; color: #1a1a2e; }
.form-control:focus { outline: none; border-color: #2563eb;
                      box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control   { cursor: pointer; }
.form-hint  { display: block; font-size: .78rem; color: #64748b; margin-top: .3rem; }

/* Checkboxes groupées */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
              gap: .35rem; margin-top: .35rem; }
.check-item { display: flex; align-items: center; gap: .4rem; padding: .35rem .6rem;
              border: 1.5px solid #e5e7eb; border-radius: 6px; cursor: pointer;
              font-size: .8rem; transition: all .15s; }
.check-item:hover  { border-color: #2563eb; background: #eff6ff; }
.check-item input  { cursor: pointer; width: 14px; height: 14px; flex-shrink: 0; }
.check-item.checked { border-color: #2563eb; background: #eff6ff; }
/* Checkbox inline */
.check-inline { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; }
.check-inline input  { width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.check-inline label  { font-size: .875rem; cursor: pointer; font-weight: 400; }

/* ── Boutons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.1rem;
       border: none; border-radius: 7px; font-size: .875rem; font-weight: 600;
       cursor: pointer; text-decoration: none; transition: all .15s; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary  { background: #2563eb; color: #fff; }
.btn-success  { background: #16a34a; color: #fff; }
.btn-danger   { background: #dc2626; color: #fff; }
.btn-secondary{ background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; width: 100%; justify-content: center; }

/* ── Alertes ──────────────────────────────────────────────────────────────── */
.alert         { padding: .85rem 1rem; border-radius: 8px; font-size: .875rem;
                 margin-bottom: 1.25rem; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert ul { margin: .5rem 0 0 1.25rem; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px;
         font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-minimal      { background: #dcfce7; color: #15803d; }
.badge-limited      { background: #fef9c3; color: #a16207; }
.badge-high         { background: #fee2e2; color: #dc2626; }
.badge-unacceptable { background: #1a1a2e; color: #fff; }
.badge-draft        { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-in_review    { background: #eff6ff; color: #1d4ed8; }
.badge-compliant    { background: #dcfce7; color: #15803d; }
.badge-non_compliant{ background: #fee2e2; color: #dc2626; }
.badge-in_progress  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-in__progress { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-exempted     { background: #f5f3ff; color: #6d28d9; }
/* ── Rôles utilisateur ─────────────────────────────── */
.badge-user        { background: #f1f5f9; color: #475569; }
.badge-admin       { background: #eff6ff; color: #1d4ed8; }
.badge-superadmin  { background: #1e3a5f; color: #fff; }
.badge-dpo         { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; font-weight: 700; }
.badge-ia_compliance_officer { background: #f5f3ff; color: #5b21b6; border: 1px solid #c4b5fd; font-weight: 700; }
.badge-viewer      { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }
/* ── États workflow dual-stage ─────────────────────── */
.badge-approved        { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.badge-rejected        { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.badge-in_review_ico   { background: #f5f3ff; color: #5b21b6; border: 1px solid #c4b5fd; }
.badge-ico_approved    { background: #eff6ff; color: #2563eb; border: 1px solid #93c5fd; }
.badge-in_review_dpo   { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-dpo_approved    { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; font-weight: 700; }
.badge-in_review_directeur { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-legal           { background: #fff1f2; color: #881337; border: 1px solid #fda4af; font-weight: 700; }
/* ── Sévérité incidents ────────────────────────────── */
.badge-low         { background: #f0fdf4; color: #15803d; }
.badge-medium      { background: #fef9c3; color: #a16207; }
.badge-high        { background: #fee2e2; color: #dc2626; }
.badge-critical    { background: #1a1a2e; color: #fff; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table  { width: 100%; border-collapse: collapse; font-size: .85rem; }
th     { background: #f8fafc; padding: .6rem .9rem; text-align: left;
         font-weight: 600; color: #475569; border-bottom: 2px solid #e2e8f0;
         white-space: nowrap; }
td     { padding: .6rem .9rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress     { background: #e5e7eb; border-radius: 20px; height: 7px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: #16a34a; transition: width .3s; }

/* ── Filters bar ──────────────────────────────────────────────────────────── */
.filters { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem;
           flex-wrap: wrap; }
.filters input, .filters select { padding: .4rem .7rem; border: 1.5px solid #d1d5db;
   border-radius: 6px; font-size: .82rem; }

/* ── Detail view ──────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 180px 1fr; gap: .4rem .75rem;
               font-size: .875rem; }
.detail-label { color: #64748b; font-weight: 500; }
.detail-value { color: #1a1a2e; }

/* ── Auth page ────────────────────────────────────────────────────────────── */
.auth-wrapper { display: flex; justify-content: center; align-items: center;
                min-height: 100vh; padding: 1rem; background: #f0f2f5; }
.auth-card    { background: #fff; border-radius: 12px; padding: 2.25rem;
                box-shadow: 0 4px 24px rgba(0,0,0,.1); width: 100%; max-width: 440px; }
.auth-logo    { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 1.75rem; color: #1a1a2e; }
.auth-logo p  { color: #64748b; font-size: .82rem; margin-top: .3rem; }
.auth-tabs    { display: flex; border-bottom: 2px solid #e5e7eb; margin-bottom: 1.75rem; }
.auth-tab     { flex: 1; text-align: center; padding: .65rem; font-size: .875rem;
                font-weight: 600; color: #94a3b8; border-bottom: 2px solid transparent;
                margin-bottom: -2px; transition: all .2s; }
.auth-tab.active { color: #2563eb; border-color: #2563eb; }
.auth-tab:hover  { text-decoration: none; color: #2563eb; }

/* ── Sélecteur de langue (compatibilité anciens templates) ───────────────── */
.lang-switcher { display: flex; align-items: center; gap: .2rem; }
.lang-btn      { color: #64748b; font-size: .72rem; font-weight: 700; padding: .2rem .35rem;
                 border-radius: 4px; transition: all .15s; letter-spacing: .04em; }
.lang-btn:hover     { color: #fff; text-decoration: none; }
.lang-active        { color: #fff !important; background: #2563eb; }
.lang-sep           { color: #334155; font-size: .65rem; }

/* ── Wizard steps ────────────────────────────────────────────────────────── */
.wizard-steps { display:flex; gap:0; margin-bottom:2rem;
                border-radius:10px; overflow:hidden;
                box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.wizard-step  { flex:1; display:flex; flex-direction:column; align-items:center;
                padding:.6rem .4rem; background:#f8fafc;
                border-right:1px solid #e2e8f0;
                text-decoration:none; transition:all .15s; color:#64748b;
                font-size:.75rem; }
.wizard-step:last-child { border-right:none; }
.wizard-step:hover { background:#eff6ff; color:#2563eb; text-decoration:none; }
.wizard-step.active { background:#2563eb; color:#fff; }
.wizard-step.done   { background:#dcfce7; color:#15803d; }
.step-num   { font-size:1rem; font-weight:700; line-height:1; }
.step-title { font-size:.65rem; margin-top:.25rem; text-align:center;
              white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
              max-width:90px; }
.wizard-nav { display:flex; gap:1rem; margin-top:1.5rem; align-items:center;
              padding-top:1.25rem; border-top:1px solid #e2e8f0; }
.wizard-progress { font-size:.8rem; color:#64748b; margin-left:auto; }

/* ── ISO 42001 gauge ────────────────────────────────────────────────────── */
.gauge-bar { height:8px; background:#e2e8f0; border-radius:4px; overflow:hidden; }
.gauge-fill { height:100%; border-radius:4px; transition:width .4s; }
.gauge-fill.green  { background:#16a34a; }
.gauge-fill.orange { background:#d97706; }
.gauge-fill.red    { background:#dc2626; }

/* ── Control status badges ──────────────────────────────────────────────── */
.ctrl-not_started   { background:#f1f5f9; color:#64748b; }
.ctrl-in_progress   { background:#fef3c7; color:#92400e; }
.ctrl-implemented   { background:#dcfce7; color:#166534; }
.ctrl-not_applicable{ background:#f5f3ff; color:#5b21b6; }
