/* Botpress Chatbot Container */
.halalgo-chatbot-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    visibility: hidden;
}

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

/* Chatbot Toggle Button */
.chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #159D6F;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1001;
    transition: all 0.3s ease;
    transform: translateY(0);
    animation: float 3s ease-in-out infinite;
}

.chatbot-toggle.hidden {
    opacity: 0;
    visibility: hidden;
}

.chatbot-toggle.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
}

@keyframes float {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
    }
}

.chatbot-toggle:hover {
    background: #0e7d57;
    transform: translateY(-2px);
}

/* Chatbot Header */
.chatbot-header {
    background: #159D6F;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 5px;
    margin-left: auto;
    margin-right: 10px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    padding: 3px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn.active {
    background: white;
    color: #159D6F;
    font-weight: bold;
}

.lang-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f5f5f5;
}

/* Individual Messages */
.message {
    margin-bottom: 15px;
    max-width: 85%;
    clear: both;
}

.message.user {
    float: right;
    margin-left: auto;
}

.message.assistant {
    float: left;
    margin-right: auto;
}

.message.system {
    float: none;
    margin: 10px auto;
    max-width: 90%;
    text-align: center;
}

.message-content {
    position: relative;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    overflow: hidden;
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    text-align: right;
    margin-top: 4px;
    margin-right: -5px;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-reply {
    background: #f0f0f0;
    border: none;
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.quick-reply:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.quick-reply:active {
    transform: translateY(0);
}

.quick-replies-container {
    background: transparent !important;
    box-shadow: none !important;
    padding: 5px 0 0 0;
}

.quick-replies-container .message-content {
    padding: 0;
    box-shadow: none;
}

.user .message-content {
    background: #e3f2fd;
    color: #0d47a1;
    border-bottom-right-radius: 4px;
}

.assistant .message-content {
    background: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
}

.system.error .message-content {
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
}

/* Typing Indicator */
.typing .message-content {
    padding: 10px 15px;
    background: #f1f1f1;
    min-width: 50px;
}

.typing .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    margin-right: 3px;
    animation: dot-pulse 1.5s infinite ease-in-out;
}

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

.typing .dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes dot-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input-container {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-input:focus {
    border-color: #159D6F;
}

.send-btn {
    background: #159D6F;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    margin-left: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-weight: 500;
}

.send-btn:hover {
    background: #0e7d57;
}

/* RTL Support for Urdu */
.halalgo-chatbot-container[dir="rtl"] .message.user {
    float: left;
    margin-right: auto;
    margin-left: 0;
}

.halalgo-chatbot-container[dir="rtl"] .message.assistant {
    float: right;
    margin-left: auto;
    margin-right: 0;
}

.halalgo-chatbot-container[dir="rtl"] .user .message-content {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 18px;
}

.halalgo-chatbot-container[dir="rtl"] .assistant .message-content {
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 18px;
}

.halalgo-chatbot-container[dir="rtl"] .message-time {
    text-align: left;
    margin-left: -5px;
    margin-right: 0;
}

.halalgo-chatbot-container[dir="rtl"] .send-btn {
    margin-right: 10px;
    margin-left: 0;
}

/* Responsive Design */
@media (max-width: 480px) {
    .halalgo-chatbot-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chatbot-toggle {
        bottom: 10px;
        right: 10px;
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .chat-input {
        font-size: 16px; /* Better for mobile input */
    }
    
    .quick-replies {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }
}
