/* Enhanced Chat Manager CSS */

/* Chat Typing Indicator */
.chat-typing-indicator {
    padding: 8px 12px;
    font-size: 12px;
    color: #888;
    font-style: italic;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 4px 0;
    animation: fadeIn 0.3s ease;
}

/* Chat Connection Status */
.chat-connection-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
}

.chat-connection-status.online {
    color: #4caf50;
}

.chat-connection-status.offline {
    color: #f44336;
}

.chat-connection-status i {
    font-size: 8px;
}

/* Character Counter */
.char-counter {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    color: #888;
    pointer-events: none;
}

/* Chat Messages */
.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    position: relative;
}

.chat-message:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-message.own-message {
    flex-direction: row-reverse;
}

.chat-message.own-message .message-content {
    text-align: right;
}

.chat-message.sending {
    opacity: 0.6;
}

.chat-message.sending::after {
    content: '⏳';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
}

/* Message Avatar */
.message-avatar {
    flex-shrink: 0;
}

.message-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Message Content */
.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-username {
    font-weight: 600;
    color: #fff;
    cursor: pointer;
}

.message-username:hover {
    text-decoration: underline;
}

.message-role {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.message-role.leader {
    background: #ffd700;
    color: #000;
}

.message-role.officer {
    background: #ff6b35;
    color: #fff;
}

.message-role.member {
    background: #4caf50;
    color: #fff;
}

.message-timestamp {
    font-size: 11px;
    color: #888;
}

.message-text {
    color: #ddd;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Message Actions */
.message-actions {
    display: none;
    position: absolute;
    top: -10px;
    right: 8px;
    background: #333;
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-message:hover .message-actions {
    display: block;
}

.message-delete {
    background: none;
    border: none;
    color: #f44336;
    cursor: pointer;
    padding: 4px;
    border-radius: 2px;
    font-size: 12px;
}

.message-delete:hover {
    background: rgba(244, 67, 54, 0.1);
}

/* Mentions */
.mention {
    background: rgba(114, 137, 218, 0.3);
    color: #7289da;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    cursor: pointer;
}

.mention:hover {
    background: rgba(114, 137, 218, 0.5);
}

/* Links */
.message-text a {
    color: #7289da;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    background: #2f3136;
    border: 1px solid #40444b;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 300px;
    display: none;
}

.emoji-picker-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
    font-size: 14px;
}

.emoji-picker-content {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Channel Switcher */
.chat-channel-switcher {
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.chat-channels {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-channel-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: none;
    border: none;
    color: #ddd;
    cursor: pointer;
    border-radius: 6px;
    text-align: left;
    transition: all 0.2s ease;
}

.chat-channel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-channel-btn.active {
    background: #7289da;
    color: #fff;
}

.chat-channel-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.chat-channel-label {
    font-size: 12px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    margin: 8px 0 4px;
}

/* DM Channels */
.dm-channel {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.dm-channel-avatar {
    position: relative;
    flex-shrink: 0;
}

.dm-channel-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.user-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #2f3136;
}

.user-status.online {
    background: #43b581;
}

.user-status.offline {
    background: #747f8d;
}

.user-status.away {
    background: #faa61a;
}

.user-status.dnd {
    background: #f04747;
}

.dm-channel-info {
    flex: 1;
    min-width: 0;
}

.dm-channel-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-channel-status {
    font-size: 11px;
    color: #888;
}

/* Guild Channels */
.guild-channel {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guild-channel-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.guild-channel-info {
    flex: 1;
    min-width: 0;
}

.guild-channel-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guild-channel-members {
    font-size: 11px;
    color: #888;
}

/* Unread Badges */
.unread-badge {
    background: #f04747;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 1.2;
}

/* Input Enhancements */
.chat-input-container {
    position: relative;
}

.message-input-wrapper {
    position: relative;
}

.char-counter {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    color: #888;
    pointer-events: none;
    z-index: 1;
}

/* Virtual Scrolling Support */
.chat-messages-virtual {
    position: relative;
    overflow-y: auto;
}

.chat-messages-virtual .chat-message {
    position: absolute;
    left: 0;
    right: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-message {
        gap: 8px;
        margin-bottom: 12px;
        padding: 6px;
    }
    
    .message-avatar img {
        width: 28px;
        height: 28px;
    }
    
    .emoji-picker {
        max-width: 250px;
    }
    
    .emoji-picker-content {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .chat-channel-btn {
        padding: 6px 8px;
        font-size: 14px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.chat-message {
    animation: fadeIn 0.3s ease;
}

.chat-channel-btn {
    animation: slideIn 0.3s ease;
}

/* Loading States */
.chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #888;
}

.chat-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #888;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.chat-error {
    padding: 12px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    color: #f44336;
    font-size: 14px;
    margin: 8px 0;
}

/* Accessibility */
.chat-message:focus-within {
    outline: 2px solid #7289da;
    outline-offset: 2px;
}

.chat-channel-btn:focus {
    outline: 2px solid #7289da;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-message {
        border: 1px solid #555;
    }
    
    .message-username {
        color: #fff;
    }
    
    .message-text {
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .chat-message,
    .chat-channel-btn,
    .emoji-btn {
        animation: none;
    }
    
    .chat-loading::after {
        animation: none;
    }
}