/* ============================================================
   KinAlert — Design System
   ============================================================ */

:root {
  --primary:       #E8311A;
  --primary-dark:  #C0281A;
  --primary-light: #FF6B55;
  --secondary:     #1A2535;
  --secondary-light:#2C3E50;
  --accent:        #F5A623;
  --success:       #27AE60;
  --warning:       #F39C12;
  --danger:        #E74C3C;
  --info:          #3498DB;

  --surface:       #FFFFFF;
  --surface-2:     #F8F9FA;
  --bg:            #F2F4F7;
  --text:          #1A2535;
  --text-muted:    #6B7280;
  --border:        #E5E7EB;
  --border-light:  #F3F4F6;

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-sm:  0 1px 4px rgba(0,0,0,.06);
  --shadow:     0 4px 20px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.12);
  --shadow-primary: 0 8px 24px rgba(232,49,26,.30);

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --nav-h: 64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

/* ── Typography ── */
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem);   font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.2rem; font-weight: 700; }
h4 { font-size: 1rem;   font-weight: 600; }
p  { color: var(--text-muted); line-height: 1.7; }

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.navbar-brand img { height: 36px; }
.navbar-spacer { flex: 1; }
.navbar-nav { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  padding: .5rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: var(--surface-2);
  color: var(--text);
}
.nav-link.active { color: var(--primary); font-weight: 600; }
.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-primary);
}
.nav-cta:hover { background: var(--primary-dark); transform: translateY(-1px); }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: .4rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.5rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(232,49,26,.35); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-light); }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(232,49,26,.04); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .45rem 1rem; font-size: .85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { padding: .6rem; border-radius: 50%; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-primary   { background: rgba(232,49,26,.12);  color: var(--primary); }
.badge-success   { background: rgba(39,174,96,.12);  color: var(--success); }
.badge-warning   { background: rgba(243,156,18,.12); color: var(--warning); }
.badge-danger    { background: rgba(231,76,60,.12);  color: var(--danger); }
.badge-info      { background: rgba(52,152,219,.12); color: var(--info); }
.badge-secondary { background: rgba(26,37,53,.08);  color: var(--secondary); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
}

/* ── Gravity badges ── */
.gravite-faible   { background: rgba(52,152,219,.12);  color: #2980B9; }
.gravite-moyenne  { background: rgba(243,156,18,.12);  color: #E67E22; }
.gravite-elevee   { background: rgba(231,76,60,.12);   color: #C0392B; }
.gravite-critique { background: rgba(192,40,26,.15);   color: #9B1A0A; }

/* ── Status badges ── */
.statut-en_attente { background: #FFF3CD; color: #856404; }
.statut-valide     { background: #D1ECF1; color: #0C5460; }
.statut-en_cours   { background: #CCE5FF; color: #004085; }
.statut-resolu     { background: #D4EDDA; color: #155724; }
.statut-rejete     { background: #F8D7DA; color: #721C24; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .3rem;
}
.form-label .required { color: var(--primary); }
.form-control {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
  appearance: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,49,26,.1); }
.form-control::placeholder { color: #B0B8C4; }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: .8rem; color: var(--text-muted); }
.form-error { font-size: .8rem; color: var(--danger); display: flex; align-items: center; gap: .25rem; }
textarea.form-control { resize: vertical; min-height: 110px; }

/* Gravité radio group */
.gravite-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media(min-width: 480px) { .gravite-options { grid-template-columns: repeat(4, 1fr); } }
.gravite-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.gravite-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .6rem .5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  transition: var(--transition);
  text-align: center;
  user-select: none;
}
.gravite-option label span.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.gravite-option input:checked + label { border-width: 2px; }
.gravite-option[data-val="faible"]   input:checked + label { border-color: #3498DB; color: #2980B9; background: rgba(52,152,219,.07); }
.gravite-option[data-val="moyenne"]  input:checked + label { border-color: #F39C12; color: #E67E22; background: rgba(243,156,18,.07); }
.gravite-option[data-val="elevee"]   input:checked + label { border-color: #E74C3C; color: #C0392B; background: rgba(231,76,60,.07); }
.gravite-option[data-val="critique"] input:checked + label { border-color: #9B1A0A; color: #9B1A0A; background: rgba(155,26,10,.07); }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: var(--surface-2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(232,49,26,.03);
}
.upload-zone .upload-icon { font-size: 2.5rem; margin: 0 auto .5rem; }
.upload-zone h4 { color: var(--text); margin-bottom: .25rem; }
.upload-zone p  { font-size: .85rem; }
.upload-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .5rem;
  margin-top: .75rem;
}
.upload-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: .65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.upload-preview .file-icon { font-size: 2rem; }
.upload-progress {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  margin-top: .5rem;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width .3s ease;
}

/* ── Step wizard ── */
.steps-nav {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 4px;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  flex: 1;
  min-width: 60px;
  position: relative;
}
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: var(--transition);
}
.step-item.done:not(:last-child)::after { background: var(--primary); }
.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  transition: var(--transition);
}
.step-item.active .step-number { border-color: var(--primary); color: var(--primary); background: rgba(232,49,26,.08); }
.step-item.done   .step-number { border-color: var(--primary); background: var(--primary); color: #fff; }
.step-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.step-item.active .step-label { color: var(--primary); }
.step-item.done   .step-label { color: var(--success); }

/* ── Alert / Toast ── */
.alert {
  display: flex;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.alert-success { background: #D4EDDA; color: #155724; border-color: var(--success); }
.alert-danger  { background: #F8D7DA; color: #721C24; border-color: var(--danger);  }
.alert-warning { background: #FFF3CD; color: #856404; border-color: var(--warning); }
.alert-info    { background: #D1ECF1; color: #0C5460; border-color: var(--info);    }
.alert-icon    { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* Token box (affiché une seule fois) */
.token-box {
  background: linear-gradient(135deg, #1A2535, #2C3E50);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.token-box .token-label { font-size: .8rem; opacity: .7; margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .08em; }
.token-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: .85rem;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  word-break: break-all;
  letter-spacing: .05em;
  border: 1px solid rgba(255,255,255,.15);
  cursor: text;
  user-select: all;
}
.token-warning {
  margin-top: .75rem;
  font-size: .8rem;
  opacity: .8;
  display: flex;
  align-items: flex-start;
  gap: .4rem;
}

/* ── Timeline (journal statuts) ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 1rem;
  padding-bottom: 1.25rem;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 36px;
  width: 2px;
  bottom: 0;
  background: var(--border);
}
.timeline-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-content { flex: 1; padding-top: .25rem; }
.timeline-date { font-size: .75rem; color: var(--text-muted); }

/* ── Commune map chip ── */
.commune-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 600;
  background: rgba(26,37,53,.07);
  color: var(--secondary);
}
.commune-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Utility ── */
.container { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 4rem 0; }
.section-sm { padding: 2rem 0; }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.d-none { display: none !important; }
.visually-hidden { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.spinner-dark { border-color: rgba(26,37,53,.2); border-top-color: var(--secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 .6rem;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -400% 0; } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar-nav { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: .75rem 1rem 1rem; gap: .25rem; z-index: 99; box-shadow: var(--shadow); }
  .navbar-nav.open { display: flex; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .gravite-options { grid-template-columns: repeat(2,1fr); }
  .nav-cta { padding: .45rem .9rem; font-size: .85rem; }
}
