/* MNM ELEK — styles */
:root {
  --marine: #14213d;
  --marine-2: #1f3260;
  --jaune: #fca311;
  --jaune-pale: #fff4dc;
  --fond: #eef0f4;
  --carte: #ffffff;
  --texte: #1a1d24;
  --texte-2: #5d6472;
  --trait: #dfe3ea;
  --moi: #fde9bf;
  --autre: #ffffff;
  --discussion: #e9e4da;
  --danger: #c62828;
  --ok: #2e7d32;
  --ombre: 0 1px 3px rgba(20, 33, 61, .12);
  --rayon: 12px;
  --st-devis: #6b7280;
  --st-devis_envoye: #7c3aed;
  --st-accepte: #2563eb;
  --st-en_cours: #d97706;
  --st-termine: #15803d;
  --st-sav: #0891b2;
  --st-annule: #b91c1c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1420;
    --carte: #1a2130;
    --texte: #e8eaf0;
    --texte-2: #9aa3b5;
    --trait: #2b3446;
    --moi: #5a4211;
    --autre: #232c3d;
    --discussion: #121826;
    --jaune-pale: #3a2d0d;
    --ombre: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond); color: var(--texte);
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--marine-2); }
@media (prefers-color-scheme: dark) { a { color: #8fb0ff; } }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cache { display: none !important; }

/* ---------- Écran de chargement / connexion ---------- */
.chargement, .ecran-connexion {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--marine); color: #fff; padding: 24px;
}
.logo-grand { font-size: 38px; font-weight: 800; letter-spacing: 1px; }
.logo-grand b, .logo b { color: var(--jaune); margin-left: 6px; }
.ecran-connexion form {
  background: var(--carte); color: var(--texte); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px;
  margin-top: 24px; display: grid; gap: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.ecran-connexion h2 { margin: 0; font-size: 18px; }
.ecran-connexion p { margin: 0; color: var(--texte-2); font-size: 14px; }

/* ---------- Champs & boutons ---------- */
label.champ { display: grid; gap: 4px; font-size: 13px; color: var(--texte-2); font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--trait); border-radius: 10px; background: var(--carte);
  font-size: 16px; color: var(--texte); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--jaune); box-shadow: 0 0 0 3px rgba(252,163,17,.25); }
textarea { resize: vertical; min-height: 90px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 600; cursor: pointer; background: var(--fond); color: var(--texte); text-decoration: none;
  min-height: 44px;
}
.btn.principal { background: var(--jaune); color: #1a1300; }
.btn.marine { background: var(--marine); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid currentColor; }
.btn.petit { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-icone {
  border: 0; background: transparent; color: inherit; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; position: relative;
}
.btn-icone:hover { background: rgba(127,127,127,.15); }
.erreur { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- Structure principale ---------- */
.cadre { display: flex; height: 100dvh; overflow: hidden; }
#liste { width: 100%; display: flex; flex-direction: column; background: var(--carte); min-width: 0; }
#vue { flex: 1; display: none; flex-direction: column; min-width: 0; background: var(--fond); }
.cadre.mode-vue #liste { display: none; }
.cadre.mode-vue #vue { display: flex; }
@media (min-width: 900px) {
  #liste { width: 380px; flex: none; border-right: 1px solid var(--trait); display: flex !important; }
  #vue { display: flex !important; }
  .seulement-mobile { display: none !important; }
}

.barre {
  background: var(--marine); color: #fff; display: flex; align-items: center; gap: 4px;
  padding: calc(6px + env(safe-area-inset-top)) 6px 6px 12px; min-height: 56px; flex: none;
}
.barre .logo { font-weight: 800; font-size: 20px; flex: 1; letter-spacing: .5px; }
.barre .titre { flex: 1; min-width: 0; }
.barre .titre b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }
.barre .titre small { display: block; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

.recherche { padding: 10px 12px 4px; display: grid; gap: 8px; flex: none; }
.puces { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
.puces::-webkit-scrollbar { display: none; }
.puce {
  border: 1px solid var(--trait); background: var(--carte); border-radius: 999px; padding: 6px 12px; font-size: 13px;
  white-space: nowrap; cursor: pointer; font-weight: 600; color: var(--texte-2);
}
.puce.on { background: var(--marine); border-color: var(--marine); color: #fff; }
@media (prefers-color-scheme: dark) { .puce.on { background: var(--jaune); border-color: var(--jaune); color: #1a1300; } }

.liste-chantiers { flex: 1; overflow-y: auto; padding-bottom: 90px; }
.ligne-chantier {
  display: flex; gap: 12px; padding: 12px; border-bottom: 1px solid var(--trait); cursor: pointer; align-items: center;
  text-decoration: none; color: inherit;
}
.ligne-chantier:hover { background: var(--fond); }
.ligne-chantier.actif { background: var(--jaune-pale); }
.pastille {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; flex: none; font-size: 17px; background-size: cover; background-position: center;
}
.ligne-chantier .corps { flex: 1; min-width: 0; }
.ligne-chantier .l1 { display: flex; gap: 8px; align-items: baseline; }
.ligne-chantier .nom { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne-chantier .date { font-size: 12px; color: var(--texte-2); flex: none; }
.ligne-chantier .l2 { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.ligne-chantier .apercu { flex: 1; font-size: 13px; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--ok); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.statut {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff;
  text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
.st-devis { background: var(--st-devis); } .st-devis_envoye { background: var(--st-devis_envoye); } .st-accepte { background: var(--st-accepte); }
.st-en_cours { background: var(--st-en_cours); } .st-termine { background: var(--st-termine); } .st-sav { background: var(--st-sav); } .st-annule { background: var(--st-annule); }
.vide { text-align: center; color: var(--texte-2); padding: 40px 20px; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 18px;
  background: var(--jaune); color: #1a1300; border: 0; box-shadow: 0 4px 14px rgba(0,0,0,.25); display: flex;
  align-items: center; justify-content: center; cursor: pointer; z-index: 5;
}
@media (min-width: 900px) { .fab { left: 304px; right: auto; } }
.cadre.mode-vue .fab { display: none; }
@media (min-width: 900px) { .cadre.mode-vue .fab { display: flex; } }

/* ---------- Dossier chantier ---------- */
.onglets {
  display: flex; background: var(--marine); overflow-x: auto; scrollbar-width: none; flex: none; padding: 0 4px;
}
.onglets::-webkit-scrollbar { display: none; }
.onglet {
  color: rgba(255,255,255,.7); border: 0; background: none; padding: 10px 12px 9px; font-weight: 600; font-size: 13px;
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.onglet svg.i { width: 18px; height: 18px; }
.onglet.on { color: #fff; border-bottom-color: var(--jaune); }
.onglet .n { font-size: 11px; opacity: .8; }
.onglet .badge { height: 18px; min-width: 18px; font-size: 11px; }
.contenu { flex: 1; overflow-y: auto; padding: 14px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.contenu.plein { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.accueil-vue { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--texte-2); gap: 8px; }
.accueil-vue .logo-grand { color: var(--marine); opacity: .25; }
@media (prefers-color-scheme: dark) { .accueil-vue .logo-grand { color: #fff; opacity: .15; } }

.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px; margin-bottom: 12px; }
.carte h3 { margin: 0 0 10px; font-size: 15px; }
.grille-form { display: grid; gap: 12px; }
@media (min-width: 640px) { .grille-form.deux { grid-template-columns: 1fr 1fr; } .grille-form .large { grid-column: 1 / -1; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .espace { flex: 1; }
.entete-section { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.entete-section h2 { margin: 0; font-size: 17px; flex: 1; }
.raccourcis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.raccourcis .btn { background: var(--carte); box-shadow: var(--ombre); }

/* Photos */
.grille-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 4px; }
.grille-photos button {
  aspect-ratio: 1; border: 0; padding: 0; background: var(--trait) center/cover no-repeat; border-radius: 6px; cursor: pointer;
}
.jour-photos { font-size: 13px; font-weight: 700; color: var(--texte-2); margin: 14px 2px 6px; }
.jour-photos:first-child { margin-top: 0; }

/* Liste de fichiers */
.fichier { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--trait); }
.fichier:last-child { border-bottom: 0; }
.fichier .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--jaune-pale); color: #b36b00; display: flex; align-items: center; justify-content: center; flex: none; font-size: 11px; font-weight: 800; }
.fichier .corps { flex: 1; min-width: 0; }
.fichier .nom { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; color: inherit; text-decoration: none; }
.fichier .meta { font-size: 12px; color: var(--texte-2); }
.fichier audio { width: 100%; height: 36px; margin-top: 4px; }

/* Notes */
.note { word-wrap: break-word; cursor: pointer; }
.txt { white-space: pre-wrap; }
.note .meta { font-size: 12px; color: var(--texte-2); margin-top: 8px; white-space: normal; }

/* Journal */
.journal-ligne { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--trait); color: var(--texte-2); }
.journal-ligne b { color: var(--texte); }

/* ---------- Discussion ---------- */
.discussion {
  flex: 1; overflow-y: auto; padding: 12px 10px; background: var(--discussion);
  display: flex; flex-direction: column; gap: 3px;
}
.jour-sep { align-self: center; background: var(--carte); color: var(--texte-2); font-size: 12px; padding: 3px 10px; border-radius: 8px; margin: 8px 0; box-shadow: var(--ombre); }
.bulle {
  max-width: min(78%, 520px); background: var(--autre); border-radius: 10px; padding: 6px 9px 4px; box-shadow: var(--ombre);
  align-self: flex-start; position: relative; word-wrap: break-word;
}
.bulle.moi { align-self: flex-end; background: var(--moi); }
.bulle .auteur { font-size: 12.5px; font-weight: 700; margin-bottom: 1px; white-space: normal; }
.bulle .heure { font-size: 11px; color: var(--texte-2); float: right; margin: 6px 0 -2px 10px; white-space: nowrap; }
.bulle img { display: block; max-width: 100%; width: 260px; height: 220px; object-fit: cover; border-radius: 6px; margin: 2px 0 4px; cursor: pointer; background: var(--trait); }
.bulle audio { width: 240px; max-width: 100%; height: 40px; display: block; margin: 4px 0; }
.bulle .piece { display: flex; gap: 8px; align-items: center; padding: 6px; background: rgba(127,127,127,.12); border-radius: 6px; margin: 2px 0 4px; text-decoration: none; color: inherit; }
.bulle.suite { margin-top: -1px; }
.bulle.suite .auteur { display: none; }
.saisie {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: var(--discussion); flex: none;
}
.saisie .zone { flex: 1; display: flex; align-items: flex-end; background: var(--carte); border-radius: 22px; padding: 0 4px; box-shadow: var(--ombre); }
.saisie textarea {
  border: 0; box-shadow: none !important; min-height: 44px; max-height: 140px; padding: 11px 6px; resize: none; background: transparent; scrollbar-width: none;
}
.saisie .rond {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--marine); color: #fff; display: flex;
  align-items: center; justify-content: center; cursor: pointer; flex: none;
}
@media (prefers-color-scheme: dark) { .saisie .rond { background: var(--jaune); color: #1a1300; } }
.saisie .rond.rouge { background: var(--danger); color: #fff; }
.enregistrement { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--carte); border-radius: 22px; padding: 0 14px; min-height: 46px; box-shadow: var(--ombre); }
.point-rouge { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: clignote 1s infinite; }
@keyframes clignote { 50% { opacity: .2; } }
.enregistrement .temps { font-variant-numeric: tabular-nums; font-weight: 700; flex: 1; }

/* ---------- Fenêtres ---------- */
.voile {
  position: fixed; inset: 0; background: rgba(10, 15, 30, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .voile { align-items: center; padding: 20px; } }
.fenetre {
  background: var(--carte); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 14px;
}
@media (min-width: 640px) { .fenetre { border-radius: 16px; } }
.fenetre h2 { margin: 0; font-size: 18px; }
.menu-liste { display: grid; gap: 2px; }
.menu-liste button { display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 12px 8px; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 600; }
.menu-liste button:hover { background: var(--fond); }

/* Visionneuse photo */
.visionneuse { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; color: #fff; }
.visionneuse .haut { display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) 6px 6px; background: rgba(0,0,0,.6); }
.visionneuse .haut .titre { flex: 1; min-width: 0; font-size: 13px; }
.visionneuse .image { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; touch-action: pan-y pinch-zoom; }
.visionneuse img { max-width: 100%; max-height: 100%; object-fit: contain; }
.visionneuse .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.4); color: #fff; }
.visionneuse .nav.g { left: 8px; } .visionneuse .nav.d { right: 8px; }
.visionneuse .bas { padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.6); font-size: 14px; }

/* Toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #222b3d; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); font-size: 14px; }
.toast.err { background: var(--danger); }
.progression { height: 4px; background: rgba(255,255,255,.25); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progression div { height: 100%; background: var(--jaune); width: 0; transition: width .2s; }

/* Équipe */
.membre { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--trait); cursor: pointer; }
.avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.couleurs { display: flex; gap: 8px; flex-wrap: wrap; }
.couleurs label { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.couleurs input { display: none; }
.couleurs input:checked + span { outline: 3px solid var(--texte); outline-offset: 2px; }
.couleurs span { display: block; width: 100%; height: 100%; border-radius: 50%; }
