/* ===================================================================
   PROBATIKOS — feuille de style de base
   =================================================================== */

:root {
  --bleu:      #1d4ed8;
  --bleu-soft: #eff4ff;
  --texte:     #1f2733;
  --gris:      #6b7280;
  --bord:      #e5e7eb;
  --fond:      #f5f7fb;
  --blanc:     #ffffff;
  --rouge:     #dc2626;
  --vert:      #16a34a;
  --radius:    12px;
  --ombre:     0 2px 8px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--texte);
  background: var(--fond);
  line-height: 1.5;
}
a { color: var(--bleu); text-decoration: none; }
h1, h2 { margin: 0 0 .3em; }

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .65rem 1.1rem; border: 0; border-radius: 8px;
  font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--bleu); color: #fff; }
.btn-primary:hover { background: #1640b8; }
.btn-block { width: 100%; }

/* ── Champs / alertes ────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-size: .9rem; font-weight: 600; }
.field input {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--bord);
  border-radius: 8px; font-size: .95rem;
}
.field input:focus { outline: 2px solid var(--bleu-soft); border-color: var(--bleu); }

.form-alert { padding: .7rem .9rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.form-alert--error   { background: #fef2f2; color: var(--rouge); }
.form-alert--success { background: #f0fdf4; color: var(--vert); }
.form-alert--info    { background: var(--bleu-soft); color: var(--bleu); }

/* ── Site public (accueil / inscription) ─────────────────── */
body.public { background: var(--fond); }
.public-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; background: #fff; border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; z-index: 10;
}
.public-logo { font-size: 1.4rem; font-weight: 800; color: var(--bleu); letter-spacing: .5px; }
.public-main { max-width: 820px; margin: 0 auto; padding: 2rem 1.25rem; }
.public-hero { text-align: center; margin-bottom: 1.5rem; }
.public-hero h1 { font-size: 2rem; margin-bottom: .4rem; }
.public-hero p { color: var(--gris); max-width: 560px; margin: 0 auto; }
.public-card { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 2rem; }
.public-card h2 { margin-bottom: 1.25rem; }
.public-footer { text-align: center; color: var(--gris); font-size: .82rem; padding: 1.5rem; }

/* ── Authentification ────────────────────────────────────── */
body.auth { display: grid; place-items: center; min-height: 100vh; }
.auth-wrap { width: 100%; max-width: 420px; padding: 1.5rem; }
.auth-card { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 2rem; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-logo { display: block; font-size: 1.6rem; font-weight: 800; color: var(--bleu); letter-spacing: .5px; }
.auth-tagline { display: block; font-size: .8rem; color: var(--gris); margin-top: .25rem; }
.auth-title { font-size: 1.4rem; }
.auth-sub { color: var(--gris); margin: 0 0 1.25rem; font-size: .92rem; }
.auth-foot { text-align: center; color: var(--gris); font-size: .8rem; margin-top: 1rem; }

/* ── Application (shell + sidebar) ───────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 250px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 1rem 0;
}
.app-logo { display: block; padding: .5rem 1.5rem 1.25rem; font-size: 1.3rem; font-weight: 800; color: #fff; }
.app-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; }
.app-nav-link {
  display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem;
  border-radius: 8px; color: #cbd5e1; font-size: .92rem;
}
.app-nav-link:hover { background: #1e293b; color: #fff; }
.app-nav-link.active { background: var(--bleu); color: #fff; }
.app-nav-link .ic { width: 1.25rem; text-align: center; }
.app-nav-link.soon { opacity: .55; cursor: default; }
.app-nav-caret { margin-left: auto; font-size: .7rem; opacity: .7; transition: transform .15s; }
.app-nav-group.open .app-nav-caret, .app-nav-group:hover .app-nav-caret { transform: rotate(180deg); }
.app-subnav { display: none; flex-direction: column; gap: 1px; padding: 2px 0 4px; }
.app-nav-group:hover .app-subnav, .app-nav-group.open .app-subnav { display: flex; }
.app-subnav-link {
  display: block; padding: .4rem .75rem .4rem 2.7rem; color: #cbd5e1;
  font-size: .86rem; border-radius: 8px;
}
.app-subnav-link:hover { background: #1e293b; color: #fff; }
.app-subnav-link.active { color: #fff; background: rgba(29,78,216,.4); }
.badge-soon { margin-left: auto; font-size: .65rem; background: #334155; color: #cbd5e1; padding: 1px 6px; border-radius: 999px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: .75rem 1.5rem; border-bottom: 1px solid var(--bord);
}
.app-user { display: flex; align-items: center; gap: .6rem; }
.app-user-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bord); }
.app-user-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--bleu); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.05rem;
}
.app-user-name { font-weight: 600; }
.app-user-role { display: block; font-size: .78rem; color: var(--gris); }
.app-logout { background: #f1f5f9; border: 0; padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.app-logout:hover { background: #e2e8f0; }
.app-content { padding: 1.75rem; }

/* ── Page interne ────────────────────────────────────────── */
.page-head { margin-bottom: 1.5rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bleu); font-weight: 700; }
.lead { color: var(--gris); margin: .25rem 0 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 1.1rem; }
.stat .k { font-size: .82rem; color: var(--gris); }
.stat .v { display: block; font-size: 1.8rem; font-weight: 800; margin: .2rem 0; }
.stat .s { font-size: .78rem; color: var(--gris); }

.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 1.5rem; }
.feature-list { margin: .5rem 0 0; padding-left: 1.1rem; }
.feature-list li { margin-bottom: .4rem; }

/* ── Variantes de boutons ────────────────────────────────── */
.btn-light  { background: #f1f5f9; color: var(--texte); }
.btn-light:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: var(--rouge); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }
.inline { display: inline; }

/* ── En-tête de page avec action à droite ────────────────── */
.page-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.form-actions { display: flex; gap: .6rem; align-items: center; }

/* ── Sous-onglets ────────────────────────────────────────── */
.subtabs { display: flex; gap: .3rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--bord); }
.subtab { padding: .55rem 1rem; color: var(--gris); font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.subtab:hover { color: var(--texte); }
.subtab.active { color: var(--bleu); border-bottom-color: var(--bleu); }

/* ── Barre d'outils (recherche / filtres) ────────────────── */
.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-search { flex: 1; min-width: 200px; padding: .55rem .75rem; border: 1px solid var(--bord); border-radius: 8px; }
.toolbar-select { padding: .55rem .75rem; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }

/* ── Tableau ─────────────────────────────────────────────── */
/* overflow-x: auto (au lieu de hidden) : un tableau plus large que l'écran
   (mobile) devient défilable horizontalement au lieu d'être tronqué. */
.panel--flush { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--bord); }
.table th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); }
.table tbody tr:hover { background: #f8fafc; }
.table .ta-right { text-align: right; }
.tlink { color: inherit; }
.tlink:hover { color: var(--bleu); }
.empty { padding: 2rem; text-align: center; color: var(--gris); }

/* ── Badges de statut ────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: #e2e8f0; color: #334155; }
.badge--visiteur         { background: #fef9c3; color: #854d0e; }
.badge--nouveau_converti { background: #dcfce7; color: #166534; }
.badge--membre           { background: var(--bleu-soft); color: var(--bleu); }
.badge--responsable      { background: #ede9fe; color: #6d28d9; }
.badge--inactif          { background: #f1f5f9; color: #64748b; }
.badge--muted            { background: #f1f5f9; color: #94a3b8; }

/* ── Formulaire en grille ────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.form-grid .field--full { grid-column: 1 / -1; }
.form-grid select { width: 100%; padding: .6rem .75rem; border: 1px solid var(--bord); border-radius: 8px; background: #fff; font-size: .95rem; }
.form-section-title { grid-column: 1 / -1; margin: 1.1rem 0 .2rem; font-size: 1rem; color: var(--bleu); border-bottom: 1px solid var(--bord); padding-bottom: .35rem; }
.form-grid input[type="file"] { width: 100%; padding: .5rem; border: 1px dashed var(--bord); border-radius: 8px; background: #fafbfc; }
.checkline { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkline input { width: auto; }

/* ── Liste de données (fiche) ────────────────────────────── */
.datalist { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 2rem; margin: 0; }
.datalist dt { font-size: .78rem; color: var(--gris); text-transform: uppercase; letter-spacing: .03em; }
.datalist dd { margin: .15rem 0 0; font-weight: 500; }

/* ── Formulaire en sections (fieldset) ───────────────────── */
.section { border: 0; margin-bottom: 1.25rem; }
.section legend { font-weight: 700; font-size: 1rem; padding: 0 .5rem; color: var(--bleu); }
.hint { color: var(--gris); font-size: .82rem; margin: .5rem 0 0; }
textarea { width: 100%; padding: .6rem .75rem; border: 1px solid var(--bord); border-radius: 8px; font-family: inherit; font-size: .95rem; resize: vertical; }
input[type="number"] { width: 100%; padding: .6rem .75rem; border: 1px solid var(--bord); border-radius: 8px; font-size: .95rem; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: .5rem .75rem; }
.abs-row { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.abs-row select { flex: 0 0 230px; padding: .55rem; border: 1px solid var(--bord); border-radius: 8px; }
.abs-row input { flex: 1; padding: .55rem .75rem; border: 1px solid var(--bord); border-radius: 8px; }

/* ── Panneau de score ────────────────────────────────────── */
.score-panel { display: flex; gap: 2rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; border-left: 6px solid var(--gris); }
.score-panel--faible    { border-left-color: #dc2626; }
.score-panel--moyen     { border-left-color: #f59e0b; }
.score-panel--bon       { border-left-color: #16a34a; }
.score-panel--excellent { border-left-color: #7c3aed; }
.score-main { text-align: center; min-width: 130px; }
.score-value { display: block; font-size: 2.8rem; font-weight: 800; line-height: 1; }
.score-value small { font-size: 1rem; color: var(--gris); font-weight: 500; }
.score-appr { display: block; margin-top: .4rem; font-weight: 600; }
.score-breakdown { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: .5rem; }
.sb-row { display: grid; grid-template-columns: 160px 1fr 44px; align-items: center; gap: .6rem; font-size: .82rem; }
.sb-bar { background: #eef2f7; border-radius: 999px; height: 9px; overflow: hidden; }
.sb-bar span { display: block; height: 100%; background: var(--bleu); border-radius: 999px; }
.sb-val { text-align: right; font-weight: 600; }

/* ── Badges de statut de rapport ─────────────────────────── */
.badge--st-brouillon { background: #f1f5f9; color: #64748b; }
.badge--st-soumis    { background: #fef9c3; color: #854d0e; }
.badge--st-valide    { background: #dcfce7; color: #166534; }
.badge--st-rejete    { background: #fee2e2; color: #b91c1c; }

/* ── Bloc de validation ──────────────────────────────────── */
.val-panel { margin-top: 1.25rem; }
.val-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.val-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--bord); }
.val-reject { display: flex; gap: .5rem; align-items: center; flex: 1; min-width: 260px; }
.val-reject input { flex: 1; padding: .55rem .75rem; border: 1px solid var(--bord); border-radius: 8px; }

/* ── Tableau de bord ─────────────────────────────────────── */
.stat--link { text-decoration: none; color: inherit; transition: box-shadow .15s; }
.stat--link:hover { box-shadow: 0 4px 14px rgba(16,24,40,.12); }
.stat--alert { border-left: 4px solid var(--rouge); }
.trend-up { color: var(--vert); font-weight: 600; }
.trend-down { color: var(--rouge); font-weight: 600; }
.panel-head { padding: 1.1rem 1.25rem 0; }
.panel-head h2 { margin: 0; }

.alert-list, .notif-list { list-style: none; margin: 0; padding: 0; }
.alert-item { display: flex; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--bord); }
.alert-item:last-child { border-bottom: 0; }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: .35rem; flex: 0 0 auto; background: var(--gris); }
.alert--info .alert-dot     { background: #3b82f6; }
.alert--attention .alert-dot { background: #f59e0b; }
.alert--critique .alert-dot  { background: #dc2626; }

.notif-item { padding: .55rem 0; border-bottom: 1px solid var(--bord); }
.notif-item:last-child { border-bottom: 0; }
.notif--unread { border-left: 3px solid var(--bleu); padding-left: .6rem; margin-left: -.6rem; }
.notif-row { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }

/* Badges de type de structure */
.badge--dep-assemblee      { background: #1e293b; color: #fff; }
.badge--dep-sous_direction { background: #ede9fe; color: #6d28d9; }
.badge--dep-departement    { background: #dbeafe; color: #1e40af; }
.badge--dep-tribu          { background: #dcfce7; color: #166534; }
.badge--dep-cellule        { background: #fef9c3; color: #854d0e; }

/* Badges de gravité d'alerte */
.badge--grav-info      { background: #dbeafe; color: #1e40af; }
.badge--grav-attention { background: #fef9c3; color: #854d0e; }
.badge--grav-critique  { background: #fee2e2; color: #b91c1c; }

/* Badge de compteur dans le menu latéral */
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--rouge); color: #fff; font-size: .72rem; font-weight: 700;
  border-radius: 999px;
}

/* ── Graphiques ──────────────────────────────────────────── */
.chart-box { position: relative; height: 260px; }

/* ── Impression (PDF via le navigateur) ──────────────────── */
@media print {
  .app-sidebar, .app-topbar, .no-print, .form-actions, .val-actions,
  .val-reject, .toolbar, .nav-badge, .badge-soon { display: none !important; }
  body, .app, .app-shell, .app-main { display: block !important; background: #fff !important; }
  .app-content { padding: 0 !important; }
  .panel, .stat { box-shadow: none !important; border: 1px solid #d0d5dd !important; break-inside: avoid; }
  .two-col, .cards, .form-grid { display: block !important; }
  .two-col > *, .cards > * { margin-bottom: 12px; }
  a { color: #000 !important; text-decoration: none !important; }
  @page { margin: 1.4cm; }
}

/* ── Mise en page 2 colonnes ─────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.plain-list { margin: 0; padding-left: 1.1rem; }
.plain-list li { margin-bottom: .35rem; }
.taglist { display: flex; flex-wrap: wrap; gap: .4rem; }

@media (max-width: 720px) {
  .app-sidebar { width: 64px; }
  .app-logo, .app-nav-link span:not(.ic):not(.nav-badge), .badge-soon { display: none; }
  /* Le compteur devient un badge flottant sur l'icône (menu réduit aux icônes seules). */
  .app-nav-link { position: relative; justify-content: center; }
  .app-nav-link .nav-badge {
    position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px;
    padding: 0 4px; font-size: .62rem;
  }
  .form-grid, .datalist, .two-col { grid-template-columns: 1fr; }
  .sb-row { grid-template-columns: 120px 1fr 40px; }
  /* Garde des colonnes lisibles : le tableau dépasse l'écran et devient
     défilable horizontalement (cf. .panel--flush) au lieu de s'écraser. */
  .table { width: max-content; min-width: 100%; }
}
