/**
 * MIBIOTA Points Redeem — dialog styling.
 *
 * Scoped entirely under .mibpts-overlay so nothing here can reach the rest of
 * the shop, and so the whole block can be safelisted in WP Rocket by two
 * selectors.
 */

.mibpts-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 24, 39, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: mibpts-fade .18s ease;
}

@keyframes mibpts-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mibpts-dialog {
    --mibpts-accent: #1f6f5b;
    position: relative;
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
    padding: 26px 26px 22px;
    border-radius: 14px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
    font-size: 15px;
    line-height: 1.45;
    animation: mibpts-rise .2s ease;
}

@keyframes mibpts-rise {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.mibpts-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}
.mibpts-close:hover { background: #f3f4f6; color: #111827; }
.mibpts-close svg { width: 16px; height: 16px; }

.mibpts-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
    padding-right: 28px;
}

.mibpts-icon {
    flex: 0 0 34px;
    width: 34px;
    font-size: 28px;
    line-height: 1;
    text-align: center;
    color: var(--mibpts-accent);
    --fa-primary-color: var(--mibpts-accent);
    --fa-secondary-color: var(--mibpts-accent);
    --fa-secondary-opacity: .38;
}

.mibpts-title {
    margin: 0 0 2px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    color: #111827;
}

.mibpts-balance {
    margin: 0;
    font-size: 14px;
    color: #4b5563;
}

.mibpts-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
}

.mibpts-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.mibpts-controls input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 4px;
    margin: 0;
    padding: 0;
    border-radius: 2px;
    background: #e5e7eb;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.mibpts-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: var(--mibpts-accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    cursor: grab;
}
.mibpts-controls input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: var(--mibpts-accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    cursor: grab;
}

.mibpts-amount {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mibpts-amount input[type="number"] {
    width: 78px;
    padding: 7px 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    text-align: right;
    color: #111827;
    background: #fff;
}
.mibpts-amount input[type="number"]:focus {
    outline: 2px solid color-mix(in srgb, var(--mibpts-accent) 45%, transparent);
    outline-offset: 1px;
    border-color: var(--mibpts-accent);
}

.mibpts-maxbtn {
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
}
.mibpts-maxbtn:hover { border-color: var(--mibpts-accent); color: var(--mibpts-accent); }

.mibpts-value {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--mibpts-accent) 8%, #fff);
}
.mibpts-value span { font-size: 14px; color: #4b5563; }
.mibpts-value strong { font-size: 20px; font-weight: 700; color: var(--mibpts-accent); }

.mibpts-note {
    margin: 0 0 16px;
    font-size: 12.5px;
    color: #6b7280;
}

.mibpts-apply {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: 0;
    border-radius: 10px;
    background: var(--mibpts-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}
.mibpts-apply:hover { background: color-mix(in srgb, var(--mibpts-accent) 88%, #000); }
.mibpts-apply[disabled] { opacity: .65; cursor: default; }
.mibpts-apply.is-busy { color: transparent; position: relative; }
.mibpts-apply.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mibpts-spin .7s linear infinite;
}

@keyframes mibpts-spin {
    to { transform: rotate(360deg); }
}

.mibpts-loading {
    padding: 34px 10px;
    text-align: center;
    color: #6b7280;
}

@media (max-width: 420px) {
    .mibpts-dialog { padding: 22px 18px 18px; }
    .mibpts-controls { flex-wrap: wrap; }
    .mibpts-controls input[type="range"] { flex: 1 1 100%; order: 2; }
    .mibpts-amount { order: 1; width: 100%; justify-content: space-between; }
    .mibpts-amount input[type="number"] { flex: 1 1 auto; }
}

/* Empty state: no points yet, or not enough for the minimum */
.mibpts-empty {
    margin: 0 0 18px;
    font-size: 14px;
    color: #4b5563;
}

.mibpts-apply--quiet {
    background: #f3f4f6;
    color: #374151;
}
.mibpts-apply--quiet:hover { background: #e5e7eb; }

/* Secondary action in the pending-discount state */
.mibpts-linkbtn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 0;
    background: none;
    color: #6b7280;
    font-size: 13.5px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.mibpts-linkbtn:hover { color: #111827; }
.mibpts-linkbtn.is-busy { opacity: .5; pointer-events: none; }

/* An empty balance keeps its (invisible) box, so a fragment refresh can fill
   it again once points come back. */
.wlr-message-info:has(.mibpts-empty-marker) {
    display: none !important;
}

/* Points box in the payment step, above the order button. Mobile only — on
   desktop the sidebar summary shows WPLoyalty's own card. Own class names, so
   the site's .mib-notices rules (display:grid !important inside
   #cfw-cart-summary-content) can't reach it. */
.mibpts-box { display: none; }

@media (max-width: 899px) {
    .mibpts-box {
        display: grid !important;
        grid-template-columns: 32px 1fr auto;
        column-gap: 14px;
        align-items: center;
        margin: 14px 0 18px !important;
        padding: 10px 12px;
        background: #fff;
        border: 1px solid #e3e9e7;
        border-radius: 10px;
        color: #1d2b2c;
        font-size: 13.5px;
        line-height: 1.45;
        font-weight: 500;
    }

    .mibpts-box__ic {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: color-mix(in srgb, #2ea68f 12%, #fff);
        color: #1c6455;
        font-size: 14px;
        --fa-primary-color: #1c6455;
        --fa-secondary-color: #1c6455;
        --fa-secondary-opacity: .38;
    }

    .mibpts-box p { margin: 0 !important; line-height: 1.45 !important; }

    .mibpts-box a {
        justify-self: end;
        color: #2ea68f !important;
        font-weight: 700 !important;
        text-decoration: none;
        white-space: nowrap;
    }
    .mibpts-box a:hover {
        color: #1c6455 !important;
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    /* Store credit (Solid Affiliate) is MOVED here from the collapsible
       summary by the script, so it leaves the #cfw-cart-summary-content
       scope its styling lived in. Give it the same card as the points box:
       its icon tile uses .mib-notice__ic and its action is a button rather
       than a link. */
    .mibpts-box .mib-notice__ic {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: color-mix(in srgb, #2ea68f 12%, #fff);
        color: #1c6455;
        font-size: 14px;
    }

    .mibpts-box .sld-ajax-button {
        grid-column: 3;
        justify-self: end;
        display: inline !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: none !important;
        box-shadow: none !important;
        color: #2ea68f !important;
        font: inherit !important;
        font-weight: 700 !important;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
    }
    .mibpts-box .sld-ajax-button:hover,
    .mibpts-box .sld-ajax-button:focus-visible {
        color: #1c6455 !important;
        background: none !important;
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    /* The moved node is still a .woocommerce-info, and WooCommerce's own
       background, border and padding outrank the card styling above. */
    /* The earn message has no action, so it needs no third column */
    .mibpts-box.mib-notice--earn { grid-template-columns: 32px 1fr; }

    .mibpts-box.woocommerce-info,
    .mibpts-box.wlr-message-info {
        background: #fff !important;
        border: 1px solid #e3e9e7 !important;
        border-radius: 10px !important;
        box-shadow: none !important;
        padding: 10px 12px !important;
        color: #1d2b2c !important;
        font-size: 13.5px !important;
        line-height: 1.45 !important;
        font-weight: 500 !important;
    }

    /* WooCommerce's own notice icon, if the node still carries one */
    .mibpts-box::before,
    .mibpts-box.woocommerce-info::before,
    .mibpts-box.wlr-message-info::before { content: none !important; }
}
