/* ── Smart Form Fields — Barcode Scanner ── */

/* Пълноекранен тъмен overlay */
#sff-barcode-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

/* Рамка на скенера — пълен екран */
#sff-barcode-frame {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* ── Camera feed контейнер ── */
#sff-camera-feed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

/* Video елементът от html5-qrcode */
#sff-camera-feed video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block !important;
}

/* Скриваме всичко вградено от html5-qrcode освен video-то */
#sff-camera-feed img,
#sff-camera-feed button,
#sff-camera-feed div:not(#sff-scan-region) {
    display: none !important;
}

/* ── Зона за сканиране (прозрачен правоъгълник + маска) ── */
#sff-scan-region {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

#sff-scan-window {
    position: relative;
    width: 72%;
    max-width: 480px;
    aspect-ratio: 2 / 1;
    /* Тъмна маска около прозрачния правоъгълник */
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    border-radius: 3px;
}

/* ── Ъглови маркери ── */
.sff-corner {
    position: absolute;
    width: 26px;
    height: 26px;
    border-color: #ffffff;
    border-style: solid;
    border-width: 0;
}
.sff-corner-tl { top:-3px;    left:-3px;   border-top-width:4px;    border-left-width:4px;   border-top-left-radius:4px; }
.sff-corner-tr { top:-3px;    right:-3px;  border-top-width:4px;    border-right-width:4px;  border-top-right-radius:4px; }
.sff-corner-bl { bottom:-3px; left:-3px;   border-bottom-width:4px; border-left-width:4px;   border-bottom-left-radius:4px; }
.sff-corner-br { bottom:-3px; right:-3px;  border-bottom-width:4px; border-right-width:4px;  border-bottom-right-radius:4px; }

/* ── Анимирана сканираща линия ── */
.sff-scan-line {
    position: absolute;
    left: 4px;
    right: 4px;
    height: 2px;
    background: linear-gradient(to right, transparent, #00e5ff 40%, #00e5ff 60%, transparent);
    border-radius: 2px;
    animation: sff-scan-move 2s ease-in-out infinite;
}

@keyframes sff-scan-move {
    0%   { top: 8%;  opacity: 0.6; }
    50%  { top: 86%; opacity: 1;   }
    100% { top: 8%;  opacity: 0.6; }
}

/* ── Бутони (фенер + затвори) ── */
#sff-barcode-controls {
    position: absolute;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 24px;
    align-items: center;
}

#sff-barcode-controls button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

#sff-barcode-controls button:hover,
#sff-barcode-controls button:active {
    background: rgba(255, 255, 255, 0.18);
    border-color: #ffffff;
}

/* Активен фенер — жълт */
#sff-torch-btn.sff-torch-active {
    background: rgba(255, 215, 0, 0.22);
    border-color: #ffd700;
    color: #ffd700;
}

/* ── Икона за сканиране до input полето ── */
.sff-barcode-field-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.sff-barcode-field-container input {
    width: 100%;
    padding-right: 40px;
    box-sizing: border-box;
}

.sff-barcode-scan-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.sff-barcode-scan-icon:hover { opacity: 1; }

/* ── Мобилни ── */
@media (max-width: 600px) {
    #sff-scan-window {
        width: 88%;
    }
    #sff-barcode-controls {
        bottom: 32px;
    }
}
