/* ZigZag fullscreen barcode scanner overlay — standalone */

body.zz-scanner-open { overflow: hidden; }

.zz-scanner {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    font-family: inherit;
    direction: rtl;
    user-select: none;
    -webkit-user-select: none;
}

.zz-scanner__topbar {
    flex: 0 0 auto;
    height: 56px;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.zz-scanner__title {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.zz-scanner__close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.15s;
}
.zz-scanner__close:hover, .zz-scanner__close:focus { background: rgba(255,255,255,0.1); outline: none; }
.zz-scanner__engine {
    font-size: 11px;
    color: #f5d33c;
    background: rgba(245,211,60,0.12);
    border: 1px solid rgba(245,211,60,0.4);
    padding: 3px 8px;
    border-radius: 999px;
    min-width: 60px;
    text-align: center;
}

.zz-scanner__stage {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background: #000;
}
.zz-scanner__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.zz-scanner__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.zz-scanner__cutout {
    position: relative;
    width: min(85vw, 540px);
    height: min(28vw, 180px);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
    border-radius: 8px;
}
.zz-scanner__corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: #f5d33c;
    border-style: solid;
    border-width: 0;
}
.zz-scanner__corner--tl { top: -2px; right: -2px; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 8px; }
.zz-scanner__corner--tr { top: -2px; left: -2px;  border-top-width: 4px; border-left-width: 4px;  border-top-left-radius: 8px; }
.zz-scanner__corner--bl { bottom: -2px; right: -2px; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 8px; }
.zz-scanner__corner--br { bottom: -2px; left: -2px;  border-bottom-width: 4px; border-left-width: 4px;  border-bottom-left-radius: 8px; }

.zz-scanner__laser {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ff3b3b 50%, transparent);
    box-shadow: 0 0 12px rgba(255,59,59,0.85);
    top: 50%;
    transform: translateY(-50%);
    animation: zz-laser 1.6s ease-in-out infinite;
}
@keyframes zz-laser {
    0%, 100% { top: 18%; }
    50%      { top: 82%; }
}

.zz-scanner__hint {
    margin-top: 22px;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.4);
    padding: 6px 14px;
    border-radius: 999px;
    transition: color 0.2s, background 0.2s;
}
.zz-scanner__hint--ok  { color: #0c0; background: rgba(0,200,0,0.15); }
.zz-scanner__hint--err { color: #ff6b6b; background: rgba(255,107,107,0.15); }
.zz-scanner__hint--dup { color: #ffb84d; background: rgba(255,184,77,0.16); font-weight: 700; }

.zz-scanner__flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
}
.zz-scanner__flash--ok  { animation: zz-flash-ok  0.32s ease-out; }
.zz-scanner__flash--err { animation: zz-flash-err 0.40s ease-out; }
.zz-scanner__flash--dup { animation: zz-flash-dup 0.36s ease-out; }
@keyframes zz-flash-ok {
    0%   { background: rgba(46, 204, 113, 0.55); opacity: 1; }
    100% { background: rgba(46, 204, 113, 0);    opacity: 0; }
}
@keyframes zz-flash-err {
    0%   { background: rgba(231, 76, 60, 0.55); opacity: 1; }
    100% { background: rgba(231, 76, 60, 0);    opacity: 0; }
}
@keyframes zz-flash-dup {
    0%   { background: rgba(245, 184, 0, 0.55); opacity: 1; }
    100% { background: rgba(245, 184, 0, 0);    opacity: 0; }
}

.zz-scanner__footer {
    flex: 0 0 auto;
    min-height: 84px;
    background: rgba(0,0,0,0.92);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
}
.zz-scanner__last { overflow: hidden; min-width: 0; }
.zz-scanner__last-label {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    margin-bottom: 2px;
}
.zz-scanner__last-value {
    font-family: 'SF Mono', Consolas, 'Liberation Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    direction: ltr;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.zz-scanner__counter {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
}
.zz-scanner__counter-num {
    font-weight: 700;
    color: #f5d33c;
    font-size: 16px;
    margin-left: 4px;
}
.zz-scanner__done {
    background: #f5d33c;
    color: #1a1a1a;
    border: 0;
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    min-width: 110px;
    transition: transform 0.1s, background 0.15s;
}
.zz-scanner__done:hover  { background: #ffe066; }
.zz-scanner__done:active { transform: scale(0.97); }

/* not found blocking alert */
.zz-scanner__alert {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.78);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 16px;
}
.zz-scanner__alert[hidden] { display: none; }
.zz-scanner__alert-card {
    background: #fff;
    color: #1a1325;
    border-radius: 18px;
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
    animation: zz-alert-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    direction: rtl;
}
.zz-scanner__alert-icon {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: #fde8e8;
    color: #d94343;
    font-size: 38px;
    font-weight: 800;
    line-height: 64px;
    margin: 0 auto 16px;
}
.zz-scanner__alert-title {
    font-size: 20px;
    font-weight: 800;
    color: #d94343;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}
.zz-scanner__alert-value {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 17px;
    font-weight: 700;
    color: #4a3c5a;
    background: #f6f4f9;
    padding: 10px 16px;
    border-radius: 10px;
    direction: ltr;
    display: inline-block;
    margin-bottom: 22px;
    word-break: break-all;
}
.zz-scanner__alert-ok {
    width: 100%;
    background: #f5d33c;
    color: #1a1a1a;
    border: 0;
    padding: 14px;
    font-size: 17px;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    min-height: 52px;
    box-shadow: 0 6px 14px rgba(248,230,0,0.45);
    transition: transform 0.08s, background 0.15s;
}
.zz-scanner__alert-ok:hover  { background: #ffe066; }
.zz-scanner__alert-ok:active { transform: scale(0.97); }
@keyframes zz-alert-pop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

@media (max-width: 600px) {
    .zz-scanner__topbar { height: 50px; padding: 0 10px; }
    .zz-scanner__title { font-size: 16px; }
    .zz-scanner__cutout { width: 92vw; height: 32vw; }
    .zz-scanner__footer { grid-template-columns: 1fr auto; padding: 10px 12px; gap: 8px; }
    .zz-scanner__counter { grid-column: 2; grid-row: 1; }
    .zz-scanner__done    { grid-column: 1 / -1; grid-row: 2; min-height: 48px; }
    .zz-scanner__last-value { font-size: 18px; }
}
