/* ==============================================
   FORTE BD - ESCÁNER DE CÓDIGOS DE BARRAS EAN v5.0
   ESPECIALIZADO para códigos EAN estándar como 003841492639001177202
   ============================================== */

/* Variables CSS para códigos EAN */
:root {
    --ean-primary: #007bff;
    --ean-success: #28a745;
    --ean-warning: #ffc107;
    --ean-info: #17a2b8;
    --ean-zone-color: #007bff;
    --ean-active: #28a745;
    --ean-red: #FF6969;
}

/* ===== BOTÓN PRINCIPAL DEL ESCÁNER ===== */
.scanner-card {
    transition: all 0.3s ease;
    background: linear-gradient(135deg, var(--ean-red), #FF8A8A) !important;
    border: none !important;
    border-radius: 15px !important;
    box-shadow: 0 8px 25px rgba(255, 105, 105, 0.3);
}

.scanner-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 105, 105, 0.4);
}

.scanner-btn {
    transition: all 0.3s ease;
    background-color: var(--lg-surface-solid, white) !important;
    color: var(--ean-red) !important;
    border: none !important;
    border-radius: 25px !important;
    font-weight: bold !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    padding: 0.7rem 1.5rem !important;
}

.scanner-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background-color: #f8f9fa !important;
}

/* ===== MODAL DEL ESCÁNER EAN ===== */
.scanner-modal .modal-dialog {
    max-width: 90%;
    margin: 1rem auto;
}

.scanner-modal .modal-content {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    box-shadow: 0 15px 40px rgba(0, 123, 255, 0.3);
    border-radius: 20px;
}

.scanner-modal .modal-header {
    background: linear-gradient(135deg, var(--ean-primary), #0056b3);
    color: white;
    border-bottom: none;
    padding: 1.5rem;
    border-radius: 20px 20px 0 0;
}

.scanner-modal .modal-body {
    padding: 2rem;
}

/* ===== CONTENEDOR DEL VIDEO OPTIMIZADO PARA EAN ===== */
#scanner-container {
    position: relative;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    margin: 0 auto;
    max-width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border: 3px solid var(--ean-primary);
}

#scanner-video {
    width: 100%;
    height: auto;
    max-height: 70vh;
    min-height: 300px;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    /* FILTROS OPTIMIZADOS para códigos EAN */
    filter: contrast(1.3) brightness(1.2) saturate(0.9) hue-rotate(0deg);
}

/* ===== OVERLAY ESPECIALIZADO PARA CÓDIGOS EAN ===== */
#scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* ZONA DE CAPTURA EAN - Más amplia y horizontal para códigos de barras largos */
.capture-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 450px;
    height: 140px;
    border: 4px solid var(--ean-zone-color);
    border-radius: 20px;
    background: rgba(0, 123, 255, 0.15);
    animation: eanZonePulse 2.5s ease-in-out infinite;
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 0.4),
        0 0 25px rgba(0, 123, 255, 0.5),
        inset 0 0 25px rgba(0, 123, 255, 0.1);
}

/* Texto de la zona de captura */
.capture-zone::before {
    content: '📊 CENTRAR CÓDIGO EAN AQUÍ 📊';
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--ean-primary), #0056b3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

/* ANIMACIÓN ESPECIALIZADA para zona EAN */
@keyframes eanZonePulse {
    0%, 100% { 
        border-color: var(--ean-zone-color);
        background: rgba(0, 123, 255, 0.15);
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4), 0 0 25px rgba(0, 123, 255, 0.5);
    }
    50% { 
        border-color: var(--ean-active);
        background: rgba(40, 167, 69, 0.2);
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7), 0 0 35px rgba(40, 167, 69, 0.7);
    }
}

/* LÍNEA DE ESCANEO EAN horizontal */
.scanner-line {
    position: absolute;
    top: 50%;
    left: 7%;
    right: 7%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--ean-primary) 10%, 
        var(--ean-active) 50%, 
        var(--ean-primary) 90%, 
        transparent 100%);
    animation: eanScanLine 2.5s ease-in-out infinite;
    transform: translateY(-50%);
    box-shadow: 0 0 15px var(--ean-primary);
    border-radius: 2px;
}

@keyframes eanScanLine {
    0%, 100% { 
        opacity: 0.4; 
        transform: translateY(-50%) scaleX(0.7); 
    }
    50% { 
        opacity: 1; 
        transform: translateY(-50%) scaleX(1.3); 
    }
}

/* ESQUINAS DE ENFOQUE EAN */
.scanner-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid var(--ean-active);
    border-radius: 5px;
}

.scanner-corner.tl {
    top: -4px;
    left: -4px;
    border-right: none;
    border-bottom: none;
    border-radius: 15px 0 0 0;
}

.scanner-corner.tr {
    top: -4px;
    right: -4px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 15px 0 0;
}

.scanner-corner.bl {
    bottom: -4px;
    left: -4px;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 15px;
}

.scanner-corner.br {
    bottom: -4px;
    right: -4px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 15px 0;
}

/* MEDIDOR DE CONFIANZA EAN */
.confidence-meter {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 25px;
    font-size: 12px;
    font-weight: bold;
    min-width: 140px;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    backdrop-filter: blur(10px);
}

.confidence-bar {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc3545, #ffc107, #28a745);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 3px;
}

/* BOTÓN DE CAPTURA MANUAL EAN */
.capture-button {
    position: absolute;
    bottom: 25px;
    right: 25px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ean-primary), #0056b3);
    color: white;
    border: 4px solid white;
    font-size: 28px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.5);
    z-index: 20;
}

.capture-button:hover {
    background: linear-gradient(135deg, var(--ean-active), #1e7e34);
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.6);
}

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

/* INDICADORES DE CÓDIGO DETECTADO EAN */
.code-detected {
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--ean-active), #1e7e34);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.5);
    animation: codeDetectedEAN 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
}

@keyframes codeDetectedEAN {
    0% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(-30px) scale(0.7); 
    }
    100% { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0) scale(1); 
    }
}

/* INFORMACIÓN DE DEBUG EAN */
#scanner-debug {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: rgba(0, 123, 255, 0.95) !important;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

/* ESTADOS ACTIVOS */
.scanner-video-container.scanner-active {
    border: 3px solid var(--ean-primary);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 123, 255, 0.4);
}

.capture-zone.active {
    border-color: var(--ean-active) !important;
    background: rgba(40, 167, 69, 0.25) !important;
    animation: eanZoneActive 1.2s ease-in-out infinite;
}

@keyframes eanZoneActive {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1); 
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7), 0 0 35px rgba(40, 167, 69, 0.7);
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.08); 
        box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.9), 0 0 45px rgba(40, 167, 69, 0.9);
    }
}

/* Responsive para móviles - EAN optimizado */
@media (max-width: 768px) {
    .scanner-modal .modal-dialog {
        max-width: 98%;
        margin: 0.2rem auto;
    }
    
    #scanner-container {
        border-radius: 12px;
        border-width: 2px;
    }
    
    #scanner-video {
        min-height: 250px;
        max-height: 60vh;
    }
    
    .capture-zone {
        width: 90%;
        max-width: none;
        height: 120px;
    }
    
    .capture-zone::before {
        content: '📊 CÓDIGO EAN 📊';
        font-size: 11px;
        padding: 6px 12px;
        top: -30px;
    }
    
    .capture-button {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .confidence-meter {
        font-size: 11px;
        padding: 8px 12px;
        min-width: 120px;
        top: 12px;
        right: 12px;
    }
    
    .confidence-bar {
        width: 100px;
        height: 6px;
    }
}

/* Campos de entrada con estilo EAN */
#scanner-result .form-control {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    transition: all 0.3s ease;
}

#scanner-result .form-control:focus {
    border-color: var(--ean-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#save-association {
    background: linear-gradient(135deg, var(--ean-active), #1e7e34);
    border: none;
    border-radius: 25px;
    padding: 0.8rem 2rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

#save-association:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.5);
}

#restart-scanner {
    background: linear-gradient(135deg, var(--ean-primary), #0056b3) !important;
    border: none !important;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: bold;
}

#restart-scanner:hover {
    background: linear-gradient(135deg, #0056b3, #004085) !important;
    transform: translateY(-2px);
}
