/* Chatbot Styles */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    font-family: 'Tajawal', sans-serif;
}

/* Position Classes */
.chatbot-container.bottom-left {
    left: 20px;
}

.chatbot-container.bottom-right {
    right: 20px;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(40, 167, 69, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    position: relative;
        float: left;

}

.chatbot-toggle::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    z-index: -1;
    opacity: 0.3;
    animation: ripple 2s infinite;
    
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(40, 167, 69, 0.6);
}

.chatbot-toggle i {
    color: white;
    font-size: 24px;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active i {
    transform: rotate(45deg);
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(40, 167, 69, 0.8);
    }
    100% {
        box-shadow: 0 4px 20px rgba(40, 167, 69, 0.4);
    }
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 400px;
    height: 700px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.chatbot-window.active {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
}

/* Window Position Classes */
.chatbot-container.bottom-left .chatbot-window {
    left: 0;
}

.chatbot-container.bottom-right .chatbot-window {
    right: 0;
}

/* تأكيد حالات الفتح والإغلاق */
.chatbot-window:not(.active) {
    transform: scale(0) translateY(20px) !important;
    opacity: 0 !important;
    pointer-events: none;
}

.chatbot-window.active {
    pointer-events: auto !important;
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 20px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.header-text {
    text-align: right;
    margin-right: 15px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.close-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* تأكيد أن زر الإغلاق قابل للنقر */
.close-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    position: relative !important;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    position: relative;
    z-index: 1;
}

.chatbot-avatar i {
    font-size: 24px;
    color: white;
}

.chatbot-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    position: relative;
    z-index: 1;
}

.chatbot-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 5px 0 0;
    position: relative;
    z-index: 1;
}

/* Chatbot Body */
.chatbot-body {
    height: 380px;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 500px;
    max-height: 550px;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

/* Message Styles */
.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideInUp 0.3s ease;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.message.user .message-avatar {
    background: #28a745;
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.message.bot .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Quick Options */
.quick-options {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.quick-options-title {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.options-grid {
    display: grid;
    gap: 12px;
    margin-top: 15px;
}

.icons-grid {
    grid-template-columns: repeat(2, 1fr);
}

.list-grid {
    grid-template-columns: 1fr;
}

.option-btn {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.option-btn:hover {
    background: #f8f9fa;
    border-color: #28a745;
    color: #28a745;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.2);
}

/* Icon Button Style */
.icon-btn {
    flex-direction: column;
    padding: 12px 8px;
    min-height: 70px;
}

.icon-wrapper {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    transition: all 0.3s ease;
}

.icon-wrapper i {
    color: white;
    font-size: 14px;
}

.icon-btn:hover .icon-wrapper {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.icon-btn .option-text {
    font-size: 10px;
    line-height: 1.2;
    margin-top: 3px;
}

/* List Button Style */
.list-btn {
    padding: 15px 20px;
    justify-content: flex-start;
    text-align: right;
}

.list-btn i {
    margin-left: 12px;
    font-size: 16px;
    color: #28a745;
}

.list-btn .option-text {
    font-size: 14px;
}

/* Questions in Chat */
.questions-in-chat {
    margin: 10px 0;
}

.questions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.question-btn-chat {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 11px;
    min-height: 50px;
    flex-direction: column;
}

.question-btn-chat:hover {
    background: #e9ecef;
    border-color: #28a745;
    transform: translateY(-1px);
}

.question-btn-chat i {
    color: #28a745;
    font-size: 14px;
    margin-bottom: 4px;
}

.question-btn-chat span {
    color: #333;
    line-height: 1.2;
}

/* Options in Chat */
.options-in-chat {
    margin: 10px 0;
}

.options-grid-chat {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.option-btn-chat {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    min-height: 45px;
    flex-direction: row;
    gap: 8px;
}

.option-btn-chat:hover {
    background: #bbdefb;
    border-color: #1976d2;
    transform: translateY(-1px);
}

.option-btn-chat i {
    color: #1976d2;
    font-size: 14px;
}

.option-btn-chat span {
    color: #1976d2;
    font-weight: 500;
    line-height: 1.2;
}

/* Contact Buttons */
.contact-buttons {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.contact-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.whatsapp-btn {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
}

.whatsapp-btn:hover {
    background: linear-gradient(135deg, #128c7e 0%, #075e54 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
}

.phone-btn {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.phone-btn:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.contact-btn i {
    font-size: 16px;
}

.contact-btn span {
    font-size: 13px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999;
    }

    .chatbot-window {
        width: 100vw !important;
        height: 90vh !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: scale(0) translateY(100%) !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 20px 20px 0 0 !important;
    }

    .chatbot-window.active {
        transform: scale(1) translateY(0) !important;
        opacity: 1 !important;
    }

    .chatbot-messages {
        min-height: 65vh !important;
        max-height: 70vh !important;
        padding: 15px !important;
    }

    .chatbot-header {
        padding: 15px 20px !important;
        border-radius: 20px 20px 0 0 !important;
    }

    .chatbot-title {
        font-size: 16px !important;
    }

    .chatbot-subtitle {
        font-size: 12px !important;
    }

    .close-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
    }

    .contact-buttons {
        padding: 15px !important;
        gap: 10px !important;
        background: #f8f9fa !important;
        border-top: 1px solid #e9ecef !important;
    }

    .contact-btn {
        padding: 12px 15px !important;
        font-size: 14px !important;
        min-height: 50px !important;
        border-radius: 12px !important;
    }

    .contact-btn i {
        font-size: 16px !important;
    }

    .contact-btn span {
        font-size: 13px !important;
    }

    .questions-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .question-btn-chat {
        padding: 15px !important;
        min-height: 60px !important;
        font-size: 13px !important;
    }

    .options-grid-chat {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .option-btn-chat {
        padding: 15px !important;
        min-height: 55px !important;
        font-size: 14px !important;
    }

    /* إخفاء الشات بوت toggle على الموبايل عندما يكون مفتوح */
    .chatbot-toggle.active {
        display: none !important;
    }
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 15px;
        left: 15px;
    }
    
    .chatbot-window {
        width: calc(100vw - 30px);
        max-width: 350px;
        height: 450px;
    }
    
    .chatbot-body {
        height: 330px;
    }
}

/* RTL Support */
[dir="rtl"] .chatbot-container {
    left: auto;
    right: 20px;
}

[dir="rtl"] .chatbot-window {
    left: auto;
    right: 0;
}

[dir="rtl"] .message.user {
    flex-direction: row;
}

[dir="rtl"] .message.bot {
    flex-direction: row-reverse;
}

[dir="rtl"] .option-btn i {
    margin-left: 0;
    margin-right: 5px;
}
