/*
 * Depot photos - styles propres a l'application.
 * Couleurs, polices, en-tete, cartes, formulaires et boutons proviennent de
 * la charte graphique (https://charte.arcpontoise.fr/), chargee avant ce
 * fichier par chaque page.
 */

/* Header follows the width of the page content: narrow for forms, wide for
   the admin pages (admin.js toggles .wide on main after login). */
header.site:has(~ main.etroit) .gabarit {
  max-width: var(--layout-width-narrow);
}

main.gabarit.wide,
header.site:has(~ main.wide) .gabarit {
  max-width: 1600px;
}

/* Formulaires empiles : un peu d'air dans et entre les cartes */
.carte {
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.5rem;
}

.carte h2 {
  margin-top: 0;
}

/* --- Navigation et filtres (pages admin) --- */

select,
.filter-bar {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--card);
}

nav.subnav {
  margin-bottom: 1rem;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

nav.subnav a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

nav.subnav a:hover {
  text-decoration: underline;
}

.progress-bar {
  margin-top: 0.75rem;
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

/* Phase serveur (validation + scan antivirus) une fois l'envoi termine :
   sa duree reelle n'est pas connue cote client, donc pas de pourcentage
   fiable a afficher - un va-et-vient indique juste qu'un traitement est
   toujours en cours plutot que de figer la barre a 100%. */
.progress-bar.indeterminate .progress-fill {
  width: 30%;
  animation: progress-indeterminate 1.1s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    margin-left: -30%;
  }

  100% {
    margin-left: 100%;
  }
}

.progress-text {
  color: var(--gray);
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

.previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.previews img, .previews video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar .count {
  font-size: 0.9rem;
  color: var(--gray);
}

/* Les boutons ont un margin-top pense pour un empilement vertical dans
   un formulaire (voir la regle button generique) : dans une barre
   d'outils flex, ce margin les decale vers le bas par rapport aux
   champs/labels voisins qui n'en ont pas. */
.toolbar button,
.toolbar input,
.toolbar select {
  width: auto;
  margin-top: 0;
}

/* --- Grille de photos (backend admin) --- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.photo-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  transition: box-shadow 0.15s ease;
}

.photo-tile:hover, .photo-tile:focus-within {
  box-shadow: 0 4px 14px rgb(0 0 0 / 12%);
}

.photo-tile.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.photo-tile .thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  cursor: pointer;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-tile .select-check {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 1.3rem;
  height: 1.3rem;
  cursor: pointer;
  z-index: 1;
}

.photo-tile .video-badge {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgb(9 19 45 / 78%);
  color: white;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  z-index: 1;
  pointer-events: none;
}

.photo-tile .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to top, rgb(0 0 0 / 72%) 0%, rgb(0 0 0 / 0%) 55%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.photo-tile:hover .overlay, .photo-tile:focus-within .overlay {
  opacity: 1;
}

.photo-tile .overlay-text {
  color: white;
  font-size: 0.78rem;
  padding: 0.5rem;
  line-height: 1.35;
}

.photo-tile .overlay-text strong {
  display: block;
  font-size: 0.85rem;
}

.photo-tile .meta {
  padding: 0.5rem 0.6rem;
  font-size: 0.78rem;
  color: var(--gray);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
}

/* stylelint-disable-next-line no-descending-specificity -- tile links, unrelated to nav.subnav links */
.photo-tile .meta a {
  color: var(--accent);
}

/* --- Historique / journal (listes texte) --- */

.history-list, .log-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

/* L'historique archer est un petit widget dans une carte : defilement
   interne pour ne pas etirer la page. Le journal admin, lui, est le
   contenu principal de sa page : il doit s'etendre avec la page plutot
   que de defiler prematurement dans une boite figee. */
.history-list {
  max-height: 320px;
  overflow-y: auto;
}

.history-list li, .log-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history-name {
  word-break: break-all;
}

.history-date,
.log-date {
  color: var(--gray-soft);
  white-space: nowrap;
  font-size: 0.82rem;
}

.log-list li {
  flex-wrap: wrap;
  align-items: center;
}

.log-event {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--blue-mid);
  border: 1px solid var(--border);
}

.status-valide {
  color: var(--success);
  border-color: var(--success);
}

.status-utilise {
  color: var(--gray-soft);
  border-color: var(--gray-soft);
}

.status-expire {
  color: var(--warning);
  border-color: var(--warning);
}

.status-revoque {
  color: var(--danger);
  border-color: var(--danger);
}

.log-detail {
  flex: 1;
  min-width: 200px;
}

.log-actor {
  color: var(--gray);
  font-size: 0.85rem;
}

/* --- Invitation administrateur --- */
.carte h3 {
  margin: 1.5rem 0 0.25rem;
  font-size: 1.05rem;
}

.totp-qr {
  display: block;
  width: 200px;
  max-width: 100%;
  margin: 0.75rem 0;
  background: white;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* --- Petits ecrans (telephone) --- */
@media (width <= 600px) {
  /* Historique : nom de fichier puis date en dessous, plutot que cote a
     cote (un nom long ecrasait la date). */
  .history-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .history-date {
    white-space: normal;
  }
}
