/* WhatsApp Chat Pro - Frontend Styles */

/* الحاوية الرئيسية */
#wcp-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    direction: rtl;
}

/* مواضع الأيقونة */
.wcp-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wcp-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wcp-bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.wcp-top-right {
    top: 20px;
    right: 20px;
}

.wcp-top-left {
    top: 20px;
    left: 20px;
}

.wcp-middle-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.wcp-middle-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

/* زر الدردشة */
.wcp-chat-button {
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.wcp-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wcp-chat-button:active {
    transform: scale(0.95);
}

/* شارة الإشعارات */
.wcp-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff0000;
    color: white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    animation: pulse 2s infinite;
    line-height: 1;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* نافذة الدردشة */
.wcp-chat-window {
    position: absolute;
    bottom: 90px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* تعديل موضع النافذة حسب موقع الزر */
.wcp-bottom-right .wcp-chat-window,
.wcp-middle-right .wcp-chat-window {
    right: 0;
}

.wcp-bottom-left .wcp-chat-window,
.wcp-middle-left .wcp-chat-window {
    left: 0;
}

.wcp-bottom-center .wcp-chat-window {
    left: 50%;
    transform: translateX(-50%);
}

.wcp-top-right .wcp-chat-window,
.wcp-top-left .wcp-chat-window {
    bottom: auto;
    top: 90px;
}

/* رأس الدردشة */
.wcp-chat-header {
    padding: 15px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wcp-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wcp-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcp-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

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

.wcp-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.wcp-close-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.wcp-close-button:hover {
    opacity: 0.8;
}

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

.wcp-welcome-message {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wcp-welcome-message p {
    margin: 0;
    color: #333;
    line-height: 1.5;
}

/* صورة الرسالة */
.wcp-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
}

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

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

/* رسالة الزائر */
.wcp-message-visitor {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 15px;
    animation: wcp-slide-in 0.3s ease;
}

.wcp-message-visitor .wcp-message-bubble {
    background: #dcf8c6;
    color: #000;
    padding: 10px 14px;
    border-radius: 8px 8px 0 8px;
    max-width: 75%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* رسالة الإدارة */
.wcp-message-admin {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 15px;
    animation: wcp-slide-in 0.3s ease;
    flex-direction: row-reverse;
}

.wcp-message-admin .wcp-msg-avatar {
    margin-right: 0;
    margin-left: 0;
}

.wcp-message-admin .wcp-message-bubble {
    background: white;
    color: #000;
    padding: 10px 14px;
    border-radius: 8px 8px 8px 0;
    max-width: 75%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wcp-message-visitor .wcp-msg-avatar {
    order: 1;
}

.wcp-message-admin .wcp-msg-avatar {
    order: 1;
}

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

.wcp-message-time {
    font-size: 11px;
    color: #667781;
    margin-top: 4px;
    display: block;
}

/* مؤشر الكتابة */
.wcp-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 8px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wcp-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #90949c;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* منطقة الإدخال */
.wcp-input-area {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 10px;
}

.wcp-visitor-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.wcp-visitor-info input {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

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

.wcp-message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#wcp-message-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

#wcp-message-input:focus {
    outline: none;
    border-color: #25d366;
}

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

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

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

.wcp-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.wcp-powered-by {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

/* فقاعة الإشعارات */
.wcp-notification-bubble {
    position: absolute;
    bottom: 90px;
    right: 0;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 280px;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.wcp-bubble-content p {
    margin: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.wcp-bubble-close {
    position: absolute;
    top: 5px;
    left: 5px;
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
}

.wcp-bubble-close:hover {
    color: #ef4444;
}

/* النافذة المنبثقة */
.wcp-notification-popup {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: slideInUp 0.4s ease;
}

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

.wcp-popup-header {
    background: #25d366;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wcp-popup-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wcp-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.wcp-popup-body {
    padding: 20px;
}

.wcp-popup-body p {
    margin: 0 0 15px 0;
    color: #333;
    line-height: 1.5;
}

.wcp-popup-action {
    width: 100%;
    padding: 12px;
    background: #25d366;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.wcp-popup-action:hover {
    background: #20ba5a;
}

/* استجابة الشاشات الصغيرة */
@media (max-width: 480px) {
    .wcp-chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        transform: none !important;
    }
    
    .wcp-bottom-center .wcp-chat-window,
    .wcp-middle-right .wcp-chat-window,
    .wcp-middle-left .wcp-chat-window {
        transform: none !important;
    }
    
    #wcp-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .wcp-notification-popup {
        right: 15px;
        left: 15px;
        width: auto;
    }
}

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

.wcp-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.wcp-messages-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.wcp-messages-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* حالة التحميل */
.wcp-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* رسائل الخطأ */
.wcp-error-message {
    background: #fee;
    color: #c00;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 13px;
    text-align: center;
}

/* رسالة النجاح */
.wcp-success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 13px;
    text-align: center;
}

/* === NEW: Attachments + Emoji helper styles */
.wcp-attachment-image {
    max-width: 220px;
    border-radius: 10px;
    display: block;
}

.wcp-attachment-caption {
    margin-top: 6px;
    font-size: 12px;
    opacity: 0.85;
}

/* (اختياري) زرّين الأدوات لو تم حقنهم من JS */
.wcp-tool-btn-front {
    user-select: none;
}

/* شريط المستخدم */
.wcp-user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 15px;
    background: rgba(0,0,0,0.05);
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    color: #555;
}

.wcp-user-bar span {
    font-weight: 500;
}

.wcp-switch-user-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.wcp-switch-user-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}