.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: start;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    height: 100vh;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: white;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    padding: 0 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    position: relative;
    overflow-y: scroll;
    height: 80vh;

}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: end;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    width: 25px;
    height: 35px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0px 10px 0;
    cursor: pointer;
    font-size: 1.5rem;
    color: red;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: white;
    background-color: red;
}

.modal-body {
    margin-bottom: 1rem;
}

.scanner-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

#scanner-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 75%;
    /* 4:3 aspect ratio */
    overflow: hidden;
    background-color: #000;
    border-radius: 8px;
    margin-bottom: 1rem;
}

#interactive.viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#interactive.viewport canvas,
video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drawingBuffer {
    position: absolute;
    top: 0;
    left: 0;
}

.scan-barcode {
    margin: 0;
    background-color: white;
    border: 2px solid #ccc;
    color: #000;
    height: 42px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.scan-barcode:disabled {
    background-color: whitesmoke;
    color: #666;
    border: none;
}

/* .scan-barcode img {
    filter: invert();
} */

.scan-barcode span {
    color: white;

}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-region {
    width: 80%;
    height: 50%;
    border: 2px solid #0071e3;
    border-radius: 8px;
    position: relative;
}

.scan-region::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #0071e3;
    animation: scan 2s linear infinite;
}

#confirmResultBtn {
    background-color: #00490a;
    display: none;
}

@keyframes scan {
    0% {
        top: 0;
    }

    50% {
        top: 100%;
    }

    100% {
        top: 0;
    }
}

/* Result styles */
.result-container {
    background-color: #f5f5f7;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.result-container.success {
    background-color: #e8f5e9;
    border: 1px solid #4caf50;
}

.result-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-code {
    font-family: monospace;
    font-size: 1.2rem;
    word-break: break-all;
}

.scanner-instructions {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}

.scan-pack-btn {
    background-color: white;
    border: 2px solid #ccc;
    padding: 0.5rem 1rem;
    width: 180px;
    color: #000;
}

.scan-pack-btn:hover {
    background-color: #f0f0f0;
}

/* Responsive adjustments */
@media (max-width: 668px) {
    .modal {
        width: 95%;
        padding: 1rem;
    }

    #scanner-container {
        padding-bottom: 100%;
        /* 1:1 aspect ratio for mobile */
    }
}

@media (max-width: 480px) {
    .modal {
        width: 100%;
        border-radius: 8px;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .scan-region {
        width: 90%;
        height: 40%;
    }
}