/* ================================================= */
/* 💬 HASTRAL MESSAGES - CSS ULTRA DESIGN */
/* ================================================= */

:root {
    --msg-primary: #667eea;
    --msg-secondary: #764ba2;
    --msg-success: #26de81;
    --msg-danger: #ff4757;
    --msg-dark: #0a0e27;
    --msg-light: #f8f9fa;
}

/* ========== MESSAGE BUTTON ========== */
#messageBtn {
    background: linear-gradient(135deg, var(--msg-primary), var(--msg-secondary));
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 20px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

#messageBtn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

#messageBtn:active {
    transform: translateY(-1px) scale(1.02);
}

/* Badge de notification */
.message-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid var(--bg, #fff);
    animation: badgePulse 2s ease-in-out infinite;
    box-shadow: 0 2px 10px rgba(255, 71, 87, 0.5);
}

@keyframes badgePulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 2px 10px rgba(255, 71, 87, 0.5);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 4px 20px rgba(255, 71, 87, 0.8);
    }
}

/* ========== MESSAGE MODAL ========== */
.message-modal {
    width: 95%;
    max-width: 1200px;
    max-height: 85vh;
    background: linear-gradient(145deg, #0a0e27 0%, #1a1f3a 100%);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========== HEADER ========== */
.message-header {
    background: linear-gradient(135deg, var(--msg-primary) 0%, var(--msg-secondary) 100%);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.message-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.03)"/></svg>');
    opacity: 0.5;
}

.message-header h2 {
    font-size: 24px;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.message-header-actions {
    display: flex;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.message-header-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message-close-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ========== CONTAINER ========== */
.message-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ========== CONVERSATIONS LIST (ADMIN) ========== */
.conversations-list {
    width: 320px;
    background: rgba(15, 20, 40, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.conversations-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conversations-header h3 {
    color: white;
    font-size: 16px;
    margin: 0 0 5px 0;
    font-weight: 600;
}

.conversations-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    margin: 0;
}

.conversation-item {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.conversation-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--msg-primary);
    transform: scaleY(0);
    transition: transform 0.3s;
}

.conversation-item:hover {
    background: rgba(102, 126, 234, 0.08);
}

.conversation-item:hover::before {
    transform: scaleY(1);
}

.conversation-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, rgba(102, 126, 234, 0.05) 100%);
}

.conversation-item.active::before {
    transform: scaleY(1);
}

.conversation-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--msg-primary);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.conversation-name {
    font-weight: 700;
    color: white;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conversation-preview {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-badge {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

/* ========== CHAT AREA ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(10, 14, 39, 0.5) 0%, rgba(15, 20, 50, 0.7) 100%);
    min-width: 0;
}

/* Chat Header */
.chat-header {
    padding: 20px 25px;
    background: rgba(15, 20, 40, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--msg-primary);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-user-info h3 {
    font-size: 17px;
    color: white;
    margin: 0 0 2px 0;
    font-weight: 700;
}

.chat-user-role {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--msg-success);
    box-shadow: 0 0 8px var(--msg-success);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar Style */
.messages-container::-webkit-scrollbar,
.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.conversations-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.messages-container::-webkit-scrollbar-thumb,
.conversations-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.4);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.conversations-list::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.6);
}

/* Message Bubbles */
.message-bubble {
    max-width: 65%;
    padding: 14px 18px;
    border-radius: 20px;
    position: relative;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-bubble.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--msg-primary) 0%, var(--msg-secondary) 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.message-bubble.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-left-radius: 6px;
}

.message-sender {
    font-size: 12px;
    font-weight: 700;
    color: var(--msg-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-text {
    line-height: 1.5;
    margin-bottom: 6px;
    font-size: 14px;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* ========== INPUT ZONE ========== */
.message-input-zone {
    padding: 20px 25px;
    background: rgba(15, 20, 40, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 14px 18px;
    color: white;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.3s;
    line-height: 1.5;
}

.message-textarea:focus {
    outline: none;
    border-color: var(--msg-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.message-textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

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

.message-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(102, 126, 234, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(102, 126, 234, 0.3);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-action-btn:hover {
    background: rgba(102, 126, 234, 0.25);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.message-send-btn {
    background: linear-gradient(135deg, var(--msg-primary), var(--msg-secondary));
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.message-send-btn:hover {
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
    transform: translateY(-3px) scale(1.05);
}

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

/* ========== IMAGE PREVIEW ========== */
.image-preview {
    position: relative;
    margin-bottom: 10px;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    border: 2px solid var(--msg-primary);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.image-preview-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
    transition: all 0.3s;
}

.image-preview-close:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.6);
}

/* ========== EMPTY STATES ========== */
.no-conversation,
.empty-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 60px 40px;
}

.no-conversation-icon,
.empty-messages-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.no-conversation h3 {
    font-size: 22px;
    margin-bottom: 12px;
    color: white;
    font-weight: 600;
}

.no-conversation p,
.empty-messages p {
    font-size: 14px;
    line-height: 1.6;
    max-width: 400px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 968px) {
    .message-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .conversations-list {
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 10;
        background: rgba(10, 14, 39, 0.98);
    }
    
    .message-bubble {
        max-width: 80%;
    }
    
    .message-header h2 {
        font-size: 20px;
    }
    
    .message-header-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 640px) {
    .message-header {
        padding: 15px 20px;
    }
    
    .chat-header {
        padding: 15px 20px;
    }
    
    .messages-container {
        padding: 20px 15px;
    }
    
    .message-input-zone {
        padding: 15px;
    }
    
    .message-bubble {
        max-width: 85%;
        padding: 12px 16px;
    }
    
    .message-action-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* Vue utilisateur - masquer la sidebar mais garder le flex */
.conversations-list {
    transition: all 0.3s ease;
}

.conversations-list[style*="display: none"] {
    width: 0;
    min-width: 0;
    padding: 0;
    border: none;
}

/* Chat en pleine largeur quand sidebar masquée */
.chat-area {
    transition: all 0.3s ease;
}