/* =========================================================
   components.css — primitives partagées
   boutons, badges, timeline, table, drawer, modal, toast, KPI, bar-chart
   ========================================================= */

/* --- Boutons --- */
.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--emerald-600);
  border-radius: var(--r-pill);
  background: var(--emerald-600);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: -.005em;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--emerald-700); border-color: var(--emerald-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; pointer-events: none; }
.btn-secondary {
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: #f6f9f7; border-color: var(--line-strong); }
.btn-ghost, .btn-text {
  border-color: transparent; background: transparent; color: var(--emerald-600); box-shadow: none;
}
.btn-ghost:hover { background: var(--emerald-050); }
.btn-text { padding-inline: 6px; min-height: auto; }
.btn-text:hover { color: var(--emerald-700); background: transparent; }
.btn-sm { min-height: 38px; padding: 7px 13px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn-gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--forest-950); }
.btn-gold:hover { background: var(--gold-400); border-color: var(--gold-400); }
.btn-dark { background: var(--forest-900); border-color: var(--forest-900); color: #fff; }
.btn-dark:hover { background: var(--forest-800); border-color: var(--forest-800); }

/* --- Panel / card --- */
.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-citizen);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.panel-pad { padding: 26px; }
.panel-title { margin-bottom: 20px; }
.panel-title h2 { margin-bottom: 6px; font-size: 1.3rem; }
.panel-title p:last-child { margin-bottom: 0; color: var(--ink-soft); font-size: .92rem; }

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-admin);
  background: var(--white);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { margin: 0; font-size: .98rem; }
.card-body { padding: 18px; }

/* --- Forms --- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--ink); font-size: .84rem; font-weight: 500; }
.field-hint { margin-top: 5px; color: var(--muted); font-size: .78rem; }
.field-error { margin-top: 5px; color: var(--danger); font-size: .78rem; font-weight: 500; }
.form-error {
  margin-bottom: 14px; padding: 11px 13px;
  border: 1px solid #e6bcbc; border-radius: var(--r-xs);
  background: var(--danger-50); color: var(--danger); font-size: .86rem; font-weight: 500;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.demo-cases { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.demo-cases-title { margin-bottom: 10px; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.demo-case-list { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-case {
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 6px 12px; background: var(--white); color: var(--ink-soft);
  font-size: .76rem; font-weight: 500; transition: all var(--t-fast);
}
.demo-case:hover { border-color: var(--emerald-600); color: var(--emerald-700); background: var(--emerald-050); }

.demo-credentials {
  margin-top: 16px; padding: 13px 15px; border-radius: var(--r-xs);
  background: var(--ivory); color: var(--ink-soft); font-size: .82rem; line-height: 1.7;
}
.demo-credentials code { color: var(--emerald-700); font-weight: 600; font-family: "SF Mono", "Roboto Mono", ui-monospace, monospace; }

/* --- Empty state --- */
.empty-state { padding: 52px 40px; text-align: center; }
.empty-state-mark {
  display: grid; width: 56px; height: 56px; margin: 0 auto 18px; place-items: center;
  border-radius: var(--r-citizen); background: var(--emerald-050); color: var(--emerald-600);
}
.empty-state-mark .brand-mark { width: 28px; color: var(--emerald-600); }
.empty-state h2 { margin-bottom: 10px; font-size: 1.3rem; }
.empty-state p { max-width: 440px; margin-inline: auto; color: var(--ink-soft); }
.empty-state-list { display: grid; gap: 8px; max-width: 300px; margin: 22px auto 0; padding: 0; text-align: left; list-style: none; color: var(--ink-soft); font-size: .88rem; }
.empty-state-list li { display: flex; align-items: center; gap: 10px; }
.empty-state-list li::before {
  content: ""; width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%;
  background: var(--emerald-100) center/10px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2319744e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* --- Status badges (MPUtils.statusBadge génère status-{tone}) --- */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill); padding: 4px 10px;
  font-size: .74rem; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-neutral  { background: #f1f4f2; color: var(--muted); border-color: var(--line); }
.status-progress { background: var(--info-50); color: var(--info); }
.status-success  { background: var(--success-50); color: var(--success); }
.status-warning  { background: var(--warning-50); color: var(--warning); }
.status-danger   { background: var(--danger-50); color: var(--danger); }

/* --- Result panel (citoyen) --- */
.result-head {
  display: flex; justify-content: space-between; gap: 18px;
  padding: 24px 26px 20px; border-bottom: 1px solid var(--line-soft);
}
.result-head h3 { margin-bottom: 6px; font-size: 1rem; }
.result-head-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: .82rem; }
.result-body { padding: 26px; }
.status-summary { display: grid; grid-template-columns: 1fr auto; gap: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--line-soft); }
.status-summary h2 { margin-bottom: 6px; font-size: 1.5rem; }
.status-summary p:last-child { margin: 0; color: var(--ink-soft); }
.estimate-box {
  min-width: 160px; padding: 14px 16px;
  border-left: 3px solid var(--gold-500); border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: linear-gradient(135deg, var(--gold-100), #fbf3dd);
}
.estimate-box span, .info-item span { display: block; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.estimate-box strong { display: block; margin-top: 5px; font-size: .9rem; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.info-item { padding: 13px 14px; border-radius: var(--r-xs); background: var(--ivory); border: 1px solid var(--line-soft); }
.info-item strong { display: block; margin-top: 5px; font-size: .88rem; }

/* --- Callouts --- */
.callout {
  margin-top: 22px; padding: 18px 20px;
  border: 1px solid var(--emerald-300); border-radius: var(--r-citizen);
  background: linear-gradient(135deg, var(--emerald-050), #f4fbf7);
}
.callout h3 { margin-bottom: 5px; font-size: .98rem; }
.callout p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.callout.success { background: linear-gradient(135deg, var(--success-50), #f1f9f4); border-color: #b6ddc4; }
.callout.warning { background: linear-gradient(135deg, var(--warning-50), #fdf6e8); border-color: #ecd5a5; }
.callout-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* --- Timeline --- */
.timeline { margin-top: 28px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding-bottom: 20px; }
.timeline-item:not(:last-child)::before {
  position: absolute; top: 20px; bottom: -2px; left: 8px; width: 2px;
  background: var(--line); content: ""; border-radius: 2px;
}
.timeline-dot {
  width: 16px; height: 16px; margin-top: 2px;
  border: 3px solid #c4d6cc; border-radius: 50%; background: var(--white); z-index: 1;
}
.timeline-item.done .timeline-dot, .timeline-item.current .timeline-dot {
  border-color: var(--emerald-600); background: var(--emerald-600);
}
.timeline-copy strong { display: block; font-size: .9rem; font-weight: 600; }
.timeline-copy p { margin: 2px 0 0; color: var(--ink-soft); font-size: .86rem; }
.timeline-copy time { color: var(--muted); font-size: .76rem; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: rgba(6, 43, 32, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  border-radius: var(--r-citizen); background: var(--white); box-shadow: var(--shadow-lg);
}
.modal-lg { width: min(760px, 100%); }
.modal-head, .modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; }
.modal-head { border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { margin-bottom: 3px; }
.modal-head p { margin: 0; color: var(--muted); font-size: .86rem; }
.modal-body { padding: 22px; }
.modal-foot { border-top: 1px solid var(--line-soft); }
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--white); color: var(--ink); font-size: 1.3rem; line-height: 1;
  display: grid; place-items: center; transition: all var(--t-fast);
}
.icon-btn:hover { background: #f6f9f7; border-color: var(--line-strong); }

/* --- Operator cards (paiement) --- */
.operator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.operator-option input { position: absolute; opacity: 0; }
.operator-card {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px;
  min-height: 120px; padding: 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-citizen); background: var(--white);
  transition: all var(--t-fast); position: relative;
}
.operator-card img { height: 26px; width: auto; max-width: 110px; }
.operator-card strong { font-size: .98rem; }
.operator-option input:checked + .operator-card {
  border-color: var(--emerald-600); border-width: 2px; background: var(--emerald-050);
  box-shadow: var(--ring);
}
.operator-option input:checked + .operator-card::after {
  content: "✓"; position: absolute; top: 10px; right: 12px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--emerald-600); color: #fff;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}

.receipt { border: 1px solid var(--line-soft); border-radius: var(--r-citizen); padding: 18px 20px; background: var(--ivory); }
.receipt h3 { margin-bottom: 14px; font-size: 1.02rem; }
.receipt-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.receipt-row:last-child { border-bottom: 0; }
.receipt-row strong { color: var(--ink); }

/* --- Toast stack (MPUtils.toast crée .toast-stack + .toast) --- */
.toast-stack { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 10px; }
.toast {
  width: min(340px, calc(100vw - 40px)); padding: 13px 16px;
  border-radius: var(--r-citizen); background: var(--forest-950); color: #fff;
  box-shadow: var(--shadow-lg); font-size: .86rem; display: grid; gap: 2px;
}
.toast strong { font-weight: 600; }
.toast span { color: #b7d4c6; font-size: .8rem; }

/* =========================================================
   ADMIN components
   ========================================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  padding: 16px 18px; border: 1px solid var(--line-soft); border-radius: var(--r-admin);
  background: var(--white); box-shadow: var(--shadow-xs);
}
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; letter-spacing: -.03em; color: var(--ink); margin: 5px 0 3px; line-height: 1; }
.kpi-foot { color: var(--muted); font-size: .76rem; }

.dashboard-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-top: 18px; }

.bar-chart { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 28px; align-items: center; gap: 12px; }
.bar-label { color: var(--ink-soft); font-size: .82rem; }
.bar-track { height: 8px; border-radius: var(--r-pill); background: #eef2ef; overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--emerald-600); transition: width .5s var(--ease); }
.bar-value { text-align: right; font-weight: 600; color: var(--ink); font-size: .86rem; }

.activity-list { display: grid; gap: 14px; }
.activity { display: grid; grid-template-columns: 12px 1fr; gap: 12px; align-items: start; }
.activity-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--emerald-600); box-shadow: 0 0 0 3px var(--emerald-100); }
.activity strong { font-size: .86rem; font-weight: 600; display: block; }
.activity p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }

.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { margin-bottom: 4px; font-size: 1.5rem; }
.view-head p { margin: 0; color: var(--muted); font-size: .9rem; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  padding: 9px 14px; border: 0; background: transparent; color: var(--muted);
  font-size: .86rem; font-weight: 500; position: relative; transition: color var(--t-fast);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--emerald-700); }
.tab.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--emerald-600); border-radius: 2px; }
.tab .count { margin-left: 6px; padding: 1px 7px; border-radius: var(--r-pill); background: var(--line-soft); color: var(--muted); font-size: .72rem; }
.tab.active .count { background: var(--emerald-100); color: var(--emerald-700); }

.search-control { position: relative; flex: 1; min-width: 200px; }
.search-control .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search-control input { padding-left: 40px; min-height: 40px; }
.toolbar select { width: auto; min-height: 40px; max-width: 200px; }

.table-wrap { border: 1px solid var(--line-soft); border-radius: var(--r-admin); background: var(--white); overflow: auto; box-shadow: var(--shadow-xs); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th {
  text-align: left; padding: 11px 16px; background: #f5f8f6;
  color: var(--muted); font-size: .72rem; font-weight: 500; letter-spacing: .04em;
  border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: #f8fbf9; }
.table-primary { font-weight: 600; color: var(--ink); }
.table-secondary { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.empty-table { padding: 36px; text-align: center; color: var(--muted); font-size: .88rem; }
.audit-table { font-size: .82rem; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: .84rem; }

/* --- Drawer --- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(6, 43, 32, .45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0;
  width: min(580px, 100%); background: var(--white); box-shadow: var(--shadow-lg); overflow: auto;
  transform: translateX(100%); transition: transform .24s var(--ease);
}
.drawer:not(.hidden) { transform: translateX(0); }
.drawer-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; padding: 20px 24px; background: var(--white); border-bottom: 1px solid var(--line-soft); z-index: 2;
}
.drawer-head h2 { font-size: 1.2rem; }
.drawer-head p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.drawer-body { padding: 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-xs); overflow: hidden; margin-bottom: 20px; }
.detail-item { padding: 12px 14px; background: var(--white); }
.detail-item span { display: block; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.detail-item strong { display: block; margin-top: 4px; font-size: .88rem; font-weight: 600; }
.drawer-section { margin-top: 20px; }
.drawer-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-section-head h3 { font-size: .94rem; }
.note { padding: 12px 14px; border-radius: var(--r-xs); background: var(--ivory); border: 1px solid var(--line-soft); color: var(--ink-soft); font-size: .86rem; line-height: 1.55; }
.note strong { color: var(--ink); }

.icon { width: 20px; height: 20px; flex-shrink: 0; }
