
#cb-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#cb-chat-widget * {
    box-sizing: border-box;
}

#cb-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--cb-header-bg);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

#cb-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#cb-chat-box {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--cb-body-bg);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
    opacity: 1;
    transform: scale(1);
}

#cb-chat-box.cb-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.cb-chat-header {
    background: var(--cb-header-bg);
    color: var(--cb-header-text);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 2;
}

.cb-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.5);
}

.cb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cb-header-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--cb-header-text);
}

.cb-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cb-dot {
    width: 8px;
    height: 8px;
    background: #4cd964;
    border-radius: 50%;
    display: inline-block;
}

.cb-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--cb-body-bg);
    scroll-behavior: smooth;
}

.cb-msg-row {
    display: flex;
    width: 100%;
}

.cb-msg-row.cb-bot { justify-content: flex-start; }
.cb-msg-row.cb-user { justify-content: flex-end; }

.cb-msg {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 14.5px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

.cb-msg-row.cb-bot .cb-msg {
    background: var(--cb-bot-bubble);
    color: var(--cb-bot-text);
    border-bottom-left-radius: 4px;
}

.cb-msg-row.cb-user .cb-msg {
    background: var(--cb-user-bubble);
    color: var(--cb-user-text);
    border-bottom-right-radius: 4px;
}

/* FAQ Options Multi-level Buttons */
.cb-faq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
    margin-bottom: 10px;
}

.cb-faq-btn {
    background: transparent;
    border: 1.5px solid var(--cb-btn-border);
    color: var(--cb-btn-text);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.cb-faq-btn:hover {
    background: var(--cb-btn-border);
    color: #ffffff; /* Si assume testo bianco al passaggio */
}

.cb-faq-btn .cb-arrow {
    font-size: 16px;
    opacity: 0.7;
    transition: transform 0.2s;
}

.cb-faq-btn:hover .cb-arrow {
    transform: translateX(4px);
}

.cb-back-btn {
    background: rgba(0,0,0,0.03) !important;
    border: 1.5px dashed var(--cb-btn-border) !important;
    color: var(--cb-bot-text) !important;
    justify-content: flex-start !important;
    gap: 10px;
}

.cb-back-btn:hover {
    background: rgba(0,0,0,0.06) !important;
    color: var(--cb-bot-text) !important;
}

/* Form inputs */
.cb-chat-input-row {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}

#cb-user-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    padding: 12px 16px;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9f9f9;
}

#cb-user-input:focus {
    border-color: var(--cb-header-bg);
    background: #ffffff;
}

#cb-send-btn {
    background: var(--cb-header-bg);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

#cb-send-btn:hover {
    transform: scale(1.1);
}

.cb-chat-footer {
    padding: 12px 20px;
    background: #ffffff;
    text-align: center;
    border-top: 1px solid rgba(0,0,0,0.04);
}

.cb-btn-wa {
    display: inline-block;
    background: #25D366;
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    width: 100%;
    transition: background 0.2s;
}

.cb-btn-wa:hover {
    background: #1ebe57;
    color: white;
}

/* Typing Indicator */
.cb-typing {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
}
.cb-typing span {
    width: 6px;
    height: 6px;
    background: var(--cb-bot-text);
    opacity: 0.5;
    border-radius: 50%;
    animation: cb-bounce 1.4s infinite ease-in-out both;
}
.cb-typing span:nth-child(1) { animation-delay: -0.32s; }
.cb-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes cb-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (max-width: 480px) {
    #cb-chat-box {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        right: -8px;
        bottom: 74px;
    }
}
