/*!
 * Serial / IMEI entry — compact table chip + entry modal.
 *
 * Presentation only. The real form field is the hidden
 * <textarea class="serial_numbers_input">, whose name and
 * one-serial-per-line format are unchanged.
 */

/* ------------------------------------------------------------------
   Compact chip shown in the product table
   ------------------------------------------------------------------ */
.serial_entry_wrapper {
    display: block;
}

.serial_manage_btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #FCD9A6;
    background: #FFFBEB;
    color: #92400E;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.serial_manage_btn:hover {
    background: #FEF3C7;
    border-color: #F59E0B;
}
.serial_manage_btn:focus-visible {
    outline: 2px solid #7C3AED;
    outline-offset: 2px;
}

.serial_manage_btn.is-complete {
    border-color: #A7F3D0;
    background: #ECFDF5;
    color: #065F46;
}
.serial_manage_btn.is-complete:hover {
    background: #D1FAE5;
    border-color: #10B981;
}

.serial_chip_icon { font-size: 12px; opacity: .85; }
.serial_chip_label { font-weight: 600; }

.serial_entry_count {
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-weight: 700;
    font-size: 11.5px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .07);
}
.serial_manage_btn.is-complete .serial_entry_count {
    background: #A7F3D0;
}

.serial_chip_action {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: .8;
}

/* ------------------------------------------------------------------
   Modal
   ------------------------------------------------------------------ */
.serial-modal .modal-dialog {
    max-width: 560px;
    width: calc(100% - 24px);
    margin: 32px auto;
}

.serial-modal__content {
    border: none;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 64px -16px rgba(15, 23, 42, .42);
}

/* Header */
.serial-modal__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #EEF0F5;
}
.serial-modal__head-main { min-width: 0; flex: 1; }
.serial-modal__title {
    font-size: 15px;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -.01em;
}
.serial-modal__title i { color: #7C3AED; margin-inline-end: 4px; }
.serial-modal__product {
    margin-top: 3px;
    font-size: 13px;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.serial-modal__close {
    border: 0;
    background: #F1F5F9;
    color: #64748B;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    flex: none;
    transition: background-color .15s ease, color .15s ease;
}
.serial-modal__close:hover { background: #E2E8F0; color: #0F172A; }

/* Meta strip */
.serial-modal__meta {
    display: flex;
    gap: 1px;
    background: #EEF0F5;
    border-bottom: 1px solid #EEF0F5;
}
.serial-modal__meta-item {
    flex: 1;
    background: #FAFBFD;
    padding: 8px 14px;
    min-width: 0;
}
.serial-modal__meta-item span {
    display: block;
    font-size: 10px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #94A3B8;
    font-weight: 600;
}
.serial-modal__meta-item strong {
    display: block;
    font-size: 13px;
    color: #0F172A;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Quantity is editable here so a bulk intake can be set up without
   going back to the table */
.serial-modal__qty {
    display: block;
    width: 100%;
    max-width: 96px;
    height: 30px;
    margin-top: 1px;
    padding: 0 8px;
    border: 1.5px solid #D9DEE7;
    border-radius: 7px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
    font-variant-numeric: tabular-nums;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.serial-modal__qty:focus {
    outline: none;
    border-color: #7C3AED;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .14);
}

/* Body */
.serial-modal__body { padding: 16px 18px; }

.serial-modal__label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #64748B;
    margin: 0 0 6px;
}

/* Scanner input — the focal control */
.serial-modal__scan {
    position: relative;
    display: flex;
    align-items: center;
}
.serial-modal__scan i {
    position: absolute;
    inset-inline-start: 13px;
    color: #94A3B8;
    font-size: 15px;
    pointer-events: none;
}
.serial-modal__scan input {
    width: 100%;
    height: 46px;
    padding-inline-start: 38px;
    padding-inline-end: 14px;
    border: 1.5px solid #D9DEE7;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    color: #0F172A;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.serial-modal__scan input::placeholder {
    font-family: inherit;
    font-weight: 400;
    color: #64748B;   /* #A3AEC0 measured 2.24:1 on white — unreadable */
}
.serial-modal__scan input:focus {
    outline: none;
    border-color: #7C3AED;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .14);
}

/* Inline error */
.serial-modal__error {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    color: #B91C1C;
    background: #FEF2F2;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    transition: max-height .18s ease, opacity .18s ease, margin .18s ease, padding .18s ease;
    padding: 0 10px;
    margin-top: 0;
}
.serial-modal__error.is-visible {
    max-height: 70px;
    opacity: 1;
    padding: 8px 10px;
    margin-top: 8px;
}

/* Progress */
.serial-modal__progress { margin: 14px 0 10px; }
.serial-modal__progress-text {
    font-size: 12.5px;
    font-weight: 700;
    color: #64748B;
    margin-bottom: 6px;
}
.serial-modal__progress.is-complete .serial-modal__progress-text { color: #047857; }
.serial-modal__progress.is-over .serial-modal__progress-text { color: #B45309; }

.serial-modal__bar {
    height: 6px;
    border-radius: 999px;
    background: #EDF0F5;
    overflow: hidden;
}
.serial-modal__bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: #7C3AED;
    transition: width .22s ease, background-color .22s ease;
}
.serial-modal__progress.is-complete .serial-modal__bar span { background: #059669; }
.serial-modal__progress.is-over .serial-modal__bar span { background: #F59E0B; }

/* Serial list */
.serial-modal__list {
    max-height: 232px;
    overflow-y: auto;
    border: 1px solid #E7EAF1;
    border-radius: 10px;
    background: #FBFCFE;
    padding: 5px;
}
.serial-modal__empty {
    padding: 22px 12px;
    text-align: center;
    color: #94A3B8;
    font-size: 12.5px;
}
.serial-modal__row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #EDF0F5;
    margin-bottom: 4px;
}
.serial-modal__row:last-child { margin-bottom: 0; }

.serial-modal__tick {
    flex: none;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #D1FAE5;
    color: #047857;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.serial-modal__serial {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-size: 13px;
    font-weight: 600;
    color: #0F172A;
    overflow: hidden;
    text-overflow: ellipsis;
}
.serial-modal__remove {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 0;
    background: transparent;
    color: #94A3B8;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.serial-modal__remove:hover { background: #FEE2E2; color: #B91C1C; }

/* Collapsible bulk tools */
.serial-modal__tools {
    margin-top: 12px;
    border-top: 1px solid #EEF0F5;
    padding-top: 10px;
}
.serial-modal__tools summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #7C3AED;
    list-style: none;
    user-select: none;
}
.serial-modal__tools summary::-webkit-details-marker { display: none; }
.serial-modal__tools summary::before { content: '+ '; font-weight: 700; }
.serial-modal__tools[open] summary::before { content: '– '; }

.serial-modal__tools-body { padding-top: 10px; }
.serial-modal__tools-body textarea {
    width: 100%;
    border: 1px solid #E2E6EE;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #0F172A;
    background: #fff;
    resize: vertical;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.serial-modal__tools-body textarea::placeholder {
    color: #64748B;   /* #A3AEC0 measured 2.24:1 on white — unreadable */
}
.serial-modal__tools-body textarea:focus {
    outline: none;
    border-color: #7C3AED;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.serial-modal__tools-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.serial-modal__gen {
    display: grid;
    grid-template-columns: 1.6fr .8fr .8fr .7fr auto;
    gap: 6px;
    margin-top: 10px;
}
.serial-modal__gen input {
    min-width: 0;
    height: 34px;
    border: 1px solid #E2E6EE;
    border-radius: 7px;
    padding: 0 9px;
    font-size: 12px;
    color: #0F172A;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.serial-modal__gen input::placeholder {
    color: #64748B;   /* #A3AEC0 measured 2.24:1 on white — unreadable */
}
.serial-modal__gen input:focus {
    outline: none;
    border-color: #7C3AED;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.serial-modal__gen-preview {
    margin-top: 6px;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-size: 11.5px;
    /* #94A3B8 sat at 2.6:1 on white, under the 4.5:1 readable threshold */
    color: #64748B;
}

/* Footer */
.serial-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 13px 18px;
    border-top: 1px solid #EEF0F5;
    background: #FAFBFD;
}
.serial-modal__foot .btn {
    min-width: 118px;
    height: 40px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 13.5px;
}
.serial-modal__foot .btn-primary {
    background: #7C3AED;
    border-color: #7C3AED;
}
.serial-modal__foot .btn-primary:hover:not(:disabled) {
    background: #5B21B6;
    border-color: #5B21B6;
}
.serial-modal__foot .btn-primary:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ------------------------------------------------------------------
   Touch / small screens
   ------------------------------------------------------------------ */
@media (max-width: 575px) {
    .serial-modal .modal-dialog { margin: 10px auto; }
    .serial-modal__meta { flex-wrap: wrap; }
    .serial-modal__meta-item { flex: 1 1 33%; }
    .serial-modal__gen { grid-template-columns: 1fr 1fr; }
    .serial-modal__foot .btn { flex: 1; min-width: 0; }
    .serial-modal__list { max-height: 180px; }
}

@media (hover: none) and (pointer: coarse) {
    .serial_manage_btn { padding: 8px 12px; }
    .serial-modal__remove { width: 34px; height: 34px; }
    .serial-modal__foot .btn { height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
    .serial-modal__bar span,
    .serial-modal__error,
    .serial_manage_btn { transition: none; }
}

/* ------------------------------------------------------------------
   Bulk tools row
   ------------------------------------------------------------------
   The Add-to-list button and the file input inherited the app theme's
   button colours, which are built for a page background rather than
   the white modal. Pinned here so the whole panel reads as one piece.
   ------------------------------------------------------------------ */
.serial-modal__tools-row .btn {
    height: 34px;
    padding: 0 12px;
    border: 1px solid #D9DEE7;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    line-height: 32px;
}
.serial-modal__tools-row .btn:hover,
.serial-modal__tools-row .btn:focus {
    border-color: #7C3AED;
    background: #F6F2FE;
    color: #5B21B6;
}
.serial-modal__tools-row .btn i {
    margin-inline-end: 4px;
}

.serial-modal__tools-row input[type="file"] {
    font-size: 12px;
    color: #334155;
    max-width: 100%;
}


/* ------------------------------------------------------------------
   Picker checkboxes
   ------------------------------------------------------------------
   Drawn here rather than left to the browser. The root now declares
   color-scheme: light, which fixes these on its own; this keeps them
   in the app's purple and immune to whatever a browser would do with
   a native box. Empty until ticked — that is the whole point of the
   column, since a filled box means 'this phone is going on the bill'.
   ------------------------------------------------------------------ */
.serial_picker_checkbox {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid #C9CFDD;
    border-radius: 5px;
    background: #fff;
    vertical-align: middle;
    cursor: pointer;
    flex: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.serial_picker_row:hover .serial_picker_checkbox { border-color: #7C3AED; }
.serial_picker_checkbox:focus-visible {
    outline: 2px solid #7C3AED;
    outline-offset: 2px;
}
.serial_picker_checkbox:checked {
    background: #7C3AED;
    border-color: #7C3AED;
}
.serial_picker_checkbox:checked::after {
    content: "";
    position: absolute;
    left: 5.5px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Both IMEIs of a phone sit in one cell, so they need to read as a pair
   of identifiers rather than as prose. */
.serial_picker_results td,
.serial_picker_results th { vertical-align: middle !important; }
.serial_picker_results tbody td:nth-child(2) {
    font-family: ui-monospace, Consolas, Menlo, monospace;
    /* These numbers are what the cashier reads off the handset and checks
       digit by digit, so they are the largest text in the modal, not the
       smallest. */
    font-size: 14.5px;
    font-weight: 600;
    color: #0F172A;
    font-variant-numeric: tabular-nums;
}
.serial_picker_results tbody td { padding-top: 9px !important; padding-bottom: 9px !important; }
.serial_picker_results thead th {
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #475569;
}

@media (prefers-reduced-motion: reduce) {
    .serial_picker_checkbox { transition: none; }
}


/* ------------------------------------------------------------------
   Identifier columns in a details table
   ------------------------------------------------------------------
   A column of 15 digit numbers is only readable if the digits line
   up, which a proportional face will not do.
   ------------------------------------------------------------------ */
.serial_identifier_cell {
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   Print button beside the serial / IMEI table
   ------------------------------------------------------------------
   Sits on the heading baseline rather than above or below it, so the
   heading still reads as one line.
   ------------------------------------------------------------------ */
.serial-print-head {
    display: flex;
    align-items: center;
    gap: 10px 14px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.serial-print-head__title {
    margin: 0;
}

/* Pushed to the far end, so the heading keeps the left edge and the two
   controls read as a pair rather than as more heading. */
.serial-print-head__tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
    flex-wrap: wrap;
}

.serial_table_search {
    width: 240px;
    max-width: 100%;
    height: 28px;
    padding: 0 11px;
    border: 1px solid #D9DEE7;
    border-radius: 7px;
    background: #fff;
    color: #0F172A;
    font-size: 12.5px;
    font-family: ui-monospace, Consolas, Menlo, monospace;
}
.serial_table_search::placeholder {
    /* Lighter greys measured under 3:1 on white and became guesswork */
    color: #64748B;
    font-family: 'DM Sans', 'Hind Siliguri', 'Nirmala UI', system-ui, sans-serif;
}
.serial_table_search:focus {
    outline: none;
    border-color: #7C3AED;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .14);
}

.serial_table_empty {
    margin: 0;
    padding: 18px 0;
    text-align: center;
    font-size: 13px;
    color: #64748B;
}

@media (max-width: 575px) {
    .serial-print-head__tools { margin-inline-start: 0; width: 100%; }
    .serial_table_search { flex: 1; width: auto; }
}

.print_serial_table {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border: 1px solid #D9DEE7;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}
.print_serial_table:hover,
.print_serial_table:focus {
    border-color: #7C3AED;
    background: #F6F2FE;
    color: #5B21B6;
}
.print_serial_table:focus-visible {
    outline: 2px solid #7C3AED;
    outline-offset: 2px;
}
