/* ============================================================
   style.css  —  Audit App  (Bootstrap 5 + custom)
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --primary:        #0d6efd;
  --primary-light:  #e8f0fe;
  --success:        #198754;
  --danger:         #dc3545;
  --warning:        #ffc107;
  --bg:             #f4f5f7;
  --surface:        #ffffff;
  --border:         #e2e5ea;
  --text:           #1a1d23;
  --muted:          #6c757d;
  --badge-bg:       #e9ecef;
  --badge-text:     #495057;
  --nav-height:     64px;
  --header-height:  56px;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

/* ── Reset / base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Layout principal ─────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .header-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  text-align: center;
  margin: 0;
}

.header-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.header-btn:hover,
.header-btn:active { background: var(--bg); }
.header-btn svg    { width: 22px; height: 22px; }

/* ── Contenu scrollable ───────────────────────────────────── */
.app-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Pages (vue router simple) ────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Liste départements ───────────────────────────────────── */
.dept-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
}

.dept-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: var(--text);
}
.dept-item:last-child { border-bottom: none; }
.dept-item:active,
.dept-item:hover      { background: var(--primary-light); }

.dept-item .dept-name {
  font-size: 16px;
  font-weight: 400;
  flex: 1;
}

.dept-item .dept-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 13px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 12px;
  margin-right: 10px;
  min-width: 34px;
  text-align: center;
}

.dept-item .dept-chevron {
  color: #c0c4cc;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Ligne "Tout" ─────────────────────────────────────────── */
.dept-item.is-all .dept-name { font-weight: 600; }

/* ── Barre de recherche ───────────────────────────────────── */
.search-bar {
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.search-bar .input-group {
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}
.search-bar .form-control {
  background: var(--bg);
  border: none;
  font-size: 15px;
  padding: 10px 14px;
  box-shadow: none;
}
.search-bar .form-control:focus { box-shadow: none; }
.search-bar .input-icon {
  background: var(--bg);
  border: none;
  padding-left: 14px;
  color: var(--muted);
}

/* ── Sous-header stats ────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.stats-bar::-webkit-scrollbar { display: none; }

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 80px;
  flex-shrink: 0;
}
.stat-chip .sc-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.stat-chip .sc-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
}
.stat-chip.chip-total    .sc-value { color: var(--primary); }
.stat-chip.chip-ok       .sc-value { color: var(--success); }
.stat-chip.chip-ko       .sc-value { color: var(--danger);  }
.stat-chip.chip-todo     .sc-value { color: var(--warning); }

/* ── Page Détail points ───────────────────────────────────── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.point-card {
  background: var(--surface);
  border-radius: 14px;
  margin: 10px 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.point-card .point-num {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.point-card .point-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 12px;
  line-height: 1.4;
}
.point-card .critere-badge {
  font-size: 11px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  padding: 2px 8px;
  display: inline-block;
  margin-bottom: 12px;
}

/* Boutons réponse */
.answer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.answer-btn {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: transparent;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.answer-btn svg { width: 20px; height: 20px; }

.answer-btn.btn-ok       { border-color: var(--success); color: var(--success); }
.answer-btn.btn-ok.active{ background: var(--success); color: #fff; }

.answer-btn.btn-ko       { border-color: var(--danger); color: var(--danger); }
.answer-btn.btn-ko.active{ background: var(--danger);  color: #fff; }

.answer-btn.btn-na       { border-color: var(--muted); color: var(--muted); }
.answer-btn.btn-na.active{ background: var(--muted);   color: #fff; }

.comment-area {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  margin-top: 10px;
  font-family: inherit;
  color: var(--text);
}
.comment-area:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Page Plan d'actions ──────────────────────────────────── */
.action-card {
  background: var(--surface);
  border-radius: 14px;
  margin: 10px 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border-left: 4px solid var(--warning);
}
.action-card.statut-en_cours { border-left-color: var(--primary); }
.action-card.statut-cloture  { border-left-color: var(--success); }

.action-card .ac-dept   { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.action-card .ac-desc   { font-size: 15px; font-weight: 500; margin: 4px 0 8px; line-height: 1.4; }
.action-card .ac-meta   { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.action-card .ac-resp   { font-size: 13px; color: var(--muted); }
.action-card .ac-ech    { font-size: 13px; }
.ac-ech.overdue         { color: var(--danger); font-weight: 600; }

.statut-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.statut-badge.ouvert    { background: #fff3cd; color: #856404; }
.statut-badge.en_cours  { background: #cfe2ff; color: #084298; }
.statut-badge.cloture   { background: #d1e7dd; color: #0a3622; }

/* ── Page Notes ───────────────────────────────────────────── */
.note-card {
  background: var(--surface);
  border-radius: 14px;
  margin: 10px 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.note-card .note-author { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note-card .note-text   { font-size: 15px; line-height: 1.5; }
.note-card .note-date   { font-size: 11px; color: var(--muted); margin-top: 8px; }

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(13,110,253,.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 50;
}
.fab:active { transform: scale(0.93); }

/* ── Bottom Navigation ────────────────────────────────────── */
.bottom-nav {
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--primary); }
.nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ── Spinner / état vide ──────────────────────────────────── */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 48px;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 32px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg  { width: 56px; height: 56px; margin-bottom: 12px; opacity: .4; }
.empty-state p    { font-size: 15px; margin: 0; }

/* ── Modal / Drawer ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}
.modal-overlay.open .drawer { transform: translateY(0); }

.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast-msg {
  background: #1a1d23;
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  animation: toastIn 2.5s forwards;
}
@keyframes toastIn {
  0%  { opacity:0; transform:translateY(8px); }
  15% { opacity:1; transform:translateY(0);   }
  75% { opacity:1; transform:translateY(0);   }
  100%{ opacity:0; transform:translateY(-4px);}
}

/* ── Utilitaires ──────────────────────────────────────────── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 14px 16px 6px;
}
.divider { height: 1px; background: var(--border); }
.fill { flex: 1; }
