/* CHATBOT WIDGET STYLES */

/* Floating Button */
.chatbot-trigger {
    position: fixed;
    bottom: 30px;
    right: 100px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: none;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, left 0.1s ease, top 0.1s ease;
}

.chatbot-trigger.dragging {
    transition: none !important;
    cursor: grabbing !important;
    opacity: 0.9;
    transform: scale(1.05);
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.5);
}

.chatbot-trigger .trigger-icon {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-trigger .close-icon {
    display: none;
}

.chatbot-trigger.active .trigger-icon {
    display: none;
}

.chatbot-trigger.active .close-icon {
    display: block;
}

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 110px;
    right: 100px;
    width: 380px;
    height: 520px;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), right 0s, left 0s, top 0s, bottom 0s;
}

.chatbot-window.dragging {
    transition: none !important;
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chatbot-header {
    padding: 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    justify-content: center;
    overflow: hidden;
    /* Ensure image stays in circle */
    background: white;
    /* White background for the PNG */
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chatbot-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.85;
}

.chatbot-header-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    margin-left: auto;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    opacity: 0.9;
}

.chatbot-header-close:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.chatbot-header-close svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
}


/* Messages Container */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    background: #262626;
    color: #f5f5f5;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-message.user {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.chat-message.typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* Input Area */
.chatbot-input {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    background: rgba(30, 30, 30, 0.9);
}

.chatbot-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    border-radius: 100px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-input input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.chatbot-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
}

.chatbot-input button:hover {
    transform: scale(1.05);
}

.chatbot-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-input button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.quick-action-btn {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

/* ─── EU AI Act Art. 50 — Badge AI nell'header ─────────────────────────── */
.ai-status-label {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.02em;
}

/* Pallino verde pulsante che indica sistema AI attivo */
.ai-badge-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    animation: ai-badge-pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes ai-badge-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    60%  { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ─── EU AI Act Art. 50 — Footer disclaimer permanente ─────────────────── */
.chatbot-ai-footer {
    padding: 8px 16px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.chatbot-ai-footer strong {
    color: rgba(255, 255, 255, 0.65);
}

.chatbot-ai-footer a {
    color: #8b5cf6;
    text-decoration: none;
    margin-left: 6px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-ai-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ─── EU AI Act Art. 50(1) — Pannello disclosure prima apertura ─────────── */
.ai-disclosure-panel {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    animation: disclosureFadeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes disclosureFadeIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-disclosure-panel.ai-disclosure-hiding {
    animation: disclosureFadeOut 0.35s ease forwards;
}

@keyframes disclosureFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.96);
    }
}

.ai-disclosure-content {
    padding: 32px 28px;
    text-align: center;
    color: #f0f0f0;
    max-width: 300px;
}

.ai-disclosure-icon {
    font-size: 44px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6));
    animation: ai-icon-float 3s ease-in-out infinite;
}

@keyframes ai-icon-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

.ai-disclosure-content h3 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-disclosure-content p {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.75);
}

.ai-disclosure-content strong {
    color: #fff;
}

.ai-disclosure-legal {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.4) !important;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 10px;
    margin-top: 6px !important;
}

.ai-disclosure-btn {
    margin-top: 16px;
    padding: 12px 28px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    letter-spacing: 0.02em;
    width: 100%;
}

.ai-disclosure-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 28px rgba(139, 92, 246, 0.55);
}

.ai-disclosure-btn:active {
    transform: scale(0.97);
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chatbot-trigger {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    /* Hide floating trigger when chat is open on mobile to prevent overlap with input */
    .chatbot-trigger.active {
        display: none !important;
    }
}