/* =========================================================================
   admin.css — Administration de l'agence, dans la robe sombre et or des
   autres apps Studio Brochure (mêmes tokens que le portail /mandat/).
   ========================================================================= */
:root {
  --bg: #0f0f10; --panel: #17171a; --panel-2: #1e1e22; --line: #2a2a30;
  --text: #ece9e2; --muted: #9a968c; --accent: #c2a36b; --accent-ink: #1a1714;
  --ok: #7fb069; --err: #e07a5f;
}
* { box-sizing: border-box; margin: 0; }
/* L'attribut hidden doit gagner contre nos display:flex */
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, sans-serif; font-size: 15px;
  min-height: 100vh;
}

/* ------------------------------ Bandeau ------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 50;
}
.topbar .home {
  color: var(--muted); text-decoration: none; font-size: 20px; line-height: 1;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
}
.topbar .home:hover { color: var(--accent); border-color: var(--accent); }
.topbar h1 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 20px; }
.topbar h1 em { font-style: normal; color: var(--accent); }
.topbar-right { margin-left: auto; }
.who { color: var(--muted); font-size: 13px; }

/* ------------------------------ Connexion ------------------------------ */
.connexion { display: flex; justify-content: center; padding: 80px 20px; }
.connexion-carte {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 38px 34px; max-width: 460px; text-align: center;
}
.connexion-carte h2 { font-family: "Fraunces", Georgia, serif; font-weight: 550; margin-bottom: 12px; }
.connexion-carte p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }

/* ------------------------------- Onglets ------------------------------- */
main { max-width: 1100px; margin: 0 auto; padding: 22px 20px 80px; }
.onglets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.onglet {
  padding: 9px 18px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.onglet:hover { color: var(--text); border-color: var(--accent); }
.onglet.actif { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
/* La carte de prospection vit sur sa propre page (plein écran) : son onglet
   est un lien, habillé comme les autres. */
a.onglet-lien { text-decoration: none; display: inline-block; line-height: normal; }
.panneau { display: none; }
.panneau.actif { display: block; }

/* -------------------------------- Cartes ------------------------------- */
.carte {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 24px; margin-bottom: 18px;
}
.carte h2 { font-family: "Fraunces", Georgia, serif; font-weight: 550; font-size: 19px; margin-bottom: 6px; }
.aide { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin-bottom: 14px; max-width: 75ch; }
.petit { color: var(--muted); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }

.barre { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.barre-haut { border-top: 1px solid var(--line); padding-top: 14px; }
.barre input[type="search"] { flex: 1; min-width: 220px; }

input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 9px 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: #6c6960; }
/* Champs date / heure : le picto natif (calendrier, horloge) est dessiné en
   noir par le navigateur et disparaissait sur le fond sombre. color-scheme:dark
   le passe en blanc ; on le grossit dans une pastille dorée, bien visible, et
   tout le champ ouvre le sélecteur. */
input[type="date"], input[type="time"], input[type="datetime-local"] { color-scheme: dark; cursor: pointer; padding-right: 6px; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  width: 22px; height: 22px; padding: 4px; margin-left: 8px; box-sizing: content-box;
  background-color: rgba(190, 177, 138, .22); border: 1px solid var(--accent); border-radius: 8px;
  opacity: 1; cursor: pointer; transition: background-color .15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover { background-color: rgba(190, 177, 138, .55); }

.case { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text); cursor: pointer; }
.case input { accent-color: var(--accent); width: 16px; height: 16px; }

.grille-champs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px; margin-top: 12px;
}
.grille-champs label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
.grille-champs input, .grille-champs select, .grille-champs textarea { width: 100%; }

a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn {
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-or { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-or:hover { filter: brightness(1.08); }
.btn-danger { color: var(--err); border-color: #4a2e28; }

/* ------------------------------- Tableaux ------------------------------ */
.tableau-cadre { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
th {
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; background: var(--panel-2);
  position: sticky; top: 0;
}
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover { background: var(--panel-2); }
td img.mini { width: 62px; height: 42px; object-fit: cover; border-radius: 8px; display: block; }
.vide {
  padding: 42px 20px; text-align: center; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; font-size: 14px;
}
.compte-lignes { color: var(--muted); font-size: 12.5px; margin: 8px 4px 0; }

.puce {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px;
  background: rgba(194, 163, 107, .16); color: var(--accent); white-space: nowrap; margin: 1px 2px 1px 0;
}
.puce.grise { background: var(--panel-2); color: var(--muted); }
.puce.amepi { background: rgba(155, 126, 222, .16); color: #9B7EDE; }
.puce.verte { background: rgba(127, 176, 105, .16); color: var(--ok); }
.puce.rouge { background: rgba(224, 122, 95, .16); color: var(--err); }
.ok { color: var(--ok); font-weight: 600; }
.erreur { color: var(--err); font-weight: 600; }
s { color: var(--muted); }

/* Suggestions d'adresses (BAN) sous le champ en cours de saisie. */
.sugg-adresse { position: absolute; z-index: 120; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); max-height: 240px; overflow-y: auto; font-size: 14px; }
.sugg-adresse div { padding: 8px 12px; cursor: pointer; }
.sugg-adresse div:hover, .sugg-adresse div.actif { background: var(--panel-2); }
.grille-champs label, .barre { position: relative; }
/* -------------------------------- Modale ------------------------------- */
.voile {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modale {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  width: 100%; max-width: 760px; max-height: 92vh; display: flex; flex-direction: column;
}
/* Fenêtre large (livret prix) : listes longues à cocher, vignettes. */
.modale.large { max-width: 1240px; max-height: 98vh; }
/* Biens en concurrence : une ligne = case, photo (grande, pleine largeur sur téléphone), texte. */
.ligne-conc { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ligne-conc > span:not(.bloc-vignette) { flex: 1 1 200px; min-width: 0; }
.bloc-vignette { flex: none; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.vignette-conc { display: block; width: 132px; height: 99px; object-fit: cover; border-radius: 8px; background: var(--line); }
.modale.large .liste-choix { max-height: 44vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
.modale.large .liste-choix.haute { max-height: 78vh;
}
.modale-tete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.modale-tete h2 { font-family: "Fraunces", Georgia, serif; font-weight: 550; font-size: 18px; }
.fermer { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.fermer:hover { color: var(--text); }
.modale-corps { padding: 18px 22px; overflow-y: auto; }
.modale-pied {
  padding: 14px 22px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
.modale-pied .btn-danger { margin-right: auto; }
.apercu-mail { width: 100%; height: 68vh; border: 1px solid var(--line); border-radius: 12px; background: #F2EEE6; }

/* Mappage des colonnes d'import */
.ligne-map { display: grid; grid-template-columns: 1fr 210px; gap: 10px; align-items: center; margin-bottom: 8px; }
.ligne-map .col-nom { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-map .col-exemple { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-fichier {
  border: 2px dashed var(--line); border-radius: 14px; padding: 34px 20px;
  text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s;
}
.zone-fichier:hover, .zone-fichier.survol { border-color: var(--accent); color: var(--text); }

/* --------------------------------- Toast ------------------------------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 420px;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.succes { background: #2c4526; color: #cfe8c5; border: 1px solid #3e6b35; }
.toast.rate { background: #4a2620; color: #f4cabd; border: 1px solid #7a4033; }

@media (prefers-reduced-motion: reduce) {
  .toast, .btn, .onglet { transition: none; }
}
/* Téléphone : tout en une colonne, onglets qui défilent, fenêtres plein écran. */
@media (max-width: 720px) {
  main { padding: 10px 10px 60px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar h1 { font-size: 16px; }
  .onglets { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
  .onglets::-webkit-scrollbar { display: none; }
  .onglet { white-space: nowrap; flex: none; }
  .carte { padding: 14px 12px; border-radius: 12px; }
  .carte h2 { font-size: 17px; }
  .aide { font-size: 13px; }
  .grille-champs { grid-template-columns: 1fr; gap: 10px; }
  .grille-champs label[style*="grid-column"] { grid-column: auto !important; }
  input, select, textarea { font-size: 16px; } /* évite le zoom automatique d'iOS */
  .barre { gap: 8px; }
  .barre input[type="search"], .barre input[type="search"][style] { min-width: 0 !important; width: 100%; flex: 1 1 100%; }
  .btn { padding: 8px 12px; font-size: 13px; }
  table { min-width: 560px; font-size: 12.5px; }
  .ligne-map { grid-template-columns: 1fr; }
  .voile { padding: 0; align-items: stretch; }
  /* 100dvh : la hauteur réellement visible (la barre de Safari / Chrome cachait le pied de la fenêtre). */
  .modale, .modale.large { max-width: 100%; max-height: 100vh; height: 100vh; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; }
  .modale-corps { padding-bottom: 24px; }
  .modale-tete { padding: 12px 14px; }
  .modale-tete h2 { font-size: 16px; }
  .modale-corps { padding: 12px 12px; }
  .modale-pied { padding: 10px 12px; gap: 8px; }
  .modale-pied .btn { flex: 1 1 45%; text-align: center; }
  .modale-pied .btn-danger { margin-right: 0; }
  .ligne-conc { flex-wrap: wrap; }
  .ligne-conc .bloc-vignette { flex: 1 1 100%; order: 3; align-items: stretch; }
  .ligne-conc .bloc-vignette .btn { align-self: flex-end; }
  .vignette-conc { width: 100%; height: 220px; }
  .modale.large .liste-choix { max-height: 40vh; }
  .modale.large .liste-choix.haute { max-height: 55vh; }
  .apercu-mail { height: 60vh; }
  /* Spécificité 3 classes : les règles générales des étapes (plus bas) ne les écrasent pas. */
  .etapes .etape { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .etapes .etape .titre { flex: 1 1 calc(100% - 40px); }
  .etapes .etape .btn { flex: 1 1 auto; font-size: 12.5px; padding: 7px 10px; }
  #px-signe, #px-signe[style] { max-width: 100% !important; width: 100%; margin-top: 4px; }
  textarea { min-height: 90px; }
}
@media (max-width: 420px) {
  .modale-pied .btn { flex: 1 1 100%; }
}

/* Parcours R1/R2 */
.etapes { display: grid; gap: 10px; margin-top: 14px; }
.etape { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; }
.etape.faite { border-color: rgba(78, 205, 196, .5); background: rgba(78, 205, 196, .08); }
.etape .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--line); flex: none; }
.etape.faite .num { background: #4ECDC4; color: #0b2b28; }
.etape .titre { flex: 1; }
.etape .quand { font-size: 12px; opacity: .75; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 50% 25%; background: var(--line); display: inline-block; vertical-align: middle; }
.parcours-avancement { display: inline-flex; gap: 3px; }
.parcours-avancement i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: inline-block; }
.parcours-avancement i.ok { background: #4ECDC4; }
