/*
 * Visionneuse d'images unique (js/cjt-viewer.js, components/image_viewer.php) — site et administration.
 * CSS autonome (pas de classes Tailwind) : même rendu avec le CSS compilé du site et le Tailwind de l'admin.
 */
.cjtv {
     position: fixed;
     inset: 0;
     z-index: 10050;                      /* au-dessus des modales (collection rapide, SweetAlert, barre mobile) */
     display: flex;
     flex-direction: column;
     background: rgba(2, 6, 23, 0.96);
     color: #fff;
     -webkit-backdrop-filter: blur(6px);
     backdrop-filter: blur(6px);
     padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
     font-family: inherit;
     user-select: none;
     -webkit-user-select: none;
     transition: opacity 0.15s ease;
}
.cjtv [hidden] { display: none !important; }

/* Barre du haut : titre + outils */
.cjtv-top {
     display: flex;
     align-items: flex-start;
     justify-content: space-between;
     gap: 12px;
     padding: 12px 16px 8px;
     position: relative;
     z-index: 2;
}
.cjtv-head { min-width: 0; flex: 1; }
.cjtv-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cjtv-meta:empty { display: none; }
.cjtv-badge {
     padding: 2px 10px;
     border-radius: 999px;
     background: #2563eb;
     font-size: 11px;
     font-weight: 800;
     letter-spacing: 0.04em;
     text-transform: uppercase;
}
.cjtv-counter { font-size: 12px; font-weight: 700; color: #cbd5e1; }
.cjtv-title {
     margin: 4px 0 0;
     font-size: 15px;
     font-weight: 800;
     line-height: 1.3;
     color: #fff;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
}
.cjtv-subtitle {
     margin: 2px 0 0;
     font-size: 12px;
     color: #cbd5e1;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
}

.cjtv-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cjtv-zoom {
     display: flex;
     align-items: center;
     gap: 2px;
     padding: 3px;
     border-radius: 14px;
     background: rgba(255, 255, 255, 0.08);
     border: 1px solid rgba(255, 255, 255, 0.12);
}
.cjtv-btn {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     min-width: 40px;
     height: 40px;
     padding: 0 8px;
     border: 0;
     border-radius: 11px;
     background: transparent;
     color: #e2e8f0;
     font-size: 15px;
     cursor: pointer;
     text-decoration: none;
     transition: background-color 0.15s, color 0.15s;
}
.cjtv-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.cjtv-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.cjtv-btn:focus-visible,
.cjtv-nav:focus-visible,
.cjtv-thumb:focus-visible,
.cjtv-action:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.cjtv-pct { min-width: 58px; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cjtv-opt { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12); }
.cjtv-close { background: rgba(244, 63, 94, 0.85); color: #fff; font-size: 18px; }
.cjtv-close:hover { background: #e11d48; }

/* Scène : l'image est positionnée et transformée par le script (zoom, déplacement, rotation) */
.cjtv-stage {
     position: relative;
     flex: 1;
     min-height: 0;
     overflow: hidden;
     touch-action: none;
     cursor: zoom-in;
}
.cjtv.is-zoomed .cjtv-stage { cursor: grab; }
.cjtv.is-zoomed .cjtv-stage:active { cursor: grabbing; }
.cjtv-img {
     position: absolute;
     left: 50%;
     top: 50%;
     max-width: none;
     max-height: none;
     background: #fff;
     border-radius: 12px;
     box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
     transform-origin: center center;
     will-change: transform;
     opacity: 0;
     pointer-events: none;
}
.cjtv-img.is-ready { opacity: 1; }
.cjtv-img.is-animating { transition: transform 0.2s ease-out; }

.cjtv-spinner {
     position: absolute;
     left: 50%;
     top: 50%;
     width: 34px;
     height: 34px;
     margin: -17px 0 0 -17px;
     border-radius: 50%;
     border: 3px solid rgba(255, 255, 255, 0.2);
     border-top-color: #fff;
     animation: cjtv-spin 0.8s linear infinite;
     opacity: 0;
     transition: opacity 0.2s;
     pointer-events: none;
}
.cjtv.is-loading .cjtv-spinner { opacity: 1; transition-delay: 0.25s; }
@keyframes cjtv-spin { to { transform: rotate(360deg); } }

.cjtv-nav {
     position: absolute;
     top: 50%;
     z-index: 2;
     width: 48px;
     height: 48px;
     margin-top: -24px;
     display: inline-flex;
     align-items: center;
     justify-content: center;
     border: 1px solid rgba(255, 255, 255, 0.15);
     border-radius: 50%;
     background: rgba(15, 23, 42, 0.6);
     color: #fff;
     font-size: 18px;
     cursor: pointer;
     transition: background-color 0.15s;
}
.cjtv-nav:hover { background: rgba(37, 99, 235, 0.9); }
.cjtv-prev { left: 12px; }
.cjtv-next { right: 12px; }

/* Bas : actions, vignettes, aide */
.cjtv-bottom {
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 8px;
     padding: 8px 16px 12px;
     position: relative;
     z-index: 2;
}
.cjtv-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cjtv-action {
     display: inline-flex;
     align-items: center;
     gap: 8px;
     min-height: 40px;
     padding: 0 16px;
     border-radius: 12px;
     border: 1px solid rgba(255, 255, 255, 0.2);
     background: rgba(255, 255, 255, 0.12);
     color: #fff;
     font-size: 13px;
     font-weight: 700;
     text-decoration: none;
     cursor: pointer;
     transition: background-color 0.15s;
}
.cjtv-action:hover { background: rgba(255, 255, 255, 0.22); color: #fff; }
.cjtv-action.is-primary { background: #2563eb; border-color: #3b82f6; }
.cjtv-action.is-primary:hover { background: #1d4ed8; }

.cjtv-strip {
     display: flex;
     gap: 8px;
     max-width: 100%;
     overflow-x: auto;
     padding: 4px;
     scrollbar-width: thin;
}
.cjtv-thumb {
     flex-shrink: 0;
     width: 56px;
     height: 56px;
     padding: 3px;
     border-radius: 12px;
     border: 2px solid transparent;
     background: #fff;
     opacity: 0.55;
     cursor: pointer;
     transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
}
.cjtv-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cjtv-thumb:hover { opacity: 0.9; }
.cjtv-thumb.is-active { opacity: 1; border-color: #60a5fa; transform: scale(1.06); }

.cjtv-hint { margin: 0; font-size: 11px; color: #94a3b8; text-align: center; }

.cjtv-sr {
     position: absolute;
     width: 1px;
     height: 1px;
     overflow: hidden;
     clip: rect(0 0 0 0);
     white-space: nowrap;
}

/* Téléphone : outils essentiels, flèches discrètes (le balayage suffit) */
@media (max-width: 640px) {
     .cjtv-top { padding: 8px 10px 4px; }
     .cjtv-title { font-size: 14px; }
     .cjtv-opt[data-act="fullscreen"] { display: none; }
     .cjtv-pct { min-width: 48px; }
     .cjtv-btn { min-width: 38px; height: 38px; }
     .cjtv-nav { width: 40px; height: 40px; margin-top: -20px; font-size: 15px; background: rgba(15, 23, 42, 0.45); }
     .cjtv-prev { left: 4px; }
     .cjtv-next { right: 4px; }
     .cjtv-bottom { padding: 6px 10px 10px; }
     .cjtv-thumb { width: 48px; height: 48px; }
     .cjtv-action { min-height: 44px; }
}
@media (max-width: 400px) {
     .cjtv-zoom [data-act="zoomOut"],
     .cjtv-zoom [data-act="zoomIn"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
     .cjtv, .cjtv-img.is-animating, .cjtv-thumb { transition: none; }
}
