/* =============================================================
   public/css/product-scanner.css
   Styles specific to the Product Scanner page
   Place in public/css/ and link via @push('styles') in the view,
   OR enqueue in webpack/vite and reference with asset().
   ============================================================= */

/* ── App shell ── */
.app {
    max-width: 390px;
    margin: 0 auto;
    font-family: var(--font-sans);
}

/* ── Screen base ── */
.screen {
    display: none;
    min-height: 580px;
    background: var(--color-background-primary);
    border-radius: var(--border-radius-lg);
    border: 0.5px solid var(--color-border-tertiary);
    overflow: hidden;
    flex-direction: column;
}
.screen.active { display: flex; }

/* ── Topbar ── */
.topbar {
    background: #1a1a2e;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.topbar-title { color: #fff; font-size: 15px; font-weight: 500; }
.topbar-sub   { color: rgba(255,255,255,0.5); font-size: 11px; margin-top: 1px; }

/* ── Step dots ── */
.step-dots { display: flex; gap: 5px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.25); }
.dot.on { background: #fff; width: 16px; border-radius: 3px; }

/* ── Mode tabs ── */
.mode-tabs { display: flex; background: #111827; flex-shrink: 0; }
.mode-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.mode-tab.active { color: #6ee7b7; border-bottom-color: #6ee7b7; }

/* ── Camera box ── */
.cam-box {
    background: #0a0a14;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

/* Barcode scan frame */
.scan-frame { width: 200px; height: 130px; position: relative; }
.corner { position: absolute; width: 18px; height: 18px; border-color: #6ee7b7; border-style: solid; }
.corner.tl { top: 0; left: 0;    border-width: 3px 0 0 3px; }
.corner.tr { top: 0; right: 0;   border-width: 3px 3px 0 0; }
.corner.bl { bottom: 0; left: 0;  border-width: 0 0 3px 3px; }
.corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; }
.scan-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #6ee7b7, transparent);
    animation: sl 2s ease-in-out infinite;
}
@keyframes sl { 0% { top: 8%; } 50% { top: 88%; } 100% { top: 8%; } }

/* Photo frame */
.photo-frame {
    width: 200px;
    height: 150px;
    border: 2px dashed rgba(99,102,241,0.6);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.photo-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(99,102,241,0.2);
    display: flex; align-items: center; justify-content: center;
}
.photo-icon svg { width: 18px; height: 18px; stroke: #818cf8; fill: none; stroke-width: 2; }
.photo-hint { color: rgba(255,255,255,0.5); font-size: 11px; text-align: center; line-height: 1.5; padding: 0 16px; }

.cam-tip {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ── Action buttons ── */
.actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #111827;
    flex-shrink: 0;
}
.abtn {
    flex: 1;
    padding: 10px 8px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: opacity var(--transition-fast);
}
.abtn:hover { opacity: 0.88; }
.abtn svg { width: 14px; height: 14px; flex-shrink: 0; }
.abtn.green  { background: #6ee7b7; color: #052e16; }
.abtn.ghost  { background: rgba(255,255,255,0.08); color: #fff; }
.abtn.purple { background: #6366f1; color: #fff; }

/* ── Manual barcode row ── */
.manual-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 0.5px solid var(--color-border-tertiary);
}
.mi {
    flex: 1;
    padding: 9px 12px;
    border-radius: 8px;
    border: 0.5px solid var(--color-border-secondary);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 13px;
}
.mb {
    padding: 9px 14px;
    border-radius: 8px;
    border: none;
    background: #3730a3;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.mb:hover { background: #312e81; }

/* ── Recent items ── */
.recent { padding: 12px 16px; flex: 1; }
.rlabel {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.ritem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 0.5px solid var(--color-border-tertiary);
}
.rthumb {
    width: 34px; height: 34px;
    border-radius: 6px;
    background: var(--color-background-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    overflow: hidden;
}
.rinfo { flex: 1; }
.rname { font-size: 12px; font-weight: 500; color: var(--color-text-primary); }
.rbar  { font-size: 10px; color: var(--color-text-secondary); }
.rprice { font-size: 12px; font-weight: 500; color: #3730a3; }

/* ── Processing screen ── */
.proc-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 16px;
}
.spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--color-border-tertiary);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-badge {
    background: #ede9fe;
    color: #4c1d95;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.ai-badge svg { width: 12px; height: 12px; fill: #6d28d9; }

.proc-title { font-size: 16px; font-weight: 500; color: var(--color-text-primary); text-align: center; }
.proc-sub   { font-size: 12px; color: var(--color-text-secondary); text-align: center; line-height: 1.6; }

/* Provider rows */
.plist { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.prow {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--color-background-secondary);
    border-radius: 8px;
    border: 0.5px solid var(--color-border-tertiary);
}
.picon {
    width: 26px; height: 26px;
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
    font-weight: 500;
    flex-shrink: 0;
}
.pname { font-size: 12px; color: var(--color-text-primary); flex: 1; }
.pst   { font-size: 11px; font-weight: 500; }
.done    { color: #059669; }
.loading { color: #6366f1; }
.wait    { color: var(--color-text-secondary); }

/* Photo result box */
.photo-result-box {
    width: 100%;
    background: var(--color-background-secondary);
    border-radius: var(--border-radius-md);
    border: 0.5px solid var(--color-border-tertiary);
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.photo-result-img {
    width: 56px; height: 56px;
    border-radius: 6px;
    background: #e8e8f0;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: #888;
    overflow: hidden;
}
.photo-result-info { flex: 1; }
.photo-result-label {
    font-size: 10px;
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.photo-result-name { font-size: 13px; font-weight: 500; color: var(--color-text-primary); line-height: 1.4; }
.photo-result-conf { font-size: 11px; color: #059669; margin-top: 3px; }

/* ── Review screen tabs ── */
.rtabs {
    display: flex;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-secondary);
    flex-shrink: 0;
}
.rtab {
    flex: 1;
    padding: 9px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.rtab.active { color: #3730a3; border-bottom-color: #3730a3; }

.rscroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Form labels & badges */
.flabel {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.fbadge { font-size: 9px; padding: 1px 6px; border-radius: 999px; font-weight: 500; }
.fbadge.amz { background: #fef3c7; color: #92400e; }
.fbadge.upc { background: #ede9fe; color: #4c1d95; }
.fbadge.ai  { background: #f0fdf4; color: #14532d; }

/* Form inputs */
.finput {
    width: 100%;
    padding: 8px 10px;
    border-radius: 7px;
    border: 0.5px solid var(--color-border-secondary);
    background: var(--color-background-primary);
    color: var(--color-text-primary);
    font-size: 12px;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast);
}
.finput:focus { outline: none; border-color: #6366f1; }

.fta {
    width: 100%;
    padding: 8px 10px;
    border-radius: 7px;
    border: 0.5px solid var(--color-border-secondary);
    background: var(--color-background-primary);
    color: var(--color-text-primary);
    font-size: 12px;
    font-family: var(--font-sans);
    resize: none;
    height: 52px;
    transition: border-color var(--transition-fast);
}
.fta:focus { outline: none; border-color: #6366f1; }

/* Prices grid */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.pcard {
    background: var(--color-background-secondary);
    border-radius: 7px;
    padding: 9px 10px;
    border: 0.5px solid var(--color-border-tertiary);
}
.psrc {
    font-size: 9px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
}
.pval  { font-size: 15px; font-weight: 500; }
.pval.a { color: #c45500; }
.pval.e { color: #0064d2; }
.pval.h { color: #f96302; }
.pval.l { color: #005f8e; }

/* Image thumbs */
.istrip { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.ithumb {
    width: 70px; height: 70px;
    border-radius: 7px;
    background: var(--color-background-secondary);
    border: 0.5px solid var(--color-border-tertiary);
    flex-shrink: 0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px;
    color: var(--color-text-secondary);
    transition: border-color var(--transition-fast);
    overflow: hidden;
}
.ithumb.sel { border: 2px solid #3730a3; }

/* Review footer */
.rfooter {
    padding: 10px 14px;
    border-top: 0.5px solid var(--color-border-tertiary);
    display: flex;
    gap: 7px;
    flex-shrink: 0;
}
.bsave {
    flex: 1;
    padding: 11px;
    background: #3730a3;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.bsave:hover { background: #312e81; }
.bback {
    padding: 11px 14px;
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    border: 0.5px solid var(--color-border-secondary);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* ── Success screen ── */
.succ-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 14px;
    text-align: center;
}
.si {
    width: 58px; height: 58px;
    border-radius: 50%;
    background: #d1fae5;
    display: flex; align-items: center; justify-content: center;
}
.si svg { width: 28px; height: 28px; stroke: #059669; fill: none; stroke-width: 2.5; }
.stitle { font-size: 18px; font-weight: 500; color: var(--color-text-primary); }
.ssub   { font-size: 12px; color: var(--color-text-secondary); line-height: 1.6; max-width: 260px; }
.scard {
    background: var(--color-background-secondary);
    border-radius: var(--border-radius-lg);
    border: 0.5px solid var(--color-border-tertiary);
    padding: 12px;
    width: 100%;
    display: flex;
    gap: 10px;
    align-items: center;
}
.simg {
    width: 48px; height: 48px;
    border-radius: 6px;
    background: #f0f0f0;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: #888;
    overflow: hidden;
}
.sinfo { flex: 1; text-align: left; }
.sname { font-size: 12px; font-weight: 500; color: var(--color-text-primary); line-height: 1.4; }
.smeta { font-size: 10px; color: var(--color-text-secondary); margin-top: 2px; }
.bscan {
    width: 100%;
    padding: 12px;
    background: #3730a3;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.bscan:hover { background: #312e81; }
.bcrm {
    width: 100%;
    padding: 12px;
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    border: 0.5px solid var(--color-border-secondary);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: block;
    text-align: center;
}

/* ── Fix overall app layout ──────────────────────────────────── */
.app {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Fix cam-box containing the video ───────────────────────── */
.cam-box {
    position: relative;
    width: 100%;
    height: 280px;          /* fixed height so video doesn't overflow */
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

/* ── Make Quagga video fill the box ─────────────────────────── */
#barcodeView {
    width: 100%;
    height: 100%;
}

#barcodeView video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}

/* ── Hide Quagga's debug canvas overlay ─────────────────────── */
#barcodeView canvas {
    display: none !important;
}

/* ── Keep scan frame corners on top of video ─────────────────── */
.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 140px;
    z-index: 10;
    pointer-events: none;
}

#barcodeView video,
#barcodeView canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast; /* Prevents browser softening */
    image-rendering: crisp-edges;
}