/* Facebook Messenger-style Messaging Interface */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
}

/* Main Layout */
.messaging-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: white;
    border-right: 1px solid #e4e6ea;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e4e6ea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.sidebar-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.sidebar-subtitle {
    opacity: 0.9;
    font-size: 0.9em;
}

.search-bar {
    padding: 15px;
    border-bottom: 1px solid #e4e6ea;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    background: #f0f2f5;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

/* Online Users */
.online-users {
    padding: 15px;
    border-bottom: 1px solid #e4e6ea;
}

.online-title {
    font-size: 0.8em;
    font-weight: 600;
    color: #65676b;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.online-user-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.online-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s ease;
    min-width: 60px;
}

.online-user:hover {
    background: #f0f2f5;
}

.online-user .avatar {
    width: 40px;
    height: 40px;
    font-size: 1em;
    margin-right: 0;
    margin-bottom: 5px;
}

.online-user-name {
    font-size: 0.7em;
    color: #65676b;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.2s ease;
    position: relative;
}

.conversation-item:hover {
    background: #f0f2f5;
}

.conversation-item.active {
    background: #e3f2fd;
    border-right: 3px solid #667eea;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2em;
    margin-right: 12px;
    position: relative;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #42b883;
    border: 2px solid white;
    border-radius: 50%;
}

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

.conversation-name {
    font-weight: 600;
    color: #1c1e21;
    margin-bottom: 2px;
    font-size: 0.95em;
}

.last-message {
    color: #65676b;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-time {
    color: #65676b;
    font-size: 0.75em;
    margin-bottom: 4px;
}

.unread-badge {
    background: #667eea;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7em;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e4e6ea;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-user-info {
    display: flex;
    align-items: center;
}

.chat-user-name {
    font-weight: 600;
    color: #1c1e21;
    margin-left: 12px;
}

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

.chat-action-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    color: #65676b;
    transition: background 0.2s ease;
}

.chat-action-btn:hover {
    background: #f0f2f5;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f0f2f5;
}

.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-end;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #1c1e21;
    border: 1px solid #e4e6ea;
    border-bottom-left-radius: 4px;
}

.message-bubble .message-time {
    font-size: 0.7em;
    opacity: 0.7;
    margin-top: 4px;
}

.message.sent .message-time {
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

/* Message Input */
.message-input-container {
    padding: 15px 20px;
    border-top: 1px solid #e4e6ea;
    background: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e4e6ea;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    background: #f0f2f5;
}

.message-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.send-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.send-button:hover {
    transform: scale(1.05);
}

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

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #65676b;
    text-align: center;
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-subtitle {
    font-size: 1em;
    opacity: 0.8;
}

/* Floating Chat Windows (Facebook Messenger style) */
.floating-chats {
    position: fixed;
    bottom: 0;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.floating-chat {
    width: 320px;
    background: white;
    border: 1px solid #e4e6ea;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.floating-chat.minimized {
    height: 42px;
    overflow: hidden;
}

.floating-chat-header {
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.floating-chat-user {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.9em;
}

.floating-chat-controls {
    display: flex;
    gap: 5px;
}

.floating-chat-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    opacity: 0.8;
}

.floating-chat-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.floating-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f0f2f5;
}

.floating-input {
    padding: 10px;
    border-top: 1px solid #e4e6ea;
    display: flex;
    gap: 8px;
}

.floating-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e4e6ea;
    border-radius: 15px;
    font-size: 13px;
}

.floating-send-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        left: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .floating-chats {
        display: none;
    }
}
