/* ═══════════════════════════════════════════════════════════
   Photos chantier — la bibliothèque alimentée depuis WhatsApp

   Le sujet, ici, c'est la photo. Tout le reste — cadres, libellés,
   pastilles — se tient en retrait : lignes fines, or rare, aucune
   surface qui vienne concurrencer l'image. Rien n'est écrit en dur,
   tout passe par les jetons du socle : la page suit la bascule
   Console / Atelier sans une seule règle en double.
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   KIT AUTONOME — jetons de style
   ───────────────────────────────────────────────────────────
   Le module d'origine (ROOS) puise ses couleurs/espacements dans le
   design-system maison. Ce bloc les redéfinit ICI pour qu'il fonctionne
   dans N'IMPORTE quel site, sans dépendance. Palette claire, accent
   « or/ambre ». Adaptez librement — ou, si votre site expose déjà ces
   variables, supprimez ce bloc pour hériter de VOTRE thème.
   La visionneuse et le QR restent volontairement sur fond sombre/blanc :
   ce sont des surfaces posées sur le média, indépendantes du thème.
   ═══════════════════════════════════════════════════════════ */
#view-photos {
  /* Typographies */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;

  /* Texte */
  --text-0: #1c1917;  --text-1: #44403c;  --text-2: #78716c;  --text-3: #a8a29e;

  /* Surfaces & filets */
  --bg-card: #ffffff;  --bg-card2: #f6f5f3;
  --ln-1: #e7e5e4;  --ln-2: #d6d3d1;  --ln-3: #b3aeaa;
  --sl-0: #ffffff;  --sl-1: #f4f3f1;

  /* Accent or/ambre */
  --gold: #a97b1e;  --gold-bd: rgba(169,123,30,.28);  --gold-bd-hi: rgba(169,123,30,.60);
  --gold-dim: rgba(169,123,30,.10);  --au-bg: rgba(169,123,30,.07);

  /* États */
  --ok: #15803d;  --ok-ln: rgba(21,128,61,.40);
  --warn: #b45309;  --warn-ln: rgba(180,83,9,.42);  --warn-bg: rgba(180,83,9,.12);
  --err: #b91c1c;

  /* Rayons, espacements, mouvement, ombres, z-index */
  --r-3: 8px;  --r-4: 12px;  --r-5: 16px;  --r-p: 999px;
  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;  --s-5: 20px;  --s-8: 32px;
  --dur-fast: .16s;  --ease: cubic-bezier(.4,0,.2,1);
  --sh-2: 0 6px 24px rgba(0,0,0,.10);  --sh-focus: 0 0 0 3px rgba(169,123,30,.35);
  --z-modale: 1000;

  padding: 28px 32px;
}
/* Les deux fenêtres modales vivent hors de #view-photos : elles ont besoin
   des mêmes jetons, on les leur redonne. */
.pc-modal-fond, .pc-viewer {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  --text-0: #1c1917;  --text-1: #44403c;  --text-2: #78716c;  --text-3: #a8a29e;
  --bg-card: #ffffff;  --bg-card2: #f6f5f3;
  --ln-1: #e7e5e4;  --ln-2: #d6d3d1;  --ln-3: #b3aeaa;
  --gold: #a97b1e;  --gold-bd: rgba(169,123,30,.28);  --gold-bd-hi: rgba(169,123,30,.60);
  --gold-dim: rgba(169,123,30,.10);  --au-bg: rgba(169,123,30,.07);
  --r-3: 8px;  --r-4: 12px;  --r-5: 16px;  --r-p: 999px;
  --s-5: 20px;  --dur-fast: .16s;  --ease: cubic-bezier(.4,0,.2,1);
  --sh-2: 0 12px 40px rgba(0,0,0,.18);  --z-modale: 1000;
}

/* `hidden` doit l'emporter sur tout le reste de ce fichier.
   La feuille du navigateur pose `[hidden] { display: none }` avec une
   spécificité de zéro : la moindre classe qui déclare `display: flex` —
   les onglets, la barre, l'état vide, la modale, la visionneuse — la bat,
   et l'élément reste affiché malgré l'attribut. La visionneuse, plein
   écran et opaque, donnait alors un écran noir sans rien qui en indique
   la cause.
   Les deux dernières sont nommées à part : elles vivent hors de la vue,
   sur le même plan que les autres modales de l'application. */
#view-photos [hidden],
.pc-modal-fond[hidden],
.pc-viewer[hidden] { display: none; }

/* ── En-tête ─────────────────────────────────────────────── */

.pc-header {
  display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.pc-header-txt { flex: 1 1 260px; }
.pc-eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--gold); margin-bottom: 4px;
}
.pc-title { font-family: var(--serif); font-size: 26px; color: var(--text-0); line-height: 1.15; }
.pc-sub { font-size: 12.5px; color: var(--text-2); margin-top: 5px; max-width: 62ch; line-height: 1.55; }

/* Témoin de temps réel : discret quand tout va bien, visible quand ça coupe. */
.pc-live {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); border: 1px solid var(--ln-1); border-radius: var(--r-p);
  padding: 5px 12px; background: var(--bg-card);
}
.pc-live .pc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ln-3); flex: none; }
.pc-live.direct { color: var(--ok); border-color: var(--ok-ln); }
.pc-live.direct .pc-dot { background: var(--ok); animation: pcPouls 2.4s var(--ease) infinite; }
.pc-live.coupe { color: var(--warn); border-color: var(--warn-ln); }
.pc-live.coupe .pc-dot { background: var(--warn); }
@keyframes pcPouls { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Onglets ─────────────────────────────────────────────── */

.pc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gold-bd); margin-bottom: var(--s-4); flex-wrap: wrap; }
.pc-tab {
  background: none; border: 1px solid transparent; border-bottom: 2px solid transparent;
  color: var(--text-2); font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 9px 16px; cursor: pointer; transition: color var(--dur-fast) var(--ease);
}
.pc-tab:hover { color: var(--text-0); }
.pc-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.pc-tab-compte {
  font-family: var(--mono); font-size: 10px; margin-left: 6px; padding: 1px 6px;
  border-radius: var(--r-p); background: var(--gold-dim); color: var(--gold);
}

/* ── Barre de contexte ───────────────────────────────────── */

.pc-bar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.pc-fil { font-size: 12.5px; color: var(--text-2); font-family: var(--mono); letter-spacing: .02em; }
.pc-fil b { color: var(--text-0); font-weight: 600; }
.pc-bar-fin { margin-left: auto; display: flex; gap: var(--s-2); }

.pc-retour {
  background: var(--bg-card2); border: 1px solid var(--ln-1); border-radius: var(--r-3);
  color: var(--text-1); font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  padding: 7px 13px; cursor: pointer; transition: all var(--dur-fast) var(--ease);
}
.pc-retour:hover { border-color: var(--gold-bd-hi); color: var(--gold); }

/* ── Grille ──────────────────────────────────────────────── */

.pc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4); padding-bottom: var(--s-8);
}

/* ── Choix du chantier ───────────────────────────────────── */
/* Aucune image tant qu'un chantier n'est pas ouvert.
   Trois raisons, dont une seule est esthétique :
     · un groupe WhatsApp charrie autant de photos privées que de photos de
       chantier — elles n'ont pas à s'afficher d'elles-mêmes sur un écran
       qu'on partage en réunion ;
     · sans vignettes côté serveur, chaque aperçu téléchargeait la photo
       ENTIÈRE. Onze dossiers, c'était une quarantaine d'images pleines pour
       n'afficher que des noms de chantier — sur une 4G de chantier, c'est la
       différence entre un écran utile et un écran qui rame ;
     · un mur d'images sans rapport les unes avec les autres ne se lit pas.
       Ce qu'on cherche à cet instant, c'est UN nom de chantier.
   Une liste, donc. Les filets d'un pixel viennent du fond qui transparaît
   entre les lignes : une seule bordure pour tout le bloc. */
.pc-grid.pc-liste {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--ln-1); border: 1px solid var(--ln-1);
  border-radius: var(--r-4); overflow: hidden;
  padding-bottom: 0; margin-bottom: var(--s-8);
}

.pc-dossier {
  display: flex; align-items: center; gap: var(--s-4);
  padding: 14px 18px; background: var(--bg-card); cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.pc-dossier:hover { background: var(--bg-card2); border-left-color: var(--gold); }
.pc-dossier:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.pc-dossier:hover .pc-dossier-fleche { color: var(--gold); transform: translateX(2px); }

.pc-dossier-corps { flex: 1 1 auto; min-width: 0; }
.pc-dossier-nom {
  font-family: var(--serif); font-size: 17px; color: var(--text-0); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-dossier-meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
  letter-spacing: .04em; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* La pastille « en attente » sort de son positionnement absolu : ici elle
   prend sa place dans la ligne, elle ne flotte sur aucune image. */
.pc-dossier .pc-puce { position: static; max-width: none; flex: none; }

.pc-dossier-compte {
  font-family: var(--serif); font-size: 20px; color: var(--gold);
  flex: none; text-align: right; line-height: 1;
}
.pc-dossier-compte span {
  display: block; font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-top: 4px;
}
.pc-dossier-fleche {
  width: 13px; height: 13px; flex: none; color: var(--text-3);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.pc-carte {
  position: relative; background: var(--bg-card); border: 1px solid var(--ln-1);
  border-radius: var(--r-4); overflow: hidden; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.pc-carte:hover { border-color: var(--gold-bd-hi); transform: translateY(-2px); box-shadow: var(--sh-2); }
.pc-carte:focus-visible { outline: none; box-shadow: var(--sh-focus); }

.pc-vignette { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg-card2); }
/* Média capté mais pas encore rangé : la case existe, l'image pas encore. */
.pc-reste {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 22px; color: var(--gold);
}

.pc-infos { padding: 10px 13px; border-top: 1px solid var(--ln-1); }
.pc-nom {
  font-size: 13px; font-weight: 600; color: var(--text-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-top: 4px; }

/* Pastilles posées sur l'image — jamais de flou derrière du texte. */
.pc-puce {
  position: absolute; top: 9px; left: 9px; z-index: 2;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: var(--r-p);
  max-width: calc(100% - 76px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--sl-1); color: var(--text-1); border: 1px solid var(--ln-2);
}
.pc-puce.pc-moi { background: var(--gold); color: var(--sl-0); border-color: var(--gold); }
.pc-puce.pc-neuf { background: var(--ok); color: var(--sl-0); border-color: var(--ok); }
.pc-puce.pc-attente { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-ln); }
.pc-puce.pc-video {
  left: auto; right: 9px; background: oklch(0 0 0 / .62); color: #fff; border-color: oklch(1 0 0 / .22);
}

/* ── Fiches téléphone ────────────────────────────────────── */

.pc-fiche {
  background: var(--bg-card); border: 1px solid var(--ln-1); border-radius: var(--r-4);
  padding: 16px 18px; display: flex; flex-direction: column;
}
.pc-fiche-titre { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text-0); }
.pc-fiche-titre .pc-puce { position: static; max-width: none; }
.pc-statut { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 12px; color: var(--text-2); }
.pc-rond { width: 7px; height: 7px; border-radius: 50%; background: var(--ln-3); flex: none; }
.pc-rond.ok { background: var(--ok); }
.pc-rond.attente { background: var(--warn); }
.pc-rond.hs { background: var(--err); }
.pc-chiffre { font-family: var(--serif); font-size: 30px; color: var(--gold); margin-top: 12px; line-height: 1; }
.pc-chiffre span { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-left: 7px; letter-spacing: .05em; text-transform: uppercase; }
.pc-groupes { font-size: 12px; color: var(--text-2); margin-top: 10px; line-height: 1.6; }
.pc-groupes b { color: var(--text-1); font-weight: 500; }

.pc-fiche-bloc { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--ln-1); }
.pc-fiche-bloc + .pc-fiche-bloc { margin-top: 10px; }
.pc-aide { font-size: 11.5px; color: var(--text-3); line-height: 1.55; margin-top: 8px; }
.pc-avance { font-size: 12px; color: var(--text-2); line-height: 1.55; margin-top: 9px; }
.pc-avance b { color: var(--gold); }

.pc-plein-large { width: 100%; }

/* Carte « rattacher un téléphone » : la seule bordure pointillée de la page. */
.pc-fiche.pc-ajout {
  align-items: center; justify-content: center; text-align: center; gap: 8px;
  border-style: dashed; border-color: var(--gold-bd); cursor: pointer; min-height: 190px;
  color: var(--gold); font-weight: 600; font-size: 13.5px;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.pc-fiche.pc-ajout:hover { background: var(--gold-dim); border-color: var(--gold-bd-hi); }
.pc-fiche.pc-ajout .pc-croix { font-family: var(--serif); font-size: 30px; line-height: 1; }
.pc-fiche.pc-ajout small { font-weight: 400; color: var(--text-3); font-size: 11.5px; line-height: 1.55; max-width: 24ch; }

/* ── États vides et service arrêté ───────────────────────── */

.pc-etat-vide {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 70px 24px; border: 1px dashed var(--ln-2); border-radius: var(--r-4);
  max-width: 560px; margin: 40px auto 0;
}
.pc-etat-vide-icone { font-family: var(--serif); font-size: 30px; color: var(--gold-dim); }
.pc-etat-vide-titre { font-family: var(--serif); font-size: 20px; color: var(--text-0); }
.pc-etat-vide-txt { font-size: 13px; color: var(--text-2); line-height: 1.6; max-width: 52ch; }
.pc-etat-vide-txt b { color: var(--text-1); font-family: var(--mono); font-size: 12px; }

/* ── Liaison d'un téléphone (QR) ─────────────────────────── */

.pc-modal-fond {
  position: fixed; inset: 0; z-index: var(--z-modale); display: flex;
  align-items: center; justify-content: center; padding: var(--s-5);
  background: oklch(0 0 0 / .68); backdrop-filter: blur(2px);
}
.pc-modal {
  background: var(--bg-card); border: 1px solid var(--gold-bd); border-radius: var(--r-5);
  box-shadow: var(--sh-2); width: 100%; max-width: 430px; padding: 28px 26px;
  text-align: center; position: relative; max-height: 90vh; overflow-y: auto;
}
.pc-modal-fermer {
  position: absolute; top: 12px; right: 14px; background: none; border: 0;
  color: var(--text-3); font-size: 19px; line-height: 1; cursor: pointer; padding: 4px;
}
.pc-modal-fermer:hover { color: var(--text-0); }
.pc-modal h3 { font-family: var(--serif); font-size: 21px; color: var(--text-0); margin-bottom: 9px; }
.pc-modal p { font-size: 13px; color: var(--text-2); line-height: 1.6; }

/* Le QR doit rester sur un fond blanc : c'est une contrainte de lecture
   optique, pas un choix graphique — il ne suit donc pas le thème. */
.pc-qr {
  width: 258px; height: 258px; margin: 20px auto 8px; display: block;
  background: #fff; border-radius: var(--r-4); padding: 10px;
  border: 1px solid var(--ln-2);
}
.pc-etapes {
  text-align: left; font-size: 12.5px; color: var(--text-2); line-height: 2;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--ln-1);
}
.pc-etapes span { font-family: var(--mono); color: var(--gold); margin-right: 8px; }
/* Le code d'appairage, à recopier sur le téléphone. Gros, monospace, aéré. */
.pc-code {
  font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: 8px;
  color: var(--gold); text-align: center; padding: 20px 12px; margin: 18px auto 6px;
  border-radius: var(--r-4); background: var(--au-bg); border: 1px solid var(--gold-bd);
  max-width: 320px;
}
/* Bascule discrète QR → code, sous le QR. */
.pc-lien-alt {
  display: inline-block; margin-top: 16px; background: none; border: none;
  color: var(--gold); font-size: 12.5px; cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.pc-lien-alt:hover { color: var(--gold-bd-hi); }
.pc-attente-anim {
  width: 34px; height: 34px; margin: 6px auto 16px; border-radius: 50%;
  border: 2px solid var(--ln-2); border-top-color: var(--gold);
  animation: pcTourne 900ms linear infinite;
}
@keyframes pcTourne { to { transform: rotate(360deg); } }

/* ── Visionneuse ─────────────────────────────────────────── */

.pc-viewer {
  position: fixed; inset: 0; z-index: var(--z-modale); display: flex;
  align-items: center; justify-content: center; padding: 26px;
  background: oklch(0 0 0 / .94);
}
.pc-viewer img, .pc-viewer video { max-width: 94vw; max-height: 86vh; border-radius: var(--r-3); display: block; }
.pc-viewer-fermer {
  position: absolute; top: 16px; right: 22px; background: none; border: 0;
  color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 6px;
}
.pc-legende {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  max-width: min(90vw, 720px); text-align: center;
  font-family: var(--mono); font-size: 11.5px; color: oklch(1 0 0 / .82);
  background: oklch(0 0 0 / .55); border: 1px solid oklch(1 0 0 / .14);
  padding: 7px 16px; border-radius: var(--r-p);
}
/* Suppression (protégée par mot de passe) : action rare et destructive, donc
   discrète et teintée de rouge, à l'écart des commandes de lecture. */
.pc-suppr {
  position: absolute; bottom: 20px; right: 22px;
  background: oklch(0 0 0 / .55); border: 1px solid oklch(0.6 0.19 25 / .5);
  color: oklch(0.74 0.17 25); font-size: 12px; font-family: inherit;
  padding: 8px 14px; border-radius: var(--r-p); cursor: pointer;
}
.pc-suppr:hover { background: oklch(0.5 0.2 25 / .24); border-color: oklch(0.66 0.22 25); color: #fff; }

/* ── Chantier : on est souvent sur un téléphone ──────────── */

@media (max-width: 700px) {
  #view-photos { padding: 18px 14px; }
  .pc-title { font-size: 22px; }
  .pc-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }
  .pc-dossier { padding: 12px 14px; gap: var(--s-3); }
  .pc-dossier-nom { font-size: 15.5px; }
  .pc-dossier-compte { font-size: 17px; }
  .pc-dossier-fleche { display: none; }
  .pc-header { align-items: flex-start; }
  .pc-live { order: -1; }
  .pc-qr { width: min(258px, 74vw); height: min(258px, 74vw); }
  .pc-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .pc-tab { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .pc-carte, .pc-dossier, .pc-dossier-fleche,
  .pc-live .pc-dot, .pc-attente-anim { transition: none; animation: none; }
}

/* Bascule concordance : photos du chantier actif / toutes */
.pc-chantier-toggle {
  background: var(--gold-dim); color: var(--gold);
  border: 1px solid var(--gold-bd); border-radius: 999px;
  padding: 3px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.pc-chantier-toggle:hover { border-color: var(--gold); }

/* ═══════════════════════════════════════════════════════════
   KIT AUTONOME — boutons référencés par le JS
   Le JS pose les classes .btn-outline / .btn-gold / .btn-sm (héritées du
   design-system ROOS). On les définit ici pour rester autonome.
   ═══════════════════════════════════════════════════════════ */
#view-photos .btn-outline,
#view-photos .btn-gold {
  font-family: var(--sans); font-weight: 600; cursor: pointer;
  border-radius: var(--r-3); padding: 9px 16px; font-size: 13px;
  transition: all var(--dur-fast) var(--ease);
}
#view-photos .btn-outline {
  background: var(--bg-card); border: 1px solid var(--ln-2); color: var(--text-1);
}
#view-photos .btn-outline:hover:not([disabled]) { border-color: var(--gold-bd-hi); color: var(--gold); }
#view-photos .btn-gold {
  background: var(--gold); border: 1px solid var(--gold); color: #fff;
}
#view-photos .btn-gold:hover:not([disabled]) { filter: brightness(1.06); }
#view-photos .btn-outline[disabled],
#view-photos .btn-gold[disabled] { opacity: .5; cursor: default; }
#view-photos .btn-sm { padding: 7px 13px; font-size: 12.5px; }
