/* 
 * Live Chat CSS
 * تنسيقات المحادثة المباشرة لموقع فورتي
 */

:root {
    --chat-primary: #0056b3;
    --chat-primary-rgb: 0, 86, 179;
    --chat-secondary: #f8f9fa;
    --chat-secondary-rgb: 248, 249, 250;
    --chat-accent: #28a745;
    --chat-accent-rgb: 40, 167, 69;
    --chat-text: #212529;
    --chat-text-light: #f8f9fa;
    --chat-border: #dee2e6;
    --chat-shadow: rgba(0, 0, 0, 0.1);
    --chat-notification: #dc3545;
}

[data-theme="dark"] {
    --chat-primary: #0d6efd;
    --chat-primary-rgb: 13, 110, 253;
    --chat-secondary: #343a40;
    --chat-secondary-rgb: 52, 58, 64;
    --chat-accent: #2fb85a;
    --chat-accent-rgb: 47, 184, 90;
    --chat-text: #f8f9fa;
    --chat-text-light: #f8f9fa;
    --chat-border: #495057;
    --chat-shadow: rgba(0, 0, 0, 0.25);
    --chat-notification: #ff4d5e;
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Noto Sans Arabic', sans-serif;
    direction: rtl;
}

/* Chat Button Container */
.chat-button-container {
    position: fixed;
    bottom: 20px;
    left: 20px; /* نقل الزر إلى يسار الصفحة أسفل الواتساب */
    right: auto;
    z-index: 1000;
    margin-bottom: 0;
}

/* Chat Button */
.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 8px var(--chat-shadow);
    transition: all 0.3s ease;
    position: relative;
    margin-bottom: 0; /* إزالة الهامش السفلي لإزالة المساحة الزائدة */
    animation: float 3s ease-in-out infinite;
}

.chat-button:hover {
    transform: scale(1.05);
    background-color: var(--chat-accent);
}

.chat-button i {
    font-size: 20px;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--chat-notification);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notification-badge.active {
    opacity: 1;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 90px; /* ليظهر فوق زر الواتساب */
    left: 20px; /* محاذاة نافذة الدردشة يسارًا مع زر الواتساب */
    right: auto;
    width: 320px; /* WhatsApp-like width */
    height: 70vh; /* Responsive height */
    max-width: 90vw;
    max-height: 500px; /* Max height */
    background-color: var(--chat-secondary);
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--chat-shadow);
    display: none; /* Hide by default */
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.chat-window.active {
    display: flex; /* Show on active */
    opacity: 1;
    transform: translateY(0);
}

/* Chat Header */
.chat-header {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 10px 10px 0 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.chat-header button {
    background: none;
    border: none;
    color: var(--chat-text-light);
    cursor: pointer;
    margin-left: 10px;
    transition: transform 0.2s ease;
}

.chat-header button:hover {
    transform: scale(1.1);
}

.faq-button {
    font-size: 16px;
}

.chat-close {
    font-size: 18px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    position: relative;
    word-wrap: break-word;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

.user-message {
    align-self: flex-start;
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    border-bottom-right-radius: 5px;
}

.admin-message {
    align-self: flex-end;
    background-color: var(--chat-accent);
    color: var(--chat-text-light);
    border-bottom-left-radius: 5px;
}

/* Chat Input */
.chat-input {
    padding: 10px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    outline: none;
    font-family: 'Noto Sans Arabic', sans-serif;
}

.chat-input button {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chat-input button:hover {
    background-color: var(--chat-accent);
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--chat-border);
    background-color: rgba(var(--chat-secondary-rgb), 0.7);
    max-height: 100px;
    overflow-y: auto;
}

.quick-reply {
    background-color: rgba(var(--chat-primary-rgb), 0.1);
    color: var(--chat-primary);
    border: 1px solid var(--chat-primary);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 200px;
    font-family: 'Noto Sans Arabic', sans-serif;
    text-align: center;
}

.quick-reply:hover {
    background-color: var(--chat-accent);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    color: var(--chat-text-light);
}

/* FAQ Section */
.chat-window .faq-container {
    position: absolute;
    top: 0;
    right: 370px;
    width: 250px;
    background-color: var(--chat-secondary);
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--chat-shadow);
    overflow: hidden;
    z-index: 999;
    transform: scale(0);
    transform-origin: top right;
    transition: transform 0.3s ease;
}

.chat-window .faq-container.active {
    transform: scale(1);
}

.chat-window .faq-header {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-window .faq-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-window .faq-close {
    background: none;
    border: none;
    color: var(--chat-text-light);
    cursor: pointer;
    font-size: 16px;
}

.chat-window .faq-items {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

.chat-window .faq-item {
    margin-bottom: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.chat-window .faq-item:hover {
    background-color: rgba(var(--chat-primary-rgb), 0.1);
}

.chat-window .faq-question {
    font-weight: 600;
    font-size: 13px;
    color: var(--chat-text);
    margin-bottom: 5px;
}

.chat-window .faq-answer {
    font-size: 12px;
    color: var(--chat-text);
    display: none;
}

.chat-window .faq-item.expanded .faq-answer {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-window {
        width: 300px;
        height: 400px;
        left: 10px; /* بدلاً من right لإبقائها بجانب الواتساب يسارًا */
        right: auto;
        bottom: 10px; /* حافة سفلية أقل من زر الواتساب ليبقى الزر أسفل بالفعل */
    }
    
    .chat-button-container {
        bottom: 10px; /* ليكون أسفل زر الواتساب (الواتساب bottom: 20px على الموبايل) */
        left: 10px;
        right: auto;
    }
    
    .chat-button {
        width: 50px;
        height: 50px;
        /* إزالة right في الموبايل لأن الزر أصبح يسارًا */
        margin-bottom: 60px; /* مسافة بسيطة فوق الحافة لتجنب الالتصاق بالحافة */
    }
    
    .quick-replies {
        max-height: 80px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 8px;
    }
    
    .quick-reply {
        max-width: 150px;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        bottom: 0;
        right: 0;
        left: 0;
        transform: none;
    }
    
    .chat-button-container {
        bottom: 10px;
        left: 10px;
        right: auto;
    }
    
    .chat-button {
        width: 50px;
        height: 50px;
    }
    
    .quick-reply {
        max-width: 120px;
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

/* Animation for floating chat button */
@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0px);
    }
}

/* Animation for new messages */
@keyframes messageAppear {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: messageAppear 0.3s ease forwards;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    align-self: flex-start;
    background-color: var(--chat-secondary);
    padding: 8px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.typing-indicator.active {
    opacity: 1;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--chat-text);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    opacity: 0.6;
}

.typing-indicator span:nth-child(1) {
    animation: typing 1s infinite 0s;
}

.typing-indicator span:nth-child(2) {
    animation: typing 1s infinite 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation: typing 1s infinite 0.4s;
}

@keyframes typing {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
    }
}