/* ============================================
   CLOUDY UI — Toasts et boite de confirmation
   Feuille commune aux pages publiques (accueil,
   espace client, finalisation, support).
   A charger EN DERNIER : elle remplace les
   anciennes regles .toast propres a chaque page.
   ============================================ */

:root {
    --cloudy-ui-success: #10b981;
    --cloudy-ui-error: #ef4444;
    --cloudy-ui-warning: #f59e0b;
    --cloudy-ui-info: #2583ff;
}

/* --- TOASTS --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    --toast-accent: var(--cloudy-ui-success);
    --toast-tint: rgba(16, 185, 129, .14);
    --toast-ring: rgba(16, 185, 129, .34);

    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 13px 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 16px;
    background:
        linear-gradient(135deg, var(--toast-tint), transparent 62%),
        rgba(10, 14, 24, .94);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(115%);
    transition: transform .42s cubic-bezier(.22, 1, .36, 1), opacity .28s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    margin: 0;
    border-radius: 11px;
    background: var(--toast-tint);
    border: 1px solid var(--toast-ring);
    color: var(--toast-accent);
    font-size: 14px;
}

.toast-message {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}

.toast-close:hover {
    background: rgba(255, 255, 255, .07);
    color: #e2e8f0;
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    transform-origin: left center;
    background: var(--toast-accent);
    opacity: .75;
}

.toast.show .toast-progress {
    animation: cloudyToastProgress var(--toast-duration, 3200ms) linear forwards;
}

@keyframes cloudyToastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

.toast-success {
    --toast-accent: var(--cloudy-ui-success);
    --toast-tint: rgba(16, 185, 129, .14);
    --toast-ring: rgba(16, 185, 129, .34);
}

.toast-error {
    --toast-accent: var(--cloudy-ui-error);
    --toast-tint: rgba(239, 68, 68, .14);
    --toast-ring: rgba(239, 68, 68, .34);
}

.toast-warning {
    --toast-accent: var(--cloudy-ui-warning);
    --toast-tint: rgba(245, 158, 11, .14);
    --toast-ring: rgba(245, 158, 11, .34);
}

/* Mobile : la pile descend du haut */
@media (max-width: 768px) {
    #toast-container {
        top: calc(env(safe-area-inset-top) + 10px);
        right: 10px;
        left: 10px;
        width: auto;
    }

    .toast {
        min-width: 0;
        padding: 12px;
        font-size: 12.5px;
        transform: translateY(-140%);
    }

    .toast.show {
        transform: translateY(0);
    }
}

/* --- BOITE DE CONFIRMATION --- */
.cloudy-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 4, 10, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .2s ease;
}

.cloudy-confirm-overlay.show {
    opacity: 1;
}

.cloudy-confirm-box {
    --confirm-accent: var(--cloudy-ui-info);
    --confirm-tint: rgba(37, 131, 255, .14);

    width: min(400px, 100%);
    padding: 26px 24px 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(18, 24, 38, .98), rgba(7, 10, 18, .98));
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
    transform: translateY(12px) scale(.96);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
}

.cloudy-confirm-overlay.show .cloudy-confirm-box {
    transform: translateY(0) scale(1);
}

.cloudy-confirm-box.is-danger {
    --confirm-accent: var(--cloudy-ui-error);
    --confirm-tint: rgba(239, 68, 68, .14);
}

.cloudy-confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 14px;
    border-radius: 16px;
    background: var(--confirm-tint);
    color: var(--confirm-accent);
    font-size: 20px;
}

.cloudy-confirm-title {
    margin: 0 0 6px;
    color: #fff;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -.01em;
}

.cloudy-confirm-message {
    margin: 0 0 22px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.cloudy-confirm-actions {
    display: flex;
    gap: 10px;
}

.cloudy-confirm-actions button {
    flex: 1;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 13px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, filter .18s ease;
}

.cloudy-confirm-cancel {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .10);
    color: #cbd5e1;
}

.cloudy-confirm-cancel:hover {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.cloudy-confirm-ok {
    background: var(--confirm-accent);
    color: #fff;
}

.cloudy-confirm-ok:hover {
    filter: brightness(1.12);
}

@media (max-width: 480px) {
    .cloudy-confirm-box {
        padding: 22px 18px 18px;
    }

    .cloudy-confirm-actions {
        flex-direction: column-reverse;
    }
}
