/* Conformité - même style que le dashboard (header avec logo, contenu, barre du bas) */

/* Variables alignées sur le dashboard */
#conformite-screen.conformite-screen.screen {
  --conformite-equal-gap: clamp(8px, 2.2vh, 24px);
  --conformite-gap-after-logo: clamp(24px, 6vh, 56px);
  /* Espacement unique : liste, sous le bandeau, et titre → méta dans la carte. */
  --conformite-stack-gap: clamp(10px, 2.5vw, 18px);
  height: 100%;
  min-height: 0;
  padding: 0 !important;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  /* Barre .note-bottom-bar en position fixed — réserve sur .conformite-main. */
  padding-bottom: 0 !important;
  background: url('../images/app-bg.png') no-repeat center bottom / cover;
  background-attachment: fixed;
}

/* Bandeau titre : mêmes classes que Notes (`.formulaire-header` + feuille-temps) — dégradé haut
 * plein écran supprimé pour aligner bordure, fond et typographie. */
#conformite-screen .conformite-header.formulaire-header {
  z-index: 200;
}
.conformite-header-spacer {
  display: block;
  width: 44px;
  min-width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.conformite-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  margin: var(--conformite-equal-gap) 0;
  padding: 4px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.conformite-logo {
  display: block;
  width: auto;
  object-fit: contain;
  object-position: center;
  margin: 0 auto;
  max-height: min(24vh, 160px);
  max-width: min(100%, 96vw);
}

/* Médias logo : ciblés :not(.minimal) car la barre seule n’affiche pas de logo. */
@media (max-height: 500px) {
  #conformite-screen.conformite-screen.screen:not(.conformite-screen--minimal) { --conformite-equal-gap: 6px; }
  .conformite-logo-wrap { padding: 2px 4px; }
  .conformite-logo { max-height: min(16vh, 70px); }
}
@media (min-height: 501px) and (max-height: 650px) {
  #conformite-screen.conformite-screen.screen:not(.conformite-screen--minimal) { --conformite-equal-gap: 8px; }
  .conformite-logo { max-height: min(20vh, 110px); }
}
@media (min-height: 651px) and (max-height: 800px) {
  .conformite-logo { max-height: min(24vh, 140px); }
}
@media (min-width: 600px) {
  .conformite-logo-wrap { padding: 6px 8px; }
  .conformite-logo { max-height: min(26vh, 180px); }
}
@media (min-width: 768px) {
  .conformite-logo-wrap { padding: 8px 10px; }
}
@media (min-width: 1024px) {
  .conformite-logo-wrap { padding: 10px 12px; }
}

/* Zone contenu sous le header (comme dashboard-content) */
#conformite-screen .conformite-content {
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 420px;
  width: 100%;
  margin-inline: auto;
  align-self: center;
  box-sizing: border-box;
  padding-top: var(--conformite-gap-after-logo);
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: var(--conformite-equal-gap);
  overscroll-behavior: none;
}

.app-ios #conformite-screen .conformite-content {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

#conformite-screen .conformite-main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 12px;
  -webkit-overflow-scrolling: touch;
  /* Même réserve que #note-screen .formulaire-main-feuille-temps (footer fixe + safe area). */
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

/* Panels */
.conformite-panel {
  display: none;
}
.conformite-panel.active {
  display: block;
}
.conformite-panel[hidden] {
  display: none !important;
}
/* Même principe que feuille-temps.css [hidden] + flex : s’assurer qu’aucun nœud n’occupe d’espace. */
#conformite-screen .conformite-loading[hidden],
#conformite-screen .conformite-empty[hidden],
#conformite-screen .conformite-error[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  border: none !important;
  overflow: hidden !important;
  pointer-events: none;
}

.conformite-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: #1a1a1a;
}

.conformite-section-desc {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0 0 1rem;
}

.conformite-list {
  display: flex;
  flex-direction: column;
  gap: var(--conformite-stack-gap, clamp(10px, 2.5vw, 18px));
  width: 100%;
  box-sizing: border-box;
}

/* Espacement haut des listes « cartes » — pas sur #projet-screen (tableau plein bord) */
.conformite-screen .conformite-list {
  padding-top: 16px;
}

/* Cartes style dashboard */
.conformite-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  box-sizing: border-box;
  width: 100%;
  background: linear-gradient(165deg, rgba(255,255,255,0.92) 0%, rgba(255,252,245,0.88) 50%, rgba(255,248,235,0.9) 100%);
  border: 1px solid rgba(212,175,55,0.25);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04), 0 0 0 1px rgba(212,175,55,0.08) inset;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.conformite-card:focus-within,
.conformite-card:hover {
  box-shadow: 0 12px 28px rgba(0,0,0,0.08), 0 0 24px rgba(212,175,55,0.15), 0 0 0 1px rgba(212,175,55,0.2) inset;
  border-color: rgba(212,175,55,0.4);
}

.conformite-card-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, rgba(255,252,240,0.95) 0%, rgba(255,248,230,0.9) 100%);
  border-radius: 14px;
  font-size: 1.35rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.conformite-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--conformite-intra-card-text-gap, 0.4rem);
}

.conformite-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.conformite-card-meta {
  font-size: 0.75rem;
  color: #9ca3af;
  margin: 0;
}
.conformite-card-badge {
  display: inline-block;
  margin-top: 0;
  align-self: flex-start;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: #b8860b;
  background: rgba(184, 134, 11, 0.12);
  border-radius: 6px;
}
.conformite-card-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
  width: 1.2em;
  height: 1.2em;
  font-size: 0.9em;
  color: #16a34a;
  background: rgba(22, 163, 74, 0.15);
  border-radius: 50%;
}
.conformite-card-confirmed {
  border-color: rgba(22, 163, 74, 0.3);
}

.conformite-card-action {
  flex-shrink: 0;
  padding: 0.45rem 0.85rem;
  background: linear-gradient(145deg, #d4a017 0%, #b8860b 100%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  text-decoration: none;
  display: inline-block;
}

.conformite-card-action:hover,
.conformite-card-action:focus {
  opacity: 0.95;
  transform: scale(1.02);
}

.conformite-empty,
.conformite-loading,
.conformite-error {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
  margin: 0;
}
.conformite-empty,
.conformite-loading {
  color: #6b7280;
}
.conformite-error {
  color: #dc2626;
}

/* Page de lecture : même barre et même emplacement que Conformité (header `.formulaire-header`
 * fixe + `top: env(safe-area-inset-top)` via base.css, réserve identique à la vue minimal). */
#conformite-lecture-screen.conformite-lecture-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: #fff;
  /* Comme #conformite-screen.conformite-screen--minimal : le contenu ne passe pas sous le bandeau. */
  padding: 0;
  padding-top: clamp(48px, 12vw, 66px) !important;
  box-sizing: border-box;
  isolation: isolate;
}
#conformite-lecture-screen.conformite-lecture-screen[hidden] {
  display: none !important;
}
#conformite-lecture-screen .conformite-lecture-header-bar.formulaire-header {
  z-index: 200;
}
#conformite-lecture-screen #conformite-lecture-back {
  position: relative;
  z-index: 601;
  pointer-events: auto;
  touch-action: manipulation;
}
.conformite-lecture-main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  padding-bottom: 1.5rem;
}
.conformite-lecture-meta {
  flex-shrink: 0;
  margin-bottom: 1rem;
}
.conformite-lecture-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: #1a1a1a;
}
.conformite-lecture-info {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 0;
}
.conformite-lecture-content-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: #f9fafb;
}
.conformite-lecture-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  box-sizing: border-box;
}
.conformite-lecture-content iframe,
.conformite-lecture-content object {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.conformite-lecture-content img {
  max-width: 100%;
  height: auto;
  max-height: 100%;
  display: block;
  object-fit: contain;
  align-self: flex-start;
}
.conformite-lecture-content video {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  object-fit: contain;
}
.conformite-lecture-footer {
  flex-shrink: 0;
  padding-top: 1rem;
  text-align: center;
}
.conformite-lecture-confirmed {
  font-size: 0.9rem;
  color: #16a34a;
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.conformite-lecture-btn-confirm {
  padding: 0.6rem 1.2rem;
  background: linear-gradient(145deg, #d4a017 0%, #b8860b 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.conformite-lecture-btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.conformite-lecture-btn-confirm:not(:disabled):hover {
  opacity: 0.95;
}
.conformite-lecture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}
.conformite-lecture-btn-next {
  padding: 0.6rem 1.2rem;
  background: rgba(22, 163, 74, 0.9);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.conformite-lecture-btn-next:hover {
  opacity: 0.95;
}

/* Navigation PDF par page (confirmation par page) */
.conformite-lecture-pdf-nav {
  flex-shrink: 0;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
}
.conformite-lecture-pdf-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.conformite-lecture-pdf-page-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  font-size: 0.85rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: #6b7280;
}
.conformite-lecture-pdf-page-dot.confirmed {
  background: rgba(22, 163, 74, 0.2);
  color: #16a34a;
}
.conformite-lecture-pdf-page-dot.current {
  background: rgba(184, 134, 11, 0.25);
  color: #b8860b;
  font-weight: 600;
}
.conformite-lecture-pdf-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
.conformite-lecture-pdf-buttons button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: linear-gradient(145deg, #d4a017 0%, #b8860b 100%);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}
.conformite-lecture-pdf-buttons button:hover:not(:disabled) {
  opacity: 0.95;
}
.conformite-lecture-pdf-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.conformite-lecture-pdf-counter {
  font-size: 0.9rem;
  color: #6b7280;
}
.conformite-lecture-content .conformite-pdf-canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #4a4a4a;
  border-radius: 8px;
}
.conformite-lecture-content .conformite-pdf-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Astuce Coach NDL / documents conformité */
#conformite-screen .app-coach-doc-hint {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #0a0a0a;
  background: #eff6ff;
  border: 1px solid #2563eb;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
#conformite-screen .app-coach-doc-hint strong {
  color: #000000;
}

/* Vue minimaliste : barre titre seule, pas de logo ni blocs d'intro (liste directe) */
#conformite-screen.conformite-screen--minimal.screen {
  /* Même retrait sous le bandeau qu’entre les cartes (voir --conformite-stack-gap). */
  --conformite-intra-card-text-gap: 0.4rem;
  /* Pas de marge "sous le logo" en vue barre seule (la variable héritée
   * clamp(24px,6vh,56px) du bloc général s'appliquait encore à .conformite-content). */
  --conformite-gap-after-logo: 0px;
  --conformite-equal-gap: 10px;
  /* Comme #note-screen.note-has-bottom-bar : réserve la hauteur du .formulaire-header fixe. */
  padding-top: clamp(48px, 12vw, 66px) !important;
  padding-bottom: 0 !important;
}
/* Redondance ciblée : évite tout écart hérité (mobile / ordre de cascade). */
#conformite-screen.conformite-screen--minimal .conformite-content {
  --conformite-gap-after-logo: 0;
  padding-top: 0 !important;
}
#conformite-screen.conformite-screen--minimal .conformite-main {
  margin-top: 0;
  /* Aligné sur le gap entre cartes : air stable sous le bandeau, sans marge négative. */
  padding-top: var(--conformite-stack-gap, clamp(10px, 2.5vw, 18px));
  scroll-padding-top: var(--conformite-stack-gap, clamp(10px, 2.5vw, 18px));
}

/* Pied d’onglets : mêmes règles que #note-screen .note-bottom-bar (note.css) —
 * le HTML réutilise .note-bottom-bar, mais seuls #note-screen / #formulaire-screen
 * y sont ciblés ailleurs ; il faut dupliquer ici pour le fixe + fond + blur. */
#conformite-screen .note-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  z-index: 999;
  flex-shrink: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  padding-left: 0;
  padding-right: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
  margin: 0;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  display: flex;
  align-items: stretch;
}
#conformite-screen .note-bottom-bar .note-bottom-menu {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 0;
  background: transparent;
  border-radius: 0;
}
#conformite-screen .note-bottom-bar .note-menu-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s;
  min-width: 0;
  border-radius: 0;
  text-align: center;
  text-wrap: balance;
}
#conformite-screen .note-bottom-bar .note-nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
#conformite-screen .note-bottom-bar .note-nav-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  min-width: 24px;
  min-height: 24px;
  flex-shrink: 0;
  color: inherit;
  stroke: currentColor;
}
#conformite-screen .note-bottom-bar .note-nav-label {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  font-weight: inherit;
  line-height: 1.2;
  text-align: center;
}
#conformite-screen .note-bottom-bar .note-menu-tab:active {
  background: rgba(0, 0, 0, 0.04);
}
#conformite-screen .note-bottom-bar .note-menu-tab.active {
  color: #2563eb;
  font-weight: 600;
}
@media (hover: hover) {
  #conformite-screen .note-bottom-bar .note-menu-tab:hover {
    background: rgba(0, 0, 0, 0.03);
  }
}

#app-container.app-theme-night #conformite-screen .note-bottom-bar {
  background: rgba(30, 41, 59, 0.75);
  border-top-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.25);
}
#app-container.app-theme-night #conformite-screen .note-bottom-bar .note-menu-tab.active {
  color: #60a5fa;
}

/* Même grille de hauteur / rebords que #note-screen (device-adaptive.css) */
@container app (min-width: 320px) {
  #conformite-screen .note-bottom-bar {
    min-height: 48px;
    padding-top: 8px;
    padding-left: 6px;
    padding-right: 6px;
  }
}
@container app (min-width: 430px) {
  #conformite-screen .note-bottom-bar {
    min-height: 54px;
  }
}
@container app (min-width: 600px) {
  #conformite-screen .note-bottom-bar {
    min-height: 56px;
    padding-top: 10px;
  }
}
@container app (min-width: 1024px) {
  #conformite-screen .note-bottom-bar {
    min-height: 64px;
  }
}
