/**
 * Price tag batches (web/index.html).
 *
 * The screen is a hub for a three-step job — create a batch, fill it with products,
 * print it — so the printing action lives on every row instead of being buried one
 * click deeper, and the batch state (items, PDFs generated) is readable at a glance.
 */

.filter-chip {
    padding: 8px 14px;
    border: 1px solid var(--color-slate-border);
    border-radius: var(--radius-badges);
    background: var(--color-paper-white);
    color: var(--color-graphite);
    font-family: var(--font-inter);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--motion-control) var(--motion-ease), color var(--motion-control) var(--motion-ease), border-color var(--motion-control) var(--motion-ease);
}

.filter-chip:hover {
    background: var(--color-light-gray);
    color: var(--color-absolute-black);
}

.filter-chip.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-paper-white);
}

.tag-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.tag-head p {
    margin: 0;
    color: var(--color-graphite);
    font-size: 0.92rem;
}

/* ─── The job, in three steps ─────────────────────────────────────────────── */

.tag-workflow {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0 24px;
    padding: 12px 16px;
    background: var(--color-light-gray);
    border: 1px solid var(--color-silver-mist);
    border-radius: 14px;
    font-size: 0.85rem;
    color: var(--color-graphite);
}

.tag-workflow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tag-workflow-step svg {
    width: 16px;
    height: 16px;
    color: var(--color-primary);
}

.tag-workflow-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-paper-white);
    border: 1px solid var(--color-slate-border);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-graphite);
}

.tag-workflow-arrow {
    color: #b9bdc4;
}

/* ─── Toolbar ─────────────────────────────────────────────────────────────── */

.tag-card {
    background: var(--color-paper-white);
    border: 1px solid var(--color-silver-mist);
    border-radius: var(--radius-cards);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.tag-card:hover {
    transform: none;
}

.tag-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-silver-mist);
}

.tag-search {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}

.tag-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-graphite);
    pointer-events: none;
}

.tag-search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border: 1px solid var(--color-slate-border);
    border-radius: var(--radius-inputs);
    background: var(--color-paper-white);
    font-family: var(--font-inter);
    font-size: 0.9rem;
    color: var(--color-absolute-black);
    box-sizing: border-box;
}

.tag-search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.tag-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-sort label {
    font-size: 0.8rem;
    color: var(--color-graphite);
    white-space: nowrap;
}

.tag-sort select {
    padding: 8px 10px;
    border: 1px solid var(--color-slate-border);
    border-radius: var(--radius-inputs);
    background: var(--color-paper-white);
    font-family: var(--font-inter);
    font-size: 0.85rem;
    color: var(--color-absolute-black);
}

.tag-sort select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.tag-toolbar-tail {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.tag-count {
    font-size: 0.82rem;
    color: var(--color-graphite);
    white-space: nowrap;
}

.tag-clear {
    border: none;
    background: transparent;
    padding: 4px 2px;
    color: var(--color-primary);
    font-family: var(--font-inter);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tag-clear[hidden] {
    display: none;
}

/* ─── Selection ───────────────────────────────────────────────────────────── */

/* Tinted, not shouting: it only appears once a row is ticked, and the buttons in it
   are the two things a tick can lead to. */
.tag-selection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: var(--color-primary-light);
    border-bottom: 1px solid var(--color-silver-mist);
}

/* The bar is hidden with the attribute, so it must not be able to outrank it. */
.tag-selection[hidden] {
    display: none;
}

.tag-selection-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tag-selection-count {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-absolute-black);
}

.tag-selection-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-graphite);
}

.tag-selection-hint[hidden] {
    display: none;
}

.tag-selection-hint svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.tag-selection-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.tag-selection-actions .btn {
    flex: none;
}

/* A blocked action has to look blocked: a full brand-red button that does nothing when
   pressed is the worst of both worlds. */
.tag-selection .btn:disabled,
.tag-selection .btn:disabled:hover {
    background: var(--color-silver-mist);
    border-color: var(--color-silver-mist);
    color: var(--color-graphite);
    cursor: not-allowed;
    box-shadow: none;
}

.tag-select-all {
    border: none;
    background: transparent;
    padding: 4px 2px;
    color: var(--color-primary);
    font-family: var(--font-inter);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tag-select-all[hidden] {
    display: none;
}

/* ─── Table ───────────────────────────────────────────────────────────────── */

.tag-table {
    width: 100%;
    border-collapse: collapse;
}

.tag-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-graphite);
    background: var(--color-light-gray);
    border-bottom: 1px solid var(--color-silver-mist);
    white-space: nowrap;
}

.tag-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-silver-mist);
    font-size: 0.9rem;
    vertical-align: middle;
}

.tag-table tbody tr:last-child td {
    border-bottom: none;
}

.tag-table tbody tr {
    transition: background var(--motion-fast) var(--motion-ease);
}

.tag-table tbody tr:hover td {
    background: var(--surface-plain);
}

.tag-table th:first-child,
.tag-table td:first-child {
    padding-left: 20px;
}

.tag-table th:last-child,
.tag-table td:last-child {
    padding-right: 20px;
}

.tag-table .col-actions {
    text-align: right;
    white-space: nowrap;
}

/* The tick column: deliberately narrow, and the label around the box enlarges the
   touch target without enlarging the box. */
.tag-table .col-select {
    width: 1%;
    white-space: nowrap;
}

.tag-select-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    margin: -6px;
    cursor: pointer;
}

.tag-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.tag-table input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.tag-table tbody tr.is-selected td {
    background: var(--color-primary-light);
}

/* The batch name is the one real link in the row: a new tab, a copied URL and the
   keyboard all work on it. */
.tag-name {
    display: inline-block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
}

.tag-name:hover {
    text-decoration: underline;
}

.tag-name:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.tag-name-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--color-graphite);
}

.tag-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-badges);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--color-sky-tint);
    color: var(--color-agent-blue);
    white-space: nowrap;
}

.tag-type-chip.is-default {
    background: var(--color-silver-mist);
    color: var(--color-graphite);
}

.tag-items {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tag-items-value {
    font-weight: 700;
    font-size: 1rem;
}

.tag-items-unit {
    font-size: 0.78rem;
    color: var(--color-graphite);
}

.tag-items-empty {
    font-size: 0.82rem;
    color: var(--warning-fg-soft);
    /* The tick column is one column narrower than it used to be: "no products yet"
       has to stay on one line, not break in the middle of a word. */
    white-space: nowrap;
}

.tag-pdf {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.82rem;
    color: var(--color-graphite);
}

.tag-pdf-times {
    font-weight: 600;
    color: var(--color-absolute-black);
}

/* The stored file: quiet enough to sit under the counter, but a real button — it is how
   the exact file from last time is fetched without printing it again. */
.tag-pdf-stored {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    margin-top: 2px;
    padding: 2px 8px;
    border: 1px solid var(--color-slate-border);
    border-radius: 999px;
    background: var(--color-light-gray);
    color: var(--color-graphite);
    font: inherit;
    font-size: 0.74rem;
    cursor: pointer;
    white-space: nowrap;
}

.tag-pdf-stored:hover {
    background: var(--color-silver-mist);
    color: var(--color-absolute-black);
}

.tag-date {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.85rem;
    color: var(--color-graphite);
}

.tag-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Icon-only row actions, named the same as the user administration screen so the two
   pages read as one product. */
.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--color-slate-border);
    border-radius: 9px;
    background: var(--color-paper-white);
    color: var(--color-graphite);
    cursor: pointer;
    transition: background var(--motion-control) var(--motion-ease), color var(--motion-control) var(--motion-ease), border-color var(--motion-control) var(--motion-ease);
}

.icon-action svg {
    width: 16px;
    height: 16px;
}

.icon-action:hover {
    background: var(--color-light-gray);
    color: var(--color-absolute-black);
    border-color: var(--color-graphite);
}

.icon-action:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.icon-action-danger {
    color: var(--danger-solid);
    border-color: var(--danger-border);
}

.icon-action-danger:hover {
    background: var(--danger-surface-strong);
    color: var(--danger-fg-strong);
    border-color: var(--danger-border);
}

.tag-open {
    padding: 8px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.tag-download {
    padding: 8px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* A batch with nothing to print keeps its action in place but out of reach. It used
   to look exactly like the working button — full brand red and a pointer cursor — so
   the only answer to a tap was silence. The reason stays visible in the product
   column and the tooltip, and the label goes quiet instead of shouting. */
.tag-download:disabled,
.tag-download:disabled:hover {
    background: var(--color-silver-mist);
    color: var(--color-graphite);
    border-color: transparent;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ─── Loading, empty and error states ────────────────────────────────────── */

/* The state block brings its own spacing, so the cell must not add more. */
.tag-state-cell {
    padding: 0 !important;
    border-bottom: none !important;
}

.tag-skeleton-row td {
    padding: 18px 16px;
}

/* lucide keeps the class when it swaps the placeholder for the icon. */
.tag-spin {
    animation: spin var(--motion-spin) linear infinite;
}

.tag-download.is-busy {
    opacity: 0.85;
    cursor: progress;
}

.tag-skeleton {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-muted) 25%, #e7e7ea 37%, var(--surface-muted) 63%);
    background-size: 400% 100%;
    animation: tag-shimmer 1.4s ease-in-out infinite;
}

@keyframes tag-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.tag-state {
    padding: 52px 24px;
    text-align: center;
}

.tag-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-light-gray);
    color: var(--color-graphite);
    margin-bottom: 14px;
}

.tag-state-icon svg {
    width: 22px;
    height: 22px;
}

.tag-state h4 {
    margin: 0 0 6px;
    font-size: 1.02rem;
}

.tag-state p {
    margin: 0 auto 16px;
    max-width: 380px;
    color: var(--color-graphite);
    font-size: 0.88rem;
}

.tag-state.is-error .tag-state-icon {
    background: var(--danger-surface-strong);
    color: var(--danger-fg-strong);
}

/* ─── Pagination ──────────────────────────────────────────────────────────── */

.tag-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--color-silver-mist);
    background: var(--color-paper-white);
}

.tag-pagination[hidden] {
    display: none;
}

.tag-page-status {
    font-size: 0.82rem;
    color: var(--color-graphite);
}

.tag-pages {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--color-slate-border);
    border-radius: 9px;
    background: var(--color-paper-white);
    color: var(--color-absolute-black);
    font-family: var(--font-inter);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--motion-control) var(--motion-ease), border-color var(--motion-control) var(--motion-ease);
}

.tag-page-btn:hover:not(:disabled) {
    background: var(--color-light-gray);
}

.tag-page-btn.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-paper-white);
    font-weight: 700;
}

.tag-page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ─── Dialog ──────────────────────────────────────────────────────────────── */

.tag-modal {
    display: flex;
    flex-direction: column;
    max-width: 500px;
    width: 92%;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.35);
}

.tag-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 14px;
    border-bottom: 1px solid var(--color-silver-mist);
}

.tag-modal-head h3 {
    margin: 0;
    font-size: 1.12rem;
}

.tag-modal-head .tag-modal-sub {
    margin: 4px 0 0;
    color: var(--color-graphite);
    font-size: 0.82rem;
}

.tag-modal-body {
    padding: 18px 24px;
    overflow-y: auto;
}

.tag-modal .modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-graphite);
    cursor: pointer;
}

.tag-modal .modal-close:hover {
    background: var(--color-light-gray);
    color: var(--color-absolute-black);
}

.tag-modal .modal-close svg {
    width: 18px;
    height: 18px;
}

.tag-field {
    margin-bottom: 16px;
}

.tag-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.tag-field .input-field {
    background: var(--color-paper-white);
}

.tag-field.error .input-field {
    border-color: var(--danger-solid);
    box-shadow: 0 0 0 3px var(--danger-surface-strong);
}

.tag-field-hint {
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--color-graphite);
}

.tag-field-error {
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--danger-fg);
    font-weight: 600;
}

.tag-field-error[hidden],
.tag-field-warning[hidden] {
    display: none;
}

.tag-field-warning {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--warning-fg-soft);
}

.tag-field-warning svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tag-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-silver-mist);
    background: var(--color-light-gray);
}

.tag-modal-foot .btn {
    padding: 10px 20px;
}

.tag-modal-error {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: var(--radius-inputs);
    background: var(--danger-surface);
    border: 1px solid var(--danger-border);
    color: var(--danger-fg-strong);
    font-size: 0.83rem;
}

.tag-modal-error svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tag-modal-error[hidden] {
    display: none;
}

/* The delete dialog names the batch and what goes with it. */
.tag-confirm-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.tag-confirm-text strong {
    color: var(--color-absolute-black);
}

.tag-confirm-meta {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: var(--radius-inputs);
    background: var(--color-light-gray);
    font-size: 0.82rem;
    color: var(--color-graphite);
}

/* A dialog that blocks the row underneath it must not look like part of the row. */
body.tag-dialog-open {
    overflow: hidden;
}

/* ─── Phone ───────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .tag-head {
        flex-direction: column;
        align-items: stretch;
    }

    .tag-head .btn {
        justify-content: center;
    }

    .tag-workflow {
        font-size: 0.8rem;
    }

    /* The table becomes one card per batch: a five column table on a phone is a
       horizontal scroll with the actions off screen. */
    .tag-table thead {
        display: none;
    }

    .tag-table,
    .tag-table tbody,
    .tag-table tr,
    .tag-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .tag-table tbody tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--color-silver-mist);
    }

    .tag-table tbody tr:last-child {
        border-bottom: none;
    }

    .tag-table td {
        padding: 3px 0;
        border: none;
        font-size: 0.88rem;
    }

    .tag-table td[data-label]:not(:first-child)::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 88px;
        color: var(--color-graphite);
        font-size: 0.78rem;
    }

    .tag-table td:first-child {
        padding: 0 0 6px;
    }

    /* The tick sits on its own line above the batch name, where a thumb can reach it. */
    .tag-table td.col-select {
        padding: 0 0 8px;
    }

    .tag-select-label {
        margin: 0;
        padding: 2px 0;
    }

    .tag-table input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .tag-selection {
        padding: 12px 16px;
    }

    .tag-selection-actions {
        margin-left: 0;
        width: 100%;
    }

    .tag-selection-actions .btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .tag-table td.col-actions {
        margin-top: 10px;
        text-align: left;
    }

    .tag-row-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .tag-open,
    .tag-download {
        flex: 1 1 140px;
    }

    .tag-name {
        max-width: 100%;
        white-space: normal;
        font-size: 1rem;
    }

    .tag-toolbar {
        padding: 14px 16px;
    }

    .tag-toolbar-tail {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .tag-pagination {
        padding: 12px 16px;
    }
}