/* Facebook-style Chat System Styles */
#chatContainer {
    position: fixed;
    bottom: 0;
    right: 20px;
    z-index: 10000;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-window {
    width: 328px;
    height: 455px;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.chat-window.minimized {
    height: 48px;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chat-avatar {
    position: relative;
    width: 32px;
    height: 32px;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.chat-avatar .online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #31a24c;
    border: 2px solid white;
    border-radius: 50%;
}

.chat-header-text h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-header-text small {
    font-size: 11px;
    opacity: 0.9;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.chat-header-btn:hover {
    background: rgba(255,255,255,0.3);
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-window.minimized .chat-body,
.chat-window.minimized .chat-footer {
    display: none;
}

.chat-message {
    display: flex;
    gap: 8px;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    flex-direction: row-reverse;
}

.chat-message-content {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.received .chat-message-content {
    background: #e4e6eb;
    color: #050505;
}

.chat-message.sent .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-message-time {
    font-size: 11px;
    color: #65676b;
    margin-top: 2px;
    padding: 0 12px;
}

.chat-footer {
    padding: 10px;
    background: white;
    border-top: 1px solid #e4e6eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 6px 12px;
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: #050505;
}

.chat-input-wrapper input::placeholder {
    color: #65676b;
}

.chat-send-btn {
    background: none;
    border: none;
    color: #667eea;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.chat-send-btn:disabled {
    color: #bcc0c4;
    cursor: not-allowed;
}

/* Chat List Modal */
.chat-list-modal {
    display: none;
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    flex-direction: column;
}

.chat-list-modal.active {
    display: flex;
}

.chat-list-header {
    background: white;
    padding: 15px;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-list-header h5 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #050505;
}

.chat-list-search {
    padding: 10px 15px;
    border-bottom: 1px solid #e4e6eb;
}

.chat-list-search input {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: #f0f2f5;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.chat-list-body {
    flex: 1;
    overflow-y: auto;
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.chat-list-item:hover {
    background: #f2f2f2;
}

.chat-list-item.active {
    background: #e7f3ff;
}

.chat-list-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.chat-list-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.chat-list-avatar .online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #31a24c;
    border: 3px solid white;
    border-radius: 50%;
}

.chat-list-info {
    flex: 1;
    min-width: 0;
}

.chat-list-info h6 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #050505;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-info p {
    margin: 0;
    font-size: 13px;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-info p.unread {
    color: #050505;
    font-weight: 600;
}

.chat-list-meta {
    text-align: right;
}

.chat-list-time {
    font-size: 12px;
    color: #65676b;
    margin-bottom: 4px;
}

.chat-unread-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Message Count Badge */
.message-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #fa3e3e;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    border: 2px solid var(--navbar-bg);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #e4e6eb;
    border-radius: 18px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #65676b;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Scrollbar Styles */
.chat-body::-webkit-scrollbar,
.chat-list-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track,
.chat-list-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb,
.chat-list-body::-webkit-scrollbar-thumb {
    background: #bcc0c4;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover,
.chat-list-body::-webkit-scrollbar-thumb:hover {
    background: #8a8d91;
}

/* Empty State */
.chat-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #65676b;
}

.chat-empty-state i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 15px;
}

.chat-empty-state p {
    margin: 10px 0 0 0;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    #chatContainer {
        right: 10px;
    }
    
    .chat-window {
        width: 280px;
        height: 400px;
    }
    
    .chat-list-modal {
        right: 10px;
        width: 100%;
        max-width: 360px;
    }
}

/* Dark mode support */
[data-theme="dark"] .chat-window,
[data-theme="dark"] .chat-list-modal {
    background: #242526;
}

[data-theme="dark"] .chat-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

[data-theme="dark"] .chat-body {
    background: #18191a;
}

[data-theme="dark"] .chat-footer,
[data-theme="dark"] .chat-list-header {
    background: #242526;
    border-color: #3a3b3c;
}

[data-theme="dark"] .chat-message.received .chat-message-content {
    background: #3a3b3c;
    color: #e4e6eb;
}

[data-theme="dark"] .chat-input-wrapper {
    background: #3a3b3c;
}

[data-theme="dark"] .chat-input-wrapper input {
    color: #e4e6eb;
}

[data-theme="dark"] .chat-list-item:hover {
    background: #3a3b3c;
}

[data-theme="dark"] .chat-list-info h6 {
    color: #e4e6eb;
}
