/**
 * AI Chatbot Widget Styles - Fixed Version
 */

/* ========================================
   MAIN WIDGET CONTAINER
   ======================================== */

.ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* ========================================
   CHAT BUTTON
   ======================================== */

.ai-chatbot-button,
#ai-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.ai-chatbot-button:hover,
#ai-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#ai-chatbot-button .chat-icon {
    font-size: 28px;
    color: white;
}

/* ========================================
   CHAT WINDOW
   ======================================== */

.ai-chatbot-window,
#ai-chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#ai-chatbot-window {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   CHAT HEADER WITH PROGRESS
   ======================================== */

.ai-chatbot-header,
#ai-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.ai-chatbot-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.ai-chatbot-agent-info,
.chatbot-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chatbot-avatar,
.chatbot-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ai-chatbot-avatar img,
.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-avatar .avatar-placeholder {
    font-size: 24px;
}

.chatbot-agent-details {
    flex: 1;
}

.ai-chatbot-agent-name,
.chatbot-agent-name {
    font-weight: 600;
    font-size: 16px;
}

.ai-chatbot-status,
.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.ai-chatbot-minimize,
.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 24px;
    line-height: 1;
}

.ai-chatbot-minimize:hover,
.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ========================================
   HEADER PROGRESS CIRCLE
   ======================================== */

.ai-chatbot-progress {
    border-radius: 100%;
    border: 1px solid rgb(238, 238, 238);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    transition: background 0.4s ease;
}

.ai-chatbot-progress-inner {
    background: #fff;
    border-radius: 100%;
    border: 1px solid #eee;
    width: 35px;
    height: 35px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-progress-value {
    font-size: 11px;
    font-weight: 500;
    color: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 35px;
    height: 35px;
}

/* ========================================
   MESSAGES AREA
   ======================================== */

.ai-chatbot-messages,
#ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.ai-chatbot-message,
.chatbot-message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbot-message.user,
.chatbot-message.user {
    justify-content: flex-end;
}

.ai-chatbot-message.assistant,
.chatbot-message.assistant {
    justify-content: flex-start;
}

.ai-chatbot-message-bubble,
.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 14px;
}

.ai-chatbot-message.user .ai-chatbot-message-bubble,
.chatbot-message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-bubble,
.chatbot-message.assistant .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ========================================
   TEXT SEGMENT CLASSES
   ======================================== */

.message-bubble.text-segment-1 {
    margin-top: -8px;
    animation-delay: 0.1s;
}

.message-bubble.text-segment-2 {
    margin-top: -8px;
    animation-delay: 0.2s;
}

.message-bubble.text-segment-3 {
    margin-top: -8px;
    animation-delay: 0.3s;
}

.message-bubble.text-segment-4 {
    margin-top: -8px;
    animation-delay: 0.4s;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.typing-indicator-message {
    margin-bottom: 16px;
}

/* ========================================
   QUICK REPLIES
   ======================================== */

.ai-chatbot-quick-replies,
#ai-chatbot-quick-replies {
    padding: 10px 20px;
    display: flex;
    flex-wrap: nowrap;
    overflow: auto hidden;
    gap: 8px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.ai-chatbot-quick-reply-btn,
.quick-reply-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-chatbot-quick-reply-btn:hover,
.quick-reply-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}


/* ========================================
   INLINE QUICK REPLIES (INSIDE MESSAGES)
   ======================================== */

.inline-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.inline-quick-replies .quick-reply-btn,
.inline-quick-replies .starter-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.inline-quick-replies .quick-reply-btn:hover,
.inline-quick-replies .starter-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.inline-quick-replies .starter-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 24px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    width: 100%;
    margin-bottom: 4px;
}

.inline-quick-replies .starter-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
    background: linear-gradient(135deg, #7c8ff5 0%, #8b5cb8 100%) !important;
}

.inline-quick-replies .starter-btn:last-child {
    margin-bottom: 0;
}

/* Keep original container hidden but functional as fallback */
.ai-chatbot-quick-replies {
    display: none !important;
}


/* ========================================
   INLINE QUICK REPLIES - EDIT MODE
   ======================================== */

.inline-quick-replies-edit {
    flex-direction: column !important;
    gap: 10px !important;
}

.inline-quick-replies-edit .quick-reply-btn {
    width: 100% !important;
    text-align: left !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
}

.inline-quick-replies-edit .quick-reply-btn:hover {
    background: #667eea !important;
    color: white !important;
    transform: translateX(4px) !important;
}

/* ========================================
   CONVERSATION STARTER BUTTONS
   ======================================== */

.starter-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 24px !important;
    cursor: pointer;
    font-size: 15px !important;
    font-weight: 600 !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    width: 100%;
    margin-bottom: 8px;
}

.starter-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
    background: linear-gradient(135deg, #7c8ff5 0%, #8b5cb8 100%) !important;
}

.starter-btn:last-child {
    margin-bottom: 0;
}

#ai-chatbot-quick-replies.has-starters {
    padding: 15px 20px;
    flex-wrap: wrap;
}

#ai-chatbot-quick-replies.has-starters .starter-btn {
    display: block;
    width: 100%;
}

/* ========================================
   INPUT AREA
   ======================================== */

.ai-chatbot-input-area,
#ai-chatbot-input-area {
    display: flex;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    gap: 10px;
    position: relative;
}

.ai-chatbot-input,
#ai-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chatbot-input:focus,
#ai-chatbot-input:focus {
    border-color: #667eea;
}

.ai-chatbot-send,
#ai-chatbot-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 20px;
}

.ai-chatbot-send:hover,
#ai-chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chatbot-send:disabled,
#ai-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.ai-chatbot-messages::-webkit-scrollbar,
#ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chatbot-messages::-webkit-scrollbar-track,
#ai-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb,
#ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover,
#ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.ai-chatbot-quick-replies::-webkit-scrollbar {
    height: 6px;
}

.ai-chatbot-quick-replies::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-chatbot-quick-replies::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 480px) {

    .ai-chatbot-window,
    #ai-chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
    }

    .ai-chatbot-widget,
    #ai-chatbot-container {
        bottom: 10px;
        right: 10px;
    }

    .ai-chatbot-button,
    #ai-chatbot-button {
        width: 50px;
        height: 50px;
    }

    #ai-chatbot-button .chat-icon {
        font-size: 24px;
    }

    .ai-chatbot-progress {
        width: 40px;
        height: 40px;
        bottom: -12px;
    }

    .ai-chatbot-progress-inner {
        width: 30px;
        height: 30px;
    }

    .ai-chatbot-progress-value {
        font-size: 10px;
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 360px) {

    .ai-chatbot-message-bubble,
    .message-bubble {
        max-width: 85%;
        font-size: 13px;
    }

    .ai-chatbot-input,
    #ai-chatbot-input {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {

    .ai-chatbot-widget,
    #ai-chatbot-container,
    .ai-chatbot-window,
    #ai-chatbot-window {
        display: none !important;
    }
}