/* ==========================================================================
   🧞‍♂️ EUGENIO AI SITE WIDGET - CSS STYLES
   Mascotte 3D (Sleep / Wake-up), Glassmorphism Chat & Web Speech Microphone
   ========================================================================== */

#eugenio-widget-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

/* ─── MASCOTTE BUTTON CONTAINER ─── */
.eugenio-mascot-btn {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    cursor: pointer;
    background: radial-gradient(circle at 30% 30%, #38bdf8 0%, #1d4ed8 70%, #0f172a 100%);
    box-shadow: 0 10px 25px -5px rgba(29, 78, 216, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 20px rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    border: none;
    padding: 0;
}

.eugenio-mascot-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 16px 32px -6px rgba(29, 78, 216, 0.6), 0 0 0 4px #ffffff, 0 0 30px rgba(56, 189, 248, 0.7);
}

.eugenio-mascot-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transition: all 0.4s ease;
    pointer-events: none;
}

/* 💤 SLEEPING STATE ANIMATIONS */
.eugenio-mascot-btn.is-sleeping {
    animation: eugenioBreathe 3.5s ease-in-out infinite;
    filter: brightness(0.92) contrast(0.95);
}

@keyframes eugenioBreathe {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(0.96) translateY(3px); }
}

/* Fumetto Zzz animato */
.eugenio-sleep-bubble {
    position: absolute;
    top: -28px;
    right: -8px;
    background: #0f172a;
    color: #38bdf8;
    font-size: 13px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    gap: 4px;
    animation: floatZzz 2.2s ease-in-out infinite;
    pointer-events: none;
    white-space: nowrap;
}

@keyframes floatZzz {
    0%, 100% { transform: translateY(0) rotate(2deg); opacity: 0.9; }
    50% { transform: translateY(-6px) rotate(-3deg); opacity: 1; }
}

/* ✨ AWAKE STATE */
.eugenio-mascot-btn.is-awake {
    animation: eugenioWakePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    filter: brightness(1.1) drop-shadow(0 0 12px rgba(56, 189, 248, 0.8));
}

@keyframes eugenioWakePop {
    0% { transform: scale(0.9) rotate(-10deg); }
    60% { transform: scale(1.18) rotate(6deg); }
    100% { transform: scale(1.05) rotate(0); }
}

/* Badge Online verde */
.eugenio-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background-color: #22c55e;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* 💬 CHAT WINDOW (Glassmorphism Modal) */
.eugenio-chat-window {
    position: absolute;
    bottom: 96px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 2rem;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0.7) translateY(20px);
    pointer-events: none;
}

.eugenio-chat-window.is-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* ── HEADER ── */
.eugenio-chat-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.eugenio-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eugenio-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #38bdf8;
    border: 2px solid #ffffff;
    object-fit: cover;
}

.eugenio-header-title {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.eugenio-header-subtitle {
    font-size: 11px;
    color: #93c5fd;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.eugenio-header-subtitle .pulse-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: greenPulse 1.5s infinite;
}

@keyframes greenPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

.eugenio-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.eugenio-close-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: rotate(90deg);
}

/* ── MESSAGES BODY ── */
.eugenio-chat-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

.eugenio-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.eugenio-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.eugenio-msg {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    font-weight: 500;
    word-break: break-word;
    animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.eugenio-msg.from-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.eugenio-msg.from-bot a {
    color: #1d4ed8;
    font-weight: 700;
    text-decoration: underline;
}

.eugenio-msg.from-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.eugenio-typing-indicator {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.eugenio-typing-dot {
    width: 6px;
    height: 6px;
    background: #3b82f6;
    border-radius: 50%;
    animation: typeBounce 1.2s infinite ease-in-out;
}
.eugenio-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.eugenio-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typeBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ── INPUT FOOTER ── */
.eugenio-chat-footer {
    padding: 12px 16px 14px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.eugenio-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 9999px;
    padding: 4px 6px 4px 14px;
    transition: all 0.2s ease;
}

.eugenio-input-row:focus-within {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.eugenio-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    font-weight: 500;
    color: #0f172a;
    outline: none;
    padding: 6px 0;
}

.eugenio-chat-input::placeholder {
    color: #94a3b8;
    font-size: 12.5px;
}

/* 🎙️ MICROPHONE BUTTON (Web Speech API) */
.eugenio-mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.eugenio-mic-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.eugenio-mic-btn.is-recording {
    background: #ef4444;
    color: #ffffff;
    animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* SEND BUTTON */
.eugenio-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #1d4ed8;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(29, 78, 216, 0.3);
}

.eugenio-send-btn:hover {
    background: #1e40af;
    transform: scale(1.05);
}

.eugenio-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* CTA Footer Bar */
.eugenio-footer-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.eugenio-footer-cta a {
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.eugenio-footer-cta a:hover {
    text-decoration: underline;
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 640px) {
    #eugenio-widget-root {
        bottom: 16px;
        right: 16px;
    }
    .eugenio-mascot-btn {
        width: 72px;
        height: 72px;
    }
    .eugenio-chat-window {
        bottom: 84px;
        right: 0;
        width: calc(100vw - 32px);
        height: 500px;
    }
}
