/* Premium Messaging CSS - Messenger Inspired */
:root {
    --chat-primary: #0084ff;
    --chat-secondary: #f0f2f5;
    --chat-text: #000000;
    --chat-text-muted: #333333;
    --chat-bg: #ffffff;
    --chat-bubble-self: #0084ff;
    --chat-bubble-other: #e4e6eb;
    --chat-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

/* Chat Modal Container */
.chat-modal-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: var(--chat-bg);
    border-radius: 12px;
    box-shadow: var(--chat-shadow);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
    transform: translateY(20px);
    opacity: 0;
}

.chat-modal-overlay.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .chat-modal-overlay {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

/* Header */
.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-avatar[src]:not([src=""]) {
    background: #eee;
}

.chat-user-name {
    font-weight: 700;
    font-size: 15px;
    color: #000000 !important;
}

.chat-status {
    font-size: 13px;
    color: var(--chat-text-muted) !important;
    margin-top: 2px;
}

.chat-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--chat-text-muted);
}

/* Middle: Message History */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    scroll-behavior: smooth;
}

.message-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message-bubble.self {
    align-self: flex-end;
    background-color: var(--chat-bubble-self);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble.other {
    align-self: flex-start;
    background-color: var(--chat-bubble-other);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

.message-bubble.other .message-time {
    text-align: left;
}

/* Input Area */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
}

.chat-input-area input {
    flex: 1;
    border: none;
    background: var(--chat-secondary);
    padding: 10px 16px;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

.chat-send-btn {
    color: var(--chat-primary);
    cursor: pointer;
    font-size: 20px;
    transition: transform 0.2s;
}

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

/* Conversation List View */
.chat-conv-list {
    flex: 1;
    overflow-y: auto;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.conv-item:hover {
    background: var(--chat-secondary);
}

.conv-info {
    flex: 1;
}

.conv-name {
    font-weight: 700;
    font-size: 15px;
    color: #000000 !important;
    margin-bottom: 2px;
}

.conv-last-msg {
    font-size: 13px;
    color: var(--chat-text-muted) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.unread-dot {
    width: 10px;
    height: 10px;
    background: var(--chat-primary);
    border-radius: 50%;
}

/* Floating Action Button (FAB) */
.chat-fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: var(--chat-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 12px rgba(0,132,255,0.4);
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.3s;
}

.chat-fab:hover {
    transform: scale(1.05) rotate(5deg);
}

.chat-fab .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: #fff;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 10px;
    font-weight: 700;
    border: 2px solid #fff;
}
/* Context Menu */
.chat-context-menu {
    position: fixed; background: #fff; border: 1px solid #ddd; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10000; overflow: hidden; min-width: 120px;
}
.chat-context-menu div {
    padding: 10px 15px; font-size: 13px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 8px;
}
.chat-context-menu div:hover { background: #f5f5f5; }

/* Reply Preview */
.chat-reply-preview {
    padding: 10px 15px; background: #f0f2f5; border-top: 1px solid rgba(0,0,0,0.05);
    display: flex; align-items: center; justify-content: space-between;
}
.chat-reply-preview .reply-content {
    display: flex; align-items: center; gap: 10px; color: #666; font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80%;
}
.chat-reply-preview .reply-text { font-style: italic; color: #444; }
.chat-reply-preview .reply-cancel {
    cursor: pointer; font-size: 18px; color: #888; padding: 0 5px;
}

/* Quoted Reply in Bubble */
.reply-quote {
    background: rgba(0,0,0,0.05); border-left: 3px solid rgba(0,0,0,0.2);
    padding: 5px 10px; border-radius: 4px; margin-bottom: 8px; font-size: 12px;
}
.message-bubble.self .reply-quote {
    background: rgba(255,255,255,0.15); border-left-color: rgba(255,255,255,0.5); color: #fff;
}
.reply-quote strong { display: block; margin-bottom: 2px; font-size: 11px; }

/* FAB Badge */
.chat-fab .badge {
    position: absolute; top: -5px; right: -5px; background: #ef4444; color: #fff;
    font-size: 10px; font-weight: bold; width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

/* Message Menu Button */
.message-bubble { position: relative; }
/* Message Menu Button */
.message-bubble { position: relative; }
.msg-menu-btn {
    position: absolute; top: 0; right: -25px; width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; color: #000 !important; 
    opacity: 0.6; transition: 0.2s; z-index: 10;
}
.message-bubble.self .msg-menu-btn { right: auto; left: -25px; color: #000 !important; }
.msg-menu-btn:hover { opacity: 1; transform: scale(1.2); }

/* Ensure Black text for header and list */
.chat-user-name, .conv-name, #chatHeaderName, .chat-header h1, .chat-header div,
.chat-status, .conv-last-msg, #chatHeaderStatus, .message-time {
    color: #000000 !important;
}

/* Modal text colors specifically */
.chat-modal-overlay * {
    color: inherit;
}
.chat-modal-overlay .chat-header *, 
.chat-modal-overlay .chat-conv-list * {
    color: #000 !important;
}
