/* =====================================================================
   JAVAT Genius — base commune (charte : docs/06-design-system.md)
   Mobile d'abord. Champs ≥ 16 px (zoom iOS), 100dvh, min-width:0.
   ===================================================================== */
:root {
  --blue: #1B44BF;
  --blue-dark: #0D2580;
  --blue-deep: #071650;
  --blue-night: #050F2E;
  --blue-mid: #3A5FD9;
  --blue-light: #EEF2FF;
  --blue-50: #F8F9FF;
  --blue-100: #F0F4FF;
  --border: #E2E8FF;
  --orange: #E86A00;
  --orange-dark: #BF5200;
  --orange-light: #FFF3E8;
  --green: #22C55E; --green-text: #16A34A; --green-bg: #DCFCE7;
  --amber: #F59E0B; --amber-text: #92400E; --amber-bg: #FEF9C3;
  --red: #EF4444; --red-text: #B91C1C; --red-bg: #FEE2E2;
  --text: #1E2A50;
  --text-2: #4A5580;
  --text-3: #94A3C8;
  --white: #FFFFFF;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 4px 20px rgba(27, 68, 191, .10);
  --shadow-lg: 0 16px 48px rgba(27, 68, 191, .18);
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gradient-top: linear-gradient(135deg, #050F2E, #1B44BF);
  --gradient-hero: linear-gradient(135deg, #071650 0%, #0D2580 45%, #1B44BF 100%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 800; color: var(--text); }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; color: var(--text-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(232, 106, 0, .55); outline-offset: 2px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------- Boutons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border: 1.5px solid transparent; border-radius: 10px;
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1.2;
  cursor: pointer; text-decoration: none !important;
  transition: background .15s, transform .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-accent { background: var(--orange); color: #fff; }
.btn-accent:hover { background: var(--orange-dark); box-shadow: 0 8px 24px rgba(232, 106, 0, .3); }
.btn-secondary { background: var(--blue-100); color: var(--blue); }
.btn-secondary:hover { background: var(--blue-light); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost-light { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .35); color: #fff; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .2); }
.btn-danger { background: var(--red-bg); color: var(--red-text); }
.btn-danger:hover { background: #fecaca; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { min-height: 40px; min-width: 40px; padding: 8px; }

/* ---------------- Formulaires ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .95rem; color: var(--text); }
.field .hint { font-size: .85rem; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 46px;
  padding: 10px 14px;
  font: inherit; font-size: 16px; /* jamais < 16 px : zoom iOS */
  color: var(--text); background: #fff;
  border: 1.5px solid var(--border); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234A5580' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27, 68, 191, .15); }
.input[aria-invalid="true"] { border-color: var(--red); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; color: var(--text-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1.5px solid var(--border); border-radius: 100px; font-size: .95rem; cursor: pointer; user-select: none; background: #fff;
}
.chip input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid rgba(232, 106, 0, .55); }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; font-size: 16px; }
.honeypot input { font-size: 16px; }

/* ---------------- Cartes, badges, alertes ---------------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-orange { background: var(--orange-light); color: var(--orange-dark); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-gray { background: #F1F5F9; color: var(--text-2); }
.alert { padding: 14px 16px; border-radius: var(--radius); font-size: .95rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-info { background: var(--blue-100); color: var(--blue-dark); border-color: var(--border); }
.alert-success { background: var(--green-bg); color: #14532D; }
.alert-warning { background: var(--amber-bg); color: var(--amber-text); }
.alert-error { background: var(--red-bg); color: var(--red-text); }

/* ---------------- Avatars à initiales (aucune photo fictive) ---------------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .95rem; text-transform: uppercase;
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.c1 { background: linear-gradient(135deg, #1B44BF, #3A5FD9); }
.avatar.c2 { background: linear-gradient(135deg, #E86A00, #F59E0B); }
.avatar.c3 { background: linear-gradient(135deg, #0D2580, #1B44BF); }
.avatar.c4 { background: linear-gradient(135deg, #16A34A, #22C55E); }
.avatar.c5 { background: linear-gradient(135deg, #7C3AED, #A78BFA); }
.avatar.team { background: #fff; padding: 3px; border: 1px solid var(--border); }
.avatar.team img { width: 100%; height: 100%; object-fit: contain; }

/* ---------------- États vides ---------------- */
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty-icon { font-size: 2.4rem; margin-bottom: 8px; }
.empty-title { font-weight: 700; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

/* ---------------- Tableaux ---------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: .95rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--blue-50); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }

/* ---------------- Modales (feuille depuis le bas sur mobile) ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(5, 15, 46, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.modal {
  background: #fff; width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { max-width: 560px; border-radius: 20px; padding: 24px; }
  .modal.wide { max-width: 760px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* ---------------- Notifications ---------------- */
.toasts { position: fixed; z-index: 2000; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (min-width: 640px) { .toasts { left: auto; width: 380px; } }
.toast { pointer-events: auto; background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .95rem; animation: up .2s ease-out; }
.toast.success { background: #14532D; }
.toast.error { background: var(--red-text); }

/* ---------------- Divers ---------------- */
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-3); }
.small { font-size: .875rem; }
.stars { color: var(--amber); letter-spacing: 1px; }
.config-banner { background: var(--amber-bg); color: var(--amber-text); text-align: center; padding: 10px 16px; font-size: .9rem; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
