/* ═══════════════════════════════════════════════════════════════
   MODAL — Premium design system  (Tigsi / checkout palette)
   ─────────────────────────────────────────────────────────────
   Classes couvertes :
     • .custom-modal / .custom-modal-content  (MM, SCI)
     • .modal-content / .modal-btn            (#custom-modal confirm)
     • Spinner, copy button, error container
═══════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
    --mo-c1:       #667eea;
    --mo-c2:       #764ba2;
    --mo-green:    #25D366;
    --mo-red:      #f5576c;
    --mo-orange:   #ff9800;
    --mo-grad:     linear-gradient(135deg, var(--mo-c1) 0%, var(--mo-c2) 100%);
    --mo-shadow:   0 24px 64px rgba(102,126,234,.22);
    --mo-radius:   20px;
    --mo-border:   rgba(102,126,234,.15);
    --mo-bg:       #ffffff;
    --mo-text:     #1f2937;
    --mo-muted:    #6b7280;
    --mo-pad:      1.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   BACKDROP
═══════════════════════════════════════════════════════════════ */
.custom-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15,15,25,.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    padding: 1.25rem;
}
/* Le JS (toast.js) fait style.display="block" — on le re-force en flex pour le centrage */
.custom-modal.active,
.custom-modal[style*="display: block"],
.custom-modal[style*="display:block"],
.custom-modal[style*="display: flex"],
.custom-modal[style*="display:flex"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Au-dessus du modal billetterie (z-index 100050) */
#sciResponseModal.ticket-pay-sci-modal,
#responseModal.ticket-pay-sci-modal {
    z-index: 100100 !important;
}

/* ═══════════════════════════════════════════════════════════════
   CARD  (shared by .custom-modal-content and .modal-content)
═══════════════════════════════════════════════════════════════ */
.custom-modal-content,
.modal-content {
    position: relative;
    background: var(--mo-bg);
    border-radius: var(--mo-radius);
    box-shadow: var(--mo-shadow);
    width: 100%;
    max-width: 460px;
    margin: auto;
    overflow: hidden;
    animation: moSlideUp .32s cubic-bezier(.22,.68,0,1.2) both;
}

@keyframes moSlideUp {
    from { opacity: 0; transform: translateY(32px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Accent bar at the top ──────────────────────────────────── */
.custom-modal-content::before,
.modal-content::before {
    content: '';
    display: block;
    height: 5px;
    background: var(--mo-grad);
    border-radius: var(--mo-radius) var(--mo-radius) 0 0;
}

/* ── Close button ───────────────────────────────────────────── */
.close,
.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(102,126,234,.08);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--mo-muted);
    line-height: 1;
    transition: background .2s ease, color .2s ease, transform .18s ease;
    z-index: 2;
    float: none; /* override legacy */
    font-weight: 400;
    padding: 0;
}
.close:hover,
.close-btn:hover,
.close:focus,
.close-btn:focus {
    background: rgba(245,87,108,.12);
    color: var(--mo-red);
    transform: rotate(90deg) scale(1.1);
    text-decoration: none;
    outline: none;
}

/* ── Inner padding zone ─────────────────────────────────────── */
.custom-modal-content > *:not(button.close),
.modal-content > *:not(.close-btn) {
    padding-left:  var(--mo-pad);
    padding-right: var(--mo-pad);
}
.custom-modal-content > *:first-child,
.modal-content > *:first-child { padding-top: 1.6rem; }
.custom-modal-content > *:last-child,
.modal-content > *:last-child  { padding-bottom: var(--mo-pad); }

/* ── Title (h1/h5 inside modal) ─────────────────────────────── */
.custom-modal-content h1,
.custom-modal-content h5,
.modal-content h1,
.modal-content h5 {
    margin: 0 0 .85rem;
    font-size: clamp(1.05rem, 2.4vw, 1.25rem);
    font-weight: 800;
    color: var(--mo-text);
    line-height: 1.3;
    padding-right: 2.5rem; /* don't overlap close btn */
}

/* ── Paragraph text ─────────────────────────────────────────── */
.custom-modal-content p,
.modal-content p {
    font-size: .9rem;
    line-height: 1.62;
    color: var(--mo-muted);
    margin: 0 0 .8rem;
}

/* ── Public ID container ────────────────────────────────────── */
.public-id-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    margin: .4rem 0 1.1rem;
    padding: .75rem 1rem;
    background: linear-gradient(135deg, rgba(102,126,234,.07) 0%, rgba(118,75,162,.05) 100%);
    border: 1.5px dashed var(--mo-border);
    border-radius: 12px;
}

.public-id {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--mo-c1);
    letter-spacing: .04em;
    margin: 0;
}

/* copy icon button */
#copyButton {
    background: rgba(102,126,234,.1);
    border: none;
    cursor: pointer;
    color: var(--mo-c1);
    font-size: .95rem;
    padding: .35rem .5rem;
    border-radius: 8px;
    transition: background .2s, color .2s, transform .18s;
    line-height: 1;
}
#copyButton:hover {
    background: var(--mo-c1);
    color: #fff;
    transform: scale(1.12);
}

/* ── Payment description block ──────────────────────────────── */
.payment-description {
    font-size: .88rem;
    line-height: 1.62;
    color: var(--mo-text);
    background: rgba(102,126,234,.05);
    border-left: 3px solid var(--mo-c1);
    border-radius: 0 10px 10px 0;
    padding: .75rem .9rem;
    margin: .2rem 0 .85rem;
}
.payment-description strong {
    color: var(--mo-c2);
    font-weight: 800;
}

/* ── Note ───────────────────────────────────────────────────── */
.note {
    font-size: .78rem;
    color: var(--mo-muted);
    font-style: italic;
    line-height: 1.5;
    margin: 0 0 .9rem;
    text-align: center;
}
.note strong {
    font-weight: 700;
    color: var(--mo-text);
}

/* ── Error container ─────────────────────────────────────────── */
.error-container {
    display: none;
    background: rgba(245,87,108,.07);
    border: 1px solid rgba(245,87,108,.25);
    border-radius: 10px;
    padding: .75rem 1rem;
    margin: .3rem 0 .85rem;
    font-size: .85rem;
    color: #b91c1c;
    line-height: 1.5;
    text-align: left;
}
.error-container p { color: inherit; margin: 0; font-size: inherit; }

/* ── Confirm / action area ───────────────────────────────────── */
.confirm-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
    padding: .4rem 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */
#confirmButton,
#openPayUrlButton,
#verifyPayment {
    width: 100%;
    padding: .9rem 1.25rem;
    font-size: .97rem;
    font-weight: 800;
    color: #fff;
    background: var(--mo-grad);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform .22s ease, box-shadow .22s ease, opacity .2s;
    box-shadow: 0 6px 20px rgba(102,126,234,.35);
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
}
#confirmButton:hover,
#openPayUrlButton:hover,
#verifyPayment:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102,126,234,.45);
}
#confirmButton:disabled,
#openPayUrlButton:disabled,
#verifyPayment:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

/* verifyPayment shown after redirect */
#verifyPayment {
    background: linear-gradient(135deg, #43e97b 0%, #128C7E 100%);
    box-shadow: 0 6px 20px rgba(37,211,102,.3);
}
#verifyPayment:hover {
    box-shadow: 0 10px 30px rgba(37,211,102,.42);
}

/* ── .modal-btn (used by #custom-modal confirm) ──────────────── */
.modal-btn {
    flex: 1;
    padding: .82rem 1rem;
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
    background: var(--mo-grad);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    box-shadow: 0 5px 16px rgba(102,126,234,.3);
}
.modal-btn:last-child {
    background: linear-gradient(135deg, #f093fb 0%, var(--mo-red) 100%);
    box-shadow: 0 5px 16px rgba(245,87,108,.3);
}
.modal-btn:hover { transform: translateY(-2px); }

/* ── p#modal-message ─────────────────────────────────────────── */
#modal-message {
    font-size: .95rem;
    color: var(--mo-text);
    font-weight: 600;
    margin: 0 0 1rem;
    line-height: 1.55;
    text-align: center;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
    display: none;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(102,126,234,.2);
    border-top-color: var(--mo-c1);
    border-radius: 50%;
    animation: moSpin .7s linear infinite;
    margin: .25rem auto;
}
.spinner.active { display: block; }

@keyframes moSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    :root { --mo-pad: 1.15rem; }

    .custom-modal { padding: .75rem; align-items: flex-end; }
    .custom-modal-content,
    .modal-content {
        border-radius: 18px 18px 14px 14px;
        max-width: 100%;
        animation: moSlideUpMobile .3s cubic-bezier(.22,.68,0,1.1) both;
    }
    @keyframes moSlideUpMobile {
        from { opacity: 0; transform: translateY(48px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .public-id { font-size: .92rem; }
    #confirmButton, #openPayUrlButton, #verifyPayment { font-size: .88rem; }

    .confirm-container { flex-direction: column; }
    .modal-btn { padding: .78rem; font-size: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
    .custom-modal-content, .modal-content { animation: none; }
    .spinner { animation-duration: 1.4s; }
}
