/* WhatsApp Chat Pro - Admin External Chat Styles */

.wcp-external-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    direction: rtl;
    height: calc(100vh - 100px);
    background: #f5f5f5;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* الهيدر */
.wcp-chat-header {
    background: linear-gradient(135deg, #25d366, #128C7E);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.wcp-header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wcp-chat-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcp-chat-header h2 i {
    font-size: 24px;
}

.wcp-admin-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.wcp-admin-name {
    font-weight: 500;
}

.wcp-admin-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    opacity: 0.9;
}

.wcp-admin-status.online {
    color: #4ade80;
}

.wcp-admin-status.online::before {
    content: '●';
    color: #4ade80;
    font-size: 16px;
}

.wcp-logout-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.wcp-logout-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

/* الجسم */
.wcp-chat-body {
    display: flex;
    height: calc(100% - 70px);
}

/* الشريط الجانبي */
.wcp-conversations-sidebar {
    width: 320px;
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

.wcp-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.wcp-sidebar-header h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.wcp-search-box {
    position: relative;
}

.wcp-search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.wcp-search-box input:focus {
    outline: none;
    border-color: #25d366;
}

.wcp-search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
}

/* قائمة المحادثات */
.wcp-conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.wcp-conversation-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 8px;
    position: relative;
    border: 1px solid transparent;
}

.wcp-conversation-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.wcp-conversation-item.active {
    background: #f0f9ff;
    border-color: #25d366;
}

.wcp-conversation-item.unread {
    background: #fef3f2;
    border-color: #fda29b;
}

.wcp-conv-avatar {
    width: 50px;
    height: 50px;
    background: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    flex-shrink: 0;
    position: relative;
}

.wcp-conv-avatar i {
    font-size: 24px;
    color: #6b7280;
}

.wcp-unread-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

.wcp-conv-info {
    flex: 1;
    min-width: 0;
}

.wcp-conv-name {
    font-weight: 600;
    color: #111827;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcp-conv-email {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcp-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.wcp-conv-time {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.wcp-conv-ip {
    font-size: 11px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* تذييل الشريط الجانبي */
.wcp-sidebar-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.wcp-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.wcp-stat-item {
    text-align: center;
}

.wcp-stat-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.wcp-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #25d366;
}

/* منطقة الدردشة الرئيسية */
.wcp-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
}

.wcp-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.wcp-chat-empty i {
    font-size: 80px;
    color: #d1d5db;
    margin-bottom: 20px;
}

.wcp-chat-empty h3 {
    margin: 0 0 10px 0;
    color: #4b5563;
}

.wcp-chat-empty p {
    margin: 0;
    color: #9ca3af;
    font-size: 14px;
}

.wcp-chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.wcp-active-header {
    background: white;
    padding: 15px 25px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wcp-active-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wcp-active-avatar {
    width: 50px;
    height: 50px;
    background: #25d366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.wcp-active-details h4 {
    margin: 0 0 5px 0;
    color: #111827;
    font-size: 18px;
}

.wcp-active-email {
    font-size: 14px;
    color: #6b7280;
}

.wcp-active-actions {
    display: flex;
    gap: 10px;
}

.wcp-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.wcp-action-btn:hover {
    background: #e5e7eb;
    transform: rotate(45deg);
}

.wcp-action-btn i {
    font-size: 18px;
    color: #6b7280;
}

/* حاوية الرسائل */
#wcp-external-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: #f0f2f5;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.03) 10px, rgba(255,255,255,.03) 20px);
}

.wcp-message-row {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

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

.wcp-ext-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.wcp-ext-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wcp-ext-msg-avatar-init {
    background: #6b7280;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
}

.wcp-message-row.wcp-message-admin {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.wcp-message-row.wcp-message-visitor {
    justify-content: flex-start;
}

.wcp-message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.wcp-bubble-admin {
    background: #dcf8c6;
    border-bottom-right-radius: 4px;
}

.wcp-bubble-visitor {
    background: white;
    border-bottom-left-radius: 4px;
}

.wcp-message-text {
    color: #111827;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.wcp-message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 5px;
    text-align: left;
}

.wcp-no-messages {
    text-align: center;
    color: #9ca3af;
    padding: 40px;
    font-size: 15px;
}

.wcp-no-conversations {
    text-align: center;
    color: #9ca3af;
    padding: 40px;
    font-size: 15px;
}

/* منطقة الإدخال */
#wcp-external-input-area {
    background: white;
    padding: 15px 25px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* شريط أدوات الإدخال (الرموز التعبيرية + رفع الملفات) */
#wcp-external-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wcp-tool-btn {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.wcp-tool-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.wcp-tool-btn:active {
    transform: translateY(0);
}

#wcp-external-upload-hint {
    font-size: 12px;
    color: #6b7280;
    opacity: 0.85;
    padding: 4px 10px;
    background: #fef3c7;
    border-radius: 4px;
    border: 1px solid #fde68a;
}

/* صف الإدخال (textarea + زر الإرسال) */
.wcp-input-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.wcp-input-row textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.3s;
}

.wcp-input-row textarea:focus {
    outline: none;
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.wcp-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #25d366;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.wcp-send-btn:hover {
    background: #20ba5a;
    transform: scale(1.05);
}

.wcp-send-btn:active {
    transform: scale(0.95);
}

.wcp-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.wcp-send-btn i {
    font-size: 20px;
}

/* شريط التمرير المخصص */
.wcp-conversations-list::-webkit-scrollbar,
#wcp-external-messages::-webkit-scrollbar {
    width: 6px;
}

.wcp-conversations-list::-webkit-scrollbar-track,
#wcp-external-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wcp-conversations-list::-webkit-scrollbar-thumb,
#wcp-external-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.wcp-conversations-list::-webkit-scrollbar-thumb:hover,
#wcp-external-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* رسالة التحميل */
.wcp-loading {
    text-align: center;
    padding: 30px;
    color: #6b7280;
    font-size: 14px;
}

/* استجابة للشاشات الصغيرة */
@media (max-width: 1024px) {
    .wcp-conversations-sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .wcp-chat-body {
        flex-direction: column;
    }
    
    .wcp-conversations-sidebar {
        width: 100%;
        height: 300px;
        border-left: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .wcp-chat-header {
        padding: 15px;
    }
    
    .wcp-chat-header h2 {
        font-size: 18px;
    }
    
    .wcp-message-bubble {
        max-width: 85%;
    }
}