/* ==========================================================================
   COMPOSANT IMAGE REUTILISABLE — Carillon Pro (chantier B2, photos metier).
   Couche chargee APRES carillon-mobile.css. N'ecrase aucune classe existante :
   tout est prefixe .cphoto*. Reutilise les tokens de charte (carillon-ui.css)
   avec repli, pour rester coherent en theme clair comme sombre.
   ========================================================================== */

.cphoto {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cphoto-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.cphoto-title {
  margin: 0;
  font-weight: 700;
  color: var(--ink, #12233b);
  font-size: 0.95rem;
}

.cphoto-count {
  font-size: 0.78rem;
  color: var(--muted, #5b6b7d);
}

/* ---- Grille de miniatures (recadrage constant) --------------------------- */
.cphoto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.cphoto-thumb {
  position: relative;
  margin: 0;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  background: var(--surface-douce, #eef2f7);
  border: 1px solid var(--line, #d8e0ea);
}

.cphoto-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* Recadrage coherent : toutes les vignettes au meme rapport, remplissage cover. */
.cphoto-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-douce, #eef2f7);
}

.cphoto-phase {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: rgba(18, 35, 59, 0.82);
  letter-spacing: 0.02em;
}

.cphoto-thumb figcaption {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  background: var(--panel, #fff);
}

.cphoto-caption {
  font-size: 0.8rem;
  color: var(--ink, #12233b);
  line-height: 1.25;
}

.cphoto-when {
  font-size: 0.7rem;
  color: var(--muted, #5b6b7d);
}

/* Bouton supprimer : cible tactile confortable, contraste suffisant. */
.cphoto-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(18, 35, 59, 0.72);
  cursor: pointer;
}
.cphoto-del:hover {
  background: var(--danger, #c0392b);
}

/* ---- Bouton d'ajout ------------------------------------------------------ */
.cphoto-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-sm, 10px);
  border: 1.5px dashed var(--primary, #1546a0);
  background: var(--surface-blue, #eef3fb);
  color: var(--primary-dark, #103a86);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  width: fit-content;
}
.cphoto-add:hover {
  background: var(--surface-cyan, #e6f0fb);
}
.cphoto-add svg {
  flex: none;
}

/* ---- Etats vides --------------------------------------------------------- */
.cphoto-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1px dashed var(--line, #d8e0ea);
  border-radius: var(--radius-sm, 10px);
  color: var(--muted, #5b6b7d);
  background: var(--surface-douce, #f4f7fb);
  text-align: center;
  font-size: 0.85rem;
}
.cphoto-empty.small {
  padding: 12px;
  font-size: 0.8rem;
}
.cphoto-empty svg {
  color: var(--muted, #8593a5);
}

/* ---- Journal de chantier (phases) ---------------------------------------- */
.cphoto-phase-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.cphoto-phase-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #5b6b7d);
}

.cphoto-limit {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted, #5b6b7d);
}

/* ---- Overlays (composition, zoom, chargement) ---------------------------- */
body.cphoto-lock {
  overflow: hidden;
}

.cphoto-backdrop {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(9, 18, 32, 0.66);
  backdrop-filter: blur(2px);
}

.cphoto-panel {
  max-width: min(560px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel, #fff);
  color: var(--ink, #12233b);
  border-radius: var(--radius-panel, 16px);
  box-shadow: var(--shadow-strong, 0 24px 60px rgba(9, 18, 32, 0.35));
}

/* Composition : apercu + alt + legende */
.cphoto-compose {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.cphoto-compose-preview {
  position: relative;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  background: var(--surface-douce, #eef2f7);
}
.cphoto-compose-preview img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: #0b1220;
}
.cphoto-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: rgba(18, 35, 59, 0.85);
}

.cphoto-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--ink, #12233b);
}
.cphoto-field span {
  font-weight: 600;
}
.cphoto-field small {
  font-weight: 400;
  color: var(--muted, #5b6b7d);
}
.cphoto-field input {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: var(--radius-sm, 10px);
  font-size: 0.9rem;
  color: var(--ink, #12233b);
  background: var(--bg, #fff);
}
.cphoto-field input:focus-visible {
  outline: var(--focus-ring, 2px solid #1546a0);
  outline-offset: 1px;
}

.cphoto-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted, #5b6b7d);
}

.cphoto-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.cphoto-compose-actions .btn {
  min-height: 44px;
}

/* Chargement */
.cphoto-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 40px;
  color: var(--ink, #12233b);
}
.cphoto-loading p {
  margin: 0;
  font-size: 0.9rem;
}
.cphoto-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line, #d8e0ea);
  border-top-color: var(--primary, #1546a0);
  animation: cphoto-spin 0.8s linear infinite;
}
@keyframes cphoto-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cphoto-spinner {
    animation-duration: 2s;
  }
}

/* Zoom plein cadre */
.cphoto-lightbox {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.cphoto-panel:has(.cphoto-lightbox) {
  background: transparent;
  box-shadow: none;
  max-width: min(1100px, 96vw);
}
.cphoto-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius-sm, 10px);
  background: #0b1220;
}
.cphoto-lightbox-cap {
  margin: 0;
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.cphoto-lightbox-close {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  color: #fff;
  background: rgba(9, 18, 32, 0.7);
  cursor: pointer;
}
.cphoto-lightbox-close:hover {
  background: rgba(9, 18, 32, 0.92);
}

/* ---- Galerie en modale (stock, produit) ---------------------------------- */
.cphoto-modal {
  position: relative;
  padding: 18px;
  min-width: min(520px, 92vw);
}
.cphoto-modal-title {
  margin: 0 34px 12px 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink, #12233b);
}
.cphoto-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted, #5b6b7d);
  background: var(--surface-douce, #eef2f7);
  cursor: pointer;
}
.cphoto-modal-close:hover {
  color: var(--ink, #12233b);
  background: var(--line, #d8e0ea);
}

/* Bouton « Photos » discret (carte produit, ligne de stock). */
.cphoto-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line, #d8e0ea);
  border-radius: var(--radius-sm, 8px);
  background: var(--panel, #fff);
  color: var(--primary-dark, #103a86);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.cphoto-open-btn:hover {
  background: var(--surface-blue, #eef3fb);
}
.cphoto-open-btn .cphoto-open-count {
  font-weight: 700;
}

/* Section photos dans la fiche client / dossier chantier (pleine largeur). */
.fiche-photos {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #d8e0ea);
}

/* Galerie photos dans la modale de production (sous les ingrédients). */
.production-modal-photos:not(:empty) {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line, #d8e0ea);
}

/* Petite grille sur telephone : 2 colonnes confortables. */
@media (max-width: 560px) {
  .cphoto-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }
  .cphoto-add {
    width: 100%;
    justify-content: center;
  }
}
