/* =========================================
   UNIVERSAL CHATBOT PLUGIN - CSS
   ========================================= */

:root {
    --chat-primary-color: #F84A22;
    /* Colore tema PINSA */
    --chat-secondary-color: #D93B18;
    --chat-bg-color: #1a1d24;
    /* Sfondo dark */
    --chat-bubble-bg: #F84A22;
    --chat-bubble-color: #ffffff;
    --chat-text-main: #f8fafc;
    --chat-text-muted: #94a3b8;
    --chat-border: rgba(255, 255, 255, 0.1);
    --chat-glass-bg: rgba(26, 29, 36, 0.85);

    --chat-font-family: 'Outfit', sans-serif;
    --chat-z-index: 9999;
}

/* Launcher Bubble */
#chatbot-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--chat-bubble-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(28, 128, 10, 0.4);
    z-index: var(--chat-z-index);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s;
}

#chatbot-launcher:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #66ff4d, var(--chat-primary-color));
}

#chatbot-launcher svg {
    width: 30px;
    height: 30px;
    fill: var(--chat-bubble-color);
}

/* Chat Window */
#chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 350px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background-color: var(--chat-glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--chat-z-index);
    font-family: var(--chat-font-family);

    /* Animation defaults (hidden state) */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#chatbot-window.cb-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.cb-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(90deg, var(--chat-primary-color), var(--chat-secondary-color));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cb-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cb-avatar {
    width: 35px;
    height: 35px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.cb-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.2;
}

.cb-status {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cb-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
}

.cb-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.cb-close:hover {
    opacity: 1;
}

/* Messages Area */
.cb-messages {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-primary-color) transparent;
}

.cb-messages::-webkit-scrollbar {
    width: 6px;
}

.cb-messages::-webkit-scrollbar-thumb {
    background-color: var(--chat-border);
    border-radius: 10px;
}

/* Message Bubbles */
.cb-msg {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    animation: cb-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    word-wrap: break-word;
}

@keyframes cb-pop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.cb-msg.cb-bot {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--chat-text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
}

.cb-msg.cb-user {
    background-color: var(--chat-primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.cb-msg a {
    color: var(--chat-secondary-color);
    text-decoration: underline;
}

/* Input Area */
.cb-input-area {
    padding: 1rem;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.2);
}

.cb-input {
    flex-grow: 1;
    background: transparent;
    border: 1px solid var(--chat-border);
    padding: 0.75rem 1rem;
    border-radius: 50px;
    color: var(--chat-text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

.cb-input:focus {
    border-color: var(--chat-primary-color);
}

.cb-input::placeholder {
    color: var(--chat-text-muted);
}

.cb-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--chat-primary-color);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.cb-send:hover {
    transform: scale(1.05);
    background-color: var(--chat-secondary-color);
}

.cb-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    margin-left: 3px;
    /* visual center for send icon */
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }

    #chatbot-launcher {
        bottom: 20px;
        right: 20px;
    }
}