.spider-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #0058a3;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    z-index: 9999;
}

.spider-launcher-label {
    position: absolute;
    left: 0;
    z-index: 10;
    top: 50%;
    width: auto;
    transform: translate(-105%, -50%);
    font-size: 1rem;
    white-space: nowrap;
    line-height: 1;
    font-weight: 500;
    background-color: #00437d;
    padding: .35rem .5rem .2rem .5rem;
    border-radius: .35rem;
    animation: pulse 1s ease-in-out infinite;
    transition: opacity .35s ease;
    opacity: 1;
}

.spider-launcher-label.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        transform: translate(-105%, -50%) scale(1);
    }
    50% {
        transform: translate(-105%, -50%) scale(1.05);
    }
    100% {
        transform: translate(-105%, -50%) scale(1);
    }
}

.spider-widget {
    position: fixed;
    right: 24px;
    bottom: 90px;
    width: 340px;
    max-height: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.spider-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0058a3;
    color: #ffffff;
}

.spider-title {
    font-size: 14px;
    font-weight: 600;
}

.spider-close {
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.spider-messages {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    background: #f5f5f5;
    min-height: 100px;
}

.msg {
    margin-bottom: 8px;
    max-width: 80%;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.msg.user {
    margin-left: auto;
    background: #0058a3;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg.bot {
    margin-right: auto;
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

/* Bolla "typing" con tre puntini animati */
.msg.typing {
    margin-right: auto;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 16px;
    min-width: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg.typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4b5563;
    margin: 0 3px;
    opacity: 0.2;
    animation: spiderTypingBounce 1s infinite ease-in-out;
}

.msg.typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.msg.typing .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes spiderTypingBounce {
    0% {
        transform: translateY(0);
        opacity: 0.2;
    }
    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
    60% {
        transform: translateY(0);
        opacity: 0.4;
    }
    100% {
        transform: translateY(0);
        opacity: 0.2;
    }
}

.spider-input-area {
    display: flex;
    padding: 8px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.spider-input {
    flex: 1;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    padding: 8px 10px;
    font-size: 13px;
}

.spider-send {
    margin-left: 8px;
    border-radius: 999px;
    border: none;
    background: #0058a3;
    color: #ffffff;
    padding: 0 14px;
    font-size: 14px;
    cursor: pointer;
}

.spider-send:hover {
    background: #00437d;
}

/* Mobile tweak */
@media (max-width: 600px) {
    .spider-widget {
        right: 12px;
        bottom: 80px;
        width: calc(100% - 24px);
        max-height: 70vh;
    }

    .spider-launcher {
        right: 12px;
        bottom: 12px;
    }
}
