/*
 * Points conversion dialogs — Figma LPV_B2C_Loyalty, "Iteration 2 / Mon compte -> Ma fidélité",
 * confirmationDialog 653:90442 (confirmation) and 727:99744 (success).
 *
 * Markup: modules/loyalty/views/templates/front/loyalty-convert-dialog.tpl (theme override),
 * behaviour: js/loyalty-convert.js. Loaded on the account page and on the cart, so the component
 * carries its own tokens and buttons instead of the page ones. Native <dialog>: shown in the top
 * layer, its ::backdrop is the overlay.
 *
 * confirmationDialog 727:100679 / mobile 653:91151 (error). Below 768px the dialogs are bottom
 * sheets (mobile frames 653:89554, 653:91151): full width, top corners, grabber, stacked buttons.
 *
 * Icons are the Lucide ones referenced by the design (x, circle-check, triangle-alert).
 */
.loyalty-dialog {
    --loyalty-text-primary: #484D52;
    --loyalty-text-light: #FFFFFF;
    --loyalty-primary: #2CC1B2;
    --loyalty-secondary: #F28231;
    --loyalty-bg-tertiary: #F8F7F4;
    --loyalty-surface: #FFFFFF;
    --loyalty-border: #E4DECB;

    box-sizing: border-box;
    width: calc(100% - 32px);
    max-width: 563px;
    margin: auto;
    padding: 30px 0 0;
    border: 0;
    border-radius: 10px;
    background: var(--loyalty-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    color: var(--loyalty-text-primary);
    font: 14px/20px var(--lpv-font-06);
    text-align: center;
}
.loyalty-dialog *,
.loyalty-dialog *::before,
.loyalty-dialog *::after {
    box-sizing: border-box;
}
.loyalty-dialog[open] {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.loyalty-dialog::backdrop {
    background: rgba(72, 77, 82, .5);
}
.loyalty-dialog p,
.loyalty-dialog dl,
.loyalty-dialog dd,
.loyalty-dialog h2 {
    margin: 0;
    color: inherit;
}

.loyalty-dialog__close {
    position: absolute;
    top: 16px;
    right: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23484D52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E") no-repeat center / 18px 18px;
    cursor: pointer;
}
.loyalty-dialog__close:focus-visible,
.loyalty-dialog__btn:focus-visible {
    outline: 2px solid var(--loyalty-text-primary);
    outline-offset: 2px;
}
.loyalty-dialog__icon {
    width: 24px;
    height: 24px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232CC1B2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") no-repeat center / 24px 24px;
}

.loyalty-dialog--error .loyalty-dialog__icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23E5302A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

.loyalty-dialog__title {
    width: 100%;
    padding: 0 54px 10px;
    font: 20px/22px var(--lpv-font-01);
    text-transform: uppercase;
}

.loyalty-dialog__body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    padding: 0 20px;
}

.loyalty-dialog--success .loyalty-dialog__title,
.loyalty-dialog--error .loyalty-dialog__title {
    padding-top: 10px;
}
.loyalty-dialog__link,
.loyalty-dialog__link:hover {
    color: var(--loyalty-primary);
    font-weight: bold;
    text-decoration: underline;
}

/* ---- Voucher details (Figma VoucherDetailsContainer) ---- */
.loyalty-dialog__details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--loyalty-bg-tertiary);
    font: 12px/16px var(--lpv-font-06);
    text-align: left;
}
.loyalty-dialog__details > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.loyalty-dialog__details dt {
    font-weight: normal;
}
.loyalty-dialog__details dd {
    text-align: right;
    white-space: nowrap;
}
/* First line: bold label, Bebas figure, dashed separator below */
.loyalty-dialog__total {
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--loyalty-border);
}
.loyalty-dialog__total dt {
    font-weight: bold;
}
.loyalty-dialog__total dd {
    font: 20px/22px var(--lpv-font-01);
    text-transform: uppercase;
}
.loyalty-dialog__total--balance {
    padding-bottom: 0;
    border-bottom: 0;
}
.loyalty-dialog__total--balance dt {
    font-weight: normal;
}
.loyalty-dialog__strong {
    font-weight: bold;
}

/* ---- Buttons (Figma Button/Tertiary & Button/Secondary) ---- */
.loyalty-dialog__footer {
    display: flex;
    gap: 12px;
    width: 100%;
    padding: 20px;
}
.loyalty-dialog__btn {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 34px;
    padding: 2px 10px;
    border: 0;
    border-radius: 6px;
    font: 20px/20px var(--lpv-font-01);
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity .15s ease;
}
.loyalty-dialog__btn:hover,
.loyalty-dialog__btn:focus-visible {
    opacity: .85;
    text-decoration: none;
}
.loyalty-dialog__btn--tertiary,
.loyalty-dialog__btn--tertiary:hover {
    background: var(--loyalty-border);
    color: var(--loyalty-text-primary);
}
.loyalty-dialog__btn--secondary,
.loyalty-dialog__btn--secondary:hover {
    background: var(--loyalty-secondary);
    color: var(--loyalty-text-light);
}
.loyalty-dialog__btn[disabled] {
    cursor: wait;
    opacity: .6;
}

/* ---- Error dialog: the parts of the other outcome (data-outcome set by loyalty-convert.js) ---- */
.loyalty-dialog[data-outcome="rejected"] [data-show-for="unknown"],
.loyalty-dialog[data-outcome="unknown"] [data-show-for="rejected"] {
    display: none;
}

/* ---- Grabber, bottom sheet only ---- */
.loyalty-dialog__grabber {
    display: none;
}

/* ---- Mobile: bottom sheet ---- */
@media (max-width: 767px) {
    .loyalty-dialog {
        width: 100%;
        max-width: none;
        margin: auto 0 0;
        padding-top: 40px;
        border-radius: 10px 10px 0 0;
    }
    .loyalty-dialog__grabber {
        display: block;
        position: absolute;
        top: 15px;
        left: 50%;
        width: 60px;
        height: 6px;
        border-radius: 20px;
        background: #EDEBE4;
        transform: translateX(-50%);
    }
    .loyalty-dialog__close {
        top: 26px;
    }
    .loyalty-dialog__footer {
        flex-direction: column-reverse;
        padding: 16px 20px;
    }
    .loyalty-dialog__btn {
        flex: 0 0 auto;
        width: 100%;
    }
}
