/* ── UWA Image Viewer — Lot B + C ──────────────────────────────────────────
   Visionneuse plein écran pour les radios/photos patients.
   Fonctionne en thème clair et sombre (variables CSS de uwa.css).
   Accessible : focus piégé, aria-labels, Échap pour fermer.
   ─────────────────────────────────────────────────────────────────────── */

/* ── Overlay ── */
.uwa-iv-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Toolbar supérieure ── */
.uwa-iv-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 48px;
}

.uwa-iv-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.5rem;
}

.uwa-iv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 7px;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    font-family: inherit;
    transition: background 0.12s;
}
.uwa-iv-btn:hover { background: rgba(255, 255, 255, 0.22); }
.uwa-iv-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.uwa-iv-btn.active { background: rgba(96, 165, 250, 0.35); border-color: #60a5fa; }

.uwa-iv-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    margin: 0 0.15rem;
}

/* ── Zone principale (image + comparaison) ── */
.uwa-iv-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ── Panneau image ── */
.uwa-iv-pane {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
}
.uwa-iv-pane:active { cursor: grabbing; }

.uwa-iv-pane-split { border-right: 2px solid rgba(255, 255, 255, 0.25); }

/* ── Conteneur transformé ── */
.uwa-iv-transform-root {
    position: absolute;
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
}

.uwa-iv-img {
    display: block;
    max-width: none;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* ── Annotations SVG overlay ── */
.uwa-iv-annotation-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}
.uwa-iv-pane.annotation-mode .uwa-iv-annotation-svg {
    pointer-events: all;
    cursor: crosshair;
}
.uwa-iv-annotation-svg.hidden { display: none; }

.uwa-iv-annot-group { cursor: pointer; pointer-events: all; }
.uwa-iv-annot-group:focus-visible { outline: none; }
.uwa-iv-annot-group.selected .uwa-iv-annot-shape { stroke-width: 3; filter: drop-shadow(0 0 4px rgba(255,255,255,0.6)); }

/* ── Barre d'annotation (basse) ── */
.uwa-iv-annot-bar {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 48px;
}
.uwa-iv-annot-bar.visible { display: flex; }

/* ── Panneau latéral annotations ── */
.uwa-iv-annot-panel {
    width: 240px;
    background: rgba(15, 23, 42, 0.92);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
.uwa-iv-annot-panel.visible { display: flex; }

/* ── Panneau compte rendu ── */
.uwa-iv-report-panel {
    width: 340px;
    padding: 0 0.8rem 0.8rem;
    background: rgba(15, 23, 42, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    overflow-y: auto;
    flex-shrink: 0;
}
.uwa-iv-report-panel.hidden { display: none; }
.uwa-iv-report-label { font-size: 0.75rem; font-weight: 650; color: #94a3b8; }
.uwa-iv-report-panel textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 7px;
    background: rgba(255,255,255,.07);
    color: #e2e8f0;
    padding: 0.55rem;
    font: inherit;
    font-size: 0.82rem;
}
.uwa-iv-report-panel textarea:focus { outline: 2px solid #60a5fa; outline-offset: 1px; }
.uwa-iv-report-annotations { display: flex; flex-direction: column; gap: 0.3rem; }
.uwa-iv-report-annotation { display: flex; gap: 0.4rem; align-items: flex-start; font-size: 0.78rem; }
.uwa-iv-report-empty { color: #64748b; font-size: 0.78rem; }
.uwa-iv-report-primary { width: 100%; }
.uwa-iv-report-error { color: #fca5a5; font-size: 0.78rem; }
.uwa-iv-report-preview-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.uwa-iv-report-preview-wrap[hidden] { display: none; }
.uwa-iv-report-preview {
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 7px;
    padding: 0.6rem;
    background: rgba(0,0,0,.18);
    font-size: 0.78rem;
    line-height: 1.45;
}
.uwa-iv-report-preview h2, .uwa-iv-report-preview h3, .uwa-iv-report-preview h4 { margin: .3rem 0; color: #e2e8f0; }

.uwa-iv-annot-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    padding: 0.65rem 0.85rem 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.uwa-iv-annot-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem 0.5rem;
}

.uwa-iv-annot-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #cbd5e1;
    transition: background 0.1s;
}
.uwa-iv-annot-row:hover { background: rgba(255, 255, 255, 0.08); }
.uwa-iv-annot-row.selected { background: rgba(96, 165, 250, 0.2); }

.uwa-iv-annot-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.uwa-iv-annot-row-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uwa-iv-annot-row-tooth {
    font-size: 0.7rem;
    color: #64748b;
    flex-shrink: 0;
}

.uwa-iv-annot-del {
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    padding: 0.1rem 0.2rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.1s;
    font-size: 0.82rem;
    line-height: 1;
}
.uwa-iv-annot-row:hover .uwa-iv-annot-del { opacity: 1; }

/* ── Dialog édition d'annotation ── */
.uwa-iv-annot-dialog {
    position: absolute;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 0.8rem;
    z-index: 9100;
    min-width: 240px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.uwa-iv-annot-dialog label {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.2rem;
    margin-top: 0.5rem;
}
.uwa-iv-annot-dialog label:first-child { margin-top: 0; }

.uwa-iv-annot-dialog input[type="text"] {
    width: 100%;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
    font-size: 0.82rem;
    font-family: inherit;
    box-sizing: border-box;
}
.uwa-iv-annot-dialog input[type="text"]:focus {
    outline: none;
    border-color: #60a5fa;
}

.uwa-iv-annot-dialog select {
    width: 100%;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.82rem;
    font-family: inherit;
    box-sizing: border-box;
    cursor: pointer;
}
.uwa-iv-annot-dialog select:focus { outline: none; border-color: #60a5fa; }

.uwa-iv-color-picker {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.uwa-iv-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}
.uwa-iv-color-swatch:hover { transform: scale(1.15); }
.uwa-iv-color-swatch.selected { border-color: #fff; transform: scale(1.15); }

.uwa-iv-dialog-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-top: 0.65rem;
}

/* ── Barre d'infos bas ── */
.uwa-iv-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    font-size: 0.72rem;
    color: #64748b;
}

/* ── Sélecteur de comparaison ── */
.uwa-iv-compare-panel {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    z-index: 9050;
    min-width: 200px;
    max-width: 280px;
    display: none;
}
.uwa-iv-compare-panel.visible { display: block; }

.uwa-iv-compare-panel h4 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.uwa-iv-compare-list { max-height: 220px; overflow-y: auto; }

.uwa-iv-compare-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #cbd5e1;
    transition: background 0.1s;
}
.uwa-iv-compare-item:hover { background: rgba(255, 255, 255, 0.1); }
.uwa-iv-compare-item.selected { background: rgba(96, 165, 250, 0.2); }

.uwa-iv-compare-item-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: #0f172a;
}

.uwa-iv-compare-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uwa-iv-compare-item-date { font-size: 0.72rem; color: #64748b; flex-shrink: 0; }

/* ── Indicateur d'annotations sur les items de document ── */
.p360-annot-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 999px;
    padding: 0.08rem 0.42rem;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── Réglages de filtres (labels) ── */
.uwa-iv-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.uwa-iv-filter-row label {
    font-size: 0.72rem;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}
.uwa-iv-range {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
    width: 80px;
}
.uwa-iv-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #60a5fa;
    cursor: pointer;
}
.uwa-iv-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #60a5fa;
    cursor: pointer;
    border: none;
}

/* ── Tablette ── */
@media (max-width: 640px) {
    .uwa-iv-annot-panel { width: 180px; }
    .uwa-iv-report-panel { position: absolute; inset: 0 0 0 auto; width: min(88vw, 340px); z-index: 2; }
    .uwa-iv-toolbar { gap: 0.25rem; padding: 0.4rem 0.5rem; }
    .uwa-iv-btn { padding: 0.25rem 0.4rem; font-size: 0.75rem; min-width: 28px; min-height: 28px; }
}
