/**
 * Easy Digital Downloads Styles
 * Checkout, Receipt, Account Pages
 *
 * @package CloveTheme
 * @since 1.0.0
 */

/* ==========================================================================
   CHECKOUT PAGE - TWO COLUMN LAYOUT
   Supports both EDD Classic and EDD Blocks checkout structures
   Left: Form fields | Right: Order summary (sticky)
   ========================================================================== */

/* ----- GLOBAL FIX: Prevent horizontal overflow ----- */
body {
    overflow-x: hidden;
}

/* ----- EDD BLOCKS CHECKOUT (Modern) ----- */
/* Structure: .edd-blocks__checkout > #edd_checkout_cart_form + #edd_purchase_form */

.edd-blocks__checkout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding-inline: var(--space-4);
    box-sizing: border-box;
}

@media (min-width: 900px) {
    .edd-blocks__checkout {
        grid-template-columns: 1fr 420px;
        gap: var(--space-8);
        align-items: start;
    }

    /* Cart form (contains cart + renewal) - Right column, sticky */
    .edd-blocks__checkout #edd_checkout_cart_form {
        grid-column: 2;
        grid-row: 1 / 2;
        position: sticky;
        top: calc(var(--header-height) + var(--space-4));
    }

    /* Purchase form (personal info, payment, billing) - Left column */
    .edd-blocks__checkout #edd_purchase_form {
        grid-column: 1;
        grid-row: 1;
    }
}

/* Mobile: Cart first, then form fields */
.edd-blocks__checkout #edd_checkout_cart_form {
    order: -1;
}

@media (min-width: 900px) {
    .edd-blocks__checkout #edd_checkout_cart_form {
        order: unset;
    }
}

/* ----- EDD CLASSIC CHECKOUT (Legacy) ----- */
/* Structure: #edd_checkout_form_wrap > fieldsets */

#edd_checkout_form_wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    max-width: 1200px;
    margin: 0 auto;
    padding-inline: var(--space-4);
    box-sizing: border-box;
}

@media (min-width: 900px) {
    #edd_checkout_form_wrap {
        grid-template-columns: 1fr 420px;
        gap: var(--space-8);
        align-items: start;
    }

    /* Order summary - Right column, sticky */
    #edd_checkout_form_wrap > #edd_checkout_cart,
    #edd_checkout_form_wrap > .edd-blocks-cart {
        grid-column: 2;
        grid-row: 1 / span 10;
        position: sticky;
        top: calc(var(--header-height) + var(--space-4));
        margin-block-end: 0;
    }

    /* Form sections - Left column */
    #edd_checkout_form_wrap > fieldset,
    #edd_checkout_form_wrap > #edd_payment_mode_select,
    #edd_checkout_form_wrap > #edd_sl_renewal_form,
    #edd_checkout_form_wrap > #edd-discount-code-wrap,
    #edd_checkout_form_wrap > #edd_purchase_submit,
    #edd_checkout_form_wrap > #edd_final_total_wrap {
        grid-column: 1;
    }
}

/* Mobile: Cart first */
#edd_checkout_cart,
.edd-blocks-cart {
    order: -1;
}

@media (min-width: 900px) {
    #edd_checkout_cart,
    .edd-blocks-cart {
        order: unset;
    }
}

/* ==========================================================================
   CART / ORDER SUMMARY (EDD Blocks)
   Structure: .edd-blocks-cart > .edd-blocks-cart__row (div-based)
   Depth & Polish
   ========================================================================== */

#edd_checkout_cart,
.edd-blocks-cart {
    width: 100%;
    margin-block-end: var(--space-8);
    background: var(--color-surface-primary);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--color-border-subtle);
}

/* Header */
.edd-blocks-cart__row-header,
#edd_checkout_cart .edd_cart_header_row {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    background: transparent;
    border-block-end: 2px solid var(--color-border-subtle);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap; /* Keep headers on single line */
}

/* Cart item rows */
.edd-blocks-cart__row:not(.edd-blocks-cart__row-header):not(.edd-blocks-cart__row-footer) {
    display: flex;
    align-items: center;
    padding: var(--space-5);
    border-block-end: 1px solid var(--color-border-subtle);
    background: var(--color-surface-primary);
    transition: background-color var(--duration-200);
}

.edd-blocks-cart__row:hover {
    background-color: var(--color-surface-secondary);
}

/* Product name - Takes available space */
.edd-blocks-cart .edd_cart_item_name,
#edd_checkout_cart .edd_cart_item_name {
    flex: 1; /* Grow to fill space */
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
    font-size: var(--text-base);
    padding-inline-end: var(--space-4);
}

/* Price cells - Fixed width aligned right */
.edd-blocks-cart .edd_cart_item_price,
#edd_checkout_cart .edd_cart_item_price {
    width: 140px; /* Fixed width for alignment */
    flex-shrink: 0;
    display: flex; /* Ensure internal alignment */
    justify-content: flex-end; /* Align content right */
    align-items: center;
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    text-align: right;
}

/* Header Price specific alignment */
.edd-blocks-cart__row-header .edd_cart_item_price {
    color: var(--color-text-tertiary); /* Muted header text */
}

/* Ensure header divs match */
#edd_checkout_cart .edd_cart_header_row div {
    display: block; /* Reset potential nested flex */
}

/* Footer rows (subtotal, total) */
.edd-blocks-cart__row-footer {
    display: flex;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    background: var(--color-surface-secondary);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* Total row - emphasized */
.edd-blocks-cart__row-footer.edd_cart_footer_row.edd_cart_total {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    padding: var(--space-5);
    background: var(--color-surface-primary);
    border-top: 1px solid var(--color-border-subtle);
}

.edd-blocks-cart__row-footer .edd_cart_total,
.edd-blocks-cart__row-footer .edd-blocks-cart__total-amount {
    color: var(--color-brand-primary);
}

/* Remove item link with X icon */
.edd-blocks-cart__action-remove,
#edd_checkout_cart .edd_cart_remove_item_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-inline-start: var(--space-3);
    font-size: 0; /* Hide text */
    color: var(--color-text-tertiary);
    background: transparent;
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all var(--duration-200);
}

.edd-blocks-cart__action-remove::before,
#edd_checkout_cart .edd_cart_remove_item_btn::before {
    font-family: 'phosphor';
    content: '\e4f6'; /* ph-x */
    font-size: 1.25rem;
}

.edd-blocks-cart__action-remove:hover,
#edd_checkout_cart .edd_cart_remove_item_btn:hover {
    color: var(--color-error);
    background: var(--color-error-light);
}

/* ==========================================================================
   CHECKOUT FORM FIELDS
   Structure: #edd_checkout_user_info, #edd-discount-code-wrap
   ========================================================================== */

/* Fieldset sections - Card Style with Depth */
#edd_checkout_form_wrap fieldset {
    margin: 0 0 var(--space-6);
    padding: var(--space-8);
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.03),
        0 4px 6px -2px rgba(0, 0, 0, 0.02); /* Multi-layer shadow */
}

/* Premium "Title with Lines" Style */
#edd_checkout_form_wrap legend {
    display: flex;
    align-items: center;
    width: 100%;
    margin-block-end: var(--space-6);
    padding: 0;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: none; /* Remove old border */
}

#edd_checkout_form_wrap legend::before,
#edd_checkout_form_wrap legend::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-subtle);
}

#edd_checkout_form_wrap legend::before {
    margin-inline-end: var(--space-4);
}

#edd_checkout_form_wrap legend::after {
    margin-inline-start: var(--space-4);
}

/* Form rows */
#edd_checkout_form_wrap p {
    margin: 0 0 var(--space-4);
}

#edd_checkout_form_wrap p:last-child {
    margin-block-end: 0;
}

/* Labels */
#edd_checkout_form_wrap label {
    display: block;
    margin-block-end: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
}

#edd_checkout_form_wrap label .edd-required-indicator {
    color: var(--color-error);
    margin-inline-start: var(--space-1);
}

/* Text inputs */
#edd_checkout_form_wrap input[type="text"],
#edd_checkout_form_wrap input[type="email"],
#edd_checkout_form_wrap input[type="tel"],
#edd_checkout_form_wrap input[type="password"],
#edd_checkout_form_wrap input[type="number"],
#edd_sl_renewal_key, /* Explicit renewal key */
#edd_checkout_form_wrap select,
#edd_checkout_form_wrap textarea {
    width: 100%;
    padding: var(--input-padding-y) var(--input-padding-x);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    background: var(--input-bg);
    border: var(--input-border);
    border-radius: var(--input-radius);
    box-shadow: var(--shadow-inner);
    transition:
        border-color var(--duration-200) var(--ease-out),
        box-shadow var(--duration-200) var(--ease-out),
        background-color var(--duration-200) var(--ease-out);
}

#edd_checkout_form_wrap input:focus,
#edd_sl_renewal_key:focus, /* Explicit renewal key */
#edd_checkout_form_wrap select:focus,
#edd_checkout_form_wrap textarea:focus {
    outline: none;
    background: var(--color-surface-primary);
    border-color: var(--color-brand-primary);
    box-shadow:
        0 0 0 4px rgba(99, 102, 241, 0.1),
        inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

#edd_checkout_form_wrap input::placeholder {
    color: var(--color-text-tertiary);
}

/* Select dropdown */
#edd_checkout_form_wrap select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-inline-end: var(--space-10);
}

/* Two column layout for name fields */
#edd_checkout_form_wrap .edd-first-name-wrap,
#edd_checkout_form_wrap .edd-last-name-wrap {
    display: inline-block;
    width: calc(50% - var(--space-2));
}

#edd_checkout_form_wrap .edd-first-name-wrap {
    margin-inline-end: var(--space-4);
}

/* ==========================================================================
   DISCOUNT CODE
   ========================================================================== */

#edd-discount-code-wrap {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
    margin-block-end: var(--space-6);
    padding: var(--space-4);
    background: var(--color-surface-secondary);
    border-radius: var(--radius-lg);
}

#edd-discount-code-wrap label {
    display: block;
    margin-block-end: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
}

#edd-discount-code-wrap input[type="text"] {
    flex: 1;
}

/* Discount Button - Secondary */
#edd-discount-code-wrap input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto; /* Don't force full width */
    padding: var(--btn-padding-y) var(--btn-padding-x);
    font-family: var(--font-sans);
    font-size: var(--btn-font-size);
    font-weight: var(--btn-font-weight);
    color: var(--color-text-primary);
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--btn-radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-200) var(--ease-out);
    box-shadow: var(--shadow-xs);
}

#edd_purchase_submit,
.edd-submit.button.blue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    font-family: var(--font-sans);
    font-size: var(--btn-font-size);
    font-weight: var(--btn-font-weight);
    color: var(--color-text-inverse);
    background: var(--gradient-brand);
    border: 1px solid transparent;
    border-radius: var(--btn-radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-200) var(--ease-out);
    box-shadow: var(--shadow-brand);
}

#edd-discount-code-wrap input[type="submit"]:hover,
#edd-discount-code-wrap button:hover {
    background: var(--color-surface-secondary);
    border-color: var(--color-border-strong);
}

/* Secondary button styles (Renew License) - FORCE OVERRIDE */
/* Multiple selectors to match EDD Blocks and Classic checkout */
#edd_sl_renewal_form #edd_sl_show_renewal_form.button,
#edd_sl_show_renewal_form.button,
.edd_sl_show_renewal_form,
#edd_checkout_form_wrap .edd-button-secondary,
.edd-blocks__checkout .edd-button-secondary,
a.edd-button-secondary {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3) var(--space-5) !important;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);

    /* Ghost button styling */
    color: var(--color-brand-primary) !important;
    background: transparent !important;
    border: 2px solid var(--color-brand-primary) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: none !important;

    text-decoration: none !important;
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
}

#edd_sl_renewal_form #edd_sl_show_renewal_form.button:hover,
#edd_sl_show_renewal_form.button:hover,
.edd_sl_show_renewal_form:hover,
#edd_checkout_form_wrap .edd-button-secondary:hover,
.edd-blocks__checkout .edd-button-secondary:hover,
a.edd-button-secondary:hover {
    background: var(--color-brand-primary) !important;
    color: var(--color-text-inverse) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2) !important;
}

/* Apply Renewal Button */
#edd-add-license-renewal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-inverse) !important;
    background: var(--color-brand-primary) !important;
    border: 1px solid var(--color-brand-primary) !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2) !important;
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
    text-transform: none;
    text-decoration: none;
}

#edd-add-license-renewal:hover {
    background: var(--color-brand-dark) !important;
    border-color: var(--color-brand-dark) !important;
    color: var(--color-text-inverse) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3) !important;
}

/* Cancel Renewal Button */
#edd-cancel-license-renewal {
    display: inline-flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary) !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    text-decoration: none !important;
    transition: color var(--duration-200);
    box-shadow: none !important;
}

#edd-cancel-license-renewal:hover {
    color: var(--color-error) !important;
    text-decoration: underline !important;
    background: transparent !important;
}

/* Applied discount */
.edd_discount {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-success);
    background: var(--color-success-light);
    border-radius: var(--radius-md);
}

.edd_discount_remove {
    color: var(--color-success);
    text-decoration: none;
}

.edd_discount_remove:hover {
    color: var(--color-error);
}

/* ==========================================================================
   PAYMENT METHODS
   Structure: #edd_payment_mode_select
   ========================================================================== */

#edd_payment_mode_select {
    margin-block-end: var(--space-6);
}

#edd_payment_mode_select_wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

#edd_payment_mode_select label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface-primary);
    border: 2px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
}

#edd_payment_mode_select label:hover {
    border-color: var(--color-brand-primary);
}

#edd_payment_mode_select input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    margin: 0;
    border: 2px solid var(--color-border-strong);
    border-radius: var(--radius-full);
    background: var(--color-surface-primary);
    cursor: pointer;
    position: relative;
}

#edd_payment_mode_select input[type="radio"]:checked {
    border-color: var(--color-brand-primary);
    background: var(--color-brand-primary);
}

#edd_payment_mode_select input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: var(--color-surface-primary);
    border-radius: var(--radius-full);
}

#edd_payment_mode_select input[type="radio"]:checked + span {
    color: var(--color-text-primary);
    font-weight: var(--weight-semibold);
}

/* Payment icons */
.edd-payment-icon {
    width: 2rem;
    height: auto;
    margin-inline-start: auto;
}

/* ==========================================================================
   PURCHASE BUTTON
   ========================================================================== */

/* Override fieldset card styling for purchase button wrapper */
/* Use display: block to allow error messages to stack above button */
#edd_checkout_form_wrap #edd_purchase_submit,
.edd-blocks__checkout #edd_purchase_submit,
#edd_purchase_submit {
    display: block !important; /* Block to stack errors above button */
    text-align: center;
    margin-block-start: var(--space-6);
    /* Force remove card styling (override fieldset) */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Error messages inside purchase submit should be full width */
#edd_purchase_submit .edd_errors,
#edd_purchase_submit .edd-alert {
    width: 100%;
    max-width: 100%;
    text-align: left;
    margin-block-end: var(--space-4);
}

#edd_purchase_submit input[type="submit"],
#edd-purchase-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    max-width: 400px;
    padding: var(--space-4) var(--space-8);
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-text-inverse);
    background: var(--gradient-brand);
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    box-shadow: var(--shadow-brand-hover);
    transition:
        transform var(--duration-300) var(--ease-out),
        box-shadow var(--duration-300) var(--ease-out);
}

#edd_purchase_submit input[type="submit"]:hover,
#edd-purchase-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-brand-lg);
}

#edd_purchase_submit input[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Terms agreement */
#edd_agree_to_terms_wrap {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-block-end: var(--space-4);
    padding: var(--space-4);
    background: var(--color-surface-secondary);
    border-radius: var(--radius-lg);
}

#edd_agree_to_terms_wrap input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-block-start: 2px;
    border: 2px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface-primary);
    cursor: pointer;
    position: relative;
}

#edd_agree_to_terms_wrap input[type="checkbox"]:checked {
    border-color: var(--color-brand-primary);
    background: var(--color-brand-primary);
}

#edd_agree_to_terms_wrap input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    inset-block-start: 2px;
    inset-inline-start: 5px;
    width: 5px;
    height: 9px;
    border: solid var(--color-surface-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#edd_agree_to_terms_wrap label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
}

#edd_agree_to_terms_wrap a {
    color: var(--color-brand-primary);
}

/* ==========================================================================
   PURCHASE RECEIPT / CONFIRMATION
   Structure: .edd_purchase_receipt_*
   ========================================================================== */

/* Center and bound the entire page wrapper for the checkout confirmation */
.prose:has(#edd_purchase_receipt) {
    max-width: 720px;
    margin-inline: auto;
}

/* Success message paragraph (for shortcode confirmation pages) */
.prose:has(#edd_purchase_receipt) > p:first-of-type {
    margin-block-end: var(--space-8);
    padding: var(--space-6) var(--space-8);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.03) 100%);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-2xl);
    text-align: center;
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: #10b981; /* Success green */
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.05);
}

.edd-blocks__confirmation,
#edd_purchase_receipt {
    max-width: 100%;
    margin: 0 auto;
}

/* Success header */
.edd-blocks__confirmation-header,
.edd_purchase_receipt_intro {
    text-align: center;
    margin-block-end: var(--space-8);
    padding: var(--space-8);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(139, 92, 246, 0.03) 100%);
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--radius-2xl);
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.05);
}

.edd-blocks__confirmation-header h2,
.edd_purchase_receipt_intro h2 {
    margin: 0 0 var(--space-3);
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--color-brand-primary);
}

.edd-blocks__confirmation-header p,
.edd_purchase_receipt_intro p {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
}

/* Receipt table */
table.edd-table {
    width: 100%;
    margin-block-end: var(--space-8);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-surface-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border-subtle);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table.edd-table thead {
    background: var(--color-surface-secondary);
}

table.edd-table th {
    padding: var(--space-4) var(--space-5);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--color-text-secondary);
    text-align: start;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 2px solid var(--color-border-subtle);
}

table.edd-table td {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

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

/* Make sure label column stands out nicely */
table.edd-table td strong {
    font-weight: var(--weight-semibold);
    color: var(--color-text-secondary);
}

/* Products list section heading */
.edd-page h3,
#edd_purchase_receipt_products_title,
table.edd-table + h3 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    margin-block-start: var(--space-8);
    margin-block-end: var(--space-4);
}

/* Download links styling */
.edd_download_file {
    display: inline-block;
    margin: 4px 0;
    padding: 0;
    background: none;
}

.edd_download_file a.edd_download_file_link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-brand-primary);
    background-color: rgba(124, 58, 237, 0.05);
    border: 1px dashed var(--color-brand-primary);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all var(--duration-200) var(--ease-out);
}

.edd_download_file a.edd_download_file_link:hover {
    color: var(--color-text-inverse);
    background: var(--gradient-brand);
    border-color: transparent;
    box-shadow: var(--shadow-brand);
    transform: translateY(-1px);
}

/* License key display */
.edd_sl_license_key {
    display: inline-block;
    padding: 6px 12px;
    font-family: monospace;
    font-size: var(--text-sm);
    color: var(--color-brand-primary);
    background: var(--color-surface-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    word-break: break-all;
    font-weight: var(--weight-semibold);
}

/* ==========================================================================
   ACCOUNT PAGES
   Structure: #edd_user_history, .edd_download_history
   ========================================================================== */

/* Purchase history table */
#edd_user_history,
.edd_purchase_history_table {
    width: 100%;
    margin-block-end: var(--space-8);
    border-collapse: collapse;
    background: var(--color-surface-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#edd_user_history thead,
.edd_purchase_history_table thead {
    background: var(--color-surface-secondary);
}

#edd_user_history th,
.edd_purchase_history_table th {
    padding: var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-secondary);
    text-align: start;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#edd_user_history td,
.edd_purchase_history_table td {
    padding: var(--space-4);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    border-block-end: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

#edd_user_history tbody tr:last-child td,
.edd_purchase_history_table tbody tr:last-child td {
    border-block-end: none;
}

/* View details link */
#edd_user_history .edd_view_order_details,
.edd_order_details_link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-brand-primary);
    text-decoration: none;
}

#edd_user_history .edd_view_order_details:hover,
.edd_order_details_link:hover {
    text-decoration: underline;
}

/* Status badges */
.edd_purchase_status {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-full);
}

.edd_purchase_status.edd-complete,
.edd_purchase_status.complete {
    color: var(--color-success);
    background: var(--color-success-light);
}

.edd_purchase_status.edd-pending,
.edd_purchase_status.pending {
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.1);
}

.edd_purchase_status.edd-refunded,
.edd_purchase_status.refunded {
    color: var(--color-error);
    background: var(--color-error-light);
}

/* ==========================================================================
   LOGIN / REGISTER FORMS
   ========================================================================== */

.edd-login-form,
.edd-register-form,
#edd_login_form,
#edd_register_form {
    max-width: 440px;
    margin: 0 auto;
    padding: var(--space-8);
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
}

.edd-login-form legend,
.edd-register-form legend {
    margin-block-end: var(--space-6);
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    text-align: center;
}

.edd-login-form p,
.edd-register-form p,
#edd_login_form p,
#edd_register_form p {
    margin: 0 0 var(--space-4);
}

.edd-login-form label,
.edd-register-form label,
#edd_login_form label,
#edd_register_form label {
    display: block;
    margin-block-end: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
}

.edd-login-form input[type="text"],
.edd-login-form input[type="email"],
.edd-login-form input[type="password"],
.edd-register-form input[type="text"],
.edd-register-form input[type="email"],
.edd-register-form input[type="password"],
#edd_login_form input[type="text"],
#edd_login_form input[type="password"],
#edd_register_form input[type="text"],
#edd_register_form input[type="email"],
#edd_register_form input[type="password"] {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition:
        border-color var(--duration-200) var(--ease-out),
        box-shadow var(--duration-200) var(--ease-out);
}

.edd-login-form input:focus,
.edd-register-form input:focus,
#edd_login_form input:focus,
#edd_register_form input:focus {
    outline: none;
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.edd-login-form input[type="submit"],
.edd-register-form input[type="submit"],
#edd_login_form input[type="submit"],
#edd_register_form input[type="submit"] {
    display: block;
    width: 100%;
    margin-block-start: var(--space-4);
    padding: var(--space-3-5) var(--space-6);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text-inverse);
    background: var(--gradient-brand);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: 0 4px 14px -4px rgba(99, 102, 241, 0.4);
    transition:
        transform var(--duration-300) var(--ease-out),
        box-shadow var(--duration-300) var(--ease-out);
}

.edd-login-form input[type="submit"]:hover,
.edd-register-form input[type="submit"]:hover,
#edd_login_form input[type="submit"]:hover,
#edd_register_form input[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.6);
}

/* Remember me checkbox */
.edd-login-form .edd-login-remember,
#edd_login_form .edd_login_remember {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-block-start: var(--space-2);
}

.edd-login-form .edd-login-remember input[type="checkbox"],
#edd_login_form .edd_login_remember input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Lost password link */
.edd-login-form .edd-lost-password,
#edd_login_form .edd_lost_password {
    display: block;
    margin-block-start: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
    text-align: center;
}

.edd-login-form .edd-lost-password a,
#edd_login_form .edd_lost_password a {
    color: var(--color-brand-primary);
}

/* ==========================================================================
   ERROR & SUCCESS MESSAGES
   ========================================================================== */

.edd_errors,
.edd-alert,
.edd-alert-error {
    display: block !important;
    width: 100%;
    padding: var(--space-4);
    margin-block-end: var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-error);
    background: var(--color-error-light);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-lg);
    list-style: none;
}

.edd_errors li,
.edd_errors p,
.edd-alert p {
    margin: 0 0 var(--space-2) 0;
    padding: 0;
}

.edd_errors li:last-child,
.edd-alert p:last-child {
    margin-bottom: 0;
}

/* Errors in purchase submit area */
#edd_purchase_submit .edd_errors,
#edd_purchase_submit .edd-alert {
    margin-block-end: var(--space-4);
}

/* Success messages */
.edd_success,
.edd-alert-success {
    padding: var(--space-4);
    margin-block-end: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-success);
    background: var(--color-success-light);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-lg);
}

/* Info messages */
.edd-alert-info {
    padding: var(--space-4);
    margin-block-end: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-info);
    background: var(--color-info-light);
    border: 1px solid var(--color-info);
    border-radius: var(--radius-lg);
}

/* Warning messages */
.edd-alert-warn {
    padding: var(--space-4);
    margin-block-end: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-warning);
    background: var(--color-warning-light);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-lg);
}

/* Field error state */
input.error,
select.error,
textarea.error {
    border-color: var(--color-error) !important;
}

/* Discount code errors */
#edd-discount-error-wrap {
    margin-block-start: var(--space-3);
}

/* ==========================================================================
   PURCHASE TOTAL BAR
   Structure: #edd_final_total_wrap
   ========================================================================== */

#edd_final_total_wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: var(--space-6) 0;
    padding: var(--space-5) var(--space-6);
    background: linear-gradient(135deg, var(--color-surface-secondary) 0%, rgba(99, 102, 241, 0.05) 100%);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
}

#edd_final_total_wrap .edd_cart_amount_label {
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
}

#edd_final_total_wrap .edd_cart_amount {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-brand-primary);
}

/* ==========================================================================
   PAYMENT ICONS SECTION
   Structure: .edd-payment-icons
   ========================================================================== */

.edd-payment-icons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-block-end: var(--space-6);
    padding: var(--space-4);
    background: var(--color-surface-secondary);
    border-radius: var(--radius-lg);
}

.edd-payment-icons img,
.edd-payment-icons svg {
    height: 1.75rem;
    width: auto;
    opacity: 0.7;
    transition: opacity var(--duration-200) var(--ease-out);
}

.edd-payment-icons img:hover,
.edd-payment-icons svg:hover {
    opacity: 1;
}

/* ==========================================================================
   EDD LABELS AND INPUTS (Refinements)
   ========================================================================== */

.edd-label {
    display: block;
    margin-block-end: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
}

.edd-required-indicator {
    color: var(--color-error);
    margin-inline-start: var(--space-1);
}

.edd-description {
    display: block;
    margin-block-start: var(--space-1);
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}

.edd-input,
input.edd-input,
select.edd-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition:
        border-color var(--duration-200) var(--ease-out),
        box-shadow var(--duration-200) var(--ease-out);
}

.edd-input:focus,
input.edd-input:focus,
select.edd-input:focus {
    outline: none;
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Checkout form paragraph spacing */
#edd_checkout_form_wrap #edd_purchase_form p {
    margin: 0 0 var(--space-4);
}

#edd_checkout_form_wrap #edd_purchase_form p:last-child {
    margin-block-end: 0;
}

/* Fieldset legends - section titles */
#edd_checkout_form_wrap fieldset legend {
    margin-block-end: var(--space-4);
    padding: 0;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
}

/* Phone number field with flag */
.iti {
    width: 100%;
}

.iti__flag-container {
    z-index: 10;
}

.iti__selected-flag {
    background: var(--color-surface-secondary);
    border-inline-end: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Select dropdowns (Country, State) */
#edd_checkout_form_wrap select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-inline-end: var(--space-10);
    cursor: pointer;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 767px) {
    #edd_checkout_cart th,
    #edd_checkout_cart td {
        padding: var(--space-3);
        font-size: var(--text-sm);
    }

    #edd_checkout_cart .edd_cart_item_image {
        width: 40px;
    }

    #edd_checkout_form_wrap fieldset {
        padding: var(--space-4);
    }

    #edd-discount-code-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .edd-login-form,
    .edd-register-form,
    #edd_login_form,
    #edd_register_form {
        padding: var(--space-6);
    }

    /* Stack name fields */
    #edd_checkout_form_wrap .edd-first-name-wrap,
    #edd_checkout_form_wrap .edd-last-name-wrap {
        display: block;
        width: 100%;
        margin-inline-end: 0;
    }

    #edd_checkout_form_wrap .edd-first-name-wrap {
        margin-block-end: var(--space-4);
    }

    /* Purchase total on mobile */
    #edd_final_total_wrap {
        flex-direction: column;
        gap: var(--space-2);
        text-align: center;
        padding: var(--space-4);
    }
}

/* ==========================================================================
   EDD BLOCKS — DOWNLOADS LISTING (Shortcode / Block grid on /products/ etc.)
   Structure: .edd-blocks__downloads > .edd-blocks__download
   ========================================================================== */

.edd-blocks__downloads.edd-blocks__columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-8);
    list-style: none;
    margin: 0;
    padding: 0;
}

@media (max-width: 991px) {
    .edd-blocks__downloads.edd-blocks__columns {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-6);
    }
}

@media (max-width: 639px) {
    .edd-blocks__downloads.edd-blocks__columns {
        grid-template-columns: 1fr;
    }
}

/* Each product card */
.edd-blocks__download {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--color-surface-primary);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-brand);
    overflow: hidden;
    transition:
        transform var(--duration-300) var(--ease-out),
        box-shadow var(--duration-300) var(--ease-out),
        border-color var(--duration-300) var(--ease-out);
}

.edd-blocks__download::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-2xl);
    padding: 2px;
    background: linear-gradient(135deg, transparent 40%, rgba(99, 102, 241, 0.4) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--duration-300) var(--ease-out);
    pointer-events: none;
    z-index: 1;
}

.edd-blocks__download:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-brand-hover);
    border-color: rgba(139, 92, 246, 0.2);
}

.edd-blocks__download:hover::before {
    opacity: 1;
}

/* Image */
.edd-blocks__download-header {
    display: flex;
    flex-direction: column;
}

.edd-blocks__download-image-link {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-surface-secondary) 0%, var(--color-surface-tertiary) 100%);
}

.edd-blocks__download-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-500) var(--ease-out);
    display: block;
}

.edd-blocks__download:hover .edd-blocks__download-image {
    transform: scale(1.08);
}

/* Title */
.edd-blocks__download-header h3 {
    margin: 0;
    padding: var(--space-5) var(--space-6) var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
}

.edd-blocks__download-header h3 a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color var(--duration-200) var(--ease-out);
}

.edd-blocks__download-header h3 a:hover {
    color: var(--color-brand-primary);
}

/* Content (excerpt + price) */
.edd-blocks__download-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 var(--space-6) var(--space-5);
}

.edd-blocks__download-content p {
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price */
.edd-blocks__download-price {
    margin-block-start: auto;
}

.edd-blocks__download-price .edd_price,
.edd-blocks__download-price .edd_price_range_low,
.edd-blocks__download-price .edd_price_range_high {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    background: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-brand-secondary) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.edd-blocks__download-price .edd_price_range_sep {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
    -webkit-text-fill-color: var(--color-text-tertiary);
}

/* Footer (buy button) */
.edd-blocks__download-footer {
    padding: var(--space-4) var(--space-6) var(--space-6);
    margin-block-start: auto;
    border-block-start: 1px solid var(--color-border-subtle);
}

.edd-blocks__download-footer .edd-blocks__buy-button .edd-submit,
.edd-blocks__download-footer .edd-add-to-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-inverse);
    background: var(--gradient-brand);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-decoration: none;
    transition:
        transform var(--duration-200) var(--ease-out),
        box-shadow var(--duration-200) var(--ease-out);
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.4);
}

.edd-blocks__download-footer .edd-blocks__buy-button .edd-submit:hover,
.edd-blocks__download-footer .edd-add-to-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.5);
}

