/* =============================================================
   HaccpGo - Scanner Theme (barcode / lotto)
   Tema visivo condiviso per tutte le sezioni che mostrano
   uno scanner barcode/lotto. Allineato al wizard di
   Prodotti\Create. Importato globalmente dal layout dell'area
   riservata. NON include logica JS: solo stili.
   ============================================================= */

/* ---- Scan area entry card ---- */
.scan-area {
    background: linear-gradient(135deg, #f0f4ff, #f8f0ff);
    border: 2px dashed #c5cae9;
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.scan-area:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #e8edff, #f0e8ff);
}

.scan-area .scan-icon {
    font-size: 40px;
    color: #667eea;
    margin-bottom: 10px;
}

.scan-area h5 {
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.scan-area p {
    color: #888;
    font-size: 13px;
    margin-bottom: 15px;
}

.manual-barcode-toggle {
    display: inline-block;
    font-size: 13px;
    color: #667eea;
    cursor: pointer;
    border-bottom: 1px dashed #667eea;
    transition: all 0.2s;
    margin-top: 10px;
}

.manual-barcode-toggle:hover {
    color: #764ba2;
    border-color: #764ba2;
}

.manual-barcode-input {
    display: none;
    margin-top: 15px;
    animation: scannerFadeIn 0.3s ease;
}

.manual-barcode-input.show {
    display: block;
}

@keyframes scannerFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Highlight campi auto-popolati ---- */
.field-filled {
    background-color: #e8f5e8 !important;
    border-color: #4caf50 !important;
    transition: all 0.3s ease;
}

/* ---- Camera / scanner ---- */
.camera-container {
    position: relative;
    max-width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.camera-preview {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.capture-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 60px;
    border: 2px dashed #fff;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    text-align: center;
}

.ai-progress {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin-top: 10px;
}

.detected-text {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
}

.ai-analysis {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 14px;
}

.btn-camera {
    background: linear-gradient(45deg, #007bff, #0056b3);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

.btn-camera:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    color: white;
}

.btn-ai {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    color: white;
}

.quality-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
}

.quality-good   { background: rgba(76, 175, 80, 0.8) !important; }
.quality-medium { background: rgba(255, 193, 7, 0.8) !important; }
.quality-poor   { background: rgba(244, 67, 54, 0.8) !important; }

.ai-confidence  { text-align: center; margin-top: 10px; font-size: 14px; }
.confidence-high   { color: #4caf50; font-weight: bold; }
.confidence-medium { color: #ff9800; font-weight: bold; }
.confidence-low    { color: #f44336; font-weight: bold; }

/* ---- QR code (sessione mobile) ---- */
.qr-section {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
}

.qr-container {
    display: inline-block;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

.qr-section .qr-target,
.qr-section #qrcode {
    margin: 0 auto;
}

.qr-instructions {
    margin-top: 20px;
    font-size: 14px;
    color: #6c757d;
}

.qr-instructions ol {
    text-align: left;
    max-width: 400px;
    margin: 10px auto;
}

.mobile-url {
    background: #e9ecef;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    word-break: break-all;
    margin: 10px 0;
}

.device-indicator {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}

.device-desktop { background: #e7f3ff; color: #004085; }
.device-mobile  { background: #d4edda; color: #155724; }

.waiting-indicator { display: none; margin-top: 20px; }
.waiting-indicator .spinner-border { width: 2rem; height: 2rem; color: #667eea; }

/* ---- Selettore sorgente (webcam vs telefono) ---- */
.capture-mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.capture-mode-selector button,
.capture-mode-selector .barcode-mode-btn,
.capture-mode-selector .mode-btn {
    flex: 1;
    max-width: 200px;
    padding: 15px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.capture-mode-selector button.active,
.capture-mode-selector .barcode-mode-btn.active,
.capture-mode-selector .mode-btn.active {
    border-color: #667eea;
    background: #f0f4ff;
    color: #667eea;
    transform: scale(1.05);
}

.capture-mode-selector button:hover,
.capture-mode-selector .barcode-mode-btn:hover,
.capture-mode-selector .mode-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.capture-mode-selector i,
.capture-mode-selector .barcode-mode-btn i,
.capture-mode-selector .mode-btn i {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}

/* Variante "barcode" (accento blu) mantenuta come override dove richiesto */
.barcode-mode-btn.active {
    border-color: #007bff;
    background: #e7f3ff;
    color: #007bff;
}
.barcode-mode-btn:hover {
    border-color: #007bff;
    background: #f0f8ff;
}

/* ---- Header step (riusato in alcune pagine) ---- */
.scanner-step-header {
    text-align: center;
    margin-bottom: 18px;
}
.scanner-step-header .step-icon {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    color: #7b1fa2;
    margin-bottom: 8px;
}
.scanner-step-header h4 {
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}
.scanner-step-header p {
    color: #888;
    font-size: 14px;
    margin-bottom: 0;
}

/* ---- Responsive ---- */
@media (max-width: 576px) {
    .scan-area { padding: 18px; }
    .scan-area .scan-icon { font-size: 32px; }
    .scan-area h5 { font-size: 1rem; }
    .capture-mode-selector { gap: 8px; }
    .capture-mode-selector button,
    .capture-mode-selector .barcode-mode-btn,
    .capture-mode-selector .mode-btn { padding: 12px; max-width: none; }
}
