/* ==========================================================
   PETSCOMPARE - TOP-BAR NAVIGATION (Zooplus-style)
   ==========================================================
   Barre horizontale par animal avec mega-menu deroulant.
   Sous le flash-promo, au-dessus du contenu.
   ========================================================== */

.topbar-nav {
    /* Position : sticky qui colle juste sous la flash-bar (40px de haut, position fixed).
       z-index sous 90 (flash-bar = z-index 90) pour ne JAMAIS la chevaucher. */
    position: sticky;
    top: 40px;
    z-index: 85;
    background: #fff;
    border-bottom: 1px solid #f3e8d0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    margin-top: 0;
}

/* Si pas de flash-bar (admin), la top-bar colle en haut */
body:not(.has-flash) .topbar-nav {
    top: 0;
}

.topbar-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: stretch;
    gap: 4px;
    /* PAS d'overflow-x ici : creerait un clipping qui empeche les
       mega-menus de deborder verticalement. Si le menu deborde
       horizontalement on accepte le scroll natif du body. */
    flex-wrap: nowrap;
}

.topbar-item {
    position: relative;
    display: flex;
    align-items: stretch;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: #1f2937;
    padding: 12px 14px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
    border-bottom: 2.5px solid transparent;
    transition: color .15s, border-color .15s, background .15s;
}

.topbar-btn:hover,
.topbar-btn[aria-expanded="true"] {
    color: #047857;
    background: rgba(4, 120, 87, .04);
    text-decoration: none;
}

.topbar-btn.is-active {
    color: #047857;
    border-bottom-color: #047857;
}

.topbar-emoji {
    font-size: 16px;
    line-height: 1;
}

.topbar-arrow {
    font-size: 10px;
    opacity: 0.5;
    transition: transform .2s;
}

.topbar-btn[aria-expanded="true"] .topbar-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

.topbar-item-extra .topbar-btn {
    color: #b45309;
}
.topbar-item-extra .topbar-btn:hover {
    color: #d97706;
    background: rgba(245, 158, 11, .06);
}

/* === MEGA MENU === */
.topbar-megamenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #f3e8d0;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .12);
    min-width: 720px;
    max-width: 90vw;
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity .18s, transform .18s, visibility 0s linear .18s;
    pointer-events: none;
}

/* L'attribut HTML [hidden] n'est plus utilise (conflit avec transitions).
   On utilise uniquement .is-open + :hover fallback. */

.topbar-megamenu.is-open,
.topbar-item:hover > .topbar-megamenu,
.topbar-item:focus-within > .topbar-megamenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity .18s, transform .18s, visibility 0s linear 0s;
}

/* Si le menu deborde a droite, on l'aligne vers la droite */
.topbar-item:last-of-type .topbar-megamenu,
.topbar-item:nth-last-of-type(2) .topbar-megamenu {
    left: auto;
    right: 0;
}

.topbar-megamenu-inner {
    padding: 1.5rem 2rem 1.75rem;
}

.topbar-megamenu-header {
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px dashed #e5e7eb;
}

.topbar-megamenu-all {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem .85rem;
    border-radius: 10px;
    background: linear-gradient(135deg, #fefaf2 0%, #fff7ed 100%);
    color: #1f2937;
    text-decoration: none;
    transition: background .15s;
}
.topbar-megamenu-all:hover {
    background: linear-gradient(135deg, #fef3c7 0%, #fef9d6 100%);
    text-decoration: none;
}

.topbar-megamenu-all-emoji {
    font-size: 1.5rem;
}

.topbar-megamenu-all strong {
    display: block;
    font-family: 'Fraunces', serif;
    font-size: 1.05rem;
    color: #047857;
    font-weight: 600;
}

.topbar-megamenu-all-sub {
    display: block;
    color: #6b7280;
    font-size: .82rem;
    margin-top: 2px;
}

.topbar-megamenu-all-arrow {
    margin-left: auto;
    color: #047857;
    font-size: 1.25rem;
}

.topbar-megamenu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.topbar-megamenu-group-title {
    font-family: 'Fraunces', serif;
    font-size: 1rem;
    color: #1f2937;
    font-weight: 600;
    margin: 0 0 .65rem;
    padding-bottom: .35rem;
    border-bottom: 2px solid #047857;
    display: inline-block;
}

.topbar-megamenu-group-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.topbar-megamenu-group-list li {
    margin-bottom: 2px;
}

.topbar-megamenu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    transition: background .12s, color .12s;
}
.topbar-megamenu-link:hover {
    background: #f0fdf4;
    color: #047857;
    text-decoration: none;
}

.topbar-megamenu-count {
    background: #f3f4f6;
    color: #6b7280;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 600;
}
.topbar-megamenu-link:hover .topbar-megamenu-count {
    background: #d1fae5;
    color: #065f46;
}

.topbar-megamenu-highlights .topbar-megamenu-group-title {
    border-bottom-color: #f59e0b;
}
.topbar-megamenu-link-highlight {
    background: #fefaf2;
    margin-bottom: 4px;
    font-weight: 500;
}
.topbar-megamenu-link-highlight:hover {
    background: #fef3c7;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .topbar-nav { display: none; } /* On garde la sidebar/burger sur mobile */
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .topbar-megamenu,
    .topbar-arrow {
        transition: none;
    }
}
