#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #6f42c1;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 20px rgba(111, 66, 193, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(111, 66, 193, 0.5);
}

#chatbot-toggle .chatbot-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
}

#chatbot-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatbotSlideUp 0.3s ease-out;
}

#chatbot-panel.open {
    display: flex;
}

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

#chatbot-header {
    background: linear-gradient(135deg, #6f42c1, #764ba2);
    color: #fff;
    padding: 16px 20px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chatbot-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    opacity: 0.8;
}

#chatbot-header-close:hover {
    opacity: 1;
}

#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chatbot-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg.user {
    align-self: flex-end;
    background: #6f42c1;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: #f1f0f7;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.bot p {
    margin: 0 0 8px;
}

.chatbot-msg.bot p:last-child {
    margin-bottom: 0;
}

.chatbot-msg.bot ul, .chatbot-msg.bot ol {
    margin: 4px 0;
    padding-left: 20px;
}

.chatbot-msg.bot a {
    color: #6f42c1;
    text-decoration: underline;
}

.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f0f7;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: chatbotTyping 1.4s infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbotTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

#chatbot-handoff-area {
    padding: 8px 16px;
    border-top: 1px solid #eee;
}

#chatbot-handoff-btn {
    width: 100%;
    padding: 8px 14px;
    background: #fff;
    color: #6f42c1;
    border: 1px solid #6f42c1;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, color 0.2s;
}

#chatbot-handoff-btn:hover {
    background: #6f42c1;
    color: #fff;
}

.chatbot-handoff-status {
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    padding: 4px 0;
}

.chatbot-handoff-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #6f42c1;
    border-top-color: transparent;
    border-radius: 50%;
    animation: chatbotSpin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes chatbotSpin {
    to { transform: rotate(360deg); }
}

.chatbot-handoff-login p {
    color: #888;
    margin: 0 0 8px;
}

.chatbot-handoff-success p {
    color: #2e7d32;
    margin: 0;
}

.chatbot-handoff-error p {
    color: #c62828;
    margin: 0 0 8px;
}

.chatbot-handoff-link {
    color: #6f42c1;
    font-weight: 600;
    text-decoration: underline;
}

.chatbot-handoff-retry {
    background: none;
    border: 1px solid #6f42c1;
    color: #6f42c1;
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 12px;
}

.chatbot-handoff-retry:hover {
    background: #6f42c1;
    color: #fff;
}

#chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: #fff;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    resize: none;
    max-height: 80px;
}

#chatbot-input:focus {
    border-color: #6f42c1;
}

#chatbot-send {
    background: #6f42c1;
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

#chatbot-send:hover {
    background: #5a32a3;
}

@media (max-width: 767px) {
    #chatbot-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }

    #chatbot-toggle {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
}
