/* Chatbot Widget Styles */
.chatbot-api-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position Classes */
.chatbot-api-widget.chatbot-api-position-bottom-right {
    bottom: 20px;
    right: 30px;
}

.chatbot-api-widget.chatbot-api-position-bottom-left {
    bottom: 20px;
    left: 30px;
}

.chatbot-api-widget.chatbot-api-position-top-right {
    top: 20px;
    right: 30px;
}

.chatbot-api-widget.chatbot-api-position-top-left {
    top: 20px;
    left: 30px;
}

/* Toggle Button */
.chatbot-api-toggle {
    width: 70px;
    height: 70px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.3s ease;
    color: #0073aa;
    overflow: visible;
    padding: 0;
}

.chatbot-api-custom-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chatbot-api-default-icon {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chatbot-api-toggle:hover {
    background: transparent;
    transform: scale(1.1);
}

.chatbot-api-toggle:hover .chatbot-api-custom-icon,
.chatbot-api-toggle:hover .chatbot-api-default-icon {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Chat Container */
.chatbot-api-container {
    position: absolute;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 650px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Container position based on widget position */
.chatbot-api-position-bottom-right .chatbot-api-container,
.chatbot-api-position-bottom-left .chatbot-api-container {
    bottom: 80px;
}

.chatbot-api-position-top-right .chatbot-api-container,
.chatbot-api-position-top-left .chatbot-api-container {
    top: 80px;
}

.chatbot-api-position-bottom-right .chatbot-api-container,
.chatbot-api-position-top-right .chatbot-api-container {
    right: 0;
}

.chatbot-api-position-bottom-left .chatbot-api-container,
.chatbot-api-position-top-left .chatbot-api-container {
    left: 0;
}

/* Header */
.chatbot-api-header {
    background: #0073aa;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-api-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-api-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.chatbot-api-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
.chatbot-api-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-api-message {
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

.chatbot-api-message-user {
    align-self: flex-end;
}

.chatbot-api-message-bot {
    align-self: flex-start;
}

.chatbot-api-message-content {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chatbot-api-message-user .chatbot-api-message-content {
    background: #0073aa;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-api-message-bot .chatbot-api-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Markdown formatting in bot messages */
.chatbot-api-message-bot .chatbot-api-message-content strong {
    font-weight: 600;
    color: #333;
}

.chatbot-api-message-bot .chatbot-api-message-content em {
    font-style: italic;
}

.chatbot-api-message-bot .chatbot-api-message-content p {
    margin: 0 0 6px 0;
    font-size: 14px;
}

.chatbot-api-message-bot .chatbot-api-message-content p:last-child {
    margin-bottom: 0;
}

.chatbot-api-message-bot .chatbot-api-message-content ol {
    margin: 6px 0;
    padding-left: 18px;
    font-size: 14px;
}

.chatbot-api-message-bot .chatbot-api-message-content ol li {
    margin: 3px 0;
    line-height: 1.5;
}

.chatbot-api-message-bot .chatbot-api-message-content ul {
    margin: 6px 0;
    padding-left: 18px;
    list-style-type: disc;
    font-size: 14px;
}

.chatbot-api-message-bot .chatbot-api-message-content ul li {
    margin: 3px 0;
    line-height: 1.5;
}

/* Loading Indicator */
.chatbot-api-loading {
    align-self: flex-start;
}

.chatbot-api-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chatbot-api-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatbot-api-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-api-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input Container */
.chatbot-api-input-container {
    display: flex;
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
}

.chatbot-api-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-api-input:focus {
    border-color: #0073aa;
}

.chatbot-api-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.chatbot-api-send {
    width: 40px;
    height: 40px;
    background: #0073aa;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.chatbot-api-send:hover:not(:disabled) {
    background: #005a87;
    transform: scale(1.05);
}

.chatbot-api-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar Styling */
.chatbot-api-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-api-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-api-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chatbot-api-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-api-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
    
    .chatbot-api-position-bottom-right .chatbot-api-container,
    .chatbot-api-position-bottom-left .chatbot-api-container {
        bottom: 80px;
        left: 10px;
        right: 10px;
    }
    
    .chatbot-api-position-top-right .chatbot-api-container,
    .chatbot-api-position-top-left .chatbot-api-container {
        top: 80px;
        left: 10px;
        right: 10px;
    }
    
    .chatbot-api-widget.chatbot-api-position-bottom-right,
    .chatbot-api-widget.chatbot-api-position-bottom-left {
        bottom: 10px;
    }
    
    .chatbot-api-widget.chatbot-api-position-top-right,
    .chatbot-api-widget.chatbot-api-position-top-left {
        top: 10px;
    }
    
    .chatbot-api-widget.chatbot-api-position-bottom-right,
    .chatbot-api-widget.chatbot-api-position-top-right {
        right: 10px;
    }
    
    .chatbot-api-widget.chatbot-api-position-bottom-left,
    .chatbot-api-widget.chatbot-api-position-top-left {
        left: 10px;
    }
}

