/* =============================================================================
   CRM EcoThatch — 04-modale.css
   -----------------------------------------------------------------------------
   Fenêtre de fiche, historique des contacts, dépôt d'images, visionneuse,
   page de connexion.
   ========================================================================== */

/* ============================ SURCOUCHE ================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 22px 14px;
  overflow-y: auto;
  background: rgba(5, 8, 16, .72);
  backdrop-filter: blur(3px);
}

.overlay.show { display: flex; }

.modal {
  width: 100%;
  max-width: 720px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal.etroite { max-width: 480px; }

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-head h2 { flex: 1; margin: 0; font-size: 17px; }

.modal-body { padding: 18px; }

.modal-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ============================ HISTORIQUE ================================= */

.add-contact { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 11px; }

.add-contact select,
.add-contact input {
  padding: 8px 11px;
  background: var(--bg2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.hist-sum {
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
}

.hist-ic {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.hist-ic.appel { background: rgba(91, 141, 255, .18); color: #a9c3ff; }
.hist-ic.email { background: rgba(34, 179, 145, .18); color: #7fd9c3; }

.hist-date { flex: 1; color: var(--muted); font-size: 12.5px; }

.hist-del {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.hist-del:hover { color: var(--alert); }

.hist-empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================ IMAGES ===================================== */

.dropzone {
  padding: 22px 14px;
  border: 2px dashed var(--line);
  border-radius: 11px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone:hover,
.dropzone.over { border-color: var(--accent); background: rgba(91, 141, 255, .07); }

.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 9px;
  margin-top: 11px;
}

.img-grid .cell { position: relative; }

.img-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: zoom-in;
}

.img-grid .del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 16, .78);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
}

.img-grid .del:hover { background: var(--alert); }

/* ============================ VISIONNEUSE ================================ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(3, 5, 11, .92);
  cursor: zoom-out;
}

.lightbox.show { display: flex; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* ============================ COMPTES (ADMIN) ============================ */

.table-comptes { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table-comptes th,
.table-comptes td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.table-comptes th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

.table-comptes tr:last-child td { border-bottom: 0; }

.table-comptes .inactif { opacity: .5; }

/* ============================ CONNEXION ================================== */

.page-connexion {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
}

.carte-connexion {
  width: 100%;
  max-width: 400px;
  padding: 30px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.carte-connexion h1 {
  margin: 0 0 4px;
  font-size: 21px;
  text-align: center;
}

.carte-connexion .sous {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.carte-connexion form { display: flex; flex-direction: column; gap: 14px; }

.carte-connexion .btn { width: 100%; padding: 11px; }

.msg-erreur {
  padding: 10px 12px;
  background: rgba(229, 72, 77, .12);
  border: 1px solid rgba(229, 72, 77, .45);
  border-radius: 10px;
  font-size: 13.5px;
}

.msg-ok {
  padding: 10px 12px;
  background: rgba(55, 194, 107, .12);
  border: 1px solid rgba(55, 194, 107, .45);
  border-radius: 10px;
  font-size: 13.5px;
}

.lien-discret {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.lien-discret:hover { color: var(--accent); }

.note-privee {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* =============================================================================
   CHECKLIST DE PARCOURS — ajoutée avec la refonte des rôles (migration 0006)
   ============================================================================= */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.ck-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
}

/* Une étape faite s'efface visuellement : ce qui reste à faire doit sauter aux
   yeux plus que ce qui est derrière. */
.ck-row.faite { opacity: .58; }
.ck-row.faite .ck-titre { text-decoration: line-through; }

.ck-case {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--ok);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.ck-case:hover { border-color: var(--accent); }
.ck-row.faite .ck-case { background: rgba(55, 194, 107, .18); border-color: var(--ok); }

.ck-rang {
  width: 18px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11.5px;
  text-align: right;
}

.ck-titre { flex: 1; display: flex; flex-direction: column; }
.ck-titre small { color: var(--muted); font-size: 11.5px; }

.ck-date { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.ck-note {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

@media (max-width: 520px) {
  .ck-date { display: none; }
}

/* Checklist en cours d'écriture : on neutralise les clics pendant l'aller-retour,
   sinon deux coches rapprochées se marchent dessus. */
.checklist.en-vol,
#zoneChecklist.en-vol .checklist { opacity: .55; pointer-events: none; }
