/* =============================================
   RM Solutions AI Chatbot Styles
   Color scheme: #1dbf73 (primary green), #353535 (dark)
   ============================================= */

/* Toggle Button */
#chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    color: #1dbf73;
    border: 2px solid #1dbf73;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(29, 191, 115, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(29, 191, 115, 0.5);
}

/* Chat Window */
#chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    font-family: 'Montserrat', sans-serif;
}

#chatbot-window.chatbot-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    overscroll-behavior: contain;
}

/* Header */
#chatbot-header {
    background: linear-gradient(135deg, #1dbf73, #17a863);
    color: #fff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

#chatbot-avatar {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chatbot-header-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

#chatbot-header-status {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}

#chatbot-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

#chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

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

/* Message Bubbles */
.chatbot-msg {
    display: flex;
    animation: chatbot-fadeIn 0.3s ease;
}

.chatbot-msg-bot {
    justify-content: flex-start;
}

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

.chatbot-msg-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chatbot-msg-bot .chatbot-msg-content {
    background: #fff;
    color: #353535;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    white-space: normal;
}

/* Markdown formatting inside bot messages */
.chatbot-msg-bot .chatbot-msg-content ul {
    margin: 8px 0 8px 4px;
    padding-left: 18px;
    list-style: disc;
}

.chatbot-msg-bot .chatbot-msg-content ol {
    margin: 8px 0 8px 4px;
    padding-left: 20px;
    list-style: decimal;
}

.chatbot-msg-bot .chatbot-msg-content li {
    margin-bottom: 4px;
    line-height: 1.5;
    padding-left: 2px;
}

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

.chatbot-msg-bot .chatbot-msg-content strong {
    font-weight: 700;
}

.chatbot-msg-bot .chatbot-msg-content .chatbot-heading {
    display: block;
    font-size: 14px;
    margin: 4px 0;
}

.chatbot-msg-bot .chatbot-msg-content a {
    color: #1dbf73;
    text-decoration: underline;
    word-break: break-all;
}

.chatbot-msg-bot .chatbot-msg-content a:hover {
    color: #17a863;
}

.chatbot-msg-user .chatbot-msg-content {
    background: #1dbf73;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 18px !important;
}

.chatbot-dot {
    width: 8px;
    height: 8px;
    background: #b0b0b0;
    border-radius: 50%;
    animation: chatbot-bounce 1.4s infinite ease-in-out;
}

.chatbot-dot:nth-child(1) {
    animation-delay: 0s;
}

.chatbot-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Input Area */
#chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
}

#chatbot-input:focus {
    border-color: #1dbf73;
    background: #fff;
}

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

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1dbf73;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

#chatbot-send:hover {
    background: #17a863;
    transform: scale(1.05);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Animations */
@keyframes chatbot-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Body scroll lock when chat is open */
body.chatbot-body-locked {
    overflow: hidden !important;
}

/* Popup Banner */
#chatbot-banner {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9999;
    background: #fff;
    color: #353535;
    border: 1px solid #1dbf73;
    border-radius: 12px;
    padding: 10px 36px 10px 14px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(29, 191, 115, 0.25);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    max-width: 240px;
}

#chatbot-banner.chatbot-banner-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#chatbot-banner-close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
}

#chatbot-banner-close:hover {
    color: #353535;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chatbot-window {
        right: 8px;
        bottom: 76px;
        width: calc(100vw - 16px);
        height: auto;
        max-height: calc(100dvh - 90px);
        border-radius: 14px;
    }

    #chatbot-messages {
        padding: 12px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .chatbot-msg-content {
        max-width: 85%;
        font-size: 14px;
    }

    #chatbot-input {
        font-size: 16px; /* prevents iOS auto-zoom on focus */
    }

    #chatbot-send {
        width: 44px;
        height: 44px;
    }

    #chatbot-toggle {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    #chatbot-banner {
        right: 16px;
        bottom: 76px;
        max-width: 200px;
        font-size: 12px;
    }
}
