﻿/* AnyData BIStore - Contract Management checkout refactor
   Add to wwwroot/css/bistore-cm-checkout.css and load after the existing BIStore CSS. */

.modal-content.buynow-modal.cm-checkout-modal {
    width: min(1240px, 96vw) !important;
    max-width: 1240px !important;
    max-height: 96vh;
    overflow: auto;
    padding: 0 !important;
}

.cm-checkout-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: stretch;
    gap: 1rem;
    padding: 1.1rem;
}

.cm-checkout-main {
    min-width: 0;
}

/* Keep the CM configuration column level with the full-height order summary. */
.modal-width-cm .cm-checkout-main {
    display: flex;
    flex-direction: column;
}

.modal-width-cm .cm-checkout-section {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.modal-width-cm .cm-option-grid {
    flex: 1 1 auto;
}

.modal-width-cm .cm-option-grid .cm-plan-card {
    height: 100%;
    box-sizing: border-box;
}

.cm-checkout-header {
    margin-bottom: .75rem;
}

    .cm-checkout-header h2 {
        margin: 0;
        color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
        font-size: clamp(1.5rem, 2.2vw, 2rem);
        line-height: 1.2;
    }

    .cm-checkout-header p {
        margin: .45rem 0 0;
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
    }

.cm-checkout-section {
    margin-top: .8rem;
}

.cm-checkout-section-title {
    margin: 0 0 .7rem;
    font-size: 1rem;
    font-weight: 700;
}

.cm-checkout-field label {
    cursor: pointer;
}

.cm-account-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(3, 16, 35, .72);
    backdrop-filter: blur(4px);
}

.cm-account-dialog {
    width: min(620px, calc(100vw - 2rem));
    max-height: min(90vh, 760px);
    overflow: auto;
    padding: 1.15rem;
    border: 1px solid var(--dxbl-border-color, var(--bs-border-color, #d8dee8));
    border-radius: 18px;
    background: var(--dxbl-card-bg, var(--bs-body-bg, #fff));
    color: var(--dxbl-body-color, var(--bs-body-color, #20242a));
    box-shadow: 0 24px 70px rgba(3, 16, 35, .3);
}

.cm-account-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

    .cm-account-dialog-header h2 {
        margin: 0;
        color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
        font-size: 1.35rem;
    }

    .cm-account-dialog-header p {
        margin: .3rem 0 0;
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
        font-size: .88rem;
    }

.cm-account-dialog .cm-account-dialog-close {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085)) !important;
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
}

.cm-account-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
}

.cm-account-dialog .cm-account-option {
    appearance: none;
    display: grid;
    gap: .15rem;
    min-height: 62px;
    padding: .65rem .8rem;
    border: 1px solid var(--dxbl-border-color, var(--bs-border-color, #d8dee8)) !important;
    border-radius: 11px !important;
    background: var(--dxbl-editor-bg, var(--bs-body-bg, #fff)) !important;
    color: var(--dxbl-body-color, var(--bs-body-color, #20242a)) !important;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

    .cm-account-dialog .cm-account-option:hover:not(:disabled) {
        border-color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
    }

    .cm-account-dialog .cm-account-option.active {
        border-color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
        background: color-mix(in srgb, var(--bistore-primary, #2b8198) 8%, var(--bs-body-bg, #fff)) !important;
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--bistore-primary, #2b8198) 12%, transparent);
    }

.cm-account-option-title {
    color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
    font-weight: 750;
}

.cm-account-option-caption {
    color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
    font-size: .78rem;
}

.cm-account-dialog-fields {
    margin-top: .85rem;
}

.cm-account-consent {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin-top: .85rem;
    padding: .7rem;
    border: 1px solid color-mix(in srgb, var(--bistore-primary, #2b8198) 24%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 6%, transparent);
    font-size: .8rem;
    line-height: 1.4;
}

    .cm-account-consent input {
        flex: 0 0 auto;
        width: 17px;
        height: 17px;
        margin-top: .18rem;
    }

    .cm-account-consent label {
        display: inline;
        margin: 0;
        text-align: left;
        line-height: 1.5;
        cursor: pointer;
    }

    .cm-account-consent .legal-document-link {
        display: inline-flex !important;
        align-items: center !important;
        width: auto !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 .18rem !important;
        padding: .08rem .38rem !important;
        border: 0 !important;
        border-radius: 999px !important;
        background: color-mix(in srgb, var(--bistore-primary, #2b8198) 12%, transparent) !important;
        box-shadow: none !important;
        color: var(--bistore-primary, #2b8198) !important;
        font-size: .68rem !important;
        font-weight: 700 !important;
        line-height: 1.25 !important;
        text-decoration: none !important;
        vertical-align: .08rem;
        white-space: nowrap;
    }

    .cm-account-consent .legal-document-link:hover,
    .cm-account-consent .legal-document-link:focus-visible {
        background: color-mix(in srgb, var(--bistore-primary, #2b8198) 20%, transparent) !important;
        color: var(--bistore-primary, #2b8198) !important;
    }

.cm-account-dialog-validation {
    margin-top: .75rem;
}

.cm-account-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    margin-top: .9rem;
    padding-top: .8rem;
    border-top: 1px solid var(--dxbl-border-color, var(--bs-border-color, #e2e7ee));
}

    .cm-account-dialog-actions .cm-account-dialog-primary {
        min-width: 210px;
    }

    .cm-account-dialog-actions .cm-account-dialog-cancel {
        min-width: 120px;
        background: transparent !important;
        color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
        border: 1px solid var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
    }

.cm-signed-in-banner {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-top: .75rem;
    padding: .65rem .8rem;
    border: 1px solid color-mix(in srgb, #20b26b 28%, transparent);
    border-radius: 11px;
    background: color-mix(in srgb, #20b26b 8%, transparent);
    font-size: .88rem;
}

.cm-signed-in-check {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #20b26b;
    color: #fff;
    font-weight: 800;
}

.cm-plan-card {
    border: 1px solid var(--dxbl-border-color, var(--bs-border-color, #d8dee8));
    border-radius: 14px;
    background: var(--dxbl-card-bg, var(--bs-body-bg, #fff));
    padding: .8rem;
}

    .cm-plan-card + .cm-plan-card {
        margin-top: .65rem;
    }

.cm-plan-card-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

    .cm-plan-card-heading h3 {
        margin: 0;
        font-size: 1.05rem;
    }

    .cm-plan-card-heading p {
        margin: .25rem 0 0;
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
        font-size: .9rem;
    }

.cm-price-badge {
    white-space: nowrap;
    font-weight: 750;
    color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
}

.cm-checkout-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
    margin-top: .65rem;
}

.cm-checkout-field {
    display: grid;
    gap: .35rem;
}

    .cm-checkout-field.full-width {
        grid-column: 1 / -1;
    }

    .cm-checkout-field label {
        font-size: .86rem;
        font-weight: 650;
    }

    .cm-checkout-field select,
    .cm-checkout-field input,
    .cm-checkout-main .email-input {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        min-height: 40px;
        border: 1px solid var(--dxbl-border-color, var(--bs-border-color, #d8dee8));
        border-radius: 10px;
        background: var(--dxbl-editor-bg, var(--bs-body-bg, #fff));
        color: var(--dxbl-body-color, var(--bs-body-color, #20242a));
        padding: .5rem .7rem;
        font: inherit;
        line-height: 1.25;
        box-sizing: border-box;
    }

    .cm-checkout-field select {
        padding-right: 2.35rem;
        background-image:
            linear-gradient(45deg, transparent 50%, currentColor 50%),
            linear-gradient(135deg, currentColor 50%, transparent 50%);
        background-position:
            calc(100% - 16px) 50%,
            calc(100% - 11px) 50%;
        background-size: 5px 5px, 5px 5px;
        background-repeat: no-repeat;
        cursor: pointer;
    }

    .cm-checkout-field select::-ms-expand {
        display: none;
    }

    .cm-checkout-field select:focus,
    .cm-checkout-field input:focus,
    .cm-checkout-main .email-input:focus {
        outline: none;
        border-color: var(--bistore-primary, #2b8198);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--bistore-primary, #2b8198) 18%, transparent);
    }

.cm-capacity-fields {
    grid-template-columns: minmax(0, 1fr) 76px;
    align-items: end;
}

    .cm-capacity-fields .cm-checkout-field {
        min-width: 0;
    }

    .cm-capacity-fields .cm-checkout-field label {
        display: flex;
        align-items: flex-end;
        min-height: auto;
        line-height: 1.2;
        white-space: nowrap;
    }

    .cm-capacity-fields select,
    .cm-capacity-fields input {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

.cm-selection-note {
    margin-top: .55rem;
    padding: .55rem .7rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 8%, transparent);
    font-size: .9rem;
    line-height: 1.45;
}

.cm-included-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .3rem .75rem;
    margin: .65rem 0 0;
    padding: 0;
    list-style: none;
    font-size: .9rem;
}

    .cm-included-list li::before {
        content: "✓";
        margin-right: .45rem;
        color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
        font-weight: 800;
    }

.cm-option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: .65rem;
    margin-top: .65rem;
}

    .cm-option-grid .cm-plan-card {
        margin-top: 0;
        padding: .65rem;
    }

    .cm-option-grid .cm-plan-card-heading h3 {
        font-size: .95rem;
        line-height: 1.2;
    }

    .cm-option-grid .cm-plan-card-heading p {
        font-size: .82rem;
        line-height: 1.3;
    }

    .cm-option-grid .cm-checkout-fields {
        margin-top: .4rem;
    }

    .cm-option-grid .cm-selection-note {
        margin-top: .4rem;
        padding: .45rem .55rem;
        font-size: .82rem;
        line-height: 1.3;
    }

.cm-order-summary {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    border: 1px solid var(--dxbl-border-color, var(--bs-border-color, #d8dee8));
    border-radius: 16px;
    background: var(--dxbl-card-bg, var(--bs-body-bg, #fff));
    box-shadow: 0 14px 36px rgba(10, 35, 58, .11);
    padding: .7rem;
}

.cm-order-summary-header {
    display: flex;
    align-items: center;
    gap: 0;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--dxbl-border-color, var(--bs-border-color, #e2e7ee));
}

.cm-order-summary h3 {
    margin: 0;
    color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
    font-size: 1.1rem;
}

.cm-summary-product {
    padding: .45rem 0 .15rem;
}

    .cm-summary-product strong,
    .cm-summary-product span {
        display: block;
    }

    .cm-summary-product span {
        margin-top: .2rem;
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
        font-size: .88rem;
    }

.cm-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .2rem 0;
    font-size: .92rem;
}

    .cm-summary-row span:last-child {
        text-align: right;
        font-weight: 650;
    }

.cm-summary-divider {
    margin: .3rem 0;
    border-top: 1px solid var(--dxbl-border-color, var(--bs-border-color, #e2e7ee));
}

.cm-summary-total {
    font-size: 1.02rem;
    font-weight: 750;
}

.cm-summary-due {
    font-size: 1.15rem;
    color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198));
}

.cm-summary-caption {
    margin: .35rem 0 0;
    color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
    font-size: .78rem;
    line-height: 1.4;
}

.cm-summary-consent {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-top: .65rem;
    padding: .65rem .7rem;
    border: 1px solid color-mix(in srgb, var(--bistore-primary, #2b8198) 24%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 6%, transparent);
    font-size: .78rem;
    line-height: 1.35;
}

    .cm-summary-consent input {
        flex: 0 0 auto;
        width: 17px;
        height: 17px;
        margin-top: .18rem;
    }

    .cm-summary-consent label {
        display: inline;
        margin: 0;
        text-align: left;
        line-height: 1.5;
        cursor: pointer;
    }

.cm-consent-optional {
    display: inline-flex;
    align-items: center;
    margin-left: .18rem;
    padding: .08rem .38rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 12%, transparent);
    color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.25;
    vertical-align: .08rem;
}

/* The legal action is a compact inline badge, not a full checkout button. */
.cm-summary-consent .legal-document-link {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 .18rem !important;
    padding: .08rem .38rem !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 12%, transparent) !important;
    box-shadow: none !important;
    color: var(--bistore-primary, #2b8198) !important;
    font-size: .68rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    text-decoration: none !important;
    vertical-align: .08rem;
    white-space: nowrap;
}

.cm-summary-consent .legal-document-link:hover,
.cm-summary-consent .legal-document-link:focus-visible {
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 20%, transparent) !important;
    color: var(--bistore-primary, #2b8198) !important;
}

.legal-document-link {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #197c9f;
    font: inherit;
    line-height: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.legal-document-link:hover,
.legal-document-link:focus-visible {
    color: #125f7a;
}

.legal-document-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(.75rem, 2vw, 1.5rem);
    background: rgba(8, 20, 43, .72);
    backdrop-filter: blur(5px);
}

.legal-document-dialog {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: min(1120px, 96vw);
    height: min(860px, 94vh);
    overflow: hidden;
    border: 1px solid #d8e5ed;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(5, 18, 40, .28);
}

.legal-document-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dceaf1;
}

.legal-document-header h2 {
    margin: 0;
    color: #2d8dac;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
}

.legal-document-close {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #526273;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.legal-document-close:hover,
.legal-document-close:focus-visible {
    background: #edf7fa;
    color: #197c9f;
}

.legal-document-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.legal-document-actions {
    display: flex;
    justify-content: center;
    padding: .75rem 1.25rem 1rem;
    border-top: 1px solid #dceaf1;
    background: #fff;
}

@media (max-width: 640px) {
    .legal-document-overlay {
        padding: .35rem;
    }

    .legal-document-dialog {
        width: 100%;
        height: 98vh;
        border-radius: 14px;
    }

    .legal-document-header {
        padding: .8rem 1rem;
    }
}

.cm-summary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .65rem;
    margin-top: auto;
    padding-top: .75rem;
}

    .cm-summary-actions .bistore-button {
        width: 100%;
        min-height: 40px;
    }

    .cm-summary-actions .cm-cancel-button {
        background: transparent !important;
        color: var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
        border: 1px solid var(--bistore-primary, var(--dxbl-accent-color, #2b8198)) !important;
        min-width: 92px;
    }

.cm-enterprise-note {
    display: grid;
    gap: .35rem;
    margin-top: .45rem;
    padding-top: .4rem;
    border-top: 1px solid var(--dxbl-border-color, var(--bs-border-color, #e2e7ee));
    font-size: .82rem;
    line-height: 1.4;
}

.cm-validation-slot {
    margin-top: .55rem;
}

.sai-checkout-main {
    display: flex;
    flex-direction: column;
}

.sai-plan-card {
    padding: 1rem;
}

.sai-purchase-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .75rem;
}

    .sai-purchase-badges span {
        padding: .3rem .6rem;
        border: 1px solid color-mix(in srgb, var(--bistore-primary, #2b8198) 22%, transparent);
        border-radius: 999px;
        background: color-mix(in srgb, var(--bistore-primary, #2b8198) 6%, transparent);
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
        font-size: .78rem;
        font-weight: 650;
    }

.sai-included-title {
    margin: .85rem 0 0;
    font-size: .95rem;
}

.sai-included-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sai-quantity-card {
    margin-top: .65rem;
}

.sai-quantity-fields {
    grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
    align-items: stretch;
}

.sai-order-note {
    display: grid;
    align-content: center;
    gap: .2rem;
    padding: .65rem .75rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--bistore-primary, #2b8198) 8%, transparent);
    font-size: .85rem;
}

    .sai-order-note span {
        color: var(--dxbl-secondary-color, var(--bs-secondary-color, #667085));
        line-height: 1.35;
    }

@media (max-width: 920px) {
    .cm-checkout-shell {
        grid-template-columns: 1fr;
    }

    .cm-order-summary {
        position: static;
    }

    .cm-option-grid {
        grid-template-columns: 1fr;
    }

    .modal-width-cm .cm-checkout-section,
    .modal-width-cm .cm-option-grid {
        flex: initial;
    }

    .modal-width-cm .cm-option-grid .cm-plan-card {
        height: auto;
    }

    .sai-included-list,
    .sai-quantity-fields {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .modal-content.buynow-modal.cm-checkout-modal {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100vh;
        border-radius: 0 !important;
    }

    .cm-checkout-shell {
        padding: 1rem;
        gap: 1rem;
    }

    .cm-checkout-fields,
    .cm-included-list,
    .cm-account-switch {
        grid-template-columns: 1fr;
    }

    .cm-account-dialog-actions {
        flex-direction: column;
    }

    .cm-account-dialog-actions .bistore-button {
        width: 100%;
    }

    .cm-summary-actions {
        grid-template-columns: 1fr;
    }

    .cm-plan-card-heading {
        display: grid;
    }
}


.cm-order-summary .cm-enterprise-button {
    display: block !important;
    width: 100% !important;
    min-height: 40px !important;
    margin: 0 !important;
    border: 1px solid #20b26b !important;
    border-radius: 999px !important;
    padding: .35rem .7rem !important;
    background: #20b26b !important;
    box-shadow: 0 8px 20px rgba(32, 178, 107, .16) !important;
    color: #fff !important;
    text-decoration: none !important;
    font: inherit !important;
    font-weight: 700;
    cursor: pointer;
}

    .cm-order-summary .cm-enterprise-button:hover {
        background: #17955a !important;
        border-color: #17955a !important;
        color: #fff !important;
    }

.cm-order-summary button:disabled,
.cm-checkout-main input:disabled,
.cm-checkout-main select:disabled,
.cm-account-dialog button:disabled,
.cm-account-dialog input:disabled {
    cursor: not-allowed;
    opacity: .65;
}
