/*
 * css/api_order.css
 *
 * Modern, card-based styling for the /order form, built on the global
 * design tokens in style.css (colors, radii, shadows, Inter). Reuses
 * .form-group / .btn / .checkbox-label / .form-error / .required and layers
 * the order-specific layout + visual polish on top. All field names, ids and
 * the [hidden] toggling are preserved so js/api_order.js keeps working.
 */

/* Tinted backdrop so the white form card lifts off the page. The
 * `order-page` class is set on the <section> in inc/api_order_page.php. */
.order-page {
    background: var(--bg-alt);
}

.order-form-wrap {
    max-width: 1040px;
    margin: 0 auto;
}

#formErrorBanner {
    margin-bottom: 20px;
}

/* The form is the elevated card. */
.order-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    position: relative;
    overflow: hidden;
}

/* Brand accent rule across the top edge of the card. */
.order-form::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

@media (max-width: 600px) {
    .order-form { padding: 24px 20px; }
}

/* ---- Section headings ---- */
.order-form h2.order-form-section {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    margin: 34px 0 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.order-form h2.order-form-section:first-of-type {
    margin-top: 6px;
}

/* The first heading inside each column should sit flush with the top of the
 * column, not carry the big inter-section top margin. */
.order-col > h2.order-form-section:first-child {
    margin-top: 0;
}

.order-form-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

/* ---- Two-column body: products (left) / customer data (right) ---- */
.order-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 32px;
    align-items: start;
}

.order-col {
    min-width: 0;
}

/* Products panel: visually distinct, sticky alongside the customer fields. */
.order-col-products {
    position: sticky;
    top: 24px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

@media (max-width: 800px) {
    .order-grid {
        grid-template-columns: 1fr;
    }
    .order-col-products {
        position: static;
    }
}

/* ---- Two-column rows ---- */
.order-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

@media (max-width: 600px) {
    .order-form .form-row { grid-template-columns: 1fr; }
}

/* ---- Fields ---- */
.order-form .form-group { margin-bottom: 18px; }

.order-form select,
.order-form input[type="text"],
.order-form input[type="email"],
.order-form textarea {
    width: 100%;
    box-sizing: border-box;
}

.order-form input[type="text"],
.order-form input[type="email"],
.order-form select,
.order-form textarea {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: .95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.order-form input[type="text"]:hover,
.order-form input[type="email"]:hover,
.order-form select:hover {
    border-color: #cbd5e1;
}

.order-form input[type="text"]:focus,
.order-form input[type="email"]:focus,
.order-form select:focus,
.order-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 87, 184, .12);
}

.order-form ::placeholder {
    color: var(--text-light);
    opacity: 1;
}

/* Selects get a custom chevron; the product picker reads a touch bolder. */
.order-form select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 40px;
    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='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}

.order-form select#product {
    font-weight: 600;
}

/* "Includes" — render the read-only description as a soft info note,
 * not a big editable textarea. */
.order-form textarea[readonly] {
    min-height: 0;
    resize: none;
    padding: 12px 14px;
    font-size: .9rem;
    color: var(--text);
    background: var(--primary-lt);
    border: 1px solid #cfe2f6;
    border-left: 3px solid var(--primary);
    cursor: default;
}

/* ---- Radios, checkboxes ---- */
.order-form input[type="checkbox"],
.order-form input[type="radio"] {
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    flex: 0 0 auto;
    vertical-align: middle;
    accent-color: var(--primary);
}

/* "Register License To" — segmented, card-style choices. */
.order-form .radio-row {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.order-form .radio-label {
    display: inline-flex !important;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 !important;
    padding: 11px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: .95rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.order-form .radio-label:hover {
    border-color: var(--primary);
}

.order-form .radio-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-lt);
    color: var(--primary-dk);
    font-weight: 600;
}

/* Inline checkboxes (delivery-same, premium upsell). */
.order-form .checkbox-label {
    display: inline-flex !important;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    font-size: .95rem;
    font-weight: 400;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
}

.order-form .radio-label > span,
.order-form .checkbox-label > span {
    display: inline;
    white-space: nowrap;
}

/* The long "recipient same as purchaser" label may wrap on small screens. */
@media (max-width: 480px) {
    .order-form .checkbox-label,
    .order-form .checkbox-label > span {
        white-space: normal;
    }
}

/* Premium support — highlighted as an amber upsell card. */
.order-form #row-premium {
    margin-top: 6px;
    padding: 14px 16px;
    border: 1px solid #f0d8a0;
    border-radius: var(--radius-sm);
    background: #fffaf0;
    transition: border-color var(--transition), background var(--transition);
}

.order-form #row-premium:has(input:checked) {
    border-color: var(--accent);
    background: #fff4dc;
}

.order-form #row-premium .checkbox-label {
    font-weight: 600;
}

/* ---- Cart: Offers (secondary section below the cart) ---- */
.order-form .cart-offers {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.order-form .cart-offers-title {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-light);
    margin: 0 0 10px;
}

/* Offers are spaced, link-style rows (not cramped buttons). */
.order-form .cart-related {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.order-form .cart-offer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font-size: .9rem;
    transition: border-color var(--transition), background var(--transition);
}

.order-form .cart-offer:hover {
    border-color: var(--primary);
    background: var(--primary-lt);
}

/* The "+" add button at the start of each offer row. */
.order-form .cart-offer-plus {
    flex: 0 0 auto;
    margin-top: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    transition: background var(--transition);
}

.order-form .cart-offer:hover .cart-offer-plus {
    background: var(--primary-dk);
}

/* Two stacked lines: name + badge on top, price below. */
.order-form .cart-offer-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.order-form .cart-offer-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 8px;
}
.order-form .cart-offer-name {
    font-weight: 500;
}

/* "Recommended" badge on a highlighted offer row. */
.order-form .cart-offer-badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent, #e8a33d);
    color: #fff;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}

.order-form .cart-offer-price {
    font-weight: 600;
    white-space: nowrap;
    color: var(--text);
}

/* Shared price formatting: struck-through original + the price actually paid. */
.order-form .cart-price-full {
    color: var(--text-light);
    font-weight: 400;
    text-decoration: line-through;
    margin-right: 2px;
}
.order-form .cart-price-net {
    font-weight: 600;
    color: var(--text);
}

/* ---- Cart: product picker row ---- */
.order-form .cart-picker {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
}

@media (max-width: 600px) {
    .order-form .cart-picker {
        grid-template-columns: 1fr;
    }
}

/* The picker's Premium toggle sits inline with the select + Add button. */
.order-form .cart-picker-premium {
    font-size: .9rem;
    color: var(--text);
    white-space: nowrap;
}

.order-form .cart-add {
    padding: 12px 22px;
    font-size: .95rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* ---- Cart: line list ---- */
.order-form .cart-items {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
}

.order-form .cart-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.order-form .cart-item:hover {
    border-color: #cbd5e1;
}

/* The renewed product line: locked (no Remove / no premium toggle), tinted
 * and emphasized so the bought product reads as the prominent part of the
 * column, standing out above the subtle Offers section. */
.order-form .cart-item-locked {
    background: var(--primary-lt);
    border-color: #cfe2f6;
    border-left: 3px solid var(--primary);
}

.order-form .cart-item-locked .cart-item-label {
    font-weight: 700;
    color: var(--primary-dk, var(--primary));
}

.order-form .cart-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-form .cart-item-label {
    flex: 1;
    font-weight: 600;
    color: var(--text);
    font-size: .95rem;
}

.order-form .cart-item-price {
    font-weight: 700;
    color: var(--text);
    font-size: .95rem;
    white-space: nowrap;
}

/* Updates + source line under each product (e.g. "Includes 12 months of
   updates. Sources Included."). */
.order-form .cart-item-desc {
    margin: 6px 0 0;
    font-size: .82rem;
    line-height: 1.4;
    color: var(--text-light);
}

/* Client-side validation: missing required field + error banner. */
.order-form .is-invalid {
    border-color: #d9534f !important;
    box-shadow: 0 0 0 3px rgba(217, 83, 79, .14);
}
.order-form .order-error {
    max-width: 640px;
    margin: 0 auto 16px;
    padding: 12px 16px;
    text-align: center;
    font-size: .9rem;
    font-weight: 600;
    color: #a11;
    background: #fdeaea;
    border: 1px solid #f3c2c2;
    border-radius: var(--radius-sm);
}

/* Renewal note, shown above the offers when a renewal coupon is present. */
.order-form .order-renewal-note {
    margin: 0 0 16px;
    padding: 10px 12px;
    font-size: .82rem;
    line-height: 1.45;
    color: var(--text);
    background: var(--primary-lt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Live price preview (subtotal / tax / total). */
.order-form .order-summary {
    margin-top: 18px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.order-form .order-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    font-size: .9rem;
    color: var(--text-light);
}
.order-form .order-summary-row > span:last-child {
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.order-form .order-summary-total {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.order-form .order-summary-update {
    margin-top: 12px;
    width: 100%;
    padding: 8px 14px;
    background: var(--primary-lt);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.order-form .order-summary-update:hover {
    background: var(--primary);
    color: #fff;
}
.order-form .order-summary-note {
    margin: 10px 0 0;
    font-size: .76rem;
    line-height: 1.4;
    color: var(--text-light);
}

.order-form .cart-item-remove {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-light);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.order-form .cart-item-remove:hover {
    border-color: #e2a4a4;
    color: #c0392b;
    background: #fdf3f2;
}

/* Per-line premium toggle, amber to echo the upsell styling. */
.order-form .cart-item-premium {
    margin-top: 10px !important;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: .85rem;
    font-weight: 500;
    color: var(--text);
    width: 100%;
}

.order-form .cart-item:has(.cart-item-premium input:checked) {
    border-color: #f0d8a0;
    background: #fffaf0;
}

/* ---- Cart: empty state ---- */
.order-form .cart-empty {
    margin: 0 0 6px;
    padding: 18px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    color: var(--text-light);
    font-size: .9rem;
    text-align: center;
}

/* ---- Cart: summary ---- */
.order-form .cart-summary {
    margin: 14px 0 6px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--primary-lt);
}

.order-form .cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: .95rem;
    color: var(--text);
    margin-bottom: 8px;
}

.order-form .cart-summary-row:last-child {
    margin-bottom: 0;
}

.order-form .cart-summary-discount {
    color: var(--accent-dk, #b97e00);
    font-weight: 600;
}

.order-form .cart-summary-total {
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid #cfe2f6;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.order-form .cart-summary-total span:last-child {
    color: var(--primary-dk, var(--primary));
}

/* ---- Cart: savings hint ---- */
.order-form .cart-savings-hint {
    margin: 8px 0 0;
    font-size: .8rem;
    color: var(--text-light);
}

/* ---- Submit + terms ---- */
.order-form-submit {
    display: block;
    width: auto;
    min-width: 260px;
    max-width: 100%;
    margin: 28px auto 0;
    padding: 15px 36px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

@media (max-width: 600px) {
    .order-form-submit { width: 100%; }
}

.order-form-submit:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.order-form-terms {
    margin-top: 14px;
    font-size: .8rem;
    color: var(--text-light);
    text-align: center;
}

/* Sets expectations before the buyer clicks: a secure payment page opens
 * next with the final total + payment fields. */
.order-checkout-note {
    max-width: 640px;
    margin: 18px auto 0;
    padding: 12px 16px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
    line-height: 1.5;
    color: var(--text-light);
    text-align: center;
}

.order-form-terms a {
    color: var(--primary);
    font-weight: 600;
}

/* JS toggles visibility via the [hidden] attribute. */
.order-form [hidden] {
    display: none !important;
}

/* The company name + VAT row must follow the LIVE "Register License To"
   radio, independent of JS timing or the browser restoring the radio on a
   back/forward navigation (e.g. returning from the Paddle checkout, where no
   change event fires). Pure CSS so the visibility can never get out of sync;
   the JS still keeps the `required` flags in step on pageshow. */
.order-form:not(:has(input[name="register"][value="company"]:checked)) #row-company {
    display: none !important;
}
.order-form:has(input[name="register"][value="company"]:checked) #row-company {
    display: grid !important;
}
