/* Campanella delle notifiche nella barra del menu (desktop e mobile) */

.notifications-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: #334155;
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease, transform 0.2s ease;
}

.notifications-bell:hover {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.notifications-bell:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.notifications-bell .notifications-bell-icon {
    display: inline-block;
    font-size: 1.25rem;
    transform-origin: top center;
}

/* Notifiche attive: campanella blu */
.notifications-bell.is-active {
    color: #2563eb;
}

/* Notifiche non attive: campanella grigia con la sbarretta */
.notifications-bell.is-inactive {
    color: #94a3b8;
}

/* Suggerimento scuro sotto la campanella, identico a quello della modalità notte
   (usa data-tooltip e non title, così il browser non mostra anche il suo riquadro grigio) */
.notifications-bell::before {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 8px;
    pointer-events: none;
}

.notifications-bell::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #1e293b;
    border-top: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    margin-top: 3px;
    pointer-events: none;
}

.notifications-bell:hover::before,
.notifications-bell:hover::after,
.notifications-bell:focus-visible::before,
.notifications-bell:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

/* Sotto i 768px resta solo la voce del menu mobile, come per il pulsante della modalità notte */
@media (max-width: 768px) {
    .notifications-bell {
        display: none !important;
    }
}

/* Pallino rosso con il numero, come quello del carrello */
.notifications-bell-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 9999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

/* Campanella che suona: al passaggio del mouse e finché ci sono notifiche nuove */
.notifications-bell:hover .notifications-bell-icon {
    animation: notifications-bell-swing 0.7s ease;
}

.notifications-bell.has-unread .notifications-bell-icon {
    animation: notifications-bell-swing 1.6s ease-in-out infinite;
}

.notifications-bell.has-unread .notifications-bell-count {
    animation: notifications-bell-pulse 1.6s ease-in-out infinite;
}

@keyframes notifications-bell-swing {
    0%, 60%, 100% { transform: rotate(0deg); }
    5% { transform: rotate(14deg); }
    15% { transform: rotate(-12deg); }
    25% { transform: rotate(9deg); }
    35% { transform: rotate(-7deg); }
    45% { transform: rotate(4deg); }
    52% { transform: rotate(-2deg); }
}

@keyframes notifications-bell-pulse {
    0%, 100% { transform: scale(1); }
    12% { transform: scale(1.18); }
    24% { transform: scale(1); }
}

/* Voce del menu mobile */
.mobile-notifications-bell-count {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 9999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* Modalità notte: la campanella segue i colori chiari della barra */
body.night-mode .notifications-bell,
html.night-mode .notifications-bell {
    color: #cbd5e1;
}

body.night-mode .notifications-bell.is-active,
html.night-mode .notifications-bell.is-active {
    color: #60a5fa;
}

body.night-mode .notifications-bell-count,
html.night-mode .notifications-bell-count {
    box-shadow: 0 0 0 2px #0f172a;
}

/* Chi preferisce meno animazioni non vede la campanella muoversi */
@media (prefers-reduced-motion: reduce) {
    .notifications-bell .notifications-bell-icon,
    .notifications-bell .notifications-bell-count {
        animation: none !important;
    }
}
