/* =====================================================================
   Cabinet IAC — Système d'alertes & échéances
   Design : éditorial moderne, sobre, accents colorés selon urgence
   ===================================================================== */

/* ---------- Polices ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Palette de base — anthracite & ivoire */
  --bg:           #f7f4ee;
  --bg-soft:      #efeae0;
  --surface:      #ffffff;
  --ink:          #1a1a1a;
  --ink-soft:     #4a4a4a;
  --ink-mute:     #8a8580;
  --line:         #e3ddd1;
  --line-soft:    #efeae0;

  /* Accent principal — bordeaux profond (sérieux, juridique) */
  --accent:       #7c2d2d;
  --accent-soft:  #f5e8e8;

  /* Niveaux d'alerte */
  --depasse:      #7f1d1d;
  --critique:     #dc2626;
  --urgent:       #ea580c;
  --attention:    #ca8a04;
  --normal:       #0e7490;
  --inactif:      #94a3b8;

  /* Tailles */
  --radius:       4px;
  --radius-lg:    8px;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 16px rgba(26,26,26,.06);
  --shadow-lg:    0 12px 32px rgba(26,26,26,.10);

  /* Typo */
  --serif:    'Fraunces', Georgia, serif;
  --sans:     'Inter', -apple-system, sans-serif;
  --mono:     'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 2.4rem; line-height: 1.1; }
h2 { font-size: 1.6rem; line-height: 1.2; }
h3 { font-size: 1.2rem; line-height: 1.3; }
.eyebrow { font-family: var(--sans); font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }

/* ---------- Layout principal ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--ink);
  color: #f7f4ee;
  padding: 2rem 1.25rem;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.sidebar__brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 1.5rem;
}
.sidebar__brand small {
  display: block;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .2em;
  color: #8a8580;
  text-transform: uppercase;
  margin-top: .25rem;
}
.sidebar__nav { list-style: none; padding: 0; margin: 0; flex: 1; }
.sidebar__nav li { margin-bottom: .25rem; }
.sidebar__nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .85rem;
  color: #c9c4ba;
  border-radius: var(--radius);
  font-size: .92rem;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.sidebar__nav a:hover { background: #2a2a2a; color: #fff; }
.sidebar__nav a.active {
  background: #fff; color: var(--ink); font-weight: 600;
}
.sidebar__nav .badge {
  margin-left: auto;
  background: var(--critique);
  color: #fff;
  font-size: .7rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.sidebar__footer {
  font-size: .75rem;
  color: #6a655e;
  border-top: 1px solid #2a2a2a;
  padding-top: 1rem;
}

/* ---------- Main ---------- */
.main { padding: 2.5rem 3rem; max-width: 1400px; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 2rem; margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.page-header__title h1 { font-style: italic; }
.page-header__actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--sans);
  font-size: .88rem; font-weight: 500;
  padding: .6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); }
.btn--accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--accent:hover { background: #5e2222; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--critique); border-color: #fbb; }
.btn--danger:hover { background: #fee; }
.btn--sm { padding: .35rem .7rem; font-size: .8rem; }

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--ink-mute);
}
.stat--depasse::before   { background: var(--depasse); }
.stat--critique::before  { background: var(--critique); }
.stat--urgent::before    { background: var(--urgent); }
.stat--attention::before { background: var(--attention); }
.stat--normal::before    { background: var(--normal); }
.stat--total::before     { background: var(--ink); }

.stat__label { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.stat__value { font-family: var(--serif); font-size: 2.4rem; font-weight: 700; line-height: 1; margin-top: .35rem; }
.stat__sub   { font-size: .8rem; color: var(--ink-soft); margin-top: .2rem; }

/* ---------- Sections ---------- */
.section { margin-bottom: 3rem; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 1rem; gap: 1rem;
}
.section__head h2 { font-style: italic; }
.section__head .eyebrow { display: block; margin-bottom: .35rem; }

/* ---------- Tableau ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: .85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th {
  background: var(--bg-soft);
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fdfbf7; }
.table .row--depasse  { background: #fef2f2; }
.table .row--depasse:hover { background: #fee2e2; }

/* ---------- Niveau badge ---------- */
.niveau {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}
.niveau::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.niveau--depasse   { color: var(--depasse);   background: #fef2f2; }
.niveau--critique  { color: var(--critique);  background: #fef2f2; }
.niveau--urgent    { color: var(--urgent);    background: #fff7ed; }
.niveau--attention { color: var(--attention); background: #fefce8; }
.niveau--normal    { color: var(--normal);    background: #ecfeff; }
.niveau--inactif   { color: var(--inactif);   background: #f1f5f9; }

/* ---------- Catégorie pill ---------- */
.cat-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 500;
  padding: 2px 8px; border-radius: var(--radius);
  background: var(--bg-soft); color: var(--ink-soft);
}
.cat-pill__dot { width: 8px; height: 8px; border-radius: 2px; }

/* ---------- Formulaires ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm);
  max-width: 900px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.form-grid--full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field--full { grid-column: 1 / -1; }
.field label {
  font-size: .78rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink-soft); text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  font-family: var(--sans); font-size: .95rem;
  padding: .65rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff; color: var(--ink);
  transition: border .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,45,45,.1);
}
.field textarea { resize: vertical; min-height: 90px; }
.field__hint { font-size: .78rem; color: var(--ink-mute); }

.form-actions {
  display: flex; gap: .75rem; justify-content: flex-end;
  margin-top: 2rem; padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

/* Multi-select de collaborateurs */
.collab-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .5rem;
  max-height: 280px; overflow-y: auto;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.collab-picker label {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem;
  background: #fff; border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  color: var(--ink);
  transition: all .12s;
}
.collab-picker label:hover { border-color: var(--ink-mute); }
.collab-picker input:checked + span { font-weight: 600; }
.collab-picker label:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent);
}

/* ---------- Détail événement ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
.detail-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}
.detail-card h3 { font-style: italic; margin-bottom: 1rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line-soft); }
.detail-row { display: flex; padding: .65rem 0; border-bottom: 1px dashed var(--line-soft); gap: 1rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row dt { flex: 0 0 180px; font-size: .8rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.detail-row dd { flex: 1; margin: 0; color: var(--ink); }

/* ---------- Compteur jours ---------- */
.countdown {
  font-family: var(--serif);
  font-size: 3rem; font-weight: 700;
  line-height: 1;
}
.countdown--depasse  { color: var(--depasse); }
.countdown--critique { color: var(--critique); }
.countdown--urgent   { color: var(--urgent); }
.countdown--attention{ color: var(--attention); }
.countdown--normal   { color: var(--normal); }
.countdown small { font-size: .9rem; font-family: var(--sans); font-weight: 500; color: var(--ink-mute); display: block; margin-top: .25rem; }

/* ---------- Filtres ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.filters input, .filters select {
  font-size: .9rem;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.filters input[type="search"] { flex: 1; min-width: 220px; }

/* ---------- Flash messages ---------- */
.flash {
  padding: .85rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: .9rem;
  border-left: 3px solid;
}
.flash--success { background: #ecfdf5; color: #065f46; border-color: #10b981; }
.flash--error   { background: #fef2f2; color: #991b1b; border-color: #dc2626; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 3rem 2rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink-mute);
}
.empty__icon { font-size: 2rem; margin-bottom: .5rem; opacity: .4; }

/* ---------- Utilities ---------- */
.muted { color: var(--ink-mute); }
.mono  { font-family: var(--mono); font-size: .85em; }
.text-right { text-align: right; }
.flex { display: flex; gap: .75rem; align-items: center; }
.gap-sm { gap: .35rem; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 1.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
