/* ALGA MOTO — barcode scanner (public/js/scanner.js). Colours: --ean-p (primary, default store red), --ean-s (header). */
#ean-root { --ean-p-: var(--ean-p, var(--red, #e3192b)); --ean-s-: var(--ean-s, #000); font-family: var(--f-body); }
#ean-root [hidden] { display: none !important; }

/* floating button: in the floating lane, above WhatsApp / back-to-top */
.ean-fab {
  position: fixed; z-index: var(--am-float-z, 60); bottom: calc(var(--am-floating-row-bottom, calc(var(--dock-h, 0px) + 16px + env(safe-area-inset-bottom))) + var(--ean-fab-up, 70px));
  width: var(--ean-fab, 46px); height: var(--ean-fab, 46px); border-radius: 50%; border: 1px solid var(--line, #e3e6eb);
  background: var(--surface, #fff); color: var(--ean-p-); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18); -webkit-tap-highlight-color: transparent; transition: transform .15s, opacity .15s;
}
.ean-fab > svg { width: var(--ean-fab-ic, 24px) !important; height: var(--ean-fab-ic, 24px) !important; max-width: 90%; max-height: 90%; flex: none; }
.ean-fab:active { transform: scale(.92); }
.ean-fab .ean-pulse { display: none; }
.ean-fab.pulse .ean-pulse { display: block; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ean-p-); animation: ean-pulse 2s infinite; pointer-events: none; }
.ean-fab .ean-badge { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--ean-p-); color: #fff; font: 800 10px/18px var(--f-body); text-align: center; }
@keyframes ean-pulse { from { opacity: .6; transform: scale(1); } to { opacity: 0; transform: scale(1.4); } }
@media (min-width: 900px) { .ean-fab { bottom: calc(96px + var(--ean-fab-up, 70px)); } }
:root:is(.is-locked, .am-overlay-open) .ean-fab, body.ean-open .ean-fab { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }

/* backdrop + panel (above the side menu 80 and the drawer 91; below the option picker 110 and toasts 120) */
.ean-bd { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .6); opacity: 0; pointer-events: none; transition: opacity .3s; backdrop-filter: blur(2px); }
.ean-bd.v { opacity: 1; pointer-events: auto; }
.ean-pan { position: fixed; z-index: 101; top: 0; bottom: 0; width: 100%; max-width: 420px; display: flex; flex-direction: column; background: #000; color: #fff; transition: transform .35s cubic-bezier(.4, 0, .2, 1); will-change: transform; }
.ean-pan.side-right { right: 0; transform: translateX(100%); }
.ean-pan.side-left { left: 0; transform: translateX(-100%); }
.ean-pan.full { inset: 0; max-width: none; transform: translateY(100%); }
.ean-pan.o { transform: none; }
body.ean-open { overflow: hidden; }

.ean-hd { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: max(8px, env(safe-area-inset-top)) 12px 8px 16px; background: var(--ean-s-); color: #fff; }
.ean-hd img { height: 28px; max-width: 150px; object-fit: contain; }
.ean-title { font: 700 15px/1.2 var(--f-body); letter-spacing: .2px; }
.ean-sp { flex: 1; }
.ean-hb { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: rgba(255, 255, 255, .8); cursor: pointer; }
.ean-hb:hover, .ean-hb:focus-visible { color: #fff; background: rgba(255, 255, 255, .1); }

.ean-manual { display: flex; gap: 8px; padding: 10px 14px; background: var(--ean-s-); }
.ean-manual input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 8px; background: rgba(255, 255, 255, .1); color: #fff; font: 600 16px/1 ui-monospace, Menlo, monospace; outline: none; }
.ean-manual input::placeholder { color: rgba(255, 255, 255, .45); font-family: var(--f-body); font-weight: 500; }
.ean-manual input:focus { border-color: var(--ean-p-); }
.ean-manual button { height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--ean-p-); color: #fff; font: 700 14px/1 var(--f-body); cursor: pointer; white-space: nowrap; }

.ean-vbox { position: relative; flex: 1; overflow: hidden; background: #000; }
.ean-vid { width: 100%; height: 100%; object-fit: cover; display: block; }
.ean-targ { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.ean-frame { position: relative; width: 78%; max-width: 320px; aspect-ratio: 1.6; border: 2px solid rgba(255, 255, 255, .3); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); }
.ean-frame .c { position: absolute; width: 22px; height: 22px; border: 0 solid var(--ean-p-); }
.ean-frame .tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 10px 0 0 0; }
.ean-frame .tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 10px 0 0; }
.ean-frame .bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 10px; }
.ean-frame .br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 10px 0; }
.ean-line { position: absolute; left: 5%; width: 90%; height: 2px; border-radius: 2px; background: var(--ean-p-); box-shadow: 0 0 12px var(--ean-p-), 0 0 36px var(--ean-p-); animation: ean-scan 2.2s ease-in-out infinite; }
@keyframes ean-scan { 0%, 100% { top: 8%; } 50% { top: 88%; } }
@media (prefers-reduced-motion: reduce) { .ean-line { animation: none; top: 50%; } }
.ean-hint { margin: 16px 0 0; color: rgba(255, 255, 255, .85); font: 500 13px/1.3 var(--f-body); text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.ean-batch { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 20; padding: 3px 9px; border-radius: 20px; background: var(--ean-p-); color: #fff; font: 800 10px/1.4 var(--f-body); letter-spacing: .5px; }

.ean-ctrl { position: absolute; inset: auto 0 0 0; z-index: 30; display: flex; justify-content: space-between; align-items: flex-end; padding: 16px 18px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent); }
.ean-ctrl-g { display: flex; gap: 10px; }
.ean-btn { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font: 700 14px/1 var(--f-body); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ean-btn:active { transform: scale(.92); }
.ean-btn.on { background: rgba(255, 255, 255, .32); color: #fbbf24; }

.ean-results { position: absolute; top: 0; left: 0; right: 0; z-index: 50; display: none; flex-direction: column; gap: 8px; max-height: 66%; padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ean-results.v { display: flex; }
.ean-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: #fff; color: #1b1e24; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); animation: ean-in .3s; }
@keyframes ean-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.ean-img { flex: none; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: #f2f3f5; }
.ean-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ean-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ean-name { overflow: hidden; color: inherit; font: 700 13.5px/1.25 var(--f-body); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ean-sku { color: #8a909b; font: 500 11px/1.3 var(--f-body); }
.ean-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.ean-price b { color: var(--ean-p-); font: italic 800 var(--ean-price, 18px)/1.15 var(--f-num, var(--f-body)); white-space: nowrap; }
html[lang="ar"] .ean-price b { font-style: normal; }
.ean-price s { color: #8a909b; font: 500 12px/1 var(--f-body); }
.ean-stock { align-self: flex-start; margin-top: 2px; padding: 1px 7px; border-radius: 4px; font: 700 10px/1.5 var(--f-body); }
.ean-stock.in { background: #dcfce7; color: #166534; } .ean-stock.out { background: #fef2f2; color: #991b1b; }
.ean-acts { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ean-act { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer; text-decoration: none; }
.ean-view { background: #f1f2f4; color: #374151; }
.ean-add { background: var(--ean-p-); color: #fff; }
.ean-add.busy { opacity: .6; } .ean-add.added { background: #16a34a; }
.ean-qty { display: flex; align-items: center; gap: 2px; }
.ean-qty button { width: 22px; height: 22px; padding: 0; border: 1px solid #dde0e5; border-radius: 5px; background: #f8f9fa; color: #1b1e24; font: 700 14px/1 var(--f-body); cursor: pointer; }
.ean-qty output { min-width: 18px; text-align: center; font: 700 12px/1 var(--f-body); }
.ean-miss .ean-code { font: 700 14px/1.3 ui-monospace, Menlo, monospace; }
.ean-miss small { color: #991b1b; font: 600 12px/1.3 var(--f-body); }

.ean-loading { position: absolute; top: 50%; left: 50%; z-index: 55; transform: translate(-50%, -50%); }
.ean-spin { display: block; width: 36px; height: 36px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--ean-p-); border-radius: 50%; animation: ean-spin .7s linear infinite; }
@keyframes ean-spin { to { transform: rotate(360deg); } }

.ean-toast { position: absolute; left: 14px; right: 14px; bottom: 92px; z-index: 60; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; border-inline-start: 4px solid #16a34a; background: #fff; color: #1b1e24; font: 600 13px/1.35 var(--f-body); box-shadow: 0 6px 16px rgba(0, 0, 0, .3); }
.ean-toast svg { flex: none; color: #16a34a; } .ean-toast.err { border-inline-start-color: #dc2626; } .ean-toast.err svg { color: #dc2626; }
.ean-toast span { overflow-wrap: anywhere; }

.ean-hist { position: absolute; inset: auto 0 0 0; z-index: 56; max-height: 70%; overflow-y: auto; padding: 14px 16px max(16px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: rgba(12, 13, 16, .96); }
.ean-hist-hd { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font: 700 14px/1.2 var(--f-body); }
.ean-link { border: 0; background: none; color: rgba(255, 255, 255, .7); font: 600 12px/1 var(--f-body); cursor: pointer; text-decoration: underline; }
.ean-hi { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .1); font-size: 12px; }
.ean-hi:last-child { border: 0; }
.ean-hcode { font: 700 12.5px/1.3 ui-monospace, Menlo, monospace; }
.ean-hcode .f { color: #4ade80; font-style: normal; } .ean-hcode .m { color: #f87171; font-style: normal; }
.ean-hmeta { display: flex; flex-direction: column; align-items: flex-end; text-align: end; min-width: 0; }
.ean-hmeta small { color: rgba(255, 255, 255, .5); } .ean-hmeta span { overflow: hidden; max-width: 190px; text-overflow: ellipsis; white-space: nowrap; } .ean-hmeta b { color: var(--ean-p-); }
.ean-hempty { margin: 8px 0; color: rgba(255, 255, 255, .6); font-size: 13px; }

/* "scan" button inside the phone search box */
.sheet-search form { position: relative; }
.sheet-search .sheet-scan { flex: none; color: var(--red); }
