/* ============================================================
   DadoMediaWeb — Social Proof / Live Activity Widget
   Non-intrusive toast notifications + floating counter bar
   Glassmorphism design, production-quality animations
   ============================================================ */

/* ================= VARIABLES ================= */
:root {
    --sp-navy: #1E1B4B;
    --sp-navy-dark: #0f0d2e;
    --sp-brand: #6366F1;
    --sp-brand-dark: #4F46E5;
    --sp-brand-light: #818CF8;
    --sp-brand-rgb: 99, 102, 241;
    --sp-glass: rgba(255, 255, 255, 0.82);
    --sp-glass-dark: rgba(30, 27, 75, 0.88);
    --sp-glass-border: rgba(255, 255, 255, 0.22);
    --sp-radius: 14px;
    --sp-shadow: 0 8px 32px rgba(30, 27, 75, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
    --sp-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= TOAST CONTAINER ================= */
#sp-toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - 48px);
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================= TOAST CARD ================= */
.sp-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--sp-glass);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border: 1px solid var(--sp-glass-border);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    pointer-events: auto;
    cursor: default;
    transform: translateX(-40px);
    opacity: 0;
    animation: spToastIn 0.5s var(--sp-transition) forwards;
    will-change: transform, opacity;
    max-width: 100%;
}

.sp-toast.sp-toast-exit {
    animation: spToastOut 0.4s var(--sp-transition) forwards;
}

/* ================= TOAST AVATAR ================= */
.sp-toast-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-toast-avatar.sp-type-preventivo {
    background: linear-gradient(135deg, var(--sp-brand), var(--sp-brand-dark));
}

.sp-toast-avatar.sp-type-visita {
    background: linear-gradient(135deg, #06B6D4, #0891B2);
}

.sp-toast-avatar.sp-type-progetto {
    background: linear-gradient(135deg, #10B981, #059669);
}

.sp-toast-avatar.sp-type-recensione {
    background: linear-gradient(135deg, #F59E0B, #D97706);
}

.sp-toast-avatar.sp-type-scelta {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
}

/* ================= TOAST BODY ================= */
.sp-toast-body {
    flex: 1;
    min-width: 0;
}

.sp-toast-text {
    font-size: 0.88rem;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.4;
    margin: 0;
}

.sp-toast-text strong {
    font-weight: 700;
    color: var(--sp-navy);
}

.sp-toast-time {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sp-toast-time::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #10B981;
    display: inline-block;
    animation: spPulse 2s ease-in-out infinite;
}

/* ================= TOAST CLOSE ================= */
.sp-toast-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-top: -2px;
    margin-right: -4px;
    opacity: 0;
    pointer-events: none;
}

.sp-toast:hover .sp-toast-close {
    opacity: 1;
    pointer-events: auto;
}

.sp-toast-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
}

/* ================= COUNTER BAR ================= */
#sp-counter-bar {
    position: fixed;
    top: 68px; /* below navbar */
    left: 0;
    right: 0;
    z-index: 1050;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.45s var(--sp-transition), opacity 0.45s var(--sp-transition);
    pointer-events: none;
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

#sp-counter-bar.sp-bar-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#sp-counter-bar.sp-bar-dismissed {
    display: none;
}

.sp-counter-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--sp-navy) 0%, var(--sp-navy-dark) 100%);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.4;
    position: relative;
}

.sp-counter-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.sp-counter-text {
    text-align: center;
}

.sp-counter-number {
    font-weight: 800;
    color: var(--sp-brand-light);
    font-family: 'Outfit', sans-serif;
    display: inline-block;
    transition: transform 0.3s var(--sp-transition);
}

.sp-counter-number.sp-bump {
    animation: spBump 0.4s var(--sp-transition);
}

.sp-counter-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sp-counter-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ================= ANIMATIONS ================= */
@keyframes spToastIn {
    0% {
        transform: translateX(-40px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes spToastOut {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-40px);
        opacity: 0;
    }
}

@keyframes spPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes spBump {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ================= MOBILE RESPONSIVE ================= */
@media (max-width: 640px) {
    #sp-toast-container {
        bottom: 16px;
        left: 12px;
        max-width: calc(100vw - 80px); /* avoid chatbot FAB on right */
        width: calc(100vw - 80px);
    }

    .sp-toast {
        padding: 10px 12px;
        gap: 10px;
        border-radius: 12px;
    }

    .sp-toast-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .sp-toast-text {
        font-size: 0.82rem;
    }

    .sp-toast-time {
        font-size: 0.72rem;
    }

    .sp-counter-inner {
        font-size: 0.8rem;
        padding: 7px 40px 7px 12px;
    }

    .sp-counter-close {
        right: 8px;
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 380px) {
    #sp-toast-container {
        bottom: 12px;
        left: 8px;
        max-width: calc(100vw - 72px);
        width: calc(100vw - 72px);
    }

    .sp-toast-avatar {
        display: none;
    }
}

/* ================= REDUCED MOTION ================= */
@media (prefers-reduced-motion: reduce) {
    .sp-toast {
        animation-duration: 0.01ms;
    }
    .sp-toast.sp-toast-exit {
        animation-duration: 0.01ms;
    }
    #sp-counter-bar {
        transition-duration: 0.01ms;
    }
    .sp-counter-number.sp-bump {
        animation-duration: 0.01ms;
    }
    .sp-toast-time::before {
        animation: none;
    }
}
