/*
 * Flash messages globaux — CakePHP 5 / Bootstrap
 * Affichage flottant professionnel en haut à gauche.
 */

:root {
    --flash-width: 390px;
    --flash-gap: 12px;
    --flash-radius: 12px;
    --flash-shadow: 0 16px 42px rgba(22, 35, 52, .18);
}

/* Le conteneur est créé automatiquement par flash.js. */
#app-flash-stack {
    position: fixed;
    top: 88px;
    left: 22px;
    z-index: 10850;
    display: flex;
    flex-direction: column;
    gap: var(--flash-gap);
    width: min(var(--flash-width), calc(100vw - 32px));
    pointer-events: none;
}

.app-flash {
    --flash-accent: #315783;
    --flash-bg: #ffffff;
    --flash-text: #203247;
    --flash-duration: 7s;

    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 78px;
    padding: 15px 46px 15px 16px;
    color: var(--flash-text);
    background: var(--flash-bg);
    border: 1px solid rgba(31, 49, 69, .12);
    border-left: 5px solid var(--flash-accent);
    border-radius: var(--flash-radius);
    box-shadow: var(--flash-shadow);
    cursor: pointer;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(-24px) scale(.98);
    transition:
        opacity .25s ease,
        transform .25s ease,
        box-shadow .2s ease;
}

.app-flash.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.app-flash:hover {
    box-shadow: 0 18px 48px rgba(22, 35, 52, .24);
}

.app-flash.is-closing {
    opacity: 0;
    transform: translateX(-24px) scale(.97);
}

.app-flash__inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.app-flash__icon {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    margin-top: 1px;
    color: #fff;
    background: var(--flash-accent);
    border-radius: 50%;
    font-family: Arial, sans-serif;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
}

.app-flash__content {
    min-width: 0;
    flex: 1 1 auto;
}

.app-flash__title {
    display: block;
    margin: 0 0 3px;
    color: var(--flash-text);
    font-family: "Oswald", Arial, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: .02em;
}

.app-flash__message {
    margin: 0;
    color: #41556b;
    font-size: .94rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.app-flash__close {
    position: absolute;
    top: 9px;
    right: 9px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    padding: 0;
    color: #526479;
    background: transparent;
    border: 0;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.app-flash__close:hover,
.app-flash__close:focus-visible {
    color: #172536;
    background: rgba(23, 37, 54, .08);
    outline: none;
}

.app-flash__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(31, 49, 69, .08);
}

.app-flash__progress::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: var(--flash-accent);
    transform-origin: left center;
    animation: app-flash-countdown var(--flash-duration) linear forwards;
}

.app-flash:hover .app-flash__progress::after,
.app-flash.is-paused .app-flash__progress::after {
    animation-play-state: paused;
}

@keyframes app-flash-countdown {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* SUCCESS — 5 secondes */
.app-flash--success {
    --flash-accent: #2f7044;
    --flash-bg: #f7fcf8;
    --flash-text: #1f5131;
    --flash-duration: 5s;
}

/* ERROR — 10 secondes */
.app-flash--error {
    --flash-accent: #a62d38;
    --flash-bg: #fff8f8;
    --flash-text: #721f28;
    --flash-duration: 10s;
}

/* INFO — 7 secondes */
.app-flash--info {
    --flash-accent: #315783;
    --flash-bg: #f7faff;
    --flash-text: #244466;
    --flash-duration: 7s;
}

/* WARNING — 7 secondes */
.app-flash--warning {
    --flash-accent: #a86e00;
    --flash-bg: #fffaf0;
    --flash-text: #704a00;
    --flash-duration: 7s;
}

@media (max-width: 575.98px) {
    #app-flash-stack {
        top: 72px;
        left: 12px;
        width: calc(100vw - 24px);
    }

    .app-flash {
        min-height: 72px;
        padding: 13px 42px 13px 13px;
        border-radius: 10px;
    }

    .app-flash__icon {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: 15px;
    }

    .app-flash__message {
        font-size: .9rem;
    }
}

/* Respect des préférences d'accessibilité. */
@media (prefers-reduced-motion: reduce) {
    .app-flash,
    .app-flash__progress::after {
        transition: none !important;
        animation: none !important;
    }
}
