/* ScanVerify widget — see core/static/core/js/widgets/scan_verify.js
 * Self-contained styling. Uses hub.css CSS variables (--success, --border,
 * --warning, etc.) so it inherits dark-mode for free. Prefixed `sv-` to
 * avoid collisions with packing/'s `pk-verify-*` rules. */

.sv-root { display: block; }

.sv-progress {
    height: 8px;
    background: var(--bg-alt, #eee);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}
.sv-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--success);
    transition: width 120ms ease-out;
}

.sv-counter-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}
.sv-counter {
    font-family: monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.sv-counter-label { color: var(--text-secondary); }

.sv-scan-row { display: flex; gap: 8px; align-items: stretch; }
.sv-scan-input {
    flex: 1;
    min-width: 0;
    font-size: 1.05rem;
    padding: 12px 16px;
    font-family: monospace;
    letter-spacing: 0.02em;
}
/* ⌨ toggle — re-enables the on-screen keyboard for manual EAN entry on a
 * handheld (inputmode=none suppresses it by default). Harmless on desktop. */
.sv-kb-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
}
.sv-kb-toggle:hover { background: var(--bg-hover); }
.sv-kb-toggle.is-active {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.sv-scan-input.sv-flash-ok {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 2px var(--success-soft-bg, rgba(46,160,67,0.25));
    animation: svFlashOk 260ms ease-out;
}
.sv-scan-input.sv-flash-err {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 2px var(--error-soft-bg, rgba(220,50,50,0.25));
    animation: svFlashErr 260ms ease-out;
}
@keyframes svFlashOk  { 0% { background: var(--success-soft-bg, #d6f5dd); } 100% { background: transparent; } }
@keyframes svFlashErr { 0% { background: var(--error-soft-bg,   #f8d7da); } 100% { background: transparent; } }

.sv-message {
    min-height: 1.3em;
    margin-top: 8px;
    font-size: 0.9rem;
}
.sv-message-ok   { color: var(--success); }
.sv-message-err  { color: var(--error); }
.sv-message-warn { color: var(--warning, #c77700); }

.sv-lines {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 380px;
    overflow-y: auto;
}
.sv-empty {
    padding: 16px;
    color: var(--text-muted);
    font-style: italic;
}

.sv-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.88rem;
}
.sv-line code { font-size: 0.85rem; }
.sv-line-icon { width: 20px; text-align: center; font-weight: 700; }
.sv-line-main {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sv-line-count {
    font-family: monospace;
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: right;
}
.sv-line-done {
    background: var(--success-bg);
    border-color: var(--success);
    opacity: 0.85;
}
.sv-line-done .sv-line-icon { color: var(--success); }
.sv-line-gift {
    background: var(--info-bg, #eaf2fb);
    border-color: var(--info, #5a9ae2);
    opacity: 0.75;
}
.sv-line-gift .sv-line-icon { color: var(--info, #5a9ae2); }
.sv-line-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.sv-line-skipped {
    background: var(--warning-bg, #fff5e0);
    border-color: var(--warning, #c77700);
    opacity: 0.9;
}
.sv-line-skipped .sv-line-icon { color: var(--warning, #c77700); }
.sv-line-skip-label {
    color: var(--warning, #c77700);
    font-weight: 600;
    min-width: auto;
    cursor: help;
}
.sv-line-skip-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.72rem;
    line-height: 1.2;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
}
.sv-line-skip-btn:hover {
    background: var(--warning-bg, #fff5e0);
    color: var(--warning, #c77700);
    border-color: var(--warning, #c77700);
}

/* Missing = the item is not physically here (never a skip). Red on purpose:
   the two buttons sit side by side and must not be confused. */
.sv-line-missing {
    background: var(--error-bg, #fdecec);
    border-color: var(--error, #c62828);
}
.sv-line-missing .sv-line-icon { color: var(--error, #c62828); }
.sv-line-missing-label {
    color: var(--error, #c62828);
    font-weight: 600;
    min-width: auto;
    margin-left: 8px;
}
.sv-line-missing-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.72rem;
    line-height: 1.2;
    border: 1px solid var(--error, #c62828);
    background: var(--bg-card);
    color: var(--error, #c62828);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
}
.sv-line-missing-btn:hover {
    background: var(--error, #c62828);
    color: #fff;
}

/* Manual-confirm lines (fractional / meter-cut quantities): no scan target,
 * completed by an explicit tap on the confirm button (or one EAN scan). */
.sv-line-manual:not(.sv-line-done):not(.sv-line-skipped) {
    background: var(--info-soft-bg, var(--info-bg, #eaf2fb));
    border-color: var(--info, #5a9ae2);
}
.sv-line-confirm-btn {
    margin-left: 8px;
    padding: 2px 10px;
    font-size: 0.72rem;
    line-height: 1.2;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
}
.sv-line-confirm-btn:hover { filter: brightness(1.1); }

/* Reset = undo the operator's work on the line (the draft survives a reload,
 * so reloading no longer undoes a wrong scan). Neutral until hovered. */
.sv-line-reset-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.72rem;
    line-height: 1.2;
    border: 1px dashed var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
}
.sv-line-reset-btn:hover {
    border-style: solid;
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Skip-reason modal — uses hub-modal-* primitives but adds layout for the
 * reason picker. */
.sv-skip-reason {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 6px;
}
.sv-skip-reason:hover { background: var(--bg-hover); }
.sv-skip-reasons input[type=radio] { margin: 0; }
.sv-skip-reason-label { flex: 1; }
.sv-skip-reason-qty { display: inline-flex; align-items: center; }
.sv-skip-reason-qty .sv-skip-qty { padding: 4px 8px; font-size: 0.9rem; height: 30px; }

/* Handheld (Zebra) — mobile-only. The widget is shared by stock_transfers
 * (RT receive/ship) and packing; on a scanner the desktop-sized per-line
 * skip button and scan field are too small for a thumb. Gated at 600px so
 * the all-day desktop stations are byte-for-byte unchanged. */
@media (max-width: 600px) {
    .sv-scan-input { font-size: 1.15rem; padding: 14px 16px; }
    .sv-kb-toggle { min-width: 52px; }
    .sv-line { padding: 10px 12px; font-size: 0.95rem; }
    .sv-line-skip-btn { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }
    .sv-line-missing-btn { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }
    .sv-line-confirm-btn { padding: 8px 14px; font-size: 0.85rem; min-height: 36px; }
    .sv-line-reset-btn { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }
    .sv-skip-reason { padding: 14px 12px; }
    .sv-lines { max-height: none; } /* the page scrolls on a handheld, not a nested box */
}

/* Portrait handheld — the single-row line truncates code + description with
 * an ellipsis, which hides exactly the data needed to spot a no-EAN item.
 * Let the text wrap onto its own full-width row; qty and skip move below,
 * pushed right. Landscape (~640px+) keeps the one-row layout. */
@media (max-width: 480px) {
    .sv-line { flex-wrap: wrap; row-gap: 4px; }
    .sv-line-main {
        flex: 1 1 calc(100% - 32px);
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }
    .sv-line-count { margin-left: auto; }
}
