/**
 * Barcode Scanner Styles
 * Modern, mobile-optimized scanner UI
 */

/* Modal fullscreen on mobile */
.modal-fullscreen-scanner {
    max-width: 100%;
    margin: 0;
    height: 100vh;
}

@media (min-width: 768px) {
    .modal-fullscreen-scanner {
        max-width: 600px;
        margin: 1.75rem auto;
        height: auto;
    }
}

.scanner-modal-content {
    height: 100%;
    border-radius: 0;
    border: none;
}

@media (min-width: 768px) {
    .scanner-modal-content {
        border-radius: 0.5rem;
        height: 80vh;
        max-height: 800px;
    }
}

/* Scanner body */
.scanner-body {
    background: #000;
    position: relative;
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scanner container */
.scanner-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video element */
.scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* Canvas for QR code detection */
.scanner-canvas {
    display: none;
}

/* Scanner overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 10;
}

/* Scanner frame */
.scanner-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px;
    height: 250px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    transition: all 0.3s ease;
}

@media (max-width: 576px) {
    .scanner-frame {
        width: 85%;
        height: 200px;
    }
}

/* Scanner frame corners */
.scanner-frame .corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #4e73df;
    border-style: solid;
}

.scanner-frame .corner.top-left {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
    border-radius: 12px 0 0 0;
}

.scanner-frame .corner.top-right {
    top: -2px;
    right: -2px;
    border-width: 4px 4px 0 0;
    border-radius: 0 12px 0 0;
}

.scanner-frame .corner.bottom-left {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 4px 4px;
    border-radius: 0 0 0 12px;
}

.scanner-frame .corner.bottom-right {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
    border-radius: 0 0 12px 0;
}

/* Scanning animation line */
.scanning-line {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        #4e73df 20%, 
        #1cc88a 50%, 
        #4e73df 80%, 
        transparent 100%);
    box-shadow: 0 0 10px rgba(28, 200, 138, 0.8);
    animation: scan 2s linear infinite;
    border-radius: 2px;
}

@keyframes scan {
    0% {
        top: 0;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Success animation */
.scanner-frame.scan-success {
    border-color: #1cc88a;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5),
                inset 0 0 30px rgba(28, 200, 138, 0.3);
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.scanner-frame.scan-success .corner {
    border-color: #1cc88a;
}

.scanner-frame.scan-success .scanning-line {
    display: none;
}

/* Instructions */
.scanner-instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    text-align: center;
    z-index: 15;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 90%;
}

.scanner-instructions p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
}

.scanner-instructions i {
    color: #4e73df;
    margin-right: 5px;
}

@media (max-width: 576px) {
    .scanner-instructions {
        bottom: 10px;
        padding: 8px 15px;
    }
    
    .scanner-instructions p {
        font-size: 11px;
    }
}

/* Status indicator */
.scanner-status {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 15;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    text-align: center;
}

.scanner-status .status-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
}

.scanner-status .status-content i {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.scanner-status .status-content.success-animation {
    animation: successBounce 0.6s ease;
}

@keyframes successBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Quagga canvas overlay */
.scanner-container canvas.drawingBuffer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

/* Camera button with icon */
.camera-scan-btn {
    position: relative;
    min-width: 40px;
    padding: 0.375rem 0.5rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
}

.camera-scan-btn .camera-icon {
    font-size: 16px;
    animation: cameraShake 2s ease-in-out infinite;
}

@keyframes cameraShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        transform: rotate(5deg);
    }
}

/* Mobile optimizations */
@media (max-width: 576px) {
    .scanner-status {
        top: 10px;
        padding: 8px 15px;
        min-width: 150px;
        font-size: 12px;
    }
    
    .scanner-status .status-content {
        font-size: 11px;
        gap: 6px;
    }
}

/* Loading spinner for camera initialization */
.scanner-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    color: white;
}

.scanner-loading i {
    font-size: 48px;
    margin-bottom: 15px;
    animation: spin 1s linear infinite;
}

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

/* Flashlight toggle (for devices that support it) */
#toggleFlashlightBtn.active {
    background: #ffc107;
    border-color: #ffc107;
    color: #000;
}

/* Better visibility on bright backgrounds */
.scanner-modal-content .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.scanner-modal-content .modal-footer {
    border-top: 1px solid #dee2e6;
}
