/* ============================================= */
/* نظام الرسائل المنبثق - تصميم عصري 2026 */
/* ============================================= */

.messages-icon {
    position: relative;
    margin-left: 15px;
}

.messages-wrapper {
    position: relative;
    cursor: pointer;
}

/* ✨ أيقونة الرسائل الجديدة */
.messages-wrapper .fa-comment-dots {
    font-size: 20px;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.messages-wrapper .fa-comment-dots:hover {
    color: #2A7DD8;
    transform: scale(1.15) translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(42, 125, 216, 0.3));
}

/* ✨ العداد الجديد - تصميم أنيق */
.messages-count {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #ff4444 0%, #ff1744 100%);
    color: #fff;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2.5px solid #0a0e27;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
    animation: pulseGlow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(255, 68, 68, 0.6);
    }
}

/* ============================================= */
/* القائمة المنسدلة للمحادثات */
/* ============================================= */
.messages-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: -120px;
    width: 380px;
    max-height: 540px;
    background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
    border: 1px solid rgba(42, 125, 216, 0.25);
    border-radius: 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.messages-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 130px;
    width: 16px;
    height: 16px;
    background: #1a2332;
    border-left: 1px solid rgba(42, 125, 216, 0.25);
    border-top: 1px solid rgba(42, 125, 216, 0.25);
    transform: rotate(45deg);
}

.messages-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* رأس القائمة */
.messages-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(42, 125, 216, 0.12) 0%, rgba(30, 95, 168, 0.08) 100%);
    border-bottom: 1px solid rgba(42, 125, 216, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.messages-header strong {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.view-all-link {
    color: #2A7DD8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.view-all-link:hover {
    background: rgba(42, 125, 216, 0.15);
    color: #4A9DFF;
}

/* قائمة الرسائل */
.messages-list {
    max-height: 460px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(42, 125, 216, 0.3) transparent;
}

.messages-list::-webkit-scrollbar {
    width: 6px;
}

.messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
    background: rgba(42, 125, 216, 0.3);
    border-radius: 3px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: rgba(42, 125, 216, 0.5);
}

.messages-loading {
    padding: 40px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ============================================= */
/* عناصر المحادثات */
/* ============================================= */
.message-item {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(42, 125, 216, 0.08);
    position: relative;
}

.message-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: #2A7DD8;
    transform: scaleY(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-item:hover {
    background: linear-gradient(90deg, rgba(42, 125, 216, 0.12) 0%, rgba(42, 125, 216, 0.05) 100%);
}

.message-item:hover::before {
    transform: scaleY(1);
}

.message-item.unread {
    background: linear-gradient(90deg, rgba(42, 125, 216, 0.15) 0%, rgba(42, 125, 216, 0.08) 100%);
}

.message-item.unread::before {
    transform: scaleY(1);
    background: linear-gradient(180deg, #2A7DD8 0%, #1e5fa8 100%);
}

/* الصورة الرمزية */
.message-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid rgba(42, 125, 216, 0.3);
    margin-left: 14px;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.message-item:hover .message-item-avatar {
    border-color: rgba(42, 125, 216, 0.6);
    transform: scale(1.05);
}

.message-item-online {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #00ff00;
    border: 2.5px solid #0f1419;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.95);
    }
}

/* معلومات الرسالة */
.message-item-info {
    flex: 1;
    min-width: 0;
}

.message-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.message-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.message-item.unread .message-item-name {
    color: #4A9DFF;
    font-weight: 700;
}

.message-item-time {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

.message-item-preview {
    font-size: 13px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.message-item.unread .message-item-preview {
    font-weight: 600;
    color: #ddd;
}

/* ============================================= */
/* تمييز محادثات الدعم */
/* ============================================= */
.message-item.support-item {
    background: linear-gradient(90deg, rgba(42, 125, 216, 0.15) 0%, rgba(30, 95, 168, 0.08) 100%);
}

.message-item.support-item::before {
    background: linear-gradient(180deg, #2A7DD8 0%, #1e5fa8 100%);
    transform: scaleY(1);
}

.message-item.support-item:hover {
    background: linear-gradient(90deg, rgba(42, 125, 216, 0.2) 0%, rgba(30, 95, 168, 0.12) 100%);
}

.support-badge-popup {
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, #2A7DD8 0%, #1e5fa8 100%);
    color: #fff;
    font-size: 10px;
    border-radius: 12px;
    margin-left: 6px;
    font-weight: 700;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(42, 125, 216, 0.3);
}

/* رسائل فارغة */
.no-messages {
    padding: 60px 20px;
    text-align: center;
    color: #888;
}

.no-messages-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ============================================= */
/* نافذة المحادثة المنبثقة */
/* ============================================= */
.popup-chat-window {
    position: fixed;
    bottom: 0;
    right: 90px;
    width: 400px;
    height: 550px;
    background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
    border-radius: 20px 20px 0 0;
    box-shadow: 
        0 -4px 40px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.popup-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-chat-window.minimized {
    height: 60px;
    overflow: hidden;
}

/* رأس النافذة */
.popup-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(42, 125, 216, 0.15) 0%, rgba(30, 95, 168, 0.08) 100%);
    border-bottom: 1px solid rgba(42, 125, 216, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: move;
    flex-shrink: 0;
}

.popup-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid rgba(42, 125, 216, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.popup-chat-info {
    flex: 1;
    min-width: 0;
}

.popup-chat-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.popup-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
}

.popup-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #666;
    flex-shrink: 0;
}

.popup-status-dot.online {
    background: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
    animation: breathe 2s ease-in-out infinite;
}

/* أزرار التحكم */
.popup-chat-controls {
    display: flex;
    gap: 8px;
}

.popup-control-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
}

.popup-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: scale(1.1);
}

.popup-control-btn.close:hover {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
}

/* منطقة الرسائل */
.popup-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0a0e27;
    scrollbar-width: thin;
    scrollbar-color: rgba(42, 125, 216, 0.3) transparent;
}

.popup-messages-area::-webkit-scrollbar {
    width: 6px;
}

.popup-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.popup-messages-area::-webkit-scrollbar-thumb {
    background: rgba(42, 125, 216, 0.3);
    border-radius: 3px;
}

.popup-loading {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 14px;
}

/* تغليف الرسائل */
.popup-message-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-message-wrapper.sent {
    flex-direction: row-reverse;
}

.popup-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(42, 125, 216, 0.3);
    flex-shrink: 0;
}

/* فقاعات الرسائل */
.popup-message-bubble {
    max-width: 65%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.popup-message-wrapper.received .popup-message-bubble {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
    border-bottom-left-radius: 4px;
    color: #fff;
}

.popup-message-wrapper.sent .popup-message-bubble {
    background: linear-gradient(135deg, #2A7DD8 0%, #1e5fa8 100%);
    border-bottom-right-radius: 4px;
    color: #fff;
}

.popup-message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    text-align: right;
}

/* ============================================= */
/* منطقة الإدخال */
/* ============================================= */
.popup-input-container {
    padding: 16px;
    background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
    border-top: 1px solid rgba(42, 125, 216, 0.2);
    flex-shrink: 0;
}

.popup-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(42, 125, 216, 0.2);
    border-radius: 24px;
    padding: 8px 12px;
    transition: all 0.2s;
}

.popup-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(42, 125, 216, 0.4);
    box-shadow: 0 0 0 3px rgba(42, 125, 216, 0.1);
}

/* ✨ أزرار الإجراءات الجديدة - تصميم عصري */
.popup-action-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-action-btn:hover {
    background: rgba(42, 125, 216, 0.15);
    color: #2A7DD8;
    transform: scale(1.1) rotate(5deg);
}

.popup-action-btn:active {
    transform: scale(0.95);
}

/* حقل الإدخال */
.popup-message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
}

.popup-message-input::placeholder {
    color: #666;
}

/* زر الإرسال */
.popup-send-btn {
    background: linear-gradient(135deg, #2A7DD8 0%, #1e5fa8 100%);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(42, 125, 216, 0.3);
}

.popup-send-btn:hover:not(:disabled) {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 16px rgba(42, 125, 216, 0.5);
}

.popup-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.popup-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* معاينة الملف */
.popup-file-preview {
    position: relative;
    padding: 12px;
    background: rgba(42, 125, 216, 0.1);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(42, 125, 216, 0.2);
}

/* ============================================= */
/* Responsive */
/* ============================================= */
@media (max-width: 768px) {
    .messages-dropdown {
        width: 340px;
        right: -100px;
    }
    
    .popup-chat-window {
        right: 20px;
        width: calc(100vw - 40px);
        max-width: 400px;
    }
    
    .popup-chat-window.active {
        width: 100vw;
        height: 100vh;
        right: 0;
        border-radius: 0;
        max-width: none;
    }
}