/* نظام الدعم الفني الاحترافي */
/* RTL Support */

/* الأيقونة العائمة */
.support-chat-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    left: auto;
    z-index: 99999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
    pointer-events: auto;
}

/* زر الأيقونة */
.support-chat-toggle {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: none;
    outline: none;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 99999;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.support-chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}

.support-chat-toggle.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* أيقونة الدعم */
.support-chat-icon {
    font-size: 28px;
    color: white;
    transition: transform 0.3s ease;
}

/* Fallback إذا لم تحمل Font Awesome */
.support-chat-icon:before {
    content: "💬";
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.support-chat-icon.fa-headset:before {
    content: "\f590";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.support-chat-toggle.active .support-chat-icon {
    transform: rotate(180deg);
}

/* شارة العدد */
.support-queue-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

/* نقطة حالة الاتصال على الأيقونة */
.online-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.online-status-dot.online {
    background: #4caf50;
}

.online-status-dot.busy {
    background: #ff9800;
}

.online-status-dot.offline {
    background: #9e9e9e;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* نافذة المحادثة */
.support-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    left: auto;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
    text-align: right;
    z-index: 99998;
}

.support-chat-window.active {
    display: flex !important;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* رأس النافذة */
.support-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.support-chat-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.support-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
    animation: statusPulse 2s infinite;
}

.support-status-dot.online {
    background: #4caf50;
}

.support-status-dot.busy {
    background: #ff9800;
    animation: none;
}

.support-status-dot.offline {
    background: #9e9e9e;
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
}

.support-chat-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 2px 0 0 0;
}

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

.support-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* منطقة حالة الطابور */
.support-queue-status {
    background: #f8f9ff;
    padding: 20px;
    border-bottom: 1px solid #e1e8ed;
    text-align: center;
}

.queue-position {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.queue-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
    gap: 8px;
}

.queue-person {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.3s ease;
}

.queue-person.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    animation: currentPulse 2s infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(102, 126, 234, 0.7); }
}

.queue-person.ahead {
    background: #4caf50;
    color: white;
}

.queue-person.waiting {
    background: #f1f3f4;
    color: #666;
}

.queue-info {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.estimated-time {
    color: #667eea;
    font-weight: 600;
}

/* منطقة الرسائل */
.support-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafbfc;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    direction: rtl;
}

.chat-message.visitor {
    flex-direction: row-reverse;
    direction: ltr;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.message-avatar.admin {
    background: #28a745;
}

.message-content {
    max-width: 70%;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chat-message.visitor .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-text {
    margin: 0;
    line-height: 1.6;
    font-size: 14px;
    direction: rtl;
    text-align: right;
    word-wrap: break-word;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
}

.chat-message.visitor .message-sender {
    color: rgba(255, 255, 255, 0.9);
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

.message-status {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 2px;
}

/* رسائل النظام */
.system-message {
    text-align: center;
    margin: 20px 0;
    padding: 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    font-size: 13px;
    color: #667eea;
}

/* منطقة الكتابة */
.support-chat-input {
    padding: 20px;
    border-top: 1px solid #e1e8ed;
    background: white;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9ff;
    border-radius: 25px;
    padding: 8px 16px;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.input-container:focus-within {
    border-color: #667eea;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    direction: rtl;
    text-align: right;
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.2s ease;
    transform: scaleX(-1); /* عكس أيقونة الإرسال للـ RTL */
}

.send-button:hover {
    transform: scale(1.1);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* حالات مختلفة */
/* ملاحظة: إخفاء/إظهار العناصر يتم عبر JavaScript في updateUIForStatus */

.support-chat-window.active-chat .support-queue-status {
    display: none;
}

/* إشعارات */
.notification-dot {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: #ff4757;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* تحسينات للموبايل */
@media (max-width: 480px) {
    .support-chat-window {
        width: calc(100vw - 30px);
        height: 450px;
        max-height: 70vh;
        right: 15px;
        bottom: 80px;
    }
    
    .support-chat-toggle {
        width: 50px;
        height: 50px;
    }
    
    .support-chat-icon {
        font-size: 22px;
    }
    
    .support-chat-header {
        padding: 12px 15px;
    }
    
    .support-chat-title {
        font-size: 15px;
    }
    
    .support-chat-subtitle {
        font-size: 11px;
    }
    
    .support-chat-messages {
        padding: 12px;
    }
    
    .support-chat-input {
        padding: 10px 12px;
    }
    
    .input-container {
        padding: 6px 12px;
    }
    
    .message-input {
        font-size: 13px;
    }
    
    .send-button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .support-queue-status {
        padding: 12px;
    }
    
    .queue-position {
        font-size: 18px;
    }
    
    .queue-info {
        font-size: 12px;
        flex-direction: column;
        gap: 8px;
    }
}

/* تأثيرات الانتقال */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* حالة الكتابة */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    margin-bottom: 15px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* تنسيق النموذج في الصفحة الرئيسية */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    backdrop-filter: blur(5px);
    visibility: visible;
    opacity: 1;
}

.modal[style*="display: flex"] {
    display: flex !important;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

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

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 12px 16px;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
    font-size: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: none;
    height: 50px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* تحسينات للموبايل */
@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: none;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }
}

/* تأثيرات التحقق من الحقول */
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #f44336 !important;
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1) !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.form-group input.success,
.form-group select.success,
.form-group textarea.success {
    border-color: #4caf50 !important;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1) !important;
}

/* رسالة خطأ تحت الحقل */
.field-error {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.field-error i {
    font-size: 10px;
}

/* تحسين Toast للنموذج */
.toast-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 10002 !important;
}

/* تأثير التركيز المحسن */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2) !important;
}

/* مؤشر الحقول المطلوبة */
.form-group label[required]::after,
.form-group label:has(+ input[required])::after,
.form-group label:has(+ select[required])::after {
    content: " *";
    color: #f44336;
    font-weight: bold;
}

/* تحسين شكل الأزرار */
.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* تأثير التحميل للزر */
.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* ============================================ */
/* Dark Mode للشات */
/* ============================================ */

/* Dark mode based on body class */
body.dark-mode .support-chat-window,
.dark-mode .support-chat-window,
[data-theme="dark"] .support-chat-window,
html[data-theme="dark"] .support-chat-window {
    background: #1a1a2e;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

body.dark-mode .support-chat-messages,
.dark-mode .support-chat-messages,
[data-theme="dark"] .support-chat-messages,
html[data-theme="dark"] .support-chat-messages {
    background: #16213e;
}

body.dark-mode .support-chat-input,
.dark-mode .support-chat-input,
[data-theme="dark"] .support-chat-input,
html[data-theme="dark"] .support-chat-input {
    background: #1a1a2e;
    border-top-color: #2a2a4a;
}

body.dark-mode .input-container,
.dark-mode .input-container,
[data-theme="dark"] .input-container,
html[data-theme="dark"] .input-container {
    background: #16213e;
    border-color: #2a2a4a;
}

body.dark-mode .input-container:focus-within,
.dark-mode .input-container:focus-within,
[data-theme="dark"] .input-container:focus-within,
html[data-theme="dark"] .input-container:focus-within {
    border-color: #667eea;
}

body.dark-mode .message-input,
.dark-mode .message-input,
[data-theme="dark"] .message-input,
html[data-theme="dark"] .message-input {
    color: #eaeaea;
}

body.dark-mode .message-input::placeholder,
.dark-mode .message-input::placeholder,
[data-theme="dark"] .message-input::placeholder,
html[data-theme="dark"] .message-input::placeholder {
    color: #666;
}

/* رسائل الأدمن في Dark Mode - مهم جداً */
body.dark-mode .message-content,
.dark-mode .message-content,
[data-theme="dark"] .message-content,
html[data-theme="dark"] .message-content {
    background: #2a2a4a !important;
    color: #eaeaea !important;
}

body.dark-mode .chat-message.admin .message-content,
.dark-mode .chat-message.admin .message-content,
[data-theme="dark"] .chat-message.admin .message-content,
html[data-theme="dark"] .chat-message.admin .message-content {
    background: #2a3a5a !important;
    color: #ffffff !important;
}

body.dark-mode .chat-message.visitor .message-content,
.dark-mode .chat-message.visitor .message-content,
[data-theme="dark"] .chat-message.visitor .message-content,
html[data-theme="dark"] .chat-message.visitor .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}

body.dark-mode .message-text,
.dark-mode .message-text,
[data-theme="dark"] .message-text,
html[data-theme="dark"] .message-text {
    color: inherit !important;
}

/* رسائل الأدمن للزائر - تأكيد إضافي */
body.dark-mode .support-chat-messages .chat-message:not(.visitor) .message-content,
.dark-mode .support-chat-messages .chat-message:not(.visitor) .message-content,
[data-theme="dark"] .support-chat-messages .chat-message:not(.visitor) .message-content,
html[data-theme="dark"] .support-chat-messages .chat-message:not(.visitor) .message-content {
    background: #2a3a5a !important;
    color: #ffffff !important;
}

body.dark-mode .support-chat-messages .chat-message:not(.visitor) .message-text,
.dark-mode .support-chat-messages .chat-message:not(.visitor) .message-text,
[data-theme="dark"] .support-chat-messages .chat-message:not(.visitor) .message-text,
html[data-theme="dark"] .support-chat-messages .chat-message:not(.visitor) .message-text {
    color: #ffffff !important;
}

body.dark-mode .message-time,
.dark-mode .message-time,
[data-theme="dark"] .message-time,
html[data-theme="dark"] .message-time {
    color: #a0a0a0 !important;
}

body.dark-mode .system-message,
.dark-mode .system-message,
[data-theme="dark"] .system-message,
html[data-theme="dark"] .system-message {
    background: rgba(102, 126, 234, 0.2);
    color: #a0a0ff;
}

body.dark-mode .support-queue-status,
.dark-mode .support-queue-status,
[data-theme="dark"] .support-queue-status,
html[data-theme="dark"] .support-queue-status {
    background: #16213e;
    border-bottom-color: #2a2a4a;
}

body.dark-mode .queue-info,
.dark-mode .queue-info,
[data-theme="dark"] .queue-info,
html[data-theme="dark"] .queue-info {
    color: #a0a0a0;
}

body.dark-mode .queue-person.waiting,
.dark-mode .queue-person.waiting,
[data-theme="dark"] .queue-person.waiting,
html[data-theme="dark"] .queue-person.waiting {
    background: #2a2a4a;
    color: #a0a0a0;
}

/* Dark mode للـ Modal */
body.dark-mode .modal-content,
.dark-mode .modal-content,
[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-content {
    background: #1a1a2e;
}

body.dark-mode .modal-body,
.dark-mode .modal-body,
[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-body {
    background: #1a1a2e;
}

body.dark-mode .modal-footer,
.dark-mode .modal-footer,
[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .modal-footer {
    background: #16213e;
    border-top-color: #2a2a4a;
}

body.dark-mode .form-group label,
.dark-mode .form-group label,
[data-theme="dark"] .form-group label,
html[data-theme="dark"] .form-group label {
    color: #eaeaea;
}

body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea,
.dark-mode .form-group input,
.dark-mode .form-group select,
.dark-mode .form-group textarea,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea {
    background: #16213e;
    border-color: #2a2a4a;
    color: #eaeaea;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus,
.dark-mode .form-group input:focus,
.dark-mode .form-group select:focus,
.dark-mode .form-group textarea:focus,
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus,
html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus,
html[data-theme="dark"] .form-group textarea:focus {
    border-color: #667eea;
    background: #1a1a2e;
}

body.dark-mode .btn-secondary,
.dark-mode .btn-secondary,
[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-secondary {
    background: #2a2a4a;
    color: #eaeaea;
    border-color: #3a3a5a;
}

body.dark-mode .btn-secondary:hover,
.dark-mode .btn-secondary:hover,
[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-secondary:hover {
    background: #3a3a5a;
}

/* ============================================ */
/* زر رفع الملفات */
/* ============================================ */

.file-upload-btn {
    background: transparent;
    border: none;
    color: #667eea;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.file-upload-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

body.dark-mode .file-upload-btn,
.dark-mode .file-upload-btn,
[data-theme="dark"] .file-upload-btn,
html[data-theme="dark"] .file-upload-btn {
    color: #a0a0ff;
}

body.dark-mode .file-upload-btn:hover,
.dark-mode .file-upload-btn:hover,
[data-theme="dark"] .file-upload-btn:hover,
html[data-theme="dark"] .file-upload-btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

/* معاينة الملف */
.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f0f2f5;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}

body.dark-mode .file-preview,
.dark-mode .file-preview,
[data-theme="dark"] .file-preview,
html[data-theme="dark"] .file-preview {
    background: #2a2a4a;
    color: #eaeaea;
}

.file-preview i {
    color: #667eea;
    font-size: 20px;
}

.file-preview .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview .file-size {
    color: #666;
    font-size: 11px;
}

body.dark-mode .file-preview .file-size,
.dark-mode .file-preview .file-size,
[data-theme="dark"] .file-preview .file-size,
html[data-theme="dark"] .file-preview .file-size {
    color: #a0a0a0;
}

.file-preview .remove-file {
    background: none;
    border: none;
    color: #f44336;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
}

/* رسالة الملف في المحادثة */
.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.message-file:hover {
    background: rgba(102, 126, 234, 0.2);
}

.message-file i {
    font-size: 24px;
    color: #667eea;
}

.message-file .file-info {
    flex: 1;
}

.message-file .file-info .name {
    font-weight: 600;
    font-size: 13px;
}

.message-file .file-info .size {
    font-size: 11px;
    opacity: 0.7;
}

/* صورة في الرسالة */
.message-image {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}


/* =====================================================
   Typing Indicator - مؤشر جاري الكتابة
   ===================================================== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f0f2f5;
    border-radius: 18px;
    margin-bottom: 15px;
    max-width: 200px;
    animation: fadeIn 0.3s ease;
}

.typing-indicator.visitor {
    margin-right: auto;
    margin-left: 0;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.typing-indicator.visitor .typing-avatar {
    background: #e4e6eb;
    color: #65676b;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #90949c;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

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

.typing-text {
    font-size: 12px;
    color: #65676b;
    white-space: nowrap;
}

/* =====================================================
   Read Receipts - علامة تم القراءة
   ===================================================== */

.read-status {
    display: inline-flex;
    align-items: center;
    margin-right: 5px;
    font-size: 12px;
}

.read-status.sent {
    color: #90949c;
}

.read-status.read {
    color: #0084ff;
}

.read-status i {
    font-size: 11px;
}

/* تحسين عرض الوقت مع علامة القراءة */
.message-time {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #90949c;
    margin-top: 5px;
}

.chat-message.visitor .message-time {
    color: rgba(255, 255, 255, 0.7);
    justify-content: flex-end;
}

.chat-message.visitor .read-status.read {
    color: rgba(255, 255, 255, 0.9);
}

.chat-message.visitor .read-status.sent {
    color: rgba(255, 255, 255, 0.6);
}

/* =====================================================
   Dark Mode للـ Typing و Read Receipts
   ===================================================== */

body.dark-mode .typing-indicator,
.dark-mode .typing-indicator,
[data-theme="dark"] .typing-indicator,
html[data-theme="dark"] .typing-indicator {
    background: #2a3a5a;
}

body.dark-mode .typing-text,
.dark-mode .typing-text,
[data-theme="dark"] .typing-text,
html[data-theme="dark"] .typing-text {
    color: #a0a0a0;
}

body.dark-mode .typing-dots span,
.dark-mode .typing-dots span,
[data-theme="dark"] .typing-dots span,
html[data-theme="dark"] .typing-dots span {
    background: #6a6a8a;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
