/* ══════════════════════════════════════
   CAMC Qualite — Styles
   Tokens visuels identiques au site principal
   ══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;0,9..40,800;0,9..40,900;1,9..40,400&display=swap');

:root {
  --bg: #eef3f2; --bg-card: #fff; --bg-header: #0f4a61;
  --text: #17363f; --text-mid: #4e6469; --text-muted: #73898d;
  --accent: #1a556d; --accent-light: #e3eef1;
  --green: #1a8a4a; --green-bg: #e4f7ed;
  --red: #bf3030; --red-bg: #fde8e8;
  --orange: #d4620a; --orange-bg: #fef0e2;
  --blue: #2563eb; --blue-bg: #eff6ff;
  --purple: #7b35b0; --purple-bg: #f1e6fa;
  --border: #d8e2e3; --radius: 12px;
  --shadow: 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 8px 28px rgba(0,0,0,.1);
  --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }

/* ══════════ LAYOUT SIDEBAR ══════════ */
.app-layout {
  display: flex; min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #0c3e52, #0f4a61);
  color: #fff; position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 100;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
}
.sidebar-brand {
  padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand h1 { font-size: 18px; font-weight: 900; letter-spacing: -.3px; }
.sidebar-brand .subtitle { font-size: 11px; opacity: .6; font-weight: 500; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; width: 100%;
  background: transparent; border: none; color: rgba(255,255,255,.7);
  font: 600 13px 'DM Sans', sans-serif; cursor: pointer; transition: .2s;
  text-align: left;
}
.sidebar-nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav-btn.active { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-nav-btn .nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 14px; }
.sidebar-user {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.15); display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 13px; font-weight: 700; }
.sidebar-user-role { font-size: 10px; opacity: .6; text-transform: uppercase; letter-spacing: .5px; }

.main-content {
  margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar-w));
}
.page-title {
  font-size: 24px; font-weight: 900; margin-bottom: 6px;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* ══════════ CARDS ══════════ */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { font-size: 18px; font-weight: 800; color: var(--text); }
.card-meta { font-size: 13px; color: var(--text-muted); }

/* ══════════ BADGES ══════════ */
.badge {
  display: inline-flex; padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.badge-brouillon { background: var(--bg); color: var(--text-muted); }
.badge-en_revue { background: var(--orange-bg); color: var(--orange); }
.badge-approuve { background: var(--green-bg); color: var(--green); }
.badge-obsolete { background: var(--red-bg); color: var(--red); }
.badge-mq { background: var(--purple-bg); color: var(--purple); }
.badge-pq { background: var(--blue-bg); color: var(--blue); }
.badge-mo { background: var(--green-bg); color: var(--green); }
.badge-it { background: var(--orange-bg); color: var(--orange); }
.badge-en { background: #fdf5e0; color: #c8950f; }
.badge-fo { background: var(--accent-light); color: var(--accent); }

/* ══════════ BOUTONS ══════════ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius); border: none;
  font: 600 14px 'DM Sans', sans-serif; cursor: pointer; transition: .2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #164a5e; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #157a3e; }
.btn-warning { background: var(--orange); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-mid); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 8px; }
.btn-logout {
  padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: rgba(255,255,255,.8); font: 600 12px 'DM Sans', sans-serif;
  cursor: pointer; transition: .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }

/* ══════════ FORMULAIRES ══════════ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-mid); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  font: 400 15px 'DM Sans', sans-serif; color: var(--text); background: var(--bg-card);
  transition: .2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,85,109,.1);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ══════════ LOGIN ══════════ */
.login-wrap {
  max-width: 420px; margin: 80px auto; padding: 0 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px;
  padding: 36px 30px; box-shadow: 0 8px 30px rgba(0,0,0,.08); text-align: center;
}
.login-card h2 { font-size: 24px; font-weight: 900; color: var(--text); margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-card .form-group { text-align: left; }
.login-error {
  display: none; padding: 10px 14px; border-radius: var(--radius);
  background: var(--red-bg); color: var(--red); font-size: 13px; font-weight: 600;
  margin-bottom: 14px;
}
.login-error.show { display: block; }

/* ══════════ STATS ══════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-value { font-size: 32px; font-weight: 900; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }

/* ══════════ TABLE ══════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; background: var(--bg); font-weight: 700; color: var(--text-mid); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tr:hover td { background: #f8fafb; }

/* ══════════ TOOLBAR ══════════ */
.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}
.toolbar .form-input, .toolbar .form-select {
  width: auto; padding: 8px 12px; font-size: 13px;
}

/* ══════════ MODAL ══════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card); border-radius: 16px; padding: 28px;
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title { font-size: 20px; font-weight: 900; margin-bottom: 18px; }

/* ══════════ EMPTY STATE ══════════ */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state h3 { font-size: 18px; color: var(--text-mid); margin-bottom: 6px; }

/* ══════════ WORKFLOW BADGES ══════════ */
.workflow-steps {
  display: flex; gap: 8px; align-items: center; margin: 14px 0;
}
.workflow-step {
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 700;
  background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
}
.workflow-step.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.workflow-step.done { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.workflow-arrow { color: var(--text-muted); font-size: 14px; }

/* ══════════ DETAIL PANEL ══════════ */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px;
}
.detail-item { }
.detail-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.detail-value { font-size: 15px; font-weight: 600; }

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 14px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ══════════ FORMATIONS / QUIZ ══════════ */
.badge-publie { background: var(--green-bg); color: var(--green); }
.badge-archive { background: var(--bg); color: var(--text-muted); }
.badge-assigne { background: var(--blue-bg); color: var(--blue); }
.badge-en_cours { background: var(--orange-bg); color: var(--orange); }
.badge-termine { background: var(--green-bg); color: var(--green); }
.badge-echoue { background: var(--red-bg); color: var(--red); }
.badge-expire { background: var(--bg); color: var(--text-muted); }

.badge-debutant { background: var(--bg); color: var(--text-muted); }
.badge-intermediaire { background: var(--orange-bg); color: var(--orange); }
.badge-confirme { background: var(--blue-bg); color: var(--blue); }
.badge-expert { background: var(--green-bg); color: var(--green); }

.quiz-question { padding: 18px; background: var(--bg); border-radius: var(--radius); margin-bottom: 14px; }
.quiz-question-text { font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.quiz-choice { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; border-radius: 8px; transition: .15s; }
.quiz-choice:hover { background: var(--accent-light); }
.quiz-choice input[type="radio"] { accent-color: var(--accent); }
.quiz-result-correct { border-left: 4px solid var(--green); background: var(--green-bg); }
.quiz-result-incorrect { border-left: 4px solid var(--red); background: var(--red-bg); }
.quiz-explication { font-size: 13px; color: var(--text-mid); margin-top: 6px; padding: 6px 12px; font-style: italic; }

.matrice-cell { text-align: center; min-width: 90px; padding: 6px; cursor: pointer; transition: .15s; font-size: 12px; }
.matrice-cell:hover { background: var(--accent-light); }
.matrice-cell.overdue { background: var(--red-bg); }
.matrice-header { font-size: 11px; font-weight: 700; writing-mode: vertical-lr; transform: rotate(180deg); min-height: 100px; text-align: left; padding: 6px 4px; }

/* ══════════ ANIMATIONS ══════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .4s ease; }
