/* Commerce & compliance surfaces (ADR 0017): invoices, gift vouchers, redemption, legal gate.
   Namespaced .cmc-* so nothing here leaks into the wider template. */

/* A light filter/action bar above a klp-panel table. Used by /admin/invoices and the voucher
   admin. klp-toolbar had no global definition before this - the admin pages that reached for it
   fell back to an unstyled block. */
.klp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1rem;
}

.klp-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    margin: 0;
}

/* Money columns line up on the decimal and read as figures, not prose. */
.cmc-invoices .cmc-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cmc-invoices .cmc-total {
    font-weight: 600;
}

/* A voided invoice is still visible (audit trail) but plainly struck through. */
.cmc-invoices tr.cmc-voided td:first-child,
.cmc-invoices tr.cmc-voided .cmc-total {
    color: var(--bs-secondary-color);
    text-decoration: line-through;
}

/* ── Gift purchase / redeem (Phase 2) ───────────────────────────────────────── */
.cmc-gift {
    max-width: 40rem;
}

.cmc-gift .cmc-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-bottom: 1rem;
}

.cmc-gift label {
    font-weight: 600;
    font-size: .9rem;
}

.cmc-code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.35rem;
    letter-spacing: .12em;
    font-weight: 700;
    padding: .5rem .9rem;
    border: 1px dashed var(--bs-border-color);
    border-radius: .5rem;
    display: inline-block;
    background: var(--bs-tertiary-bg);
}

.cmc-voucher-card {
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    padding: 1.25rem 1.4rem;
    background: var(--bs-card-bg);
}

.cmc-voucher-card.is-invalid {
    border-color: var(--bs-danger-border-subtle);
    background: var(--bs-danger-bg-subtle);
}

/* ── Legal acceptance gate (Phase 3) ────────────────────────────────────────── */
.cmc-legal {
    max-width: 42rem;
    margin: 3rem auto;
    padding: 2rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .9rem;
    background: var(--bs-card-bg);
}

.cmc-legal h1 {
    margin-top: 0;
}

.cmc-legal-summary {
    background: var(--bs-tertiary-bg);
    border-radius: .6rem;
    padding: 1rem 1.2rem;
    margin: 1.25rem 0;
    font-size: .95rem;
}

.cmc-legal-actions {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ── Checkout: review trust notes, outcome banner, promo disclosure, country confirm ───────── */
.cmc-trust {
    list-style: none;
    padding: 0;
    margin: .85rem 0 0;
    display: grid;
    gap: .3rem;
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

.cmc-trust li {
    display: flex;
    gap: .45rem;
    align-items: baseline;
}

.cmc-trust li > span:first-child {
    flex: 0 0 1rem;
    text-align: center;
}

.cmc-outcome {
    font-size: .9rem;
}

.cmc-outcome ul {
    padding-left: 1.1rem;
}

.cmc-havecode > summary {
    cursor: pointer;
    font-size: .88rem;
    color: var(--bs-link-color);
    width: max-content;
}

.cmc-confirm-country {
    font-size: .88rem;
}

/* "Activating your access…" */
.cmc-dots::after {
    content: "";
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: cmc-dots 1.2s steps(4, end) infinite;
}

@keyframes cmc-dots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
}

@media (prefers-reduced-motion: reduce) {
    .cmc-dots::after { animation: none; content: "..."; }
}

/* ── Sale window + countdown (catalogue card and course page) ─────────────────────────────── */
.crs-sale-state {
    display: inline-block;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--bs-body-color);
}

.crs-enrolbox .crs-sale-state {
    font-size: 1.35rem;
    margin-top: .35rem;
}

.crs-sale-state--inline {
    font-weight: 600;
}

.crs-countdown {
    display: inline-block;
    margin-top: .2rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}

.crs-countdown--inline {
    margin-left: .4rem;
    vertical-align: .1em;
}

.crs-buy-price .crs-countdown {
    display: block;
    width: max-content;
}

.mx-price-basenote {
    display: block;
}

/* ── Sticky mobile price + CTA bar on the course page ─────────────────────────────────────── */
.crs-stickybar {
    display: none;
}

@media (max-width: 767.98px) {
    .crs-stickybar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1010;
        padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom, 0px));
        background: var(--bs-body-bg);
        border-top: 1px solid var(--bs-border-color);
        box-shadow: 0 -6px 24px -14px rgba(0, 0, 0, .35);
    }

    .crs-stickybar-price {
        font-weight: 700;
        font-size: 1.05rem;
        min-width: 0;
    }

    .crs-stickybar-price .mx-price-indicative {
        font-weight: 400;
    }

    /* room for the bar so it never covers the page's last lines, and lift the WhatsApp bubble over it */
    body:has(.crs-stickybar):not(:has([data-enrol-nothing-to-buy])) .mkt-section[data-merch-page] {
        padding-bottom: 5.5rem;
    }

    body:has(.crs-stickybar):not(:has([data-enrol-nothing-to-buy])) .mx-wa-float {
        bottom: 5.2rem;
    }

    /* The page is cached (same HTML for all), so the enrol box drops a marker once it knows the visitor
       owns the course or there's nothing to buy - then the "Buy now" bar goes. */
    body:has([data-enrol-nothing-to-buy]) .crs-stickybar {
        display: none;
    }
}

/* ── Printable gift card ──────────────────────────────────────────────────────────────────── */
.cmc-giftcard {
    max-width: 34rem;
    margin: 0 auto;
    padding: 2.2rem 2rem;
    border: 2px solid var(--bs-border-color);
    border-radius: 1.1rem;
    background: var(--bs-card-bg);
    text-align: center;
}

.cmc-giftcard-brand {
    --mx-logo-w: 11rem;
}

.cmc-giftcard-title {
    font-size: 1.8rem;
    margin: .6rem 0 .4rem;
}

.cmc-giftcard-course {
    font-size: 1.1rem;
}

.cmc-giftcard-msg {
    font-style: italic;
    margin: 1rem auto;
    max-width: 26rem;
}

.cmc-giftcard-code-label {
    margin-top: 1.2rem;
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

.cmc-giftcard-code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: .14em;
    margin: .3rem 0 1rem;
}

.cmc-giftcard-how,
.cmc-giftcard-exp {
    font-size: .88rem;
    margin-bottom: .3rem;
}

@media print {
    body * { visibility: hidden; }
    .cmc-giftcard, .cmc-giftcard * { visibility: visible; }
    .cmc-giftcard { position: absolute; left: 0; right: 0; top: 2cm; border-color: #000; color: #000; background: #fff; }
    .cmc-giftcard-actions { display: none !important; }
}
