*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --lt-blue-rgb: 26, 86, 219;
    --bg-blue: #eaf1fd;
}

.hidden { display: none !important; }

/* ── Site header ──────────────────────────────────────── */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 150;
    isolation: isolate;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.site-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-header-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #1a202c;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.site-header-logo svg {
    width: 32px;
    height: 32px;
}

.site-header-logo span {
    color: #1a56db;
}

.site-header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-header-nav a {
    color: #4a5568;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.site-header-nav a:hover {
    background: #f0f4f8;
    color: #1a56db;
}

.site-header-nav a.has-new-badge {
    position: relative;
}

.nav-badge-new {
    position: absolute;
    top: -2px;
    right: 2px;
    background: #ff0000;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.nav-badge-count {
    position: absolute;
    top: -4px;
    right: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #1a56db;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
}

/* Favoris sorti des liens texte de la nav : une icône seule (comme un panier/wishlist), pour ne
   pas alourdir la nav avec un 4e mot alors que c'est une action différente (mes favoris) plutôt
   qu'une destination de contenu (Formations/Métiers/Le Mag). */
/* Pousse le groupe à l'extrémité droite : plus robuste que justify-content:space-between sur
   .site-header-inner maintenant que le burger (masqué en desktop, visible en mobile) est un 3e
   enfant direct avant le logo — space-between aurait réparti les 3 éléments visibles en mobile
   au lieu de coller le logo contre le burger à gauche. */
.site-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.site-header-favoris-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    color: #4a5568;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.site-header-favoris-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.site-header-favoris-btn:hover {
    background: #f0f4f8;
    color: #1a56db;
}

.site-header-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.site-header-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #1a202c;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.site-header-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.site-header-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
    .site-header-burger { display: flex; }

    .site-header-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 8px 20px rgba(0,0,0,0.1);
        padding: 0.5rem;
    }

    .site-header-nav.open { display: flex; }

    .site-header-nav a { padding: 0.75rem 1rem; }

    /* Le lien est étiré pleine largeur en mobile (menu déroulant) : le badge
       "NEW" en position absolue finirait collé au bord droit de l'écran, loin
       du mot "Le Mag" — on le remet en flux, juste à côté du texte. */
    .site-header-nav a.has-new-badge {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .site-header-nav a.has-new-badge .nav-badge-new {
        position: static;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    color: #1a202c;
    background: radial-gradient(circle at top right, rgba(var(--lt-blue-rgb), .16), transparent 55%),
                radial-gradient(circle at bottom left, rgba(var(--lt-blue-rgb), .10), transparent 50%),
                linear-gradient(135deg, #f8f9fa 0%, #eef4fc 60%, var(--bg-blue) 100%) fixed !important;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.site-main {
    flex: 1 0 auto;
}

/* ── Site footer ──────────────────────────────────────── */
.site-footer {
    background: #1a202c;
    color: #a0aec0;
    margin-top: 4rem;
    flex-shrink: 0;
}

.site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1.5rem 2rem;
    display: flex;
    justify-content: center;
    text-align: center;
}

.footer-brand {
    max-width: 400px;
}

.footer-logo {
    display: inline-block;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    margin-bottom: 0.75rem;
}

.footer-brand p {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #718096;
}

.footer-bottom {
    border-top: 1px solid #2d3748;
    text-align: center;
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: #4a5568;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    flex-wrap: wrap;
}

.footer-legal-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-legal-links a {
    color: #718096;
    text-decoration: none;
}

.footer-legal-links a:hover {
    color: #a0aec0;
    text-decoration: underline;
}

/* ── Assistant d'orientation ──────────────────────────── */
.orient-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a56db;
    border: none;
    box-shadow: 0 4px 16px rgba(26,86,219,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    transition: transform 0.15s, box-shadow 0.15s;
}

.orient-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(26,86,219,0.45);
}

.orient-fab svg {
    width: 26px;
    height: 26px;
}

.orient-fab-wiggle {
    animation: orient-fab-wiggle 0.8s ease-in-out;
}

@keyframes orient-fab-wiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    15% { transform: rotate(-12deg) scale(1.08); }
    30% { transform: rotate(10deg) scale(1.08); }
    45% { transform: rotate(-8deg) scale(1.05); }
    60% { transform: rotate(6deg) scale(1.05); }
    75% { transform: rotate(-3deg); }
    90% { transform: rotate(2deg); }
}

.orient-panel {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 320px;
    max-width: calc(100vw - 2rem);
    max-height: min(480px, calc(100vh - 8rem));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
}

.orient-panel.hidden {
    display: none;
}

.orient-panel-header {
    background: #1a56db;
    color: #fff;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.orient-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.orient-close,
.orient-restart {
    background: none;
    border: none;
    color: #fff;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.orient-close:hover,
.orient-restart:hover {
    opacity: 1;
}

.orient-close {
    font-size: 1.3rem;
}

.orient-restart {
    font-size: 1.05rem;
}

.orient-panel-body {
    padding: 1.1rem;
    overflow-y: auto;
    flex: 1;
}

.orient-messages {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.orient-bubble {
    max-width: 85%;
    padding: 0.55rem 0.85rem;
    border-radius: 14px;
    font-size: 0.87rem;
    line-height: 1.45;
    animation: orient-fade-in 0.2s ease;
}

.orient-bubble-bot {
    align-self: flex-start;
    background: #f0f4f8;
    color: #1a202c;
    border-bottom-left-radius: 4px;
}

.orient-bubble-user {
    align-self: flex-end;
    background: #1a56db;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.orient-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.7rem 0.9rem;
}

.orient-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a0aec0;
    animation: orient-bounce 1.1s infinite ease-in-out;
}

.orient-typing span:nth-child(2) { animation-delay: 0.15s; }
.orient-typing span:nth-child(3) { animation-delay: 0.3s; }

.orient-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    animation: orient-fade-in 0.2s ease;
}

.orient-chip {
    display: inline-block;
    background: #fff;
    color: #1a56db;
    border: 1px solid #cbd8f5;
    border-radius: 50px;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}

.orient-chip:hover {
    background: #ebf2ff;
}

.orient-chip-cta {
    background: #1a56db;
    color: #fff;
    border-color: #1a56db;
}

.orient-chip-cta:hover {
    background: #1345b5;
}

.orient-chip-back {
    background: none;
    border-color: transparent;
    color: #a0aec0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.orient-chip-back:hover {
    background: none;
    color: #718096;
    text-decoration: underline;
}

@keyframes orient-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes orient-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 640px) {
    /* Panneau plein écran sur mobile plutôt qu'une petite fenêtre flottante contrainte en
       hauteur : plus de place pour lire la conversation et taper une réponse personnalisée. */
    .orient-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .orient-panel-header {
        padding: 1rem 1.1rem;
        padding-top: max(1rem, env(safe-area-inset-top));
        flex-shrink: 0;
    }

    .orient-panel-body {
        padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
    }

    /* Zones tactiles plus grandes qu'au format desktop compact */
    .orient-close { font-size: 1.6rem; padding: 0.2rem 0.5rem; }
    .orient-restart { font-size: 1.2rem; padding: 0.2rem 0.5rem; }

    /* Le bouton flottant serait sinon visible par-dessus le panneau plein écran */
    .orient-fab[aria-expanded="true"] {
        display: none;
    }

    /* Évite que la page défile derrière le panneau plein écran */
    body.orient-panel-open {
        overflow: hidden;
    }
}

/* ── Toast comparateur (cf. assets/scripts/compare.js) ───────── */
/* Dans app.css (chargé sur toutes les pages) plutôt que home.css : le bouton comparateur peut être
   cliqué depuis les résultats de recherche comme depuis une fiche formation, pages qui ne partagent
   pas toujours la même feuille de style. */
.compare-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%) translateY(100%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #1a202c;
    color: #fff;
    padding: 0.75rem 1.1rem;
    border-radius: 10px;
    font-size: 0.88rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    max-width: calc(100vw - 2rem);
}

.compare-toast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.compare-toast a {
    color: #90cdf4;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.compare-toast a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .compare-toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        transform: translateY(100%);
        max-width: none;
    }
    .compare-toast.is-visible {
        transform: translateY(0);
    }
}

/* ── Bandeau de consentement cookies (cf. assets/scripts/consent.js) ─────────
   Dans app.css (chargé sur toutes les pages) et non home.css : le bandeau vit dans base.html.twig,
   il doit donc être stylé partout, y compris sur les fiches détail qui ne chargent pas home.css. */
.cookie-consent {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    background: #1a202c;
    color: #fff;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
}

.cookie-consent-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-consent-text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    flex: 1;
    min-width: 240px;
}

.cookie-consent-text a {
    color: #90cdf4;
    font-weight: 600;
}

.cookie-consent-actions {
    display: flex;
    gap: 0.6rem;
    flex-shrink: 0;
}

.cookie-consent-btn {
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* "Refuser" aussi mis en avant qu'"Accepter" (exigence CNIL : refus aussi simple que l'acceptation),
   juste distingué par la couleur — pas relégué en lien discret. */
.cookie-consent-refuse {
    background: #4a5568;
    color: #fff;
}

.cookie-consent-refuse:hover {
    background: #5a6678;
}

.cookie-consent-accept {
    background: #1a56db;
    color: #fff;
}

.cookie-consent-accept:hover {
    background: #1345b5;
}

@media (max-width: 560px) {
    .cookie-consent-actions {
        width: 100%;
    }
    .cookie-consent-btn {
        flex: 1;
    }
}
