/*
 * Messaggi (flash) del sito retail.
 * custom.css (remoto) mette ogni .alert fisso in alto a sinistra a 240px di larghezza, sopra il logo:
 * qui lo sovrascrivo.
 * - i messaggi del servizio Messages (.flash-wrapper in vetrina/base.twig) diventano notifiche
 *   impilate sotto l'header, in alto a destra, vicino al carrello;
 * - eventuali altri .alert tornano nel flusso della pagina, dove sono scritti.
 */
:root {
    --alert-header-offset: 82px; /* altezza dell'header + stacco */
    --alert-success: #78f10d;
    --alert-info: #0deaf1;
    --alert-danger: #ff2a2a;
}

/* Stile comune: scheda scura con barra colorata a sinistra e icona */
.alert {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    z-index: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 44px 14px 16px;
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.4;
    text-align: left;
    background: linear-gradient(180deg, #1b1b1b 0%, #0e0e0e 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-left: 4px solid var(--alert-accent, var(--alert-info)) !important;
    border-radius: 12px !important;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.alert::before {
    flex: 0 0 auto;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 16px;
    line-height: 1.35;
    color: var(--alert-accent, var(--alert-info));
    content: "\f05a"; /* info */
}
.alert-success { --alert-accent: var(--alert-success); }
.alert-success::before { content: "\f058"; } /* circle-check */
.alert-danger,
.alert-error { --alert-accent: var(--alert-danger); }
.alert-danger::before,
.alert-error::before { content: "\f071"; } /* triangle-exclamation */

.alert .close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    padding: 0;
    margin: 0 !important;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 26px;
    text-align: center;
    text-shadow: none;
    opacity: 1;
    cursor: pointer;
}
.alert .close:hover,
.alert .close:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

/* Notifiche dei messaggi di sistema: pila fissa sotto l'header, a destra */
.flash-wrapper {
    position: fixed;
    top: var(--alert-header-offset);
    right: 16px;
    z-index: 1060; /* sopra l'header, sotto i modali di Bootstrap (1050+ per il backdrop dei nostri) */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    margin: 0 !important;
    pointer-events: none;
}
.flash-wrapper .alert {
    margin: 0;
    pointer-events: auto;
    animation: alert-in .28s ease-out both;
}
.flash-wrapper .alert.is-leaving {
    animation: alert-out .22s ease-in both;
}
/* barra di avanzamento della chiusura automatica */
.flash-wrapper .alert[data-autohide]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 0 0 12px 12px;
    background: var(--alert-accent, var(--alert-info));
    opacity: .6;
    transform-origin: left;
    animation: alert-timer var(--alert-duration, 6s) linear both;
}
.flash-wrapper .alert[data-autohide]:hover::after {
    animation-play-state: paused;
}

@keyframes alert-in {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: none; }
}
@keyframes alert-out {
    to { opacity: 0; transform: translateX(16px); }
}
@keyframes alert-timer {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Su mobile: a tutta larghezza, sempre sotto l'header */
@media (max-width: 767px) {
    :root { --alert-header-offset: 72px; }
    .flash-wrapper {
        right: 16px;
        left: 16px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flash-wrapper .alert,
    .flash-wrapper .alert.is-leaving,
    .flash-wrapper .alert[data-autohide]::after {
        animation: none;
    }
}
