/* Intuitive Nutrition Label Scanner with Animated Scanning Process */

.scanner-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: scannerFadeIn 0.3s ease-out;
}

@keyframes scannerFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scanner-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.scanner-header h4 {
    margin: 0;
    font-weight: 600;
}

.scanner-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.scanner-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.scanner-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
}

/* Camera Container */
.camera-container {
    position: relative;
    flex: 1;
    border-radius: 15px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

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

/* Scanning Overlay */
.scanning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
}

.scan-frame {
    position: relative;
    width: 80%;
    max-width: 400px;
    aspect-ratio: 3/4;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.scan-corners {
    position: absolute;
    width: 100%;
    height: 100%;
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #00ff88;
    opacity: 0;
    transition: all 0.5s ease;
}

.corner.active {
    opacity: 1;
    box-shadow: 0 0 15px #00ff88;
}

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

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

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

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

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #00ff88 50%, transparent 100%);
    opacity: 0;
    animation: none;
}

.scan-line.scanning {
    opacity: 1;
    animation: scanLineMove 2s ease-in-out infinite;
}

@keyframes scanLineMove {
    0% {
        transform: translateY(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh * 0.6));
        opacity: 0;
    }
}

.scan-instructions {
    position: absolute;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem 1.5rem;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.scan-instructions p {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    font-size: 1.1rem;
}

.scan-instructions small {
    opacity: 0.8;
}

/* Processing Overlay */
.processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.processing-animation {
    text-align: center;
    color: white;
    max-width: 300px;
    padding: 2rem;
}

.scanning-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #00ff88;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.processing-animation h5 {
    color: #00ff88;
    margin-bottom: 1rem;
    font-weight: 600;
}

.processing-step {
    margin-bottom: 1.5rem;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.progress {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, #00ff88, #00d4aa);
    transition: width 0.8s ease;
}

/* Success Animation */
.success-animation {
    text-align: center;
    color: white;
}

.success-checkmark {
    font-size: 4rem;
    color: #00ff88;
    margin-bottom: 1rem;
    animation: checkmarkBounce 0.6s ease-out;
}

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

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

#captureBtn {
    background: linear-gradient(135deg, #00ff88, #00d4aa);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
    transition: all 0.3s ease;
}

#captureBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 136, 0.4);
}

#captureBtn:active {
    transform: translateY(0);
}

#switchCameraBtn {
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#switchCameraBtn:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Upload Alternative */
.upload-alternative {
    text-align: center;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.upload-alternative p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
}

#uploadBtn {
    border: 2px solid #667eea;
    color: #667eea;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    background: rgba(102, 126, 234, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#uploadBtn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .scanner-content {
        padding: 0.5rem;
    }
    
    .scan-frame {
        width: 90%;
    }
    
    .scan-instructions {
        bottom: -60px;
        padding: 0.75rem 1rem;
    }
    
    .scanner-controls {
        flex-direction: column;
        align-items: center;
    }
    
    #captureBtn {
        width: 100%;
        max-width: 300px;
    }
}

/* Button to open scanner */
.open-scanner-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.open-scanner-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white;
}

.open-scanner-btn:active {
    transform: translateY(0);
}

/* Loading states */
.scanner-loading {
    pointer-events: none;
    opacity: 0.7;
}

.scanner-loading .btn {
    cursor: not-allowed;
}