/**
 * UMOA Scanner - Styles modernes pour le scanner QR/Code-barres
 * 
 * Design plein écran avec overlay sombre, viseur central et ligne laser animée
 * 
 * @package UMOA
 * @version 1.0.0
 */

/* ============================================================================
   OVERLAY PRINCIPAL
   ============================================================================ */

#umoa-scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#umoa-scanner-overlay.active {
    display: flex;
    opacity: 1;
}

/* ============================================================================
   CONTENEUR PRINCIPAL
   ============================================================================ */

.scanner-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   CONTENEUR VIDÉO
   ============================================================================ */

#scanner-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Masquer les éléments superflus de html5-qrcode */
#scanner-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#scanner-video-container canvas {
    display: none !important;
}

#scanner-video-container > div {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================================
   VISEUR (VIEWFINDER)
   ============================================================================ */

.scanner-viewfinder {
    position: relative;
    width: 280px;
    height: 280px;
    z-index: 10;
    margin: 20px;
}

/* Angles du viseur */
.viewfinder-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 4px solid #E67E22;
    box-shadow: 0 0 10px rgba(230, 126, 34, 0.6);
}

.viewfinder-corner-tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 8px;
}

.viewfinder-corner-tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 8px;
}

.viewfinder-corner-bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 8px;
}

.viewfinder-corner-br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 8px;
}

/* Zone transparente centrale (masque) */
.scanner-viewfinder::before {
    content: '';
    position: absolute;
    top: -100vh;
    left: -100vw;
    width: 200vw;
    height: 200vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: -1;
    clip-path: polygon(
        0% 0%,
        0% 100%,
        calc(50% - 140px) 100%,
        calc(50% - 140px) calc(50% - 140px),
        calc(50% + 140px) calc(50% - 140px),
        calc(50% + 140px) calc(50% + 140px),
        calc(50% - 140px) calc(50% + 140px),
        calc(50% - 140px) 100%,
        100% 100%,
        100% 0%
    );
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Alternative : masque avec box-shadow */
.scanner-viewfinder::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    box-shadow: 
        inset 0 0 0 9999px rgba(0, 0, 0, 0.75),
        0 0 0 9999px rgba(0, 0, 0, 0.75);
    pointer-events: none;
    z-index: 2;
}

/* ============================================================================
   LIGNE LASER ANIMÉE
   ============================================================================ */

.scanner-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, 
        transparent 0%,
        #E67E22 20%,
        #FF8C42 50%,
        #E67E22 80%,
        transparent 100%
    );
    box-shadow: 
        0 0 10px #E67E22,
        0 0 20px #E67E22,
        0 0 30px rgba(230, 126, 34, 0.5);
    animation: scan-laser 2s ease-in-out infinite;
    z-index: 11;
}

@keyframes scan-laser {
    0% {
        top: 0;
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        top: calc(100% - 2px);
        opacity: 1;
    }
}

/* ============================================================================
   INFORMATIONS ET INSTRUCTIONS
   ============================================================================ */

.scanner-info {
    position: relative;
    z-index: 12;
    margin-top: 20px;
    text-align: center;
    color: white;
}

.scanner-instruction {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.scanner-error {
    font-size: 14px;
    font-weight: 600;
    color: #ff6b6b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0 0 8px 0;
}

/* ============================================================================
   BOUTONS DE CONTRÔLE
   ============================================================================ */

.scanner-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 12;
}

.scanner-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scanner-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.scanner-btn:active {
    transform: scale(0.95);
}

.scanner-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* Bouton lampe torche actif */
.scanner-btn-flash.active {
    background: rgba(230, 126, 34, 0.8);
    color: white;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(230, 126, 34, 0.6);
}

/* Bouton fermer */
.scanner-btn-close {
    background: rgba(255, 107, 107, 0.2);
}

.scanner-btn-close:hover {
    background: rgba(255, 107, 107, 0.4);
}

/* ============================================================================
   RESPONSIVE - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .scanner-viewfinder {
        width: 250px;
        height: 250px;
    }

    .scanner-instruction {
        font-size: 14px;
        padding: 10px 20px;
    }

    .scanner-controls {
        bottom: 30px;
        gap: 16px;
    }

    .scanner-btn {
        width: 48px;
        height: 48px;
    }

    .scanner-btn svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .scanner-viewfinder {
        width: 220px;
        height: 220px;
    }

    .scanner-info {
        margin-top: 16px;
    }

    .scanner-instruction {
        font-size: 13px;
        padding: 8px 16px;
    }
}

/* ============================================================================
   ANIMATIONS D'ENTRÉE/SORTIE
   ============================================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#umoa-scanner-overlay.active {
    animation: fadeIn 0.3s ease;
}

#umoa-scanner-overlay:not(.active) {
    animation: fadeOut 0.3s ease;
}

/* ============================================================================
   ACCESSIBILITÉ
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .scanner-laser,
    #umoa-scanner-overlay {
        animation: none;
        transition: none;
    }
}

/* ============================================================================
   AMÉLIORATIONS VISUELLES
   ============================================================================ */

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(230, 126, 34, 0);
    }
}

