/* ==========================================================================
   PHILIPPE VALENCIA — Notify UI
   Système unifié de notifications (toasts) et de confirmations (modales)
   pour remplacer les alert()/confirm()/prompt() natifs du navigateur.
   Utilisé par le storefront, l'admin et (potentiellement) le TPE.
   ========================================================================== */

:root {
    --notify-accent: #bfa37a;
    --notify-accent-dark: #ab8e65;
    --notify-ink: #1f2430;
    --notify-muted: #6b7280;
    --notify-surface: #ffffff;
    --notify-border: #e9e5dd;

    --notify-success: #1f8a5f;
    --notify-success-bg: #eaf7f0;
    --notify-danger: #c0392b;
    --notify-danger-bg: #fdecea;
    --notify-warning: #a9762c;
    --notify-warning-bg: #fbf2e2;
    --notify-info: #3b6ea5;
    --notify-info-bg: #eaf2fb;

    --notify-radius: 12px;
    --notify-shadow: 0 16px 40px -12px rgba(15, 15, 26, 0.28), 0 2px 8px rgba(15, 15, 26, 0.06);
}

/* --------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------- */

.notify-viewport {
    position: fixed;
    z-index: 10600;
    right: 1.25rem;
    bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

@media (max-width: 560px) {
    .notify-viewport {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 0.75rem;
        width: auto;
    }
}

.notify-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    background: var(--notify-surface);
    color: var(--notify-ink);
    border-radius: var(--notify-radius);
    box-shadow: var(--notify-shadow);
    padding: 0.85rem 2.1rem 0.85rem 0.9rem;
    border-left: 4px solid var(--notify-info);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.notify-toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.notify-toast.is-leaving {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.notify-toast--success { border-left-color: var(--notify-success); }
.notify-toast--error { border-left-color: var(--notify-danger); }
.notify-toast--warning { border-left-color: var(--notify-warning); }
.notify-toast--info { border-left-color: var(--notify-info); }

.notify-toast__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    margin-top: 0.05rem;
}

.notify-toast--success .notify-toast__icon { background: var(--notify-success-bg); color: var(--notify-success); }
.notify-toast--error .notify-toast__icon { background: var(--notify-danger-bg); color: var(--notify-danger); }
.notify-toast--warning .notify-toast__icon { background: var(--notify-warning-bg); color: var(--notify-warning); }
.notify-toast--info .notify-toast__icon { background: var(--notify-info-bg); color: var(--notify-info); }

.notify-toast__body {
    flex: 1;
    min-width: 0;
}

.notify-toast__title {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0 0 0.15rem;
    color: var(--notify-ink);
}

.notify-toast__message {
    font-size: 0.86rem;
    line-height: 1.45;
    margin: 0;
    color: var(--notify-ink);
    white-space: pre-line;
    word-break: break-word;
}

.notify-toast__close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--notify-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.notify-toast__close:hover { background: rgba(15, 15, 26, 0.06); color: var(--notify-ink); }
.notify-toast__close:focus-visible { outline: 2px solid var(--notify-accent); outline-offset: 1px; }

.notify-toast__progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: currentColor;
    opacity: 0.32;
    animation-name: notify-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.notify-toast--success .notify-toast__progress { color: var(--notify-success); }
.notify-toast--error .notify-toast__progress { color: var(--notify-danger); }
.notify-toast--warning .notify-toast__progress { color: var(--notify-warning); }
.notify-toast--info .notify-toast__progress { color: var(--notify-info); }

@keyframes notify-progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* --------------------------------------------------------------------
   Confirmation modal
   -------------------------------------------------------------------- */

.notify-overlay {
    position: fixed;
    inset: 0;
    z-index: 10650;
    background: rgba(15, 15, 26, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.notify-overlay.is-visible { opacity: 1; }

.notify-modal {
    background: var(--notify-surface);
    color: var(--notify-ink);
    width: min(420px, 100%);
    border-radius: 16px;
    box-shadow: var(--notify-shadow);
    padding: 1.6rem 1.6rem 1.3rem;
    transform: translateY(14px) scale(0.96);
    opacity: 0;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
}

.notify-overlay.is-visible .notify-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.notify-modal__icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    margin-bottom: 0.9rem;
    background: var(--notify-warning-bg);
    color: var(--notify-warning);
}

.notify-modal--danger .notify-modal__icon { background: var(--notify-danger-bg); color: var(--notify-danger); }

.notify-modal__title {
    font-size: 1.08rem;
    font-weight: 600;
    margin: 0 0 0.45rem;
    color: var(--notify-ink);
}

.notify-modal__message {
    font-size: 0.92rem;
    color: var(--notify-muted);
    line-height: 1.55;
    margin: 0 0 1.35rem;
    white-space: pre-line;
}

.notify-modal__message:empty { display: none; margin: 0 0 0.5rem; }

.notify-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.notify-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.notify-btn:active { transform: translateY(1px); }
.notify-btn:focus-visible { outline: 2px solid var(--notify-accent); outline-offset: 2px; }

.notify-btn--ghost { background: transparent; border-color: var(--notify-border); color: var(--notify-ink); }
.notify-btn--ghost:hover { background: #f5f3ef; }

.notify-btn--primary { background: var(--notify-accent); border-color: var(--notify-accent); color: #fff; }
.notify-btn--primary:hover { background: var(--notify-accent-dark); border-color: var(--notify-accent-dark); }

.notify-btn--danger { background: var(--notify-danger); border-color: var(--notify-danger); color: #fff; }
.notify-btn--danger:hover { background: #a5311f; border-color: #a5311f; }

body.notify-modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .notify-toast,
    .notify-toast.is-visible,
    .notify-toast.is-leaving,
    .notify-overlay,
    .notify-modal {
        transition: none !important;
        animation: none !important;
    }
}
