/* ===== Global Chat Feature ===== */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px var(--primary-blue-glow);
    outline: none;
}

.chat-toggle-btn:focus {
    outline: none;
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px var(--primary-blue-glow);
}

.chat-toggle-btn i {
    font-size: 1.3rem;
    color: #fff;
}

/* Chat Panel */
.global-chat-panel {
    position: fixed;
    bottom: 0;
    left: -350px;
    width: 350px;
    height: calc(100vh - 64px);
    background: var(--bg-card-solid);
    border-right: 1px solid var(--border-color);
    z-index: 998;
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
}

.global-chat-panel.active {
    left: 0;
}

/* Push content when chat is open */
.main-content {
    transition: margin-left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body.chat-open .main-content {
    margin-left: 350px;
}

body.chat-open .site-footer {
    margin-left: 350px;
}

.chat-toggle-btn {
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body.chat-open .chat-toggle-btn {
    display: none;
}

/* Chat Header */
.global-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(255, 59, 59, 0.05), transparent);
}

.global-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.global-chat-title i {
    color: #FF3B3B;
    font-size: 1.2rem;
}

.global-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 1px;
}

.global-chat-status i {
    font-size: 0.5rem;
    animation: pulse-dot 1.5s infinite;
}

.chat-close-btn,
.chat-signout-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-input);
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn:hover,
.chat-signout-btn:hover {
    background: var(--border-color);
    color: var(--text-secondary);
}

.chat-signout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Chat Messages Area */
.global-chat-announcement {
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
    border-bottom: 2px solid #ef4444;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-chat-announcement:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.15));
}

.announcement-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ef4444;
    font-weight: 600;
    font-size: 0.85rem;
}

.announcement-content i:first-child {
    font-size: 1rem;
}

.announcement-content i:last-child {
    margin-left: auto;
    font-size: 0.8rem;
}

.announcement-content span {
    flex: 1;
}

.global-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.global-chat-messages::-webkit-scrollbar {
    display: none;
}

.global-chat-message {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    position: relative;
    animation: messageSlideIn 0.3s ease;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.global-chat-message:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 59, 59, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.global-chat-message:hover .message-reply-btn {
    opacity: 1 !important;
}

.global-chat-message:hover .message-delete-btn {
    opacity: 1 !important;
}

.message-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.global-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
}

.global-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.global-chat-content {
    flex: 1;
    min-width: 0;
}

.global-chat-header-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.global-chat-username {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-chat-username:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.global-chat-username.mentioned {
    color: var(--primary-blue) !important;
}

.global-chat-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.global-chat-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

.mention {
    color: var(--primary-blue);
    font-weight: 700;
    background: var(--primary-blue-subtle);
    padding: 2px 6px;
    border-radius: 4px;
}

.global-chat-text.highlighted {
    background: rgba(255, 59, 59, 0.05);
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 2px solid var(--primary-blue);
}

.reply-indicator.reply-to-me {
    border-left-color: var(--primary-blue);
    background: rgba(255, 59, 59, 0.05);
    color: var(--primary-blue);
}

.reply-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid var(--text-muted);
    border-radius: 4px;
}

.reply-indicator i {
    font-size: 0.65rem;
    opacity: 0.6;
}

.message-reply-btn {
    position: absolute;
    top: 8px;
    right: 50px;
    width: 28px;
    height: 28px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.message-delete-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.message-reply-btn:hover {
    background: var(--primary-blue-subtle);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.replying-to {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-input);
    border-left: 3px solid var(--primary-blue);
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.replying-to>div {
    flex: 1;
}

.replying-to span {
    color: var(--primary-blue);
    font-weight: 600;
}

.cancel-reply {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.cancel-reply:hover {
    color: var(--danger);
}

/* Chat Input Area */
.global-chat-input-area {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #0c0c12;
}

.chat-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 20, 28, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 6px 8px;
}

.chat-action-btn {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.chat-gif-btn {
    height: 34px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-gif-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.global-chat-input {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    min-width: 0;
}

.global-chat-input:focus {
    outline: none;
}

.global-chat-input::placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chat-send-btn {
    height: 34px;
    padding: 0 18px;
    background: #FF3B3B;
    border: none;
    border-radius: 6px;
    color: #000;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #FF6B6B;
}

.chat-send-btn:active {
    transform: scale(0.97);
}

.global-chat-input-wrapper {
    display: flex;
    gap: 10px;
}

/* Empty State */
.global-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.global-chat-empty i {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 16px;
}

.global-chat-empty p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .global-chat-panel {
        width: 100%;
        left: -100%;
        height: 70vh;
        top: auto;
        bottom: 0;
    }

    .global-chat-panel.active {
        left: 0;
    }

    body.chat-open .main-content {
        margin-left: 0;
    }

    body.chat-open .chat-toggle-btn {
        display: none;
    }

    .global-chat-header {
        padding: 10px 14px;
        flex-shrink: 0;
    }

    .global-chat-title {
        font-size: 0.85rem;
    }

    .chat-close-btn,
    .chat-signout-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.1rem !important;
        flex-shrink: 0;
    }

    .global-chat-announcement {
        padding: 10px 14px;
        flex-shrink: 0;
    }

    .announcement-content {
        font-size: 0.8rem;
    }

    .global-chat-messages {
        padding: 10px;
        flex: 1;
        overflow-y: auto;
        max-height: calc(70vh - 180px);
    }

    .global-chat-input-area {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        flex-shrink: 0;
    }

    .global-chat-login-btn {
        width: 100%;
        padding: 12px;
        font-size: 0.9rem;
        font-weight: 700;
    }
}


/* Role Badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.mini {
    padding: 3px 5px;
    gap: 0;
}

.role-owner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #ef4444;
}

.role-developer {
    background: linear-gradient(135deg, #eab308, #ca8a04);
    color: #000;
}

.role-admin {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
}

.role-moderator {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
}

.role-vip {
    background: linear-gradient(135deg, #1f2937, #111827);
    color: #fff;
}

.role-abi {
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: #fff;
}

.role-gay {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}
