/**
 * 🎯 DOCUMENT-SCANNER.CSS - Styles du scanner de documents
 * 
 * 📝 Description : Interface mobile de scan avec caméra, preview, contrôles
 * 🔗 Utilisé par : contract-analysis.html
 */

/* Conteneur principal du scanner - MASQUER BARRE SAFARI ET FOOTER */
#documentScannerUI {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    z-index: 10000;
    background: #000;
    animation: fadeIn 0.3s ease;
    overflow: hidden;
}

/* Masquer le footer pendant le scan */
body:has(#documentScannerUI) .footer-simple {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Overlay du scanner */
.scanner-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #000;
}

/* Header du scanner - OVERLAY TRANSPARENT COMPACT */
.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 50px;
}

.scanner-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.scanner-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.scanner-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    text-align: center;
}

.scanner-counter {
    background: #6366f1;
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
}

/* Conteneur de la caméra - PLEIN ÉCRAN */
.scanner-camera-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
    background: #000;
    z-index: 1;
}

#scannerVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Guide de cadrage - CENTRÉ SUR TOUTE LA HAUTEUR */
.scanner-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 400px;
    pointer-events: none;
    z-index: 10;
}

.scanner-guide-frame {
    width: 100%;
    padding-bottom: 141.4%; /* Ratio A4 */
    border: 3px solid rgba(99, 102, 241, 0.8);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Coins du cadre */
.scanner-guide-frame::before,
.scanner-guide-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid #6366f1;
}

.scanner-guide-frame::before {
    top: -4px;
    left: -4px;
    border-right: none;
    border-bottom: none;
    border-radius: 12px 0 0 0;
}

.scanner-guide-frame::after {
    top: -4px;
    right: -4px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 12px 0 0;
}

.scanner-guide-text {
    display: none; /* Masqué - le cadre suffit */
}

/* Contrôles du scanner - BOUTONS FLOTTANTS SANS BARRE */
.scanner-controls {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: transparent;
    justify-content: center;
    align-items: center;
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 100;
}

.scanner-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 90px;
}

.scanner-btn i {
    font-size: 14px;
}

.scanner-btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    flex: 0 0 auto;
}

.scanner-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.scanner-btn-capture {
    background: #6366f1;
    color: white;
    flex: 0 0 auto;
}

.scanner-btn-capture:hover {
    background: #5b21b6;
    transform: scale(1.05);
}

.scanner-btn-capture:active {
    transform: scale(0.95);
}

.scanner-btn-primary {
    background: #10b981;
    color: white;
    flex: 0 0 auto;
}

.scanner-btn-primary:hover {
    background: #059669;
    transform: scale(1.05);
}

/* Preview des images capturées - MASQUÉE PAR DÉFAUT */
.scanner-preview-container {
    display: none !important;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 200px;
    overflow-y: auto;
    position: fixed;
    bottom: 90px;
    left: 0;
    right: 0;
    z-index: 99;
}

.scanner-preview-title {
    color: white;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.scanner-preview-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.scanner-preview-item {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.scanner-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-preview-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.scanner-preview-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.scanner-preview-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(99, 102, 241, 0.9);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

/* Effet de flash lors de la capture */
@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Scrollbar personnalisée pour le preview */
.scanner-preview-grid::-webkit-scrollbar {
    height: 6px;
}

.scanner-preview-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.scanner-preview-grid::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.8);
    border-radius: 3px;
}

.scanner-preview-grid::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}

/* Responsive - Petits écrans */
@media (max-width: 380px) {
    .scanner-btn {
        padding: 10px 12px;
        font-size: 13px;
        gap: 4px;
        min-width: 80px;
    }
    
    .scanner-controls {
        gap: 6px;
        padding: 10px;
    }
}

/* Responsive - Landscape mobile */
@media (orientation: landscape) and (max-height: 500px) {
    .scanner-header {
        padding: 12px 16px;
    }
    
    .scanner-title {
        font-size: 16px;
    }
    
    .scanner-controls {
        padding: 12px 16px;
    }
    
    .scanner-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .scanner-preview-container {
        max-height: 120px;
    }
    
    .scanner-guide-frame {
        padding-bottom: 70%; /* Ratio plus court en landscape */
    }
}

/* Desktop - Message d'avertissement */
@media (min-width: 769px) {
    .scanner-guide-text {
        font-size: 16px;
        padding: 12px 24px;
    }
}

