@import url("../variables/global-qhqcgov.css");

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex; /* pour centrer le contenu */
    align-items: center;
    justify-content: center;
    z-index: 1000; /* au-dessus de tout */
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    z-index: 1001; /* au-dessus du backdrop */
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.datasaver {
    font-size: .95rem;
}

.datasaver input {
    transform: translateY(1px);
}

.offline-datasaver-meter {
    font-size: .95rem;
    opacity: .9;
}

.offline-datasaver-meter .ok {
    color: #2563eb;
}

.offline-datasaver-meter .warn {
    color: #b45309;
}

.offline-datasaver-meter .danger {
    color: #b91c1c;
}

.upload-card {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-family: sans-serif;
}

.upload-card__title {
    margin: 0 0 1rem;
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

.upload-card__field {
    margin-bottom: 1.5rem;
}

.upload-card__label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.upload-card__input {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    color: #333;
    background: #fafafa;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.upload-card__input:hover {
    border-color: #999;
}

.upload-card__input:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.upload-card__submit {
    display: inline-block;
    padding: 10px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-secondary);
    background: var(--color-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: .75rem;
}

.upload-card__submit:hover {
    background: #0056b3;
}

.photo-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: .5rem;
    margin-top: .75rem;
}

.photo-thumb-card {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: .5rem;
    overflow: hidden;
    background: #f4f4f5;
    isolation: isolate;
}

.photo-thumb-card .photo-thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform .2s ease;
    will-change: transform;
}

.photo-thumb-card:hover .photo-thumb {
    transform: scale(1.05);
}

.photo-thumb-card .thumb-remove {
    position: absolute;
    top: .35rem;
    right: .35rem;
    z-index: 3;
    width: 1.25rem;
    height: 1.25rem;
    line-height: 1.25rem;
    font-size: .75rem;
    border: 0;
    border-radius: 9999px;
    text-align: center;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
}

/* Les images ne captent pas les clics, les <video> restent interactives */
.photo-thumb-card img.photo-thumb {
    pointer-events: none;
}

/* --- Bouton caméra (mêmes codes que le submit, version "outline") --- */
.upload-card__button-camera {
    display: inline-block;
    padding: 10px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-primary);
    background: #fff;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
    margin-right: .5rem;
}

.upload-card__button-camera:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
    border-color: var(--color-primary);
}

/* --- Zone caméra --- */
.camera-area {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.camera-area.hidden {
    display: none;
}

/* Cadre qui CLIPSE le zoom logiciel */
.camera-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

/* La vidéo remplit le cadre; le zoom logiciel agit via transform */
.camera-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center;
    will-change: transform;
}

/* Canvas utilisé pour le snapshot (reste caché) */
.camera-canvas {
    display: none;
}

/* Barre de contrôles prise de vue */
.camera-area .mt-2 {
    margin-top: .75rem;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.camera-area .btn,
.camera-area .btn.btn-sm {
    padding: 8px 10px;
    font-size: .95rem;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.camera-area .btn:hover,
.camera-area .btn.btn-sm:hover {
    background: #f2f2f2;
    border-color: #999;
}

/* État actif (caméra ouverte) */
.camera-area.is-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
}

/* Messages d’info/erreur optionnels */
.camera-tip,
.camera-error {
    margin-top: .5rem;
    font-size: .95rem;
    line-height: 1.4;
}

.camera-tip {
    color: #444;
}

.camera-error {
    color: #b00020;
}

/* Prévisualisations déjà présentes : léger ajustement quand la caméra est ouverte */
.camera-area + .photo-preview-container {
    margin-top: 1rem;
}

.zoom-ctrl {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-top: .5rem;
}

.zoom-ctrl.hidden {
    display: none;
}

/* Mobile */
@media (max-width: 600px) {
    .modal-content {
        padding: 1rem;
        max-width: 96%;
        max-height: 92%;
    }

    .camera-video {
        max-height: 45vh;
    }
}