/* ---------------------------
 * COMMUNITY CHAT WIDGET (Advanced Multi-Room)
 * --------------------------- */
#chat-widget-container {
    position: fixed;
    bottom: 50px;
    right: 3vw;
    width: var(--chat-width, 450px);
    height: var(--chat-height, 420px);
    --chat-sidebar-width: 140px;
    z-index: 3000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
    overflow: hidden;
    background: var(--color-surface-80);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    font-family: 'Inter', system-ui, sans-serif;
}

#chat-widget-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.6), transparent);
}

#chat-widget-container.minimized {
    display: none !important;
}

/* --- UNREAD MESSAGE BADGE --- */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow:
        0 0 15px rgba(255, 107, 107, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3);
    animation: badgePulse 2s infinite;
    z-index: 10;
}

.chat-unread-badge.hidden {
    display: none;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 107, 107, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(255, 107, 107, 0.7), 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* --- NEW MESSAGE SLIDE-IN ANIMATION --- */
.chat-message-bubble.new-message {
    animation: messageSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Flash effect for new messages */
.chat-message-bubble.new-message::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.2) 0%, transparent 100%);
    border-radius: inherit;
    pointer-events: none;
    animation: messageFlash 0.5s ease-out forwards;
}

@keyframes messageFlash {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.chat-header {
    background: rgba(255, 255, 255, 0.02);
    color: #fff;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.1em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
}

.chat-header:hover {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.2) 0%, rgba(18, 96, 120, 0.25) 100%);
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--color-text-light);
}

.chat-icon-svg {
    width: 18px;
    height: 18px;
    fill: var(--color-accent-cyan);
    filter: drop-shadow(0 0 5px rgba(0, 242, 254, 0.4));
}

/* Emoji replaced by SVG in HTML */

/* .chat-toggle-btn — consolidated into universal close button rule in style.css */

#chat-widget-container .window-resizer {
    z-index: 3001;
}

#chat-widget-container .window-resizer.top-left {
    background: var(--color-base);
    border: 1px solid var(--color-glow);
}

/* Hide the resizer when the chat is minimized */
#chat-widget-container.minimized .window-resizer {
    display: none;
}

/* New Container for Sidebar + Messages */
.chat-body {
    flex-grow: 1;
    display: flex;
    min-height: 0;
}

/* New Sidebar for Room Selection */
.chat-rooms-sidebar {
    width: var(--chat-sidebar-width, 140px);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--color-border);
    padding: 12px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Vertical Resizer Handle */
.chat-sidebar-resizer {
    width: 2px;
    flex-shrink: 0;
    background: rgba(0, 242, 254, 0.15);
    cursor: col-resize;
    position: relative;
    transition: background 0.2s, box-shadow 0.2s;
    z-index: 10;
}

.chat-sidebar-resizer:hover,
.chat-widget-container.sidebar-resizing .chat-sidebar-resizer {
    background: var(--color-accent-cyan);
    box-shadow: 0 0 10px var(--color-accent-cyan);
}

.chat-sidebar-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    right: -4px;
}

/* Custom Scrollbar for Sidebar */
.chat-rooms-sidebar::-webkit-scrollbar {
    width: 4px;
}

.chat-rooms-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.chat-rooms-sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 254, 0.3);
    border-radius: 2px;
}

.rooms-list-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px 8px 12px;
    flex-shrink: 0;
}

.room-list-title {
    color: rgba(255, 255, 255, 0.4);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

#create-channel-btn {
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.3);
    color: var(--color-accent-cyan);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#create-channel-btn:hover {
    background: var(--color-accent-cyan);
    color: var(--color-base);
    box-shadow: 0 0 8px var(--color-glow);
}


.room-list {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 4px 0 10px 0;
}

/* Custom Scrollbar for Room List */
.room-list::-webkit-scrollbar {
    width: 4px;
}

.room-list::-webkit-scrollbar-track {
    background: transparent;
}

.room-list::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 254, 0.2);
    border-radius: 2px;
}

/* Container for the room name and the X button */
.chat-room-item {
    padding: 8px 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    margin: 1px 0;

    /* Flex Layout to align Name + X */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
}

.chat-room-item:hover {
    background: rgba(0, 242, 254, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-left-color: rgba(0, 242, 254, 0.3);
}

.chat-room-item.active {
    background: linear-gradient(90deg, rgba(0, 242, 254, 0.15), transparent);
    color: var(--color-accent-cyan);
    font-weight: 600;
    border-left: 2px solid var(--color-accent-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

/* Text Span: Truncates with '...' */
.chat-room-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    min-width: 0;
}

/* Delete Button: Always present in layout, but hidden visually */
.chat-room-delete-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px;
    border-radius: 4px;
    opacity: 0;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Show button on hover */
.chat-room-item:hover .chat-room-delete-btn {
    opacity: 1;
}

.chat-room-delete-btn:hover {
    background: var(--color-negative);
    color: var(--color-base);
    opacity: 1;
    /* Ensure it stays visible */
}

/* Message Area (Main Panel) */
.chat-main-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

/* Custom Scrollbar for Messages */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(0, 242, 254, 0.4), rgba(0, 242, 254, 0.2));
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(0, 242, 254, 0.6), rgba(0, 242, 254, 0.3));
}

/* Individual Message Style */
.chat-message-bubble {
    margin-bottom: 4px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--color-bg-bubble);
    border-radius: 16px;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* For hover action bar positioning */

    /* --- AVATAR LAYOUT --- */
    display: flex;
    align-items: flex-start;

    /* --- TEXT WRAPPING --- */
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chat-message-bubble:hover {
    background: rgba(0, 242, 254, 0.04);
    border-color: rgba(0, 242, 254, 0.1);
}

/* When menu is open, bubble stacks above other messages */
.chat-message-bubble.menu-open {
    z-index: 100;
}

/* --- CHAT AVATAR STYLES --- */
.chat-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
    object-fit: cover;
    border: 2px solid rgba(0, 242, 254, 0.25);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.chat-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.chat-message-content {
    flex: 1;
    min-width: 0;
    /* Allows text to shrink and wrap */
    position: relative;
}

/* --- HOVER ACTION BAR (EMOJI + MORE MENU) --- */
.chat-message-actions {
    position: absolute;
    top: -8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.chat-message-bubble:hover .chat-message-actions {
    opacity: 1;
}

.chat-action-btn {
    background: rgba(6, 13, 20, 0.95);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-action-btn:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--color-accent-cyan);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.2);
}

.chat-action-btn .reaction-icon {
    width: 16px;
    height: 16px;
}

.chat-more-btn {
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
    padding: 4px 10px;
}

/* --- MESSAGE DROPDOWN MENU --- */
.message-dropdown-menu {
    position: fixed;
    background: #050a14;
    border: 1px solid var(--color-accent-cyan);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    min-width: 120px;
    z-index: 99999;
}

.message-dropdown-menu .menu-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
}

.message-dropdown-menu .menu-item:hover {
    background: rgba(0, 242, 254, 0.1);
}

.message-dropdown-menu .menu-item-delete:hover {
    background: rgba(255, 0, 0, 0.1);
}

.reaction-picker-popup {
    display: flex;
    gap: 5px;
    background: #050a14;
    border: 1px solid var(--color-accent-cyan);
    border-radius: 20px;
    padding: 5px 10px;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.3);
    z-index: 200;
}

.picker-emoji {
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.1s;
}

.picker-emoji:hover {
    transform: scale(1.3);
}

.reaction-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    object-fit: contain;
}

.reaction-picker-btn .reaction-icon {
    width: 16px;
    height: 16px;
}

.mention-highlight {
    color: var(--color-accent-cyan);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 242, 254, 0.6);
    background: rgba(0, 242, 254, 0.1);
    padding: 0 4px;
    border-radius: 4px;
    cursor: pointer;
}

.mention-highlight.self-mention {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.chat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

/* --- MENTION POPUP --- */
.mention-popup {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: #050a14;
    border: 1px solid var(--color-accent-cyan);
    border-radius: 8px;
    width: 200px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.3);
    display: none;
}

.mention-popup.visible {
    display: block;
}

.mention-user-item {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--color-text-dim);
    transition: all 0.2s;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mention-user-item:hover,
.mention-user-item.selected {
    background: rgba(0, 242, 254, 0.1);
    color: var(--color-accent-cyan);
}

.reaction-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-badge:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--color-accent-cyan);
}

.reaction-badge.reacted {
    background: rgba(0, 242, 254, 0.2);
    border-color: var(--color-accent-cyan);
}

.chat-message-bubble .message-text {
    white-space: pre-wrap;
    display: inline;
    /* Ensures it flows correctly with the timestamp */
}

.chat-message-bubble .sender {
    font-weight: 600;
    color: var(--color-accent-cyan);
    margin-right: 6px;
    font-size: 12px;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
    cursor: pointer;
    transition: color 0.2s;
}

.chat-message-bubble .sender:hover {
    color: #fff;
    text-shadow: 0 0 12px rgba(0, 242, 254, 0.5);
}

.msg-edited-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    margin-left: 4px;
}

.chat-message-bubble .timestamp {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-left: 8px;
    font-family: 'Inter', 'Space Mono', monospace;
    font-weight: 400;
}

/* Chat Date Separator */
.chat-date-separator {
    display: flex;
    align-items: center;
    margin: 16px 0;
    gap: 12px;
}

.chat-date-line {
    flex: 1;
    height: 1px;
    background: rgba(0, 242, 254, 0.15);
}

.chat-date-label {
    font-size: 11px;
    font-family: 'Space Mono', monospace;
    font-weight: 600;
    color: var(--color-accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 12px;
    white-space: nowrap;
}

/* Chat Input Area */
#chat-input-area {
    padding: 5px 10px !important;
    border-top: 1px solid rgba(0, 242, 254, 0.15);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.3) 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px !important;
    position: relative;
}

/* Chat Input Box */
#chat-input {
    flex-grow: 1;
    margin: 0 !important;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 242, 254, 0.25);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

#chat-input:focus {
    outline: none;
    border-color: var(--color-accent-cyan);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.2), inset 0 0 10px rgba(0, 242, 254, 0.05);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Emoji Button */
#chat-emoji-btn {
    padding: 6px;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

#chat-emoji-btn:hover {
    background: rgba(0, 242, 254, 0.1);
}

/* Emoji icon image */
.emoji-icon-img {
    width: 22px;
    height: auto;
    vertical-align: middle;
    transition: transform 0.2s ease, filter 0.2s ease;
    opacity: 0.7;
}

#chat-emoji-btn:hover .emoji-icon-img {
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px var(--color-accent-cyan));
    opacity: 1;
}

/* Send Button */
#chat-send-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
    color: var(--color-accent-cyan);
    border: 1px solid rgba(0, 242, 254, 0.4);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

#chat-send-btn:hover {
    background: rgba(0, 242, 254, 0.08);
    border-color: var(--color-accent-cyan);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}

#chat-send-btn:active {
    background: rgba(0, 242, 254, 0.15);
}

/* --- CHAT INPUT EXTRAS --- */
.icon-btn {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.3s;
    /* NEW: Add margin to separate icons from input */
    margin-right: 5px;
}

.icon-btn:hover {
    color: var(--color-accent-cyan);
}

.sound-toggle-btn {
    background: transparent;
    border: 1px solid rgba(0, 242, 254, 0.2);
    color: var(--color-text-dim);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 12px;
    vertical-align: middle;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}

.sound-toggle-btn:hover,
.sound-toggle-btn.active {
    color: var(--color-accent-cyan);
    border-color: var(--color-accent-cyan);
    background: rgba(0, 242, 254, 0.1);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
}

/* Emoji Picker Container */
.emoji-picker {
    position: absolute;
    bottom: 50px;
    /* Moved closer to the input bar */
    left: 10px;
    /* Aligned with the buttons */
    width: 220px;
    /* Slightly wider */
    background: rgba(4, 8, 11, 0.95);
    border: 1px solid var(--color-accent-cyan);
    border-radius: 8px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    z-index: 10000;
    /* Higher than everything */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

/* The Magic Fix for the "Dot" */
.emoji-picker.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.emoji-picker span {
    cursor: pointer;
    font-size: 22px;
    /* Bigger emojis */
    text-align: center;
    transition: transform 0.1s;
}

.emoji-picker span:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 0 5px var(--color-glow));
}

/* Chat Images */
.chat-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 5px;
    border: 1px solid rgba(0, 242, 254, 0.3);
    display: block;
    cursor: pointer;
}

/* 1. Style images inside the Picker */
.picker-emoji {
    width: 28px;
    /* Perfect grid size */
    height: 28px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s;
    margin: auto;
    /* Center in the grid cell */
}

.picker-emoji:hover {
    transform: scale(1.3);
    filter: drop-shadow(0 0 5px var(--color-accent-cyan));
}

/* 2. Style images inside the Chat Bubble (Inline) */
.chat-inline-emoji {
    width: 22px;
    /* Slightly smaller to fit text line */
    height: 22px;
    object-fit: contain;
    vertical-align: middle;
    /* Aligns with text */
    margin: 0 2px;
    /* Tiny breathing room */
    display: inline-block;
}

/* --- RICH TEXT CHAT INPUT (Fixed Wrapping) --- */
.chat-input-div {
    flex-grow: 1;
    margin: 0 !important;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--color-accent-cyan);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-light);
    font-size: 14px;
    box-sizing: border-box;

    /* SCROLLING & SIZING */
    overflow-y: auto;
    /* Scroll vertically if text gets too tall */
    max-height: 100px;
    /* Max height before scrolling starts */
    min-height: 26px;
    /* Ensure it has a base height */

    /* TEXT WRAPPING MAGIC */
    white-space: pre-wrap;
    /* Preserve Enter keys/Paragraphs */
    overflow-wrap: anywhere;
    /* CRITICAL: Forces "asdasd" strings to break */
    word-break: break-word;
    /* Backup for older browsers */

    outline: none;
}

/* Simulate Placeholder text */
.chat-input-div:empty::before {
    content: attr(placeholder);
    color: var(--color-text-dim);
    pointer-events: none;
    display: block;
    /* For Firefox */
}

.chat-input-div:focus {
    border-color: #33ffff;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

/* Ensure the inline emoji inside the input matches the size */
.chat-input-div img.chat-inline-emoji {
    vertical-align: middle;
    width: 20px;
    height: 20px;
    margin: 0 2px;
}

/* MOBILE RESPONSIVE TWEAKS */
@media (max-width: 768px) {

    /* Fixed to Bottom on Mobile */
    #chat-widget-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 50px;
        /* Minimized height */
        border-radius: 0 !important;
        z-index: 9999 !important;
    }

    /* When open on mobile, make it full screen */
    #chat-widget-container:not(.minimized) {
        height: 100vh !important;
        border-top: 2px solid var(--color-accent-cyan);
        border-radius: 0 !important;
    }

    .chat-header {
        height: 50px !important;
        padding: 0 16px !important;
    }

    .chat-rooms-sidebar {
        width: 100px !important;
    }

    .chat-room-item {
        padding: 12px 10px !important;
        font-size: 11px !important;
    }

    #chat-input-area {
        padding: 12px !important;
    }

    #chat-input,
    .chat-input-div {
        padding: 14px !important;
        font-size: 16px !important;
    }

    #chat-send-btn {
        padding: 14px 20px !important;
        font-size: 13px !important;
    }
}
/* ============================================================
   GHOST PROTOCOL - TERMINAL STYLE MESSAGES
   ============================================================ */

/* Ghost Protocol message container */
.chat-message[data-user-login="ghost-protocol"],
.chat-message.ghost-protocol-message {
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.08), rgba(0, 255, 136, 0.02));
    border-left: 2px solid var(--color-positive, #00e676);
    padding: 12px 15px;
    margin: 8px 0;
    font-family: 'Space Mono', monospace;
}

/* Ghost username styling */
.chat-message[data-user-login="ghost-protocol"] .chat-username,
.ghost-protocol-message .chat-username {
    color: var(--color-positive, #00e676) !important;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
    font-weight: 700;
    letter-spacing: 1px;
}

/* Ghost message text - terminal green with glow */
.chat-message[data-user-login="ghost-protocol"] .chat-text,
.ghost-protocol-message .chat-text {
    color: rgba(0, 255, 136, 0.9);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-line;
}

/* Special message type badges */
.chat-message[data-message-type="level-up"]::before {
    content: "[LEVEL_UP]";
    display: inline-block;
    color: #FFD700;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
    padding: 2px 6px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 3px;
}

.chat-message[data-message-type="achievement"]::before {
    content: "[ACHIEVEMENT]";
    display: inline-block;
    color: #00f2fe;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
    padding: 2px 6px;
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 3px;
}

.chat-message[data-message-type="token-launch"]::before {
    content: "[TOKEN_LAUNCH]";
    display: inline-block;
    color: #d946ef;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
    padding: 2px 6px;
    background: rgba(217, 70, 239, 0.1);
    border: 1px solid rgba(217, 70, 239, 0.3);
    border-radius: 3px;
}

.chat-message[data-message-type="market-alert"]::before {
    content: "[MARKET_ALERT]";
    display: inline-block;
    color: #ff4444;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
    padding: 2px 6px;
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 3px;
}

.chat-message[data-message-type="daily-gm"]::before {
    content: "[DAILY_SYNC]";
    display: inline-block;
    color: var(--color-positive, #00e676);
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
    padding: 2px 6px;
    background: rgba(0, 230, 118, 0.1);
    border: 1px solid rgba(0, 230, 118, 0.3);
    border-radius: 3px;
}

/* Ghost Protocol badge (if user has special badge) */
.ghost-protocol-badge {
    display: inline-block;
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.2), rgba(0, 255, 136, 0.1));
    border: 1px solid var(--color-positive, #00e676);
    color: var(--color-positive, #00e676);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-left: 6px;
    text-shadow: 0 0 6px rgba(0, 255, 136, 0.6);
}

/* Animation for new Ghost messages */
@keyframes ghostMessageAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-message[data-user-login="ghost-protocol"],
.ghost-protocol-message {
    animation: ghostMessageAppear 0.3s ease-out;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .chat-message[data-user-login="ghost-protocol"],
    .ghost-protocol-message {
        padding: 10px 12px;
    }

    .chat-message[data-user-login="ghost-protocol"] .chat-text,
    .ghost-protocol-message .chat-text {
        font-size: 0.75rem;
    }

    .chat-message[data-message-type]::before {
        font-size: 0.65rem;
        padding: 1px 4px;
    }
}
