/* Chat Widget Styles */

#chatWidget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

#chatToggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
}

#chatToggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#chatBox {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

#chatClose {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#chatClose:hover {
    background: rgba(255, 255, 255, 0.2);
}

#chatMessages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    text-align: right;
}

.user-message .message-content {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    max-width: 75%;
    word-wrap: break-word;
    text-align: left;
}

.assistant-message .message-content {
    display: inline-block;
    background: white;
    color: #333;
    padding: 10px 14px;
    border-radius: 18px 18px 18px 4px;
    max-width: 75%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.error-message .message-content {
    display: inline-block;
    background: #f8d7da;
    color: #721c24;
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    border: 1px solid #f5c6cb;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.user-message .message-time {
    text-align: right;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    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);
    }
    30% {
        transform: translateY(-10px);
    }
}

.chat-input-container {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
}

#messageInput {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
}

#sendMessageBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#sendMessageBtn:hover:not(:disabled) {
    transform: scale(1.1);
}

#sendMessageBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#connectionStatus {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #chatBox {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        right: 20px;
    }
}

/* Scrollbar styling */
#chatMessages::-webkit-scrollbar {
    width: 6px;
}

#chatMessages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chatMessages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#chatMessages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* RTL (Right-to-Left) Support for Arabic */
.message-content.rtl {
    direction: rtl;
    text-align: right;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* User messages in Arabic - keep on right but apply RTL */
.user-message .message-content.rtl {
    text-align: right;
}

/* Assistant messages in Arabic - left-aligned but RTL text */
.assistant-message.rtl {
    text-align: left;
}

.assistant-message .message-content.rtl {
    direction: rtl;
    text-align: right;
    /* Flip border-radius for RTL */
    border-radius: 18px 18px 4px 18px;
}

/* Input field RTL support */
#messageInput.rtl {
    direction: rtl;
    text-align: right;
}
