:root {
    --papak-red: #ef4056;
    --papak-red-dark: #d92d45;
    --papak-ink: #232933;
    --papak-muted: #626b79;
    --papak-line: #e6e8ec;
    --papak-surface: #f7f7f8;
}

.papak-waitlist-card,
.papak-waitlist-modal,
.papak-account-waitlists {
    box-sizing: border-box;
    font-family: inherit;
}

.papak-waitlist-card *,
.papak-waitlist-modal *,
.papak-account-waitlists * {
    box-sizing: border-box;
}

.papak-waitlist-card {
    direction: rtl;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    border: 1px solid var(--papak-line);
    border-radius: 12px;
    background: var(--papak-surface);
    color: var(--papak-ink);
}

.papak-waitlist-card__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    color: var(--papak-red);
}

.papak-waitlist-card__icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.papak-waitlist-card__copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.papak-waitlist-card__copy strong {
    color: var(--papak-ink);
    font-size: 14px;
    line-height: 1.7;
}

.papak-waitlist-card__copy span {
    color: var(--papak-muted);
    font-size: 12px;
    line-height: 1.8;
}

.papak-waitlist-card__button {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    background: var(--papak-red);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    transition: background-color 160ms ease, transform 160ms ease;
}

.papak-waitlist-card__button:hover,
.papak-waitlist-card__button:focus-visible {
    background: var(--papak-red-dark);
    color: #fff;
}

.papak-waitlist-card__button:active {
    transform: translateY(1px);
}

.papak-waitlist-card.is-subscribed .papak-waitlist-card__button {
    background: #078f60;
}

/* Woodmart sets display:grid on the card, which otherwise overrides [hidden]. */
.papak-waitlist-card[hidden] {
    display: none !important;
}

/* Variable products: shown in place of Woodmart's add-to-cart control. */
.papak-waitlist-replace-cart {
    display: block;
    width: 100%;
    min-height: 46px;
    margin-top: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--papak-red);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.papak-waitlist-replace-cart:hover,
.papak-waitlist-replace-cart:focus-visible {
    background: var(--papak-red-dark);
    color: #fff;
}

.papak-waitlist-replace-cart[hidden] {
    display: none !important;
}

/* Woodmart applies display:flex to these controls, overriding the browser's
 * native [hidden] rule. Enforce the replacement state for unavailable items. */
.variations_form .woocommerce-variation-add-to-cart[hidden],
.variations_form .woocommerce-variation-add-to-cart[hidden] .single_add_to_cart_button,
.variations_form .woocommerce-variation-add-to-cart[hidden] .quantity {
    display: none !important;
}

/* Do not show WooCommerce's stock warning beside the replacement action. */
.variations_form.papak-waitlist-oos-active .woocommerce-variation-availability,
.variations_form.papak-waitlist-oos-active .single_variation > .stock {
    display: none !important;
}

/* Keep an unavailable Woodmart swatch selectable, while making its state clear. */
.variations_form .wd-swatch.papak-waitlist-swatch--sold-out {
    position: relative;
    opacity: .62;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.variations_form .wd-swatch.papak-waitlist-swatch--sold-out::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 8%;
    left: 8%;
    height: 1px;
    background: currentColor;
    transform: rotate(-17deg);
    transform-origin: center;
    pointer-events: none;
}

.variations_form .wd-swatch.papak-waitlist-swatch--selected-oos {
    color: #b42338;
    outline: 2px solid #ef4056;
    outline-offset: 2px;
}

.papak-waitlist-modal[hidden] {
    display: none !important;
}

.papak-waitlist-modal {
    position: fixed;
    z-index: 999999;
    inset: 0;
    direction: rtl;
    display: grid;
    place-items: center;
    padding: 20px;
}

.papak-waitlist-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 22, 29, 0.58);
    backdrop-filter: blur(3px);
    animation: papak-fade-in 180ms ease both;
}

.papak-waitlist-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 24px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(18, 22, 29, 0.24);
    animation: papak-dialog-in 220ms cubic-bezier(.2, .75, .25, 1) both;
}

.papak-waitlist-modal__close {
    position: absolute;
    top: 14px;
    left: 14px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f2f4;
    color: #4d5562;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.papak-waitlist-modal__heading {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 0 18px;
    border-bottom: 1px solid var(--papak-line);
}

.papak-waitlist-modal__product-image {
    flex: 0 0 68px;
    width: 68px;
    height: 68px;
    padding: 4px;
    border: 1px solid var(--papak-line);
    border-radius: 10px;
    background: #fff;
}

.papak-waitlist-modal__product-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.papak-waitlist-modal__heading span {
    display: block;
    margin-bottom: 3px;
    color: var(--papak-red);
    font-size: 11px;
    font-weight: 700;
}

.papak-waitlist-modal__heading h2 {
    margin: 0;
    color: var(--papak-ink);
    font-size: 20px;
    line-height: 1.55;
}

.papak-waitlist-modal__heading p {
    margin: 3px 0 0;
    color: var(--papak-muted);
    font-size: 12px;
    line-height: 1.7;
}

.papak-waitlist-form {
    padding-top: 20px;
}

.papak-waitlist-scopes {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
}

.papak-waitlist-scopes legend {
    margin-bottom: 10px;
    color: var(--papak-ink);
    font-size: 13px;
    font-weight: 700;
}

.papak-waitlist-scope {
    position: relative;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 66px;
    padding: 12px 14px;
    border: 1px solid var(--papak-line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.papak-waitlist-scope > input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.papak-waitlist-scope__check {
    position: relative;
    width: 20px;
    height: 20px;
    border: 2px solid #b7bdc7;
    border-radius: 50%;
}

.papak-waitlist-scope input:checked ~ .papak-waitlist-scope__check {
    border-color: var(--papak-red);
}

.papak-waitlist-scope input:checked ~ .papak-waitlist-scope__check::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--papak-red);
}

.papak-waitlist-scope:has(input:checked) {
    border-color: var(--papak-red);
    background: #fff8f9;
}

.papak-waitlist-scope.is-disabled {
    opacity: 0.58;
    background: #f5f6f7;
    cursor: not-allowed;
}

.papak-waitlist-scope__copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.papak-waitlist-scope__copy strong {
    color: var(--papak-ink);
    font-size: 13px;
    line-height: 1.6;
}

.papak-waitlist-scope__copy small {
    color: var(--papak-muted);
    font-size: 11px;
    line-height: 1.7;
}

.papak-waitlist-variation-state {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f4f5f6;
    color: var(--papak-muted);
    font-size: 11px;
    line-height: 1.8;
}

.papak-waitlist-mobile {
    display: block;
    margin-top: 18px;
}

.papak-waitlist-mobile > span {
    display: block;
    margin-bottom: 7px;
    color: var(--papak-ink);
    font-size: 13px;
    font-weight: 700;
}

.papak-waitlist-mobile input {
    width: 100%;
    height: 50px;
    padding: 0 14px;
    border: 1px solid #cdd1d7;
    border-radius: 8px;
    background: #fff;
    direction: ltr;
    color: var(--papak-ink);
    font: inherit;
    font-size: 15px;
    text-align: left;
    outline: none;
}

.papak-waitlist-mobile input:focus {
    border-color: var(--papak-red);
    box-shadow: 0 0 0 3px rgba(239, 64, 86, 0.12);
}

.papak-waitlist-submit {
    position: relative;
    width: 100%;
    min-height: 50px;
    margin-top: 14px;
    border: 0;
    border-radius: 8px;
    background: var(--papak-red);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.papak-waitlist-submit:hover,
.papak-waitlist-submit:focus-visible {
    background: var(--papak-red-dark);
    color: #fff;
}

.papak-waitlist-submit:disabled {
    cursor: wait;
    opacity: 0.72;
}

.papak-waitlist-submit.is-loading span::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -2px;
    animation: papak-spin 700ms linear infinite;
}

.papak-waitlist-result {
    display: none;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.8;
}

.papak-waitlist-result.is-loading,
.papak-waitlist-result.is-success,
.papak-waitlist-result.is-error {
    display: block;
}

.papak-waitlist-result.is-loading {
    background: #f3f4f6;
    color: #596273;
}

.papak-waitlist-result.is-success {
    background: #eaf8f2;
    color: #08764f;
}

.papak-waitlist-result.is-error {
    background: #fff0f1;
    color: #b42338;
}

.papak-waitlist-privacy {
    margin: 10px 0 0;
    color: #858c98;
    font-size: 10px;
    line-height: 1.8;
    text-align: center;
}

.papak-waitlist-is-open {
    overflow: hidden;
}

/* WooCommerce account page */
.papak-account-waitlists {
    direction: rtl;
}

.papak-account-waitlists__header {
    margin-bottom: 22px;
    padding: 20px 22px;
    border-right: 4px solid var(--papak-red);
    border-radius: 10px;
    background: #f7f7f8;
}

.papak-account-waitlists__header > span {
    color: var(--papak-red);
    font-size: 11px;
    font-weight: 700;
}

.papak-account-waitlists__header h2 {
    margin: 4px 0 5px;
    font-size: 20px;
}

.papak-account-waitlists__header p,
.papak-account-waitlists__empty p {
    margin: 0;
    color: var(--papak-muted);
    font-size: 12px;
    line-height: 1.8;
}

.papak-account-waitlists__grid {
    display: grid;
    gap: 12px;
}

.papak-account-waitlist {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--papak-line);
    border-radius: 12px;
    background: #fff;
}

.papak-account-waitlist__image {
    display: block;
    width: 92px;
    height: 92px;
    padding: 4px;
    border-radius: 8px;
    background: #fafafa;
}

.papak-account-waitlist__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.papak-account-waitlist__content h3 {
    margin: 7px 0 3px;
    font-size: 14px;
    line-height: 1.7;
}

.papak-account-waitlist__content h3 a {
    color: var(--papak-ink);
}

.papak-account-waitlist__content p,
.papak-account-waitlist__content small {
    display: block;
    margin: 0;
    color: var(--papak-muted);
    font-size: 11px;
    line-height: 1.8;
}

.papak-status {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 999px;
    background: #fff3dc;
    color: #8d5c00;
    font-size: 10px;
    font-weight: 700;
}

.papak-status--notified {
    background: #e8f7f1;
    color: #08764f;
}

.papak-status--unsubscribed {
    background: #f0f1f3;
    color: #68707d;
}

.papak-account-waitlist__cancel {
    display: inline-block;
    margin-top: 8px;
    color: #b42338;
    font-size: 11px;
    text-decoration: none;
}

.papak-account-waitlists__empty {
    padding: 34px 20px;
    border: 1px dashed #cfd3d9;
    border-radius: 12px;
    text-align: center;
}

.papak-account-waitlists__empty strong {
    display: block;
    margin-bottom: 7px;
}

@keyframes papak-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes papak-dialog-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes papak-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 520px) {
    .papak-waitlist-card {
        grid-template-columns: 42px minmax(0, 1fr) auto;
        align-items: center;
    }

    .papak-waitlist-card__button {
        grid-column: auto;
        width: auto;
        min-width: 156px;
        padding: 0 16px;
    }
}

@media (max-width: 600px) {
    .papak-waitlist-modal {
        place-items: end center;
        padding: 0;
    }

    .papak-waitlist-modal__dialog {
        width: 100%;
        max-height: 90vh;
        padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
        border-radius: 18px 18px 0 0;
        animation-name: papak-sheet-in;
    }

    .papak-account-waitlist {
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 12px;
    }

    .papak-account-waitlist__image {
        width: 72px;
        height: 72px;
    }
}

@keyframes papak-sheet-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .papak-waitlist-modal__backdrop,
    .papak-waitlist-modal__dialog,
    .papak-waitlist-submit.is-loading span::after {
        animation: none;
    }
}
