/**
 * Imagilire Libre - Styles pour le module OCR Optimisé
 * Interface utilisateur pour la reconnaissance de texte améliorée
 * 
 * @version 2.0.0
 * @compatibilité iOS 12+, Android 8+, Desktop, Tablet
 */

/* ============================================================================
   VARIABLES CSS POUR OCR ENHANCED
   ============================================================================ */

:root {
    --ocr-primary-color: #36B1B3;
    --ocr-success-color: #28a745;
    --ocr-error-color: #dc3545;
    --ocr-warning-color: #ffc107;
    --ocr-info-color: #17a2b8;
    --ocr-overlay-bg: rgba(0, 0, 0, 0.85);
    --ocr-progress-height: 6px;
    --ocr-animation-duration: 0.3s;
}

/* ============================================================================
   CONTENEUR PRINCIPAL DE PROGRESSION OCR
   ============================================================================ */

.ocr-enhanced-container {
    position: relative;
    width: 100%;
    margin: 1rem 0;
}

/* ============================================================================
   BARRE DE PROGRESSION AMÉLIORÉE
   ============================================================================ */

.ocr-progress-enhanced {
    position: relative;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #e9ecef 0%, #dee2e6 100%);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.75rem;
}

.ocr-progress-bar-enhanced {
    height: 100%;
    background: linear-gradient(90deg, 
        var(--ocr-primary-color) 0%, 
        #28a745 50%, 
        #17a2b8 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: progressShine 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(54, 177, 179, 0.5);
}

@keyframes progressShine {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================================================
   STATUT OCR AVEC INDICATEURS
   ============================================================================ */

.ocr-status-enhanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: all var(--ocr-animation-duration) ease;
}

.ocr-status-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.ocr-status-icon {
    font-size: 1.1rem;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.ocr-status-percentage {
    font-weight: 600;
    color: var(--ocr-primary-color);
    font-size: 1rem;
    min-width: 45px;
    text-align: right;
}

/* États de la barre de statut */
.ocr-status-enhanced.processing {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid var(--ocr-info-color);
}

.ocr-status-enhanced.success {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-left: 4px solid var(--ocr-success-color);
}

.ocr-status-enhanced.error {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border-left: 4px solid var(--ocr-error-color);
}

/* ============================================================================
   OVERLAY DE PRÉTRAITEMENT
   ============================================================================ */

.ocr-preprocessing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ocr-overlay-bg);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.ocr-preprocessing-overlay.active {
    display: flex;
}

.ocr-preprocessing-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ocr-preprocessing-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 1rem;
    text-align: center;
}

.ocr-preprocessing-steps {
    margin: 1.5rem 0;
}

.ocr-preprocessing-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: #6c757d;
    transition: all 0.3s ease;
}

.ocr-preprocessing-step.active {
    color: var(--ocr-primary-color);
    font-weight: 500;
}

.ocr-preprocessing-step.completed {
    color: var(--ocr-success-color);
}

.ocr-preprocessing-step-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.ocr-preprocessing-step.active .ocr-preprocessing-step-icon {
    animation: stepRotate 2s linear infinite;
}

@keyframes stepRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   INDICATEUR DE QUALITÉ D'IMAGE
   ============================================================================ */

.ocr-quality-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.ocr-quality-indicator.high {
    background: #d4edda;
    color: #155724;
}

.ocr-quality-indicator.medium {
    background: #fff3cd;
    color: #856404;
}

.ocr-quality-indicator.low {
    background: #f8d7da;
    color: #721c24;
}

.ocr-quality-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: qualityPulse 2s ease-in-out infinite;
}

.ocr-quality-indicator.high .ocr-quality-badge {
    background: #28a745;
}

.ocr-quality-indicator.medium .ocr-quality-badge {
    background: #ffc107;
}

.ocr-quality-indicator.low .ocr-quality-badge {
    background: #dc3545;
}

@keyframes qualityPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

/* ============================================================================
   BOUTON OCR AMÉLIORÉ
   ============================================================================ */

.ocr-enhanced-button {
    background: linear-gradient(135deg, var(--ocr-primary-color) 0%, #28a745 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(54, 177, 179, 0.3);
    position: relative;
    overflow: hidden;
}

.ocr-enhanced-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(54, 177, 179, 0.4);
}

.ocr-enhanced-button:active {
    transform: translateY(0);
}

.ocr-enhanced-button:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
}

.ocr-enhanced-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ocr-enhanced-button:active::before {
    width: 300px;
    height: 300px;
}

/* ============================================================================
   NOTIFICATION DE CONFIANCE OCR
   ============================================================================ */

.ocr-confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.ocr-confidence-badge.excellent {
    background: #d4edda;
    color: #155724;
}

.ocr-confidence-badge.good {
    background: #d1ecf1;
    color: #0c5460;
}

.ocr-confidence-badge.fair {
    background: #fff3cd;
    color: #856404;
}

.ocr-confidence-badge.poor {
    background: #f8d7da;
    color: #721c24;
}

/* ============================================================================
   RESPONSIVE MOBILE
   ============================================================================ */

@media (max-width: 767px) {
    .ocr-enhanced-container {
        margin: 0.75rem 0;
    }
    
    .ocr-status-enhanced {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .ocr-status-percentage {
        align-self: flex-end;
        font-size: 0.9rem;
    }
    
    .ocr-preprocessing-content {
        padding: 1.5rem;
        max-width: 90%;
    }
    
    .ocr-preprocessing-title {
        font-size: 1.1rem;
    }
    
    .ocr-enhanced-button {
        width: 100%;
        padding: 0.85rem 1rem;
    }
}

/* Optimisations tactiles */
@media (hover: none) and (pointer: coarse) {
    .ocr-enhanced-button {
        padding: 0.9rem 1.5rem;
        font-size: 1.05rem;
    }
    
    .ocr-status-enhanced {
        padding: 0.8rem 1rem;
    }
}

/* ============================================================================
   SUPPORT iOS
   ============================================================================ */

@supports (-webkit-touch-callout: none) {
    .ocr-preprocessing-overlay {
        /* Support notch iOS */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    .ocr-enhanced-button {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ============================================================================
   ANIMATIONS HARDWARE-ACCELERATED
   ============================================================================ */

.ocr-progress-bar-enhanced,
.ocr-status-icon,
.ocr-preprocessing-step-icon,
.ocr-quality-badge {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* ============================================================================
   ACCESSIBILITÉ
   ============================================================================ */

.ocr-enhanced-button:focus-visible,
.ocr-status-enhanced:focus-visible {
    outline: 3px solid rgba(54, 177, 179, 0.5);
    outline-offset: 2px;
}

/* Réduire les animations si préférence utilisateur */
@media (prefers-reduced-motion: reduce) {
    .ocr-progress-bar-enhanced,
    .ocr-status-icon,
    .ocr-preprocessing-step-icon,
    .ocr-quality-badge,
    .ocr-preprocessing-content {
        animation: none;
        transition: none;
    }
}

/* ============================================================================
   MODE SOMBRE
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --ocr-overlay-bg: rgba(0, 0, 0, 0.92);
    }
    
    .ocr-status-enhanced {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
    }
    
    .ocr-preprocessing-content {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .ocr-preprocessing-title {
        color: #f7fafc;
    }
    
    .ocr-progress-enhanced {
        background: linear-gradient(90deg, #2d3748 0%, #1a202c 100%);
    }
}

/* ============================================================================
   TABLET OPTIMISATIONS
   ============================================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .ocr-enhanced-container {
        max-width: 600px;
        margin: 1.5rem auto;
    }
    
    .ocr-preprocessing-content {
        max-width: 500px;
    }
}

/* ============================================================================
   DESKTOP OPTIMISATIONS
   ============================================================================ */

@media (min-width: 1025px) {
    .ocr-enhanced-container {
        max-width: 700px;
        margin: 2rem auto;
    }
    
    .ocr-preprocessing-content {
        max-width: 550px;
        padding: 2.5rem;
    }
    
    .ocr-enhanced-button:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(54, 177, 179, 0.4);
    }
}
