/* ============================================================
   Chatroom — Phase 1
   Real-time chat panel (bottom LEFT — AI chatbot at bottom right)
   Uses chatroom-* prefix to avoid collision with chatbot's chat-* classes
   ============================================================ */

/* Color: green to distinguish from brown AI chatbot */
:root {
    --chatroom-primary: #4A7C59;
    --chatroom-primary-dark: #375F43;
    --chatroom-accent: #6BA37B;
}

/* Floating trigger button (bottom LEFT) */
.chatroom-trigger {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chatroom-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 124, 89, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 998;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.chatroom-trigger:hover {
    transform: scale(1.08);
    background: var(--chatroom-primary-dark);
    box-shadow: 0 6px 20px rgba(74, 124, 89, 0.45);
}
.chatroom-trigger svg {
    width: 26px;
    height: 26px;
}
.chatroom-trigger-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #D9534F;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    line-height: 1.2;
}

/* Chat panel (slide-in from bottom left) */
.chatroom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 380px;
    height: min(600px, calc(100vh - 80px));
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 0 12px 0 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    max-width: calc(100vw - 16px);
}
.chatroom-panel.chatroom-open {
    transform: translateY(0);
}

/* Header */
.chatroom-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--chatroom-primary);
    color: #fff;
    border-radius: 0 12px 0 0;
    gap: 10px;
    flex-shrink: 0;
}
.chatroom-header-icon {
    font-size: 1.2rem;
}
.chatroom-header-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}
.chatroom-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
    font-weight: 400;
}
.chatroom-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.85;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}
.chatroom-close-btn:hover {
    opacity: 1;
}

/* Messages list */
.chatroom-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg, #FAF8F5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chatroom-messages::-webkit-scrollbar {
    width: 6px;
}
.chatroom-messages::-webkit-scrollbar-thumb {
    background: var(--border, #E5DDD5);
    border-radius: 3px;
}

/* Date separator */
.chatroom-date-sep {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted, #999);
    margin: 12px 0 6px;
    position: relative;
}
.chatroom-date-sep::before,
.chatroom-date-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border, #E5DDD5);
}
.chatroom-date-sep::before { left: 0; }
.chatroom-date-sep::after { right: 0; }

/* Individual message */
.chatroom-msg {
    display: flex;
    gap: 8px;
    padding: 6px 4px;
    position: relative;
}
.chatroom-msg.chatroom-msg-grouped {
    padding-top: 0;
}
.chatroom-msg.chatroom-msg-grouped .chatroom-avatar,
.chatroom-msg.chatroom-msg-grouped .chatroom-msg-meta {
    visibility: hidden;
}
.chatroom-msg.chatroom-msg-grouped .chatroom-msg-body {
    margin-top: -4px;
}
.chatroom-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chatroom-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    overflow: hidden;
}
.chatroom-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chatroom-msg-content {
    flex: 1;
    min-width: 0;
}
.chatroom-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.chatroom-msg-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text, #2C2C2C);
}
.chatroom-msg-time {
    font-size: 0.7rem;
    color: var(--text-muted, #999);
}
.chatroom-msg-body {
    color: var(--text, #2C2C2C);
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.chatroom-msg-body a {
    color: var(--chatroom-primary);
    text-decoration: underline;
}
.chatroom-msg-body code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.85em;
}
.chatroom-msg-body strong { font-weight: 700; }
.chatroom-msg-body em { font-style: italic; }

/* Own messages */
.chatroom-msg.chatroom-msg-own .chatroom-avatar {
    background: var(--chatroom-primary);
}

/* Empty / loading state */
.chatroom-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #999);
    font-size: 0.9rem;
}
.chatroom-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}
.chatroom-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted, #999);
    font-size: 0.85rem;
}

/* Input area */
.chatroom-input-area {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--border, #E5DDD5);
    flex-shrink: 0;
}
.chatroom-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 20px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s;
}
.chatroom-input-wrapper:focus-within {
    border-color: var(--chatroom-primary);
}
.chatroom-input {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text, #2C2C2C);
    max-height: 100px;
    min-height: 24px;
    padding: 3px 0;
}
.chatroom-input::placeholder {
    color: var(--text-muted, #999);
}
.chatroom-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chatroom-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chatroom-send-btn:hover:not(:disabled) {
    background: var(--chatroom-primary-dark);
}
.chatroom-send-btn:disabled {
    background: var(--border, #E5DDD5);
    cursor: not-allowed;
}
.chatroom-send-btn svg {
    width: 16px;
    height: 16px;
}
.chatroom-char-count {
    font-size: 0.7rem;
    color: var(--text-muted, #999);
    text-align: right;
    padding: 2px 8px 0 0;
    height: 14px;
}
.chatroom-char-count.chatroom-char-warning { color: #D9534F; }

/* Rate limit message */
.chatroom-rate-limit {
    background: #FFF3CD;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    margin: 8px 12px 0;
}

/* Mobile responsive */
@media (max-width: 520px) {
    .chatroom-panel {
        width: 100%;
        max-width: 100%;
        left: 0;
        bottom: 0;
        height: 100vh;
        border-radius: 0;
    }
    .chatroom-header {
        border-radius: 0;
    }
    .chatroom-trigger {
        bottom: 16px;
        left: 16px;
    }
}

/* ========== Phase 2: Rooms, channels, views ========== */

.chatroom-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Header buttons */
.chatroom-header-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.85;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}
.chatroom-header-btn:hover { opacity: 1; }

/* Rooms header */
.chatroom-rooms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid var(--border, #E5DDD5);
    gap: 8px;
    flex-shrink: 0;
}
.chatroom-rooms-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text, #2C2C2C);
}
.chatroom-rooms-actions {
    display: flex;
    gap: 6px;
}

/* Small buttons */
.chatroom-small-btn {
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    color: var(--text, #2C2C2C);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}
.chatroom-small-btn:hover {
    background: var(--border, #E5DDD5);
}
.chatroom-small-btn-primary {
    background: var(--chatroom-primary);
    color: #fff;
    border-color: var(--chatroom-primary);
}
.chatroom-small-btn-primary:hover {
    background: var(--chatroom-primary-dark);
}

/* Room list */
.chatroom-rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.chatroom-rooms-list::-webkit-scrollbar { width: 6px; }
.chatroom-rooms-list::-webkit-scrollbar-thumb {
    background: var(--border, #E5DDD5);
    border-radius: 3px;
}

.chatroom-room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
    position: relative;
}
.chatroom-room-item:hover {
    background: var(--border, #E5DDD5);
}
.chatroom-room-active {
    background: rgba(74, 124, 89, 0.15);
}
.chatroom-room-active:hover {
    background: rgba(74, 124, 89, 0.2);
}
.chatroom-room-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    color: #fff;
}
.chatroom-room-info {
    flex: 1;
    min-width: 0;
}
.chatroom-room-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text, #2C2C2C);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chatroom-room-desc {
    font-size: 0.72rem;
    color: var(--text-muted, #999);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chatroom-room-unread {
    background: var(--chatroom-primary);
    color: #fff;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}
.chatroom-room-leave {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}
.chatroom-room-item:hover .chatroom-room-leave {
    opacity: 0.7;
}
.chatroom-room-leave:hover {
    opacity: 1;
    background: rgba(217, 83, 79, 0.15);
    color: #D9534F;
}

/* Browse rooms view */
.chatroom-browse-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.chatroom-browse-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, #E5DDD5);
}
.chatroom-browse-join-btn {
    background: var(--chatroom-primary);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
}
.chatroom-browse-join-btn:hover:not(:disabled) {
    background: var(--chatroom-primary-dark);
}
.chatroom-browse-join-btn:disabled {
    background: var(--border, #E5DDD5);
    cursor: not-allowed;
}
.chatroom-browse-joined {
    color: var(--text-muted, #999);
    font-size: 0.75rem;
    padding: 6px 14px;
}

/* Create room form */
.chatroom-create-form {
    padding: 16px;
    overflow-y: auto;
}
.chatroom-create-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text, #2C2C2C);
    margin: 10px 0 4px;
}
.chatroom-create-form input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    color: var(--text, #2C2C2C);
    box-sizing: border-box;
}
.chatroom-create-form input[type="text"]:focus {
    outline: none;
    border-color: var(--chatroom-primary);
}
.chatroom-emoji-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin: 4px 0;
}
.chatroom-emoji-btn {
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 6px;
    padding: 6px 0;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}
.chatroom-emoji-btn:hover {
    background: var(--border, #E5DDD5);
}
.chatroom-emoji-btn-selected {
    background: rgba(74, 124, 89, 0.15);
    border-color: var(--chatroom-primary);
}

.chatroom-create-submit {
    width: 100%;
    background: var(--chatroom-primary);
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 16px;
}
.chatroom-create-submit:hover {
    background: var(--chatroom-primary-dark);
}

/* Delete button on own message */
.chatroom-msg-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border, #E5DDD5);
    color: var(--text-muted, #999);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s, border-color 0.2s;
    display: flex;
}
.chatroom-msg:hover .chatroom-msg-delete {
    opacity: 1;
}
.chatroom-msg-delete:hover {
    opacity: 1;
    color: #D9534F;
    border-color: #D9534F;
    background: #FFF5F5;
}

/* ========== Phase 3: Mentions, previews, tree integration ========== */

/* @mention dropdown */
.chatroom-mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    background: #fff;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    margin-bottom: 4px;
}
.chatroom-input-area {
    position: relative;
}
.chatroom-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(229, 221, 213, 0.5);
}
.chatroom-mention-item:last-child {
    border-bottom: none;
}
.chatroom-mention-item-active,
.chatroom-mention-item:hover {
    background: var(--bg, #FAF8F5);
}
.chatroom-mention-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--chatroom-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.chatroom-mention-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text, #2C2C2C);
    flex: 1;
}
.chatroom-mention-sub {
    font-size: 0.7rem;
    color: var(--text-muted, #999);
}

/* Rendered mentions in messages */
.chatroom-mention {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
    text-decoration: none;
    font-size: 0.88em;
}
.chatroom-mention-user {
    background: rgba(74, 124, 89, 0.15);
    color: var(--chatroom-primary);
}
.chatroom-mention-user:hover {
    background: rgba(74, 124, 89, 0.25);
}
.chatroom-mention-person {
    background: rgba(193, 154, 107, 0.18);
    color: #8B6914;
}
.chatroom-mention-person:hover {
    background: rgba(193, 154, 107, 0.28);
}

/* Link preview cards */
.chatroom-previews {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chatroom-preview-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border, #E5DDD5);
    border-left: 3px solid var(--chatroom-primary);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text, #2C2C2C);
    transition: background 0.15s;
}
.chatroom-preview-card:hover {
    background: var(--bg, #FAF8F5);
}
.chatroom-preview-card img {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}
.chatroom-preview-placeholder {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    background: var(--bg, #FAF8F5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.chatroom-preview-info {
    flex: 1;
    min-width: 0;
}
.chatroom-preview-title {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chatroom-preview-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted, #999);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Phase 4: Presence & Typing ========== */

.chatroom-typing-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: var(--text-muted, #999);
    background: var(--bg, #FAF8F5);
    border-top: 1px solid var(--border, #E5DDD5);
    font-style: italic;
}

.chatroom-typing-dots {
    display: inline-flex;
    gap: 2px;
}
.chatroom-typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--chatroom-primary);
    animation: chatroom-typing 1.2s infinite ease-in-out;
}
.chatroom-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chatroom-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatroom-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

/* Presence dots on avatars */
.chatroom-presence-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg, #FAF8F5);
    background: var(--text-muted, #999);
}
.chatroom-presence-online { background: #4A7C59; }
.chatroom-presence-idle { background: #E0A800; }
.chatroom-presence-away { background: #D9534F; }
.chatroom-presence-offline { background: #B0B0B0; }
.chatroom-avatar { position: relative; }

/* ========== Phase 5: Rich Content, Reactions, Edit, Reply ========== */

/* Message action bar */
.chatroom-msg-actions {
    position: absolute;
    top: 0;
    right: 8px;
    background: #fff;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 6px;
    padding: 2px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.chatroom-msg:hover .chatroom-msg-actions {
    opacity: 1;
}
.chatroom-msg-action {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.chatroom-msg-action:hover {
    color: var(--chatroom-primary);
    background: var(--bg, #FAF8F5);
}
.chatroom-msg-delete-btn:hover {
    color: #D9534F;
}

/* Reply context in messages */
.chatroom-msg-reply {
    border-left: 3px solid var(--chatroom-primary);
    padding: 2px 8px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    color: var(--text-muted, #777);
    background: rgba(74, 124, 89, 0.08);
    border-radius: 0 4px 4px 0;
}
.chatroom-msg-reply strong {
    color: var(--chatroom-primary);
}

/* Reply/Edit banner in input area */
.chatroom-reply-banner,
.chatroom-edit-banner {
    display: none;
    align-items: center;
    padding: 6px 10px;
    background: rgba(74, 124, 89, 0.1);
    border-left: 3px solid var(--chatroom-primary);
    margin-bottom: 4px;
    font-size: 0.8rem;
    border-radius: 4px;
}
.chatroom-edit-banner {
    background: rgba(217, 119, 6, 0.1);
    border-left-color: #D97706;
}
.chatroom-reply-info {
    flex: 1;
}
.chatroom-reply-excerpt {
    color: var(--text-muted, #999);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.chatroom-reply-cancel {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.chatroom-reply-cancel:hover {
    color: #D9534F;
}

/* Image attachment */
.chatroom-msg-image {
    margin-top: 6px;
    max-width: 100%;
}
.chatroom-msg-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: zoom-in;
    display: block;
}

/* File attachment */
.chatroom-msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text, #2C2C2C);
    margin-top: 6px;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.chatroom-msg-file:hover {
    background: var(--border, #E5DDD5);
}

/* Attach button */
.chatroom-attach-btn {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.chatroom-attach-btn:hover {
    color: var(--chatroom-primary);
    background: var(--bg, #FAF8F5);
}

/* Reactions on messages */
.chatroom-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.chatroom-reaction {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--bg, #FAF8F5);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 12px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: background 0.15s, border-color 0.15s;
}
.chatroom-reaction:hover {
    background: var(--border, #E5DDD5);
}
.chatroom-reaction-mine {
    background: rgba(74, 124, 89, 0.15);
    border-color: var(--chatroom-primary);
}
.chatroom-reaction-mine:hover {
    background: rgba(74, 124, 89, 0.25);
}
.chatroom-reaction-emoji {
    font-size: 1rem;
    line-height: 1;
}
.chatroom-reaction-count {
    color: var(--text-muted, #999);
    font-weight: 600;
}
.chatroom-reaction-mine .chatroom-reaction-count {
    color: var(--chatroom-primary);
}

/* Reaction picker popup */
.chatroom-reaction-picker {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 6px;
    display: flex;
    gap: 2px;
    z-index: 2000;
}
.chatroom-reaction-option {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.1s, transform 0.1s;
}
.chatroom-reaction-option:hover {
    background: var(--bg, #FAF8F5);
    transform: scale(1.2);
}

/* Dark mode Phase 5 */
.dark-mode .chatroom-msg-actions {
    background: #26221E;
    border-color: #2E2922;
}
.dark-mode .chatroom-reaction,
.dark-mode .chatroom-msg-file,
.dark-mode .chatroom-reaction-picker {
    background: #1E1B18;
    border-color: #2E2922;
    color: #F0EBE5;
}

/* ========== Phase 6: Notifications, Moderation, Search ========== */

/* Report button */
.chatroom-msg-report-btn:hover {
    color: #E0A800;
}

/* Search bar */
.chatroom-search-bar {
    display: flex;
    padding: 8px 10px;
    background: #fff;
    border-bottom: 1px solid var(--border, #E5DDD5);
    gap: 6px;
    flex-shrink: 0;
}
.chatroom-search-bar input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    background: var(--bg, #FAF8F5);
    color: var(--text, #2C2C2C);
}
.chatroom-search-bar input:focus {
    border-color: var(--chatroom-primary);
}
.chatroom-search-bar button {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0 6px;
}

/* Search results */
.chatroom-search-results {
    background: var(--bg, #FAF8F5);
    max-height: 300px;
    overflow-y: auto;
}
.chatroom-search-results:empty {
    display: none;
}
.chatroom-search-result {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #E5DDD5);
}
.chatroom-search-author {
    font-size: 0.72rem;
    color: var(--text-muted, #999);
    margin-bottom: 3px;
    font-weight: 600;
}
.chatroom-search-excerpt {
    font-size: 0.82rem;
    color: var(--text, #2C2C2C);
    line-height: 1.4;
}

/* Dark mode Phase 6 */
.dark-mode .chatroom-search-bar,
.dark-mode .chatroom-search-results {
    background: #26221E;
    border-color: #2E2922;
}
.dark-mode .chatroom-search-bar input {
    background: #1E1B18;
    border-color: #2E2922;
    color: #F0EBE5;
}
.dark-mode .chatroom-search-excerpt {
    color: #F0EBE5;
}

/* Dark mode Phase 3 */
.dark-mode .chatroom-mention-dropdown,
.dark-mode .chatroom-preview-card {
    background: #26221E;
    border-color: #2E2922;
    color: #F0EBE5;
}
.dark-mode .chatroom-mention-label,
.dark-mode .chatroom-preview-title {
    color: #F0EBE5;
}
.dark-mode .chatroom-msg-delete {
    background: #26221E;
    border-color: #2E2922;
}

/* Dark mode Phase 2 */
.dark-mode .chatroom-rooms-header,
.dark-mode .chatroom-small-btn {
    background: #26221E;
    border-color: #2E2922;
    color: #F0EBE5;
}
.dark-mode .chatroom-rooms-title,
.dark-mode .chatroom-room-name {
    color: #F0EBE5;
}
.dark-mode .chatroom-room-item:hover {
    background: #2E2922;
}
.dark-mode .chatroom-room-active {
    background: rgba(74, 124, 89, 0.25);
}
.dark-mode .chatroom-create-form input[type="text"] {
    background: #1E1B18;
    border-color: #2E2922;
    color: #F0EBE5;
}
.dark-mode .chatroom-msg-delete {
    background: #26221E;
    border-color: #2E2922;
}

/* Dark mode */
.dark-mode .chatroom-panel {
    background: #1E1B18;
    border-color: #2E2922;
}
.dark-mode .chatroom-messages {
    background: #1E1B18;
}
.dark-mode .chatroom-input-area {
    background: #26221E;
    border-top-color: #2E2922;
}
.dark-mode .chatroom-input-wrapper {
    background: #1E1B18;
    border-color: #2E2922;
}
.dark-mode .chatroom-msg-author,
.dark-mode .chatroom-msg-body,
.dark-mode .chatroom-input {
    color: #F0EBE5;
}
.dark-mode .chatroom-msg-body code {
    background: rgba(255, 255, 255, 0.1);
}
