/* ============================================
   GAMIFICATION NOTIFICATIONS SYSTEM
   Cruciverba - Sistema Notifiche Premium
   ============================================ */

/* === VARIABILI CSS === */
:root {
    /* Colori rarita */
    --gn-comune: #CD7F32;
    --gn-non-comune: #C0C0C0;
    --gn-raro: #FFD700;
    --gn-epico: #9400D3;
    --gn-leggendario: #FF4500;

    /* Timing */
    --gn-transition-fast: 200ms;
    --gn-transition-normal: 300ms;
    --gn-transition-slow: 500ms;

    /* Z-index */
    --gn-z-toast: 10000;
    --gn-z-celebration: 10001;
    --gn-z-confetti: 10002;
}

/* === UTILITY === */
.gn-no-scroll {
    overflow: hidden !important;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.gn-toast-container {
    position: fixed;
    z-index: var(--gn-z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 440px;
    width: calc(100% - 20px);
    pointer-events: none;
}

/* Posizioni */
.gn-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.gn-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.gn-position-top-right {
    top: 80px;
    right: 20px;
}

/* Toast singolo */
.gn-toast {
    position: relative;
    background: #fff;
    border-radius: 14px;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    padding: 18px 20px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition:
        transform var(--gn-transition-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity var(--gn-transition-normal) ease;
}

.gn-toast-visible {
    transform: translateX(0);
    opacity: 1;
}

/* Bordo colorato laterale */
.gn-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color, #007bff);
    border-radius: 12px 0 0 12px;
}

/* Icona toast */
.gn-toast-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--accent-color, #007bff);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
}

.gn-toast-icon i {
    color: #fff;
    font-size: 22px;
}

/* Contenuto toast */
.gn-toast-content {
    flex: 1;
    min-width: 0;
}

.gn-toast-title {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.gn-toast-message {
    font-size: 15px;
    color: #5f6368;
    line-height: 1.5;
}

/* Bottone CTA nel toast */
.gn-toast-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: var(--accent-color, #007bff);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 11pt;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--gn-transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.gn-toast-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.gn-toast-btn:active {
    transform: translateY(0);
}

/* Bottone chiusura */
.gn-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 8px;
    margin: -8px -8px -8px 8px;
    cursor: pointer;
    color: #9aa0a6;
    font-size: 18px;
    line-height: 1;
    border-radius: 50%;
    transition: all var(--gn-transition-fast);
}

.gn-toast-close:hover {
    background: #f1f3f4;
    color: #5f6368;
}

/* Varianti toast per tipo */
.gn-toast-points .gn-toast-title {
    color: #28a745;
    font-size: 18px;
}

.gn-toast-streak .gn-toast-icon {
    animation: gn-fire-pulse 1s ease-in-out infinite;
}

@keyframes gn-fire-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Toast Help - Senza icona (domande senza risposta) */
.gn-toast-help .gn-toast-icon {
    display: none;
}
.gn-toast-help .gn-toast-title {
    color: #e67e00;
}

/* Toast Flash - Success */
.gn-toast-flash-success .gn-toast-icon {
    background: #28a745;
}
.gn-toast-flash-success .gn-toast-title {
    color: #28a745;
}

/* Toast Flash - Warning */
.gn-toast-flash-warning .gn-toast-icon {
    background: #ffc107;
}
.gn-toast-flash-warning .gn-toast-title {
    color: #d39e00;
}

/* Toast Flash - Error */
.gn-toast-flash-error .gn-toast-icon {
    background: #dc3545;
}
.gn-toast-flash-error .gn-toast-title {
    color: #dc3545;
}

/* Toast Flash - Notice/Info */
.gn-toast-flash-notice .gn-toast-icon {
    background: #17a2b8;
}
.gn-toast-flash-notice .gn-toast-title {
    color: #17a2b8;
}

/* Toast cliccabili - hover effect */
.gn-toast[style*="cursor: pointer"]:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

/* ============================================
   CELEBRAZIONE FULLSCREEN
   ============================================ */

.gn-celebration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--gn-z-celebration);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--gn-transition-normal),
        visibility var(--gn-transition-normal);
}

.gn-celebration-visible {
    opacity: 1;
    visibility: visible;
}

.gn-celebration-modal {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 24px;
    max-width: 400px;
    width: 90%;
    padding: 40px 30px;
    text-align: center;
    transform: scale(0.8) translateY(30px);
    transition: transform var(--gn-transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.gn-celebration-visible .gn-celebration-modal {
    transform: scale(1) translateY(0);
}

/* Glow effect per rarita */
.gn-rarity-raro .gn-celebration-modal {
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 0 40px rgba(255, 215, 0, 0.3);
}

.gn-rarity-epico .gn-celebration-modal {
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 0 50px rgba(148, 0, 211, 0.4);
}

.gn-rarity-leggendario .gn-celebration-modal {
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 0 60px rgba(255, 69, 0, 0.5);
    animation: gn-legendary-pulse 2s ease-in-out infinite;
}

@keyframes gn-legendary-pulse {
    0%, 100% { box-shadow: 0 25px 60px rgba(0,0,0,0.3), 0 0 60px rgba(255, 69, 0, 0.5); }
    50% { box-shadow: 0 25px 60px rgba(0,0,0,0.3), 0 0 80px rgba(255, 69, 0, 0.7); }
}

/* Close button */
.gn-celebration-close {
    position: absolute;
    top: 15px;
    right: 18px;
    background: #f1f3f4;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--gn-transition-fast);
    z-index: 1;
}

.gn-celebration-close:hover {
    background: #e8eaeb;
    transform: rotate(90deg);
}

/* Header con badge */
.gn-celebration-header {
    margin-bottom: 20px;
}

/* Badge animato */
.gn-badge-animated {
    animation: gn-badge-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gn-badge-entrance {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Level up badge speciale */
.gn-levelup-badge {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 30px rgba(255, 165, 0, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.4);
    animation: gn-levelup-bounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gn-levelup-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.gn-levelup-number {
    font-size: 42px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.gn-levelup-label {
    font-size: 11pt;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 2px;
}

/* Body celebration */
.gn-celebration-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.gn-celebration-subtitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--gn-raro);
    margin-bottom: 12px;
}

.gn-rarity-comune .gn-celebration-subtitle { color: var(--gn-comune); }
.gn-rarity-non_comune .gn-celebration-subtitle { color: var(--gn-non-comune); }
.gn-rarity-epico .gn-celebration-subtitle { color: var(--gn-epico); }
.gn-rarity-leggendario .gn-celebration-subtitle { color: var(--gn-leggendario); }

/* Level up: colore più scuro per leggibilità su sfondo bianco */
.gn-type-levelup .gn-celebration-subtitle {
    color: #B8860B; /* DarkGoldenrod */
}

/* Badge summary: colore più scuro per leggibilità su sfondo bianco */
.gn-type-badge_summary .gn-celebration-subtitle {
    color: #B8860B; /* DarkGoldenrod */
}

.gn-celebration-desc {
    font-size: 14px;
    color: #5f6368;
    line-height: 1.5;
    margin: 0 0 16px;
}

.gn-celebration-points {
    display: inline-block;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 700;
}

.gn-celebration-points span {
    font-size: 11pt;
    font-weight: 400;
    opacity: 0.9;
}

/* Footer con bottone */
.gn-celebration-footer {
    margin-top: 24px;
}

.gn-celebration-btn {
    background: linear-gradient(135deg, #ff5200, #ff8d00);
    color: #fff;
    border: none;
    padding: 14px 40px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--gn-transition-fast);
    box-shadow: 0 4px 15px rgba(255, 82, 0, 0.3);
}

.gn-celebration-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 82, 0, 0.4);
}

.gn-celebration-btn:active {
    transform: translateY(0);
}

/* ============================================
   CONFETTI EFFECT
   ============================================ */

.gn-confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--gn-z-confetti);
    overflow: hidden;
}

.gn-confetto {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    left: var(--x, 50vw);
    animation: gn-confetti-fall 3s linear forwards;
    animation-delay: var(--delay, 0s);
    transform: rotate(var(--rotation, 0deg));
}

@keyframes gn-confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Forme confetti variabili */
.gn-confetto:nth-child(odd) {
    border-radius: 50%;
}

.gn-confetto:nth-child(3n) {
    width: 8px;
    height: 14px;
    border-radius: 2px;
}

.gn-confetto:nth-child(5n) {
    width: 6px;
    height: 6px;
}

/* ============================================
   BADGE ESAGONALE PER CELEBRAZIONE
   (Estende badges-3d.css)
   ============================================ */

.gn-celebration-header .hex-badge.large {
    width: 5em;
    height: 7.7em;
    margin: 0.5em auto;
    cursor: default;
}

.gn-celebration-header .hex-badge.large:hover {
    top: 0;
}

.gn-celebration-header .hex-badge.large .circle {
    width: 70px;
    height: 70px;
}

.gn-celebration-header .hex-badge.large .circle i {
    font-size: 2.2em;
}

.gn-celebration-header .hex-badge.large .ribbon {
    display: none;
}

/* Shine effect per badge nella celebrazione */
.gn-celebration-header .hex-badge::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    animation: gn-shine 2s ease-in-out infinite;
    z-index: 5;
}

@keyframes gn-shine {
    0% { transform: translateX(-100%) rotate(60deg); }
    100% { transform: translateX(100%) rotate(60deg); }
}

/* ============================================
   RESPONSIVE - Mobile
   ============================================ */

@media (max-width: 768px) {
    /* Toast: in basso su mobile con margine per anchor ads */
    .gn-toast-container {
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 90px;
        max-width: calc(100% - 20px);
    }

    .gn-position-bottom-right,
    .gn-position-bottom-left,
    .gn-position-top-right {
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 90px;
    }

    .gn-toast {
        transform: translateX(120%);
    }

    .gn-toast-visible {
        transform: translateX(0);
    }

    /* Celebration: piu compatta */
    .gn-celebration-modal {
        padding: 30px 20px;
        margin: 15px;
        width: calc(100% - 30px);
    }

    .gn-celebration-title {
        font-size: 20px;
    }

    .gn-levelup-badge {
        width: 100px;
        height: 100px;
    }

    .gn-levelup-number {
        font-size: 36px;
    }

    .gn-celebration-header .hex-badge.large {
        width: 4em;
        height: 6.2em;
    }

    .gn-celebration-header .hex-badge.large .circle {
        width: 55px;
        height: 55px;
    }

    .gn-celebration-header .hex-badge.large .circle i {
        font-size: 1.8em;
    }

    /* Disabilita confetti su mobile */
    .gn-confetti-container {
        display: none;
    }

    /* Riduci animazioni shine */
    .gn-celebration-header .hex-badge::after {
        animation: none;
    }
}

/* Riduzione motion per accessibilita */
@media (prefers-reduced-motion: reduce) {
    .gn-toast,
    .gn-celebration-modal,
    .gn-badge-animated,
    .gn-levelup-badge,
    .gn-confetto,
    .gn-toast-streak .gn-toast-icon {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }

    .gn-toast {
        transform: translateX(0);
        opacity: 1;
    }

    .gn-celebration-visible .gn-celebration-modal {
        transform: scale(1);
    }

    .gn-confetti-container {
        display: none;
    }

    .gn-celebration-header .hex-badge::after {
        animation: none;
    }
}

/* ============================================
   FALLBACK NO-JS (noscript alert)
   ============================================ */

.gn-noscript-alert {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: 400px;
    margin-left: auto;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #28a745;
    z-index: 9999;
}

.gn-noscript-alert h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #1a1a1a;
}

.gn-noscript-alert p {
    margin: 0;
    font-size: 14px;
    color: #5f6368;
}

/* ============================================
   SWEETALERT2 - Font minimo 13pt
   ============================================ */

.swal2-popup {
    font-size: 15pt !important;
}

.swal2-title {
    font-size: 17pt !important;
}

.swal2-html-container,
.swal2-content {
    font-size: 15pt !important;
}

.swal2-styled.swal2-confirm,
.swal2-styled.swal2-cancel,
.swal2-styled.swal2-deny {
    font-size: 15pt !important;
}

.swal2-input,
.swal2-textarea,
.swal2-select {
    font-size: 15pt !important;
}

.swal2-validation-message {
    font-size: 15pt !important;
}

/* ============================================
   SISTEMA LIVELLI - LEVEL TIERS
   Stili per gli avatar con badge livello
   ============================================ */

/* Avatar Container Base */
.avatar-container {
    position: relative;
    display: inline-block;
}

.avatar-container .notify-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10pt;
    padding: 1px 6px;
    min-width: 20px;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.avatar-container .circleimg {
    border-radius: 50%;
    border: 2px solid #ff9900;
    transition: all 0.3s ease;
}

/* Principiante (1-10) */
.level-tier-1 .notify-badge {
    background: #6c757d !important;
}
.level-tier-1 .circleimg,
.level-tier-1 .img-responsive {
    border-color: #6c757d !important;
}
.level-tier-1.level-badge {
    background: #6c757d;
}

/* Apprendista (11-25) */
.level-tier-2 .notify-badge {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
}
.level-tier-2 .circleimg,
.level-tier-2 .img-responsive {
    border-color: #28a745 !important;
    box-shadow: 0 0 10px rgba(40,167,69,0.4) !important;
}
.level-tier-2.level-badge {
    background: linear-gradient(135deg, #28a745, #20c997);
}

/* Intermedio (26-50) */
.level-tier-3 .notify-badge {
    background: linear-gradient(135deg, #17a2b8, #0dcaf0) !important;
}
.level-tier-3 .circleimg,
.level-tier-3 .img-responsive {
    border-color: #17a2b8 !important;
    box-shadow: 0 0 12px rgba(23,162,184,0.5) !important;
}
.level-tier-3.level-badge {
    background: linear-gradient(135deg, #17a2b8, #0dcaf0);
}

/* Esperto (51-75) */
.level-tier-4 .notify-badge {
    background: linear-gradient(135deg, #9400D3, #BA55D3) !important;
}
.level-tier-4 .circleimg,
.level-tier-4 .img-responsive {
    border-color: #9400D3 !important;
    box-shadow: 0 0 15px rgba(148,0,211,0.5) !important;
}
.level-tier-4.level-badge {
    background: linear-gradient(135deg, #9400D3, #BA55D3);
}

/* Maestro (76-100) */
.level-tier-5 .notify-badge {
    background: linear-gradient(135deg, #00CED1, #20B2AA) !important;
}
.level-tier-5 .circleimg,
.level-tier-5 .img-responsive {
    border-color: #00CED1 !important;
    box-shadow: 0 0 20px rgba(0,206,209,0.6) !important;
}
.level-tier-5.level-badge {
    background: linear-gradient(135deg, #00CED1, #20B2AA);
    color: #fff;
}

/* Leggenda (101-150) */
.level-tier-6 .notify-badge {
    background: linear-gradient(135deg, #ff5200, #ff8c00) !important;
}
.level-tier-6 .circleimg,
.level-tier-6 .img-responsive {
    border-color: #ff5200 !important;
    box-shadow: 0 0 25px rgba(255,82,0,0.7) !important;
}
.level-tier-6.level-badge {
    background: linear-gradient(135deg, #ff5200, #ff8c00);
}

/* Campione (151+) - EFFETTO PREMIUM */
.level-tier-7 .notify-badge {
    background: linear-gradient(135deg, #FF4500, #ff0080, #FF4500) !important;
    background-size: 200% 200% !important;
    animation: gn-level-badge-shimmer 2s ease infinite !important;
}
.level-tier-7 .circleimg,
.level-tier-7 .img-responsive {
    border-color: transparent !important;
    border-width: 3px !important;
    background: linear-gradient(#fff, #fff) padding-box, linear-gradient(45deg, #FF4500, #ff0080, #FFD700, #FF4500) border-box !important;
    background-size: 100% 100%, 300% 300% !important;
    animation: gn-level-rainbow-border 3s ease infinite !important;
    box-shadow: 0 0 20px rgba(255,69,0,0.6), 0 0 40px rgba(255,0,128,0.4), 0 0 60px rgba(255,215,0,0.3) !important;
}
.level-tier-7.level-badge {
    background: linear-gradient(135deg, #FF4500, #ff0080, #FFD700);
    background-size: 200% 200%;
    animation: gn-level-badge-shimmer 2s ease infinite;
}

/* Animazioni Level Tier-7 */
@keyframes gn-level-rainbow-border {
    0% { background-position: 100% 100%, 0% 50%; }
    50% { background-position: 100% 100%, 100% 50%; }
    100% { background-position: 100% 100%, 0% 50%; }
}

@keyframes gn-level-badge-shimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ============================================
   HEADER AVATAR - 40px compact size
   ============================================ */

.navbar-nav .avatar-container {
    line-height: 1;
}

.navbar-nav .avatar-container .circleimg[style*="40px"] + .notify-badge,
.navbar-nav .avatar-container .notify-badge {
    font-size: 9pt;
    padding: 0 5px;
    min-width: 18px;
    bottom: -6px;
}
