/* ========================================
   AI Chatbot Widget Styles
   ======================================== */

/* ---- Container ---- */
#ai-chatbot-widget {
    position: fixed;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Chat Bubble ---- */
.ai-chatbot-bubble {
    position: fixed;
    bottom: 24px;
    right: 90px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.ai-chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.ai-chatbot-bubble:active {
    transform: scale(0.95);
}

.ai-chatbot-bubble-icon {
    color: #ffffff;
    width: 28px;
    height: 28px;
}

.ai-chatbot-bubble-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* ---- Chat Window ---- */
.ai-chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    height: calc(100vh - 120px);
    max-height: 600px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-chatbot-slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
}

@keyframes ai-chatbot-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Header ---- */
.ai-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chatbot-assistant-name {
    font-weight: 600;
    font-size: 15px;
}

.ai-chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.ai-chatbot-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Messages Area ---- */
.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

.ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ---- Message Bubbles ---- */
.ai-chatbot-message {
    margin-bottom: 12px;
    display: flex;
    animation: ai-chatbot-fadeIn 0.3s ease-out;
}

@keyframes ai-chatbot-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbot-message.user {
    justify-content: flex-end;
}

.ai-chatbot-message.assistant {
    justify-content: flex-start;
}

.ai-chatbot-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-chatbot-message.user .ai-chatbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content {
    background: #ffffff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* ---- Markdown Content Styles ---- */
.ai-chatbot-message.assistant .ai-chatbot-message-content p {
    margin: 0 0 8px 0;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content p:last-child {
    margin-bottom: 0;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content strong {
    font-weight: 600;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content em {
    font-style: italic;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content h3,
.ai-chatbot-message.assistant .ai-chatbot-message-content h4 {
    margin: 8px 0 4px 0;
    font-weight: 600;
    line-height: 1.3;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content h3 {
    font-size: 14px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content h4 {
    font-size: 13px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content ul,
.ai-chatbot-message.assistant .ai-chatbot-message-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content li {
    margin-bottom: 2px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content code {
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 10px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 12px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content a {
    color: #667eea;
    text-decoration: underline;
}

.ai-chatbot-message.assistant .ai-chatbot-message-content a:hover {
    color: #764ba2;
}

.ai-chatbot-message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    text-align: right;
}

.ai-chatbot-message.user .ai-chatbot-message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* ---- Typing Indicator ---- */
.ai-chatbot-typing-indicator {
    padding: 8px 16px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
}

.ai-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-chatbot-typing-dots span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ai-chatbot-bounce 1.4s infinite ease-in-out both;
}

.ai-chatbot-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-chatbot-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes ai-chatbot-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.ai-chatbot-typing-text {
    font-size: 12px;
    color: #6b7280;
}

/* ---- Input Area ---- */
.ai-chatbot-input-wrapper {
    flex-shrink: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.ai-chatbot-form {
    display: flex;
    padding: 12px;
    gap: 8px;
    align-items: center;
}

.ai-chatbot-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chatbot-input:focus {
    border-color: #667eea;
}

.ai-chatbot-input::placeholder {
    color: #9ca3af;
}

.ai-chatbot-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.ai-chatbot-send-btn:hover {
    transform: scale(1.05);
}

.ai-chatbot-send-btn:active {
    transform: scale(0.95);
}

.ai-chatbot-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

.ai-chatbot-footer-note {
    padding: 8px 12px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #f3f4f6;
}

/* ---- Error Message ---- */
.ai-chatbot-error {
    padding: 12px;
    background: #fef2f2;
    color: #991b1b;
    border-left: 3px solid #ef4444;
    margin: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
}

/* ---- Responsive Design ---- */
@media (max-width: 480px) {
    .ai-chatbot-bubble {
        right: 16px;
        bottom: 16px;
    }

    .ai-chatbot-window {
        bottom: 80px;
        right: 0;
        left: 0;
        width: 100%;
        max-width: none;
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 16px 16px 0 0;
    }
}

@media (max-height: 600px) {
    .ai-chatbot-window {
        height: calc(100vh - 40px);
        bottom: 20px;
    }
}