/*
 * WC Herroeping - Frontend styles
 *
 * Scope: all rules nested under `.wch-form` so styles do not leak into the
 * surrounding theme. Override any `--wch-*` variable in your theme (or via
 * the Custom CSS field in the plugin settings) to restyle without forking.
 *
 * Default look:
 *   No border radius. Transparent backgrounds. Black borders.
 *   Primary blue #015D91 with #faab4b chevron accent.
 *   Text #232323.
 */

.wch-form {
    /* Colour tokens */
    --wch-color-text: #232323;
    --wch-color-muted: #6b6b6b;
    --wch-color-border: #000000;
    --wch-color-border-focus: #015D91;
    --wch-color-bg: transparent;
    --wch-color-bg-subtle: transparent;
    --wch-color-bg-disabled: #f3f4f6;
    --wch-color-primary: #015D91;
    --wch-color-primary-hover: #014875;
    --wch-color-primary-text: #ffffff;
    --wch-color-accent: #faab4b;
    --wch-color-error: #b91c1c;
    --wch-color-error-bg: #fef2f2;
    --wch-color-success: #047857;
    --wch-color-success-bg: #ecfdf5;

    /* Spacing & sizing */
    --wch-spacing-xs: 0.25rem;
    --wch-spacing-sm: 0.5rem;
    --wch-spacing-md: 1rem;
    --wch-spacing-lg: 1.5rem;
    --wch-radius: 0;
    --wch-font-size: 1rem;
    --wch-font-size-sm: 0.875rem;
    --wch-line-height: 1.5;
    --wch-max-width: 48rem;
    /* Left-aligned by default. Override to "0 auto" to centre the form. */
    --wch-form-margin: 0;

    box-sizing: border-box;
    max-width: var(--wch-max-width);
    margin: var(--wch-form-margin);
    color: var(--wch-color-text);
    font-size: var(--wch-font-size);
    line-height: var(--wch-line-height);
}

.wch-form *,
.wch-form *::before,
.wch-form *::after {
    box-sizing: border-box;
}

/* Step titles */

.wch-step-title {
    margin: 0 0 var(--wch-spacing-sm);
    color: var(--wch-color-text);
    font-size: 1.5rem;
    line-height: 1.3;
}

.wch-step-title:focus {
    outline: none;
}

.wch-step-intro {
    margin: 0 0 var(--wch-spacing-lg);
    color: var(--wch-color-muted);
}

/* Fields */

.wch-field {
    margin-bottom: var(--wch-spacing-md);
}

.wch-label {
    display: block;
    margin-bottom: var(--wch-spacing-xs);
    font-weight: 600;
}

.wch-input {
    display: block;
    width: 100%;
    border: 1px solid #000 !important;
    border-radius: 0 !important;
    color: #000000 !important;
    padding: 20px !important;
    background-color: #ffffff00 !important;
    font: inherit;
    line-height: var(--wch-line-height);
}

.wch-input:focus {
    outline: 2px solid var(--wch-color-border-focus);
    outline-offset: 1px;
}

.wch-input[aria-invalid="true"] {
    outline: 2px solid var(--wch-color-error);
    outline-offset: 1px;
}

.wch-help {
    margin: var(--wch-spacing-xs) 0 0;
    color: var(--wch-color-muted);
    font-size: var(--wch-font-size-sm);
}

/* Turnstile container */

.wch-turnstile {
    margin: var(--wch-spacing-md) 0;
    min-height: 65px;
}

.wch-turnstile:empty {
    min-height: 0;
}

/* Messages (errors and notices) */

.wch-messages {
    margin: var(--wch-spacing-md) 0;
    padding: 0;
    color: var(--wch-color-error);
    font-size: var(--wch-font-size-sm);
}

.wch-messages:empty {
    display: none;
}

.wch-message {
    padding: var(--wch-spacing-sm) var(--wch-spacing-md);
    background: var(--wch-color-error-bg);
    border-left: 3px solid var(--wch-color-error);
}

.wch-message-info {
    color: var(--wch-color-text);
    background: #E2F2FD;
    border-left: 3px solid var(--wch-color-primary);
}

.wch-messages:has(.wch-message-info) {
    color: var(--wch-color-text);
}

/* Actions and buttons */

.wch-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wch-spacing-md);
    align-items: center;
    margin-top: var(--wch-spacing-lg);
}

.wch-button {
    display: inline-block;
    padding: var(--wch-spacing-sm) var(--wch-spacing-lg);
    background: transparent;
    color: inherit;
    border: 1px solid transparent;
    border-radius: 0;
    font: inherit;
    font-weight: 600;
    line-height: var(--wch-line-height);
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.wch-button:focus {
    outline: 2px solid var(--wch-color-border-focus);
    outline-offset: 2px;
}

.wch-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wch-button-primary {
    background: var(--wch-color-primary);
    color: var(--wch-color-primary-text);
    border-color: var(--wch-color-primary);
    padding: 18px 28px;
    font-weight: 500;
}

.wch-button-primary:hover:not(:disabled),
.wch-button-primary:focus {
    background: var(--wch-color-primary-hover);
    border-color: var(--wch-color-primary-hover);
}

.wch-button-primary::after {
    content: " \203A"; /* › chevron */
    margin-left: 10px;
    color: var(--wch-color-accent);
    font-weight: 700;
}

.wch-button-link {
    background: transparent;
    color: var(--wch-color-text);
    border-color: transparent;
    padding-left: 0;
    padding-right: 0;
    text-decoration: underline;
}

.wch-button-link:hover:not(:disabled) {
    color: var(--wch-color-primary);
}

/* Scope radio options */

.wch-scope-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wch-spacing-md);
    margin-bottom: var(--wch-spacing-lg);
}

.wch-scope-option {
    display: inline-flex;
    align-items: center;
    gap: var(--wch-spacing-sm);
    padding: var(--wch-spacing-sm) var(--wch-spacing-md);
    background: var(--wch-color-bg-subtle);
    color: var(--wch-color-text);
    border: 1px solid var(--wch-color-border);
    cursor: pointer;
}

.wch-scope-option input[type="radio"] {
    margin: 0;
}

.wch-scope-option:has(input:checked) {
    border-color: var(--wch-color-primary);
    border-width: 2px;
    padding: calc(var(--wch-spacing-sm) - 1px) calc(var(--wch-spacing-md) - 1px);
}

/* Items table */

.wch-items-table {
    width: 100%;
    margin: 0 0 var(--wch-spacing-lg);
    border-collapse: collapse;
    border: 1px solid var(--wch-color-border);
}

.wch-items-table caption {
    margin-bottom: var(--wch-spacing-sm);
    padding: 0;
    color: var(--wch-color-text);
    font-weight: 600;
    text-align: left;
    caption-side: top;
}

.wch-items-table thead th {
    padding: var(--wch-spacing-sm) var(--wch-spacing-md);
    background: var(--wch-color-bg-subtle);
    border-bottom: 1px solid var(--wch-color-border);
    color: var(--wch-color-muted);
    font-size: var(--wch-font-size-sm);
    font-weight: 600;
    text-align: left;
}

.wch-items-table tbody td {
    padding: var(--wch-spacing-sm) var(--wch-spacing-md);
    vertical-align: middle;
    border-top: 1px solid var(--wch-color-border);
}

.wch-items-table tbody tr:first-child td {
    border-top: none;
}

.wch-col-select {
    width: 56px;
    text-align: center;
}

.wch-col-select input[type="checkbox"] {
    width: 1.5em;
    height: 1.5em;
    cursor: pointer;
    accent-color: var(--wch-color-primary);
}

.wch-col-select input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.wch-col-image {
    width: 80px;
}

.wch-col-image img {
    display: block;
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.wch-col-product .wch-item-name {
    font-weight: 600;
}

.wch-col-product .wch-item-block-reason {
    display: block;
    margin-top: var(--wch-spacing-xs);
    color: var(--wch-color-muted);
    font-size: var(--wch-font-size-sm);
    font-style: italic;
}

.wch-col-qty {
    width: 80px;
    text-align: right;
}

.wch-quantity-input {
    width: 64px;
    padding: var(--wch-spacing-xs) var(--wch-spacing-sm);
    border: 1px solid var(--wch-color-border);
    border-radius: 0;
    font: inherit;
    text-align: center;
    background: transparent;
    color: var(--wch-color-text);
}

.wch-quantity-input:focus {
    outline: 2px solid var(--wch-color-border-focus);
    outline-offset: 1px;
}

.wch-quantity-input:disabled {
    background: var(--wch-color-bg-disabled);
    color: var(--wch-color-muted);
    cursor: not-allowed;
}

.wch-quantity-fixed {
    display: inline-block;
    color: var(--wch-color-muted);
}

/* Blocked rows */

.wch-item-blocked {
    background: var(--wch-color-bg-disabled);
    color: var(--wch-color-muted);
}

.wch-item-blocked .wch-col-product .wch-item-name {
    color: var(--wch-color-muted);
}

/* Confirmation step */

.wch-step-confirmed {
    padding: var(--wch-spacing-lg);
    background: #ffffff;
    border: 1px solid var(--wch-color-primary);
}

.wch-step-confirmed .wch-step-title {
    color: var(--wch-color-primary);
}

/* Busy state */

.wch-form[data-state="busy"] .wch-actions button,
.wch-form[data-state="busy"] .wch-input,
.wch-form[data-state="busy"] input[type="checkbox"],
.wch-form[data-state="busy"] input[type="radio"] {
    opacity: 0.6;
    pointer-events: none;
}

/* Visually hidden helper for screen readers */

.wch-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;
}

/* Mobile-responsive: tighter padding and smaller thumbnail on narrow screens */

@media (max-width: 480px) {
    .wch-items-table thead th,
    .wch-items-table tbody td {
        padding: var(--wch-spacing-sm) var(--wch-spacing-sm);
    }

    .wch-col-image {
        width: 60px;
    }

    .wch-col-image img {
        width: 48px;
        height: 48px;
    }

    .wch-col-qty {
        width: 64px;
    }

    .wch-button-primary {
        width: 100%;
        padding: 16px 20px;
    }
}
