/**
 * TejCart Express Checkout Component Styles
 *
 * Loaded on every surface that renders the Express Checkout component
 * (product page, cart page, side cart, checkout page). Depends on
 * design tokens declared in tejcart-public.css.
 *
 * The PayPal button container has an explicit reserved min-height so
 * CLS stays at 0 while the PayPal SDK is loading.
 *
 * @package TejCart
 */

.tejcart-express-checkout {
    display: flex;
    flex-direction: column;
    gap: var(--tejcart-space-3);
    padding: var(--tejcart-space-4) var(--tejcart-space-5);
    border-radius: var(--tejcart-radius-lg);
    background: var(--tejcart-bg-surface);
    border: 1px solid var(--tejcart-border-subtle);
    margin: var(--tejcart-space-3) 0;
    position: relative;
    box-shadow: var(--tejcart-shadow-subtle);
    animation: tejcart-express-entrance 0.4s var(--tejcart-ease) both;
}

.tejcart-express-checkout--top {
    margin: 0 0 var(--tejcart-space-5);
    padding: var(--tejcart-space-6) var(--tejcart-space-7) var(--tejcart-space-5);
    gap: var(--tejcart-space-2);
    border-radius: var(--tejcart-radius-lg);
    border: 1px solid var(--tejcart-border);
    background: var(--tejcart-bg-surface);
    box-shadow: var(--tejcart-shadow-subtle);
}

.tejcart-express-checkout--top .tejcart-express-checkout-buttons {
    margin: 0;
    min-height: 40px;
}

.tejcart-express-checkout--top .tejcart-express-checkout-buttons > div[id^="tejcart-"] {
    min-height: 40px;
}

.tejcart-express-checkout--top .tejcart-express-checkout-buttons > div[id^="tejcart-"]:last-child,
.tejcart-express-checkout--top .tejcart-express-checkout-buttons > div[id^="tejcart-"]:empty {
    margin-bottom: 0;
}

.tejcart-express-checkout--top paypal-button,
.tejcart-express-checkout--top venmo-button,
.tejcart-express-checkout--top apple-pay-button {
    margin-bottom: 0;
    min-height: 40px;
}

.tejcart-express-checkout--top paypal-messages:empty {
    display: none;
}

@keyframes tejcart-express-entrance {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tejcart-express-checkout-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: var(--tejcart-space-3);
    row-gap: 2px;
    align-items: center;
    padding-bottom: var(--tejcart-space-3);
    border-bottom: 1px solid var(--tejcart-border-subtle);
}

.tejcart-express-checkout-icon {
    grid-row: 1;
    grid-column: 1;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--tejcart-accent);
    box-shadow: none;
    box-sizing: content-box;
    align-self: center;
}

.tejcart-express-checkout-header-text {
    display: contents;
}

.tejcart-express-checkout-title {
    grid-row: 1;
    grid-column: 2;
    font-size: var(--tejcart-font-size-base);
    font-weight: var(--tejcart-font-weight-bold);
    color: var(--tejcart-text);
    line-height: 1.3;
    letter-spacing: -0.005em;
    min-width: 0;
}

.tejcart-express-checkout-title--inline {
    font-size: var(--tejcart-font-size-sm);
    text-align: center;
}

.tejcart-express-checkout-desc {
    grid-row: 2;
    grid-column: 2 / -1;
    font-size: var(--tejcart-font-size-sm);
    color: var(--tejcart-text-muted);
    line-height: 1.4;
}

.tejcart-express-checkout-badge {
    grid-row: 1;
    grid-column: 3;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    background: var(--tejcart-featured-bg);
    color: var(--tejcart-featured-fg);
    border: 1px solid var(--tejcart-featured-border);
    border-radius: var(--tejcart-radius-pill);
    font-size: 10px;
    font-weight: var(--tejcart-font-weight-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.5;
    white-space: nowrap;
    align-self: center;
    justify-self: end;
    box-shadow: var(--tejcart-shadow-xs, 0 1px 2px rgba(0, 0, 0, 0.04));
}

.tejcart-express-checkout-badge svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.tejcart-express-checkout-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--tejcart-space-2);
    min-height: 52px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.tejcart-express-checkout-buttons > div[id^="tejcart-"],
.tejcart-express-checkout-buttons .tejcart-product-paypal-btn,
.tejcart-express-checkout-buttons .tejcart-product-venmo-btn,
.tejcart-express-checkout-buttons .tejcart-product-googlepay-btn,
.tejcart-express-checkout-buttons .tejcart-product-applepay-btn {
    display: block;
    flex: 1 1 0;
    min-width: 152px;
    min-height: 45px;
    box-sizing: border-box;
}

/*
 * Cart-page sidebar and drawer surfaces stack the wallet buttons in a
 * column. flex: 1 1 0 then grows each child along the *vertical* axis,
 * stretching every button to fill the parent and producing the large
 * empty gaps seen on the cart page. Override to auto sizing so each
 * button stays at its natural 45px height regardless of parent height.
 */
.tejcart-cart-express-zone > div[id^="tejcart-"],
.tejcart-cart-smart-buttons > div[id^="tejcart-"],
.tejcart-cart-drawer-express > div[id^="tejcart-"] {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
}

@media (max-width: 479px) {
    .tejcart-express-checkout-buttons > div[id^="tejcart-"],
    .tejcart-express-checkout-buttons .tejcart-product-paypal-btn,
    .tejcart-express-checkout-buttons .tejcart-product-venmo-btn,
    .tejcart-express-checkout-buttons .tejcart-product-googlepay-btn,
    .tejcart-express-checkout-buttons .tejcart-product-applepay-btn {
        flex-basis: 100%;
        min-width: 0;
    }
}

#tejcart-express-googlepay,
#tejcart-drawer-express-googlepay,
#tejcart-cart-googlepay-btn,
#tejcart-googlepay-container,
.tejcart-product-googlepay-btn {
    height: 45px;
}

.tejcart-express-checkout-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--tejcart-space-2);
    pointer-events: none;
    z-index: 1;
}

.tejcart-express-checkout-skeleton-row {
    flex: 1 1 0;
    min-width: 0;
    height: 45px;
    background: var(--tejcart-bg-surface-alt);
    border-radius: var(--tejcart-radius-md);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--tejcart-border-subtle);
}

/*
 * Cart-page and drawer surfaces stack their wallet buttons vertically
 * (see tejcart-cart-express-zone / tejcart-cart-drawer-express in
 * tejcart-cart-page.css and tejcart-side-cart.css). Mirror that for the
 * loading skeleton so the placeholders match the buttons that come in
 * instead of cramming N rows into the narrow sidebar as a thin bar.
 * The parent zone's min-height is set in JS (populateExpressSkeletons)
 * based on the rendered slot count so the absolute overlay has room.
 */
.tejcart-cart-express-zone > .tejcart-express-checkout-skeleton,
.tejcart-cart-smart-buttons > .tejcart-express-checkout-skeleton,
.tejcart-cart-drawer-express > .tejcart-express-checkout-skeleton {
    flex-direction: column;
    flex-wrap: nowrap;
}

.tejcart-cart-express-zone .tejcart-express-checkout-skeleton-row,
.tejcart-cart-smart-buttons .tejcart-express-checkout-skeleton-row,
.tejcart-cart-drawer-express .tejcart-express-checkout-skeleton-row {
    flex: 0 0 45px;
    width: 100%;
}

@media (max-width: 479px) {
    .tejcart-express-checkout-skeleton-row {
        flex-basis: 100%;
        min-width: 0;
    }
}

.tejcart-express-checkout-skeleton-row::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.55) 40%,
        rgba(255, 255, 255, 0.55) 60%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: tejcart-shimmer 1.6s infinite var(--tejcart-ease-standard);
}

.tejcart-express-checkout-buttons.is-ready .tejcart-express-checkout-skeleton {
    display: none;
}

paypal-button,
venmo-button,
apple-pay-button,
paypal-messages {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 45px;
    box-sizing: border-box;
}

paypal-messages {
    min-height: 0;
}

.tejcart-express-checkout-buttons > div[id^="tejcart-"] > paypal-button + paypal-button,
.tejcart-express-checkout-buttons > div[id^="tejcart-"] > paypal-button + venmo-button,
.tejcart-express-checkout-buttons > div[id^="tejcart-"] > venmo-button + paypal-button {
    margin-top: var(--tejcart-space-2);
}

#tejcart-paypal-button-container > paypal-button,
#tejcart-paypal-button-container > venmo-button,
#tejcart-cart-paypal-btn > paypal-button,
#tejcart-cart-paypal-btn > venmo-button,
[id^="tejcart-express-"] > paypal-button,
[id^="tejcart-express-"] > venmo-button,
[id^="tejcart-drawer-express-"] > paypal-button,
[id^="tejcart-drawer-express-"] > venmo-button,
[id^="tejcart-product-"] > paypal-button,
[id^="tejcart-product-"] > venmo-button {
    display: block;
    width: 100%;
}

#tejcart-paypal-button-container > paypal-button + *,
#tejcart-paypal-button-container > venmo-button + *,
#tejcart-cart-paypal-btn > paypal-button + *,
#tejcart-cart-paypal-btn > venmo-button + *,
[id^="tejcart-express-"] > paypal-button + *,
[id^="tejcart-express-"] > venmo-button + *,
[id^="tejcart-drawer-express-"] > paypal-button + *,
[id^="tejcart-drawer-express-"] > venmo-button + *,
[id^="tejcart-product-"] > paypal-button + *,
[id^="tejcart-product-"] > venmo-button + * {
    margin-top: var(--tejcart-space-2);
}

.tejcart-express-checkout-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tejcart-space-5);
    padding-top: var(--tejcart-space-3);
    margin-top: var(--tejcart-space-1);
    border-top: 1px solid var(--tejcart-border-subtle);
    color: var(--tejcart-text-subtle);
    font-size: 11px;
    font-weight: var(--tejcart-font-weight-medium);
    line-height: 1;
    letter-spacing: 0.04em;
}

.tejcart-express-checkout-trust-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.tejcart-express-checkout-trust-item svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    opacity: 0.65;
}

/*
 * Canonical Pay Later message styling — !important is used on the
 * critical properties because:
 *   1. Other CSS files (tejcart-shop.css, tejcart-checkout.css) reset
 *      `margin` via shorthand on more-specific selectors.
 *   2. PayPal's <paypal-message> web component ships its own host /
 *      shadow-DOM defaults that would otherwise stretch the box and
 *      bake in a larger inline font size.
 */
.tejcart-paylater-message {
    display: block !important;
    width: fit-content !important;
    max-width: 100% !important;
    min-height: 0;
    margin-top: var(--tejcart-space-2);
    margin-right: auto !important;   /* left-pin in block / row-flex */
    margin-bottom: var(--tejcart-space-2);
    margin-left: 0 !important;
    padding: 0;
    background: transparent;
    border: 0;
    align-self: flex-start !important; /* left-pin in column-flex parents */
    justify-self: start !important;    /* left-pin in grid parents */
    float: none !important;
    clear: none !important;
    font-size: 12px !important;
    line-height: 1.4;
    text-align: left !important;
}

/* PayPal injects spans/anchors with inline font sizes — clamp them. */
.tejcart-paylater-message * {
    font-size: 12px !important;
    text-align: left !important;
}

.tejcart-paylater-message:empty,
.tejcart-paylater-message[hidden] {
    display: none !important;
}

.tejcart-express-checkout-error {
    display: flex;
    align-items: flex-start;
    gap: var(--tejcart-space-3);
    padding: var(--tejcart-space-3) var(--tejcart-space-4);
    background: var(--tejcart-warning-bg);
    border: 1px solid var(--tejcart-warning-border);
    border-radius: var(--tejcart-radius-md);
    color: var(--tejcart-warning-fg);
    font-size: var(--tejcart-font-size-sm);
}

.tejcart-express-checkout-error svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
}

.tejcart-express-checkout-error-dismiss {
    margin-left: auto;
    background: transparent;
    border: none;
    color: inherit;
    font-size: var(--tejcart-font-size-lg);
    cursor: pointer;
    padding: 0 var(--tejcart-space-2);
    line-height: 1;
}

.tejcart-express-divider {
    display: flex;
    align-items: center;
    gap: var(--tejcart-space-3);
    margin: var(--tejcart-space-5) 0;
    color: var(--tejcart-text-muted);
    font-size: var(--tejcart-font-size-xs);
    font-weight: var(--tejcart-font-weight-medium);
    text-transform: uppercase;
    letter-spacing: var(--tejcart-letter-spacing-wide);
}

.tejcart-express-divider::before,
.tejcart-express-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--tejcart-border);
}

.tejcart-express-divider span {
    padding: 0 var(--tejcart-space-1);
    background: transparent;
    color: var(--tejcart-text-muted);
}

.tejcart-product-smart-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tejcart-space-2);
    min-height: 45px;
    width: 100%;
    box-sizing: border-box;
}

.tejcart-product-smart-buttons[hidden] {
    display: none;
}

.tejcart-product-smart-buttons > div[id^="tejcart-product-"] {
    display: block;
    flex: 1 1 0;
    min-width: 152px;
    min-height: 45px;
    box-sizing: border-box;
}

@media (max-width: 479px) {
    .tejcart-product-smart-buttons > div[id^="tejcart-product-"] {
        flex-basis: 100%;
        min-width: 0;
    }
}

@media (max-width: 599px) {
    .tejcart-express-checkout {
        padding: var(--tejcart-space-3) var(--tejcart-space-4);
        gap: var(--tejcart-space-3);
    }

    .tejcart-express-checkout-icon {
        width: 14px;
        height: 14px;
    }

    .tejcart-express-checkout-title {
        font-size: var(--tejcart-font-size-sm);
    }

    .tejcart-express-checkout-desc {
        font-size: var(--tejcart-font-size-xs);
    }

    .tejcart-express-checkout-badge {
        font-size: 9px;
        padding: 2px 7px;
    }

    .tejcart-express-checkout-buttons {
        padding: 0;
    }

    .tejcart-express-checkout-skeleton {
        inset: 0;
    }

    .tejcart-express-checkout-trust {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--tejcart-space-3);
        font-size: 10px;
    }

    .tejcart-express-divider {
        margin: var(--tejcart-space-4) 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tejcart-express-checkout {
        animation: none;
    }

    .tejcart-express-checkout-skeleton-row::after {
        animation: none;
    }
}
