/* Ajuste de inventario PT por producto */

body.pt-adjust-modal-open {
    overflow: hidden;
}

.pt-adjust-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.5rem, 1.2vw, var(--pv-page-gutter));
    background: color-mix(in srgb, var(--pv-bg-base) 84%, transparent);
    backdrop-filter: var(--pv-glass-blur);
    -webkit-backdrop-filter: var(--pv-glass-blur);
}

.pt-adjust-modal[hidden],
.pt-adjust-exhausted[hidden],
.pt-adjust-alert[hidden],
.pt-adjust-preview[hidden] {
    display: none;
}

.pt-adjust-dialog {
    width: min(1080px, 96vw);
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-card-radius);
    background: var(--pv-card-surface-solid);
    box-shadow: var(--pv-elevation);
    color: var(--pv-text-primary);
    font-family: var(--pv-font-ui);
    font-size: var(--pv-text-sm, 0.78rem);
}

.pt-adjust-header,
.pt-adjust-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--pv-card-border);
}

.pt-adjust-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    border-top: 1px solid var(--pv-card-border);
    border-bottom: 0;
}

.pt-adjust-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
}

.pt-adjust-preview-help {
    max-width: 42rem;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.3;
}

.pt-adjust-preview-help[data-tone="error"] {
    color: var(--pv-red-text);
}

.pt-adjust-preview-help[data-tone="success"] {
    color: var(--pv-green-text);
}

.pt-adjust-eyebrow {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.pt-adjust-header h3 {
    margin: 0.1rem 0 0;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-base, 0.88rem);
    line-height: 1.25;
}

.pt-adjust-header p {
    margin: 0.12rem 0 0;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.3;
}

.pt-adjust-close {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
    color: var(--pv-text-secondary);
    cursor: pointer;
}

.pt-adjust-close:hover,
.pt-adjust-close:focus-visible {
    border-color: var(--pv-accent);
    color: var(--pv-text-primary);
}

.pt-adjust-body {
    padding: 0.7rem 0.85rem;
    overflow: auto;
}

.pt-adjust-alert,
.pt-adjust-preview {
    margin-bottom: 0.55rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.35;
}

.pt-adjust-alert[data-tone="error"],
.pt-adjust-preview[data-tone="error"] {
    border-color: var(--pv-red);
    color: var(--pv-red-text);
}

.pt-adjust-alert[data-tone="success"],
.pt-adjust-preview[data-tone="success"] {
    border-color: var(--pv-green);
    color: var(--pv-green-text);
}

.pt-adjust-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.pt-adjust-summary > div {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
}

.pt-adjust-summary span {
    display: block;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 800;
    text-transform: uppercase;
}

.pt-adjust-summary strong {
    display: block;
    margin-top: 0.1rem;
    color: var(--pv-text-primary);
    font-family: var(--pv-font-mono);
    font-size: var(--pv-text-sm, 0.78rem);
}

#pt-adjust-delta.is-positive {
    color: var(--pv-green-text);
}

#pt-adjust-delta.is-negative {
    color: var(--pv-red-text);
}

#pt-adjust-delta.is-unbalanced {
    color: var(--pv-amber-text);
}

.pt-adjust-mode,
.pt-adjust-bulk,
.pt-adjust-exhausted {
    display: grid;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.55rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-glass-surface);
}

.pt-adjust-mode {
    grid-template-columns: minmax(240px, 1fr) auto;
}

.pt-adjust-mode-options {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
}

.pt-adjust-mode-options label {
    position: relative;
    cursor: pointer;
}

.pt-adjust-mode-options input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.pt-adjust-mode-options span {
    min-height: 1.55rem;
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border: 1px solid transparent;
    border-radius: calc(var(--pv-input-radius) - 2px);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 750;
    white-space: nowrap;
    transition: border-color var(--pv-duration-fast) var(--pv-ease-out),
        color var(--pv-duration-fast) var(--pv-ease-out),
        background var(--pv-duration-fast) var(--pv-ease-out);
}

.pt-adjust-mode-options input:checked + span {
    border-color: var(--pv-accent);
    background: var(--pv-glass-surface);
    color: var(--pv-accent-cyan);
}

.pt-adjust-mode-options input:focus-visible + span {
    outline: 2px solid var(--pv-accent);
    outline-offset: 1px;
}

.pt-adjust-mode-options input:disabled + span {
    opacity: 0.45;
    cursor: not-allowed;
}

.pt-adjust-bulk {
    grid-template-columns: minmax(240px, 1fr) minmax(110px, 0.32fr) auto;
}

.pt-adjust-exhausted {
    grid-template-columns: minmax(210px, 1fr) minmax(220px, 0.9fr) auto;
}

.pt-adjust-control-copy strong,
.pt-adjust-control-copy span {
    display: block;
}

.pt-adjust-control-copy strong {
    font-size: var(--pv-text-xs, 0.68rem);
}

.pt-adjust-control-copy span {
    margin-top: 0.08rem;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.25;
}

.pt-adjust-bulk-field {
    display: grid;
    gap: 0.12rem;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 700;
}

.pt-adjust-table-wrap {
    max-height: min(460px, 50vh);
    overflow: auto;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
}

.pt-adjust-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.25;
}

.pt-adjust-table th,
.pt-adjust-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--pv-card-border);
    vertical-align: middle;
}

.pt-adjust-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--pv-card-surface-solid);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 800;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
}

.pt-adjust-table tbody tr:last-child td {
    border-bottom: 0;
}

.pt-adjust-table tbody tr.is-focused td {
    background: var(--pv-glass-surface);
}

.pt-adjust-number {
    text-align: right !important;
    font-family: var(--pv-font-mono);
}

.pt-adjust-target-wrap {
    display: grid;
    justify-items: end;
    gap: 0.05rem;
}

.pt-adjust-target-wrap small {
    color: var(--pv-text-secondary);
    font-family: var(--pv-font-ui);
    font-size: var(--pv-text-xs, 0.68rem);
    line-height: 1.15;
}

.pt-adjust-input {
    width: 100%;
    min-height: 1.9rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
    color: var(--pv-text-primary);
    font: inherit;
    outline: none;
}

textarea.pt-adjust-input {
    min-height: 3rem;
    resize: vertical;
}

.pt-adjust-input:focus,
.pt-adjust-input:focus-visible {
    border-color: var(--pv-accent);
    box-shadow: var(--pv-glow-accent);
}

.pt-adjust-input[aria-invalid="true"] {
    border-color: var(--pv-red);
}

.pt-adjust-target {
    width: 6rem;
    text-align: right;
    font-family: var(--pv-font-mono);
}

.pt-adjust-diff.is-positive {
    color: var(--pv-green-text);
}

.pt-adjust-diff.is-negative {
    color: var(--pv-red-text);
}

.pt-adjust-status {
    display: inline-flex;
    align-items: center;
    min-height: 1.25rem;
    padding: 0 0.4rem;
    border-radius: var(--pv-input-radius);
    background: var(--pv-glass-surface);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 700;
    white-space: nowrap;
}

.pt-adjust-status.is-positive {
    color: var(--pv-green-text);
}

.pt-adjust-status.is-negative,
.pt-adjust-status.is-invalid {
    color: var(--pv-red-text);
}

.pt-adjust-status.is-reactivated,
.pt-adjust-status.is-unbalanced {
    color: var(--pv-amber-text);
}

.pt-adjust-empty {
    padding: 1rem !important;
    color: var(--pv-text-secondary);
    text-align: center;
}

.pt-adjust-form {
    display: grid;
    grid-template-columns: minmax(220px, 0.75fr) minmax(300px, 1.25fr);
    gap: 0.55rem;
    margin-top: 0.55rem;
}

.pt-adjust-form label {
    display: grid;
    align-content: start;
    gap: 0.2rem;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 700;
}

.pt-adjust-preview {
    margin-top: 0.55rem;
    margin-bottom: 0;
}

.pt-adjust-preview p {
    margin: 0.15rem 0 0;
}

.pt-adjust-preview ul {
    margin: 0.3rem 0 0;
    padding-left: 1.2rem;
}

.pt-adjust-button,
.pt-adjust-trigger {
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
    color: var(--pv-text-secondary);
    font-family: var(--pv-font-ui);
    font-size: var(--pv-text-xs, 0.68rem);
    font-weight: 700;
    cursor: pointer;
    transition: border-color var(--pv-duration-fast) var(--pv-ease-out),
        color var(--pv-duration-fast) var(--pv-ease-out),
        background var(--pv-duration-fast) var(--pv-ease-out);
}

.pt-adjust-trigger {
    min-height: 1.65rem;
    padding: 0.2rem 0.4rem;
    font-size: var(--pv-text-xs, 0.68rem);
}

.pt-adjust-trigger .material-symbols-outlined,
.pt-adjust-close .material-symbols-outlined {
    font-size: 0.9rem;
    line-height: 1;
}

.pt-adjust-trigger--parent {
    color: var(--pv-accent-cyan);
}

.pt-lot-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.pt-reassign-history-trigger {
    width: 1.8rem;
    min-width: 1.8rem;
    padding-inline: 0;
    color: var(--pv-amber-text);
}

.pt-adjust-button:hover,
.pt-adjust-button:focus-visible,
.pt-adjust-trigger:hover,
.pt-adjust-trigger:focus-visible {
    border-color: var(--pv-accent);
    color: var(--pv-text-primary);
    outline: none;
}

.pt-adjust-button--primary {
    border-color: var(--pv-accent);
    background: var(--pv-accent);
    color: var(--pv-text-primary);
}

.pt-adjust-button--primary:hover,
.pt-adjust-button--primary:focus-visible {
    border-color: var(--pv-accent-hover);
    background: var(--pv-accent-hover);
}

.pt-adjust-button--secondary {
    color: var(--pv-accent-cyan);
}

.pt-adjust-button--ghost {
    background: transparent;
}

.pt-adjust-button:disabled,
.pt-adjust-trigger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pt-adjust-remove {
    min-width: 2rem;
    padding-inline: 0.4rem;
    color: var(--pv-red-text);
}

.pt-adjust-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    .pt-adjust-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pt-adjust-mode,
    .pt-adjust-bulk,
    .pt-adjust-exhausted,
    .pt-adjust-form {
        grid-template-columns: 1fr;
    }

    .pt-adjust-dialog {
        width: 100%;
        max-height: 96vh;
    }

    .pt-adjust-footer {
        grid-template-columns: 1fr;
    }

    .pt-adjust-footer-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .pt-adjust-summary {
        grid-template-columns: 1fr;
    }

    .pt-adjust-footer {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pt-adjust-button,
    .pt-adjust-trigger {
        transition: none;
    }
}
