/**
 * Barcode Scanner Styles
 * Mobile-optimized camera scanner interface
 */

/* Scanner Button */
.barcode-scan-btn {
    display: none; /* Hidden by default, shown via JS if camera available */
    background-color: var(--primary-color, #3498db);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-left: 10px;
}

.barcode-scan-btn:hover {
    background-color: #2980b9;
}

.barcode-scan-btn:active {
    transform: scale(0.98);
}

.barcode-scan-btn .scan-icon {
    display: inline-block;
    margin-right: 5px;
}

/* Scanner Modal */
.barcode-scanner-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* Scanner Container */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Scanner Header */
.scanner-header {
    width: 100%;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    z-index: 10;
}

.scanner-title {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

.close-scanner-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    transition: opacity 0.3s ease;
}

.close-scanner-btn:hover {
    opacity: 0.7;
}

/* Scanner Viewport */
.scanner-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

.scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-viewport canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Scanner Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Scanning Frame */
.scanning-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 180px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
}

.scanning-frame::before,
.scanning-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #00ff00;
}

.scanning-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scanning-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

/* Scanning Line Animation */
.scanning-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #00ff00, transparent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: calc(100% - 2px); }
    100% { top: 0; }
}

/* Scanner Status */
.scanner-status {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    text-align: center;
    z-index: 10;
}

.scanner-status.success {
    background-color: rgba(39, 174, 96, 0.9);
}

.scanner-status.error {
    background-color: rgba(231, 76, 60, 0.9);
}

/* Scanner Controls */
.scanner-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 10;
}

.switch-camera-btn {
    display: none; /* Shown via JS if multiple cameras */
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.switch-camera-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Success Flash Animation */
.scanner-viewport.success-flash {
    animation: successFlash 0.5s ease;
}

@keyframes successFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; background-color: rgba(39, 174, 96, 0.5); }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .scanner-container {
        max-height: 100vh;
    }

    .scanning-frame {
        width: 260px;
        height: 160px;
    }

    .scanner-header {
        padding: 15px;
    }

    .scanner-title {
        font-size: 16px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 600px) {
    .scanner-header {
        padding: 10px 20px;
    }

    .scanning-frame {
        width: 320px;
        height: 140px;
    }

    .scanner-status {
        bottom: 60px;
    }

    .scanner-controls {
        bottom: 10px;
    }
}

/* Permission Request Styles */
.camera-permission-request {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
}

.camera-permission-request h3 {
    margin-bottom: 15px;
    color: #333;
}

.camera-permission-request p {
    color: #666;
    margin-bottom: 20px;
}

.camera-permission-request .permission-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
}

/* Loading Spinner */
.scanner-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .scanning-line {
        animation: none;
    }

    .scanner-loading {
        animation: none;
    }

    .scanner-viewport.success-flash {
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .camera-permission-request {
        background-color: rgba(40, 40, 40, 0.95);
    }

    .camera-permission-request h3 {
        color: #fff;
    }

    .camera-permission-request p {
        color: #ccc;
    }
}
