/* ============================================================
 * Pied de page (2026-11-21) — commun à l'instance et au portail.
 * Même fichier dans infra/portal-iam/assets/css/footer.css et app/assets/css/components/footer.css.
 * Les couleurs suivent les variables du thème quand elles existent
 * (instance) ; sinon les valeurs de repli s'appliquent (portail).
 * ============================================================ */

.site-footer {
    --sf-fg: var(--text-secondary, #5b6472);
    --sf-muted: var(--text-tertiary, #8a93a3);
    --sf-strong: var(--text-primary, #1a1a1a);
    --sf-line: var(--border-color, rgba(15, 23, 42, 0.09));
    --sf-surface: var(--glass-bg-subtle, rgba(255, 255, 255, 0.6));
    --sf-thumb: #ffffff;
    --sf-accent: var(--primary, #15559a);
    --sf-danger: var(--danger, #ff3b30);
    --sf-brand: #F05A28;
    --sf-pill: var(--radius-pill, 999px);

    position: relative;
    margin-top: auto;
    padding: 2rem 0 1.5rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--sf-fg);
}

[data-bs-theme="dark"] .site-footer {
    --sf-fg: var(--text-secondary, #a3afc2);
    --sf-muted: var(--text-tertiary, #6f7d93);
    --sf-strong: var(--text-primary, #eef3fb);
    --sf-line: var(--border-color, rgba(255, 255, 255, 0.1));
    --sf-surface: var(--glass-bg-subtle, rgba(30, 41, 59, 0.55));
    --sf-thumb: #f5f5f7;
}

/* Filet supérieur, fondu aux extrémités */
.site-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: min(1100px, calc(100% - 2rem));
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, var(--sf-line) 18%, var(--sf-line) 82%, transparent);
}

.site-footer__main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
}

/* Identité */
.site-footer__brand {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.site-footer__name {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--sf-strong);
}

.site-footer__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    color: var(--sf-muted);
}

.site-footer__version {
    padding: 0.05rem 0.5rem;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-pill);
    font-family: var(--font-family-mono, ui-monospace, 'SF Mono', Menlo, monospace);
    font-size: 0.6875rem;
    color: var(--sf-fg);
}

/* Liens */
.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 1.25rem;
}

.site-footer .site-footer__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--sf-fg);
    text-decoration: none;
    opacity: 1;
    transition: color 0.18s ease;
}

.site-footer .site-footer__link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.site-footer .site-footer__link:hover,
.site-footer .site-footer__link:focus-visible {
    color: var(--sf-strong);
    opacity: 1;
}

.site-footer .site-footer__link:hover::after,
.site-footer .site-footer__link:focus-visible::after {
    transform: scaleX(1);
}

/* Lien vers le portail : pastille */
.site-footer .site-footer__link--portal {
    padding: 0.3rem 0.75rem 0.3rem 0.85rem;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-pill);
    background: var(--sf-surface);
    color: var(--sf-strong);
    font-weight: 500;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.site-footer .site-footer__link--portal::after {
    display: none;
}

.site-footer .site-footer__link--portal:hover,
.site-footer .site-footer__link--portal:focus-visible {
    border-color: var(--sf-accent);
    color: var(--sf-accent);
}

.site-footer__link svg {
    width: 0.875rem;
    height: 0.875rem;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.site-footer__link--portal:hover svg {
    transform: translate(2px, -2px);
}

/* Réglages */
.site-footer__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.site-footer__controls form {
    margin: 0;
}

/* Interrupteur (thème, debug) : la case reste une vraie case à cocher,
   seulement masquée visuellement, pour le clavier et les lecteurs d'écran. */
.footer-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
    color: var(--sf-fg);
}

.footer-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.footer-switch__track {
    position: relative;
    flex: none;
    box-sizing: border-box;
    width: 2.5rem;
    height: 1.375rem;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-pill);
    background: var(--sf-surface);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.footer-switch__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    display: grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--sf-thumb);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.footer-switch__thumb svg {
    grid-area: 1 / 1;
    width: 0.65rem;
    height: 0.65rem;
    stroke-width: 2.5;
    transition: opacity 0.2s ease, transform 0.3s ease;
}

.footer-switch__icon--off { color: #f5a623; }
.footer-switch__icon--on { color: var(--sf-accent); opacity: 0; transform: rotate(-60deg) scale(0.6); }

.footer-switch__input:checked + .footer-switch__track {
    border-color: transparent;
    background: var(--sf-accent);
}

.footer-switch__input:checked + .footer-switch__track .footer-switch__thumb {
    transform: translateX(1.125rem);
}

.footer-switch__input:checked + .footer-switch__track .footer-switch__icon--off {
    opacity: 0;
    transform: rotate(60deg) scale(0.6);
}

.footer-switch__input:checked + .footer-switch__track .footer-switch__icon--on {
    opacity: 1;
    transform: none;
}

.footer-switch__input:focus-visible + .footer-switch__track {
    outline: 2px solid var(--sf-accent);
    outline-offset: 2px;
}

.footer-switch:hover .footer-switch__label {
    color: var(--sf-strong);
}

.footer-switch__label {
    transition: color 0.18s ease;
}

/* Variante debug : rouge une fois activée */
.footer-switch--danger .footer-switch__icon--off { color: var(--sf-muted); }
.footer-switch--danger .footer-switch__icon--on { color: var(--sf-danger); }
.footer-switch--danger .footer-switch__input:checked + .footer-switch__track { background: var(--sf-danger); }

/* Statut de l'application */
.footer-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.7rem;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-pill);
    background: transparent;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--sf-fg);
    cursor: help;
}

.footer-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.footer-chip--danger {
    color: var(--sf-danger);
    border-color: color-mix(in srgb, var(--sf-danger) 35%, transparent);
    background: color-mix(in srgb, var(--sf-danger) 8%, transparent);
}

.footer-chip--danger::before {
    animation: footer-chip-pulse 2s ease-in-out infinite;
}

@keyframes footer-chip-pulse {
    50% { opacity: 0.35; }
}

/* Ligne du bas */
.site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: var(--sf-muted);
}

.site-footer .site-footer__credit {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--sf-muted);
    text-decoration: none;
    opacity: 1;
    transition: color 0.18s ease;
}

.site-footer .site-footer__credit strong {
    font-weight: 600;
    color: var(--sf-brand);
}

.site-footer .site-footer__credit::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sf-brand);
}

.site-footer .site-footer__credit:hover {
    color: var(--sf-strong);
    opacity: 1;
}

@media (max-width: 767.98px) {
    .site-footer__main,
    .site-footer__bottom {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }

    .site-footer__brand,
    .site-footer__meta,
    .site-footer__links,
    .site-footer__controls {
        align-items: center;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-footer *,
    .site-footer *::before,
    .site-footer *::after {
        transition: none !important;
        animation: none !important;
    }
}
