/* ==========================================================================
   Alertes du site public — <x-fo-alert />

   Un bandeau à l'image du `.bo-banner-warning` du backoffice, transposé côté
   public en respectant la charte graphique du tenant. Icône à gauche, bordure
   gauche 4px de la couleur de l'état, fond soft calculé au vol par
   `color-mix()` sur le jeton `--fo-alert-<type>`.

   Les couleurs viennent des jetons `--fo-alert-*` que `site_app.blade.php`
   injecte dans le <head> à partir des couleurs backoffice réglées par le
   tenant dans Paramètres graphiques → Backoffice
   (`bo_success` / `bo_warning` / `bo_info` / `bo_danger`). Les fallbacks
   ci-dessous couvrent le cas où l'injection ne se fait pas (tenant qui n'a
   rien réglé, ou incident au layout) : le tenant garde toujours des alertes
   lisibles, avec les couleurs par défaut du socle backoffice.
   ========================================================================== */

:root {
    --fo-alert-success: #2ecc71;
    --fo-alert-warning: #f5a623;
    --fo-alert-info:    #4fa3ff;
    --fo-alert-danger:  #e05c70;

    --fo-alert-radius:  8px;
    --fo-alert-padding: 14px 18px;
    --fo-alert-gap:     14px;
    --fo-alert-max:     100%;
}

.fo-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--fo-alert-gap);
    flex-wrap: wrap;
    padding: var(--fo-alert-padding);
    border-radius: var(--fo-alert-radius);
    border: 1px solid transparent;
    border-left-width: 4px;
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.5;
    max-width: var(--fo-alert-max);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    animation: fo-alert-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.fo-alert.fo-alert--hiding {
    animation: fo-alert-out 0.24s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
}

@keyframes fo-alert-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fo-alert-out {
    to { opacity: 0; transform: translateY(-6px); }
}

/* Les utilisateurs qui ont demandé « moins de mouvement » n'entendent plus
   l'animation d'entrée — un bandeau qui pousse le contenu déclenche mal des
   sensibilités vestibulaires. Le message reste visible instantanément. */
@media (prefers-reduced-motion: reduce) {
    .fo-alert,
    .fo-alert.fo-alert--hiding {
        animation: none;
    }
}

/* L'icône à gauche : taille lisible, alignée sur le premier titre / la
   première ligne du message, sans grossir avec le texte. */
.fo-alert__icon {
    font-size: 1.4rem;
    line-height: 1.4;
    flex-shrink: 0;
    margin-top: 1px;
}

.fo-alert__body {
    flex: 1;
    min-width: 240px;
    color: inherit;
}

.fo-alert__title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 4px;
    color: inherit;
}

.fo-alert__message {
    font-size: 14px;
    margin: 0;
    color: inherit;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.fo-alert__message > p {
    margin: 0 0 8px;
}

.fo-alert__message > p:last-child {
    margin-bottom: 0;
}

/* Bouton d'action : plein, texte contrasté sur la couleur de l'état.
   `--fo-alert-action-fg` défaut blanc, mais chaque variante peut le passer
   au noir si sa couleur de fond est trop claire pour rester lisible. */
.fo-alert__action {
    background: var(--fo-alert-tone, currentColor);
    color: var(--fo-alert-action-fg, #fff);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fo-alert__action:hover {
    filter: brightness(1.08);
    color: var(--fo-alert-action-fg, #fff);
    text-decoration: none;
}

.fo-alert__action:focus-visible {
    outline: 2px solid var(--fo-alert-tone, currentColor);
    outline-offset: 2px;
}

.fo-alert__action:active {
    transform: scale(0.97);
}

/* Bouton de fermeture : discret par défaut, cible tactile au pointer coarse.
   Un `!important` sur `color` : certains thèmes public héritent une couleur
   d'accent sur les <button>, sinon l'icône disparaît dans le fond soft. */
.fo-alert__close {
    background: transparent;
    border: none;
    color: var(--fo-alert-tone, currentColor) !important;
    opacity: 0.55;
    padding: 4px 8px;
    margin: -4px -6px -4px 0;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1;
    transition: opacity 0.15s ease, background 0.15s ease;
    align-self: flex-start;
    flex-shrink: 0;
}

.fo-alert__close:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--fo-alert-tone, currentColor) 12%, transparent);
}

.fo-alert__close:focus-visible {
    opacity: 1;
    outline: 2px solid var(--fo-alert-tone, currentColor);
    outline-offset: 1px;
}

@media (pointer: coarse) {
    .fo-alert__close {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   Variantes — chacune règle son `--fo-alert-tone` et sa couleur de texte.
   Le fond est calculé au vol par `color-mix()` pour suivre la couleur réglée
   par le tenant, sans figer une valeur rgba() dans la feuille.

   `color-mix()` est supporté par Chrome ≥ 111, Safari ≥ 16.4, Firefox ≥ 113.
   Fallback : `background` avec un rgba() dérivé du défaut, posé avant.
   ========================================================================== */

.fo-alert--success {
    --fo-alert-tone: var(--fo-alert-success);
    background: rgba(46, 204, 113, 0.12);
    background: color-mix(in srgb, var(--fo-alert-success) 10%, transparent);
    border-color: var(--fo-alert-success);
    color: #1e6b3a;
}

.fo-alert--warning {
    --fo-alert-tone: var(--fo-alert-warning);
    --fo-alert-action-fg: #1f1305;
    background: rgba(245, 166, 35, 0.14);
    background: color-mix(in srgb, var(--fo-alert-warning) 12%, transparent);
    border-color: var(--fo-alert-warning);
    color: #7a4b00;
}

.fo-alert--info {
    --fo-alert-tone: var(--fo-alert-info);
    background: rgba(79, 163, 255, 0.12);
    background: color-mix(in srgb, var(--fo-alert-info) 10%, transparent);
    border-color: var(--fo-alert-info);
    color: #1e4a80;
}

.fo-alert--danger {
    --fo-alert-tone: var(--fo-alert-danger);
    background: rgba(224, 92, 112, 0.12);
    background: color-mix(in srgb, var(--fo-alert-danger) 10%, transparent);
    border-color: var(--fo-alert-danger);
    color: #7a1e2c;
}

.fo-alert__icon {
    color: var(--fo-alert-tone);
}

/* ==========================================================================
   Site public à thème sombre — le contraste du texte s'inverse.
   Les tenants Diva Yoga (clair) ne sont pas touchés par cette règle, mais un
   tenant qui bascule son fond en sombre garde un titre lisible. Détection sur
   `prefers-color-scheme: dark` ET sur la présence de la classe `.dark-mode`
   qu'emploient plusieurs tenants.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) .fo-alert--success { color: #7ee2a3; }
    body:not(.light-mode) .fo-alert--warning { color: #ffcf7a; }
    body:not(.light-mode) .fo-alert--info    { color: #a6cfff; }
    body:not(.light-mode) .fo-alert--danger  { color: #f0a3ae; }
}

body.dark-mode .fo-alert--success { color: #7ee2a3; }
body.dark-mode .fo-alert--warning { color: #ffcf7a; }
body.dark-mode .fo-alert--info    { color: #a6cfff; }
body.dark-mode .fo-alert--danger  { color: #f0a3ae; }

/* ==========================================================================
   Responsive — le bouton d'action et la croix passent sous le texte plutôt
   qu'à côté quand la largeur ne suffit plus. Sans cette règle, le mobile
   forçait la largeur naturelle du bouton et poussait le titre en une colonne
   de deux caractères de large.
   ========================================================================== */

@media (max-width: 520px) {
    .fo-alert {
        padding: 12px 14px;
        gap: 10px;
    }
    .fo-alert__action {
        margin-top: 4px;
    }
    .fo-alert__body {
        min-width: 100%;
    }
}
