/* PC instant messaging chat room */
.forum-chat-panel {
    padding: 0 !important;
    overflow: hidden;
}

.im-chat-app {
    display: flex;
    height: 620px;
    min-height: 620px;
}

/* 聊天室 Tab：模块高度随视口向下延伸 */
.forum-page[data-active-tab="chat"] .im-chat-app {
    height: calc(100vh - 138px);
    min-height: 620px;
}

/* ---- Sidebar ---- */
.im-chat-sidebar {
    background: #2f3238;
    box-sizing: border-box;
    color: #c8cdd3;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 240px;
}

.im-sidebar-head {
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    flex-shrink: 0;
    padding: 16px 16px 12px;
}

.im-sidebar-head h3 {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.im-room-list {
    flex: 1;
    list-style: none;
    margin: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.im-room-list::-webkit-scrollbar {
    width: 4px;
}

.im-room-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border-radius: 2px;
}

.im-room-item {
    align-items: center;
    border-left: 3px solid transparent;
    cursor: pointer;
    display: flex;
    gap: 10px;
    padding: 12px 14px 12px 11px;
    transition: background .15s;
}

.im-room-item:hover {
    background: rgba(255, 255, 255, .05);
}

.im-room-item.is-active {
    background: rgba(231, 59, 59, .12);
    border-left-color: #e73b3b;
}

.im-room-icon {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    height: 28px;
    justify-content: center;
    line-height: 1;
    text-align: center;
    width: 28px;
}

.im-room-icon img {
    border-radius: 50%;
    display: block;
    height: 28px;
    object-fit: cover;
    width: 28px;
}

.im-room-info {
    flex: 1;
    min-width: 0;
}

.im-room-name-row {
    align-items: center;
    display: flex;
    gap: 6px;
    margin-bottom: 2px;
}

.im-room-name {
    color: #eef1f4;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-room-item.is-active .im-room-name {
    color: #fff;
}

.im-room-tag {
    background: rgba(231, 59, 59, .25);
    border-radius: 8px;
    color: #ff8a8a;
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1;
    padding: 2px 6px;
}

.im-room-online {
    color: #7d8690;
    font-size: 11px;
}

.im-room-item.is-active .im-room-online {
    color: #9aa3ad;
}

.im-online-dot,
.im-user-dot {
    background: #52c41a;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    height: 7px;
    width: 7px;
}

.im-sidebar-title {
    color: #7d8690;
    font-size: 11px;
    letter-spacing: .5px;
    padding: 8px 16px 6px;
    text-transform: uppercase;
}

.im-user-list {
    flex: 1;
    list-style: none;
    margin: 0;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.im-user-list li {
    align-items: center;
    border-radius: 6px;
    color: #d7dde3;
    display: flex;
    font-size: 13px;
    gap: 8px;
    padding: 8px 10px;
}

.im-user-list li:hover {
    background: rgba(255, 255, 255, .05);
}

/* ---- Main chat area ---- */
.im-chat-main {
    background: #eceff4;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.im-chat-header {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e3e8ef;
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    padding: 14px 20px;
}

.im-chat-header-info h2 {
    color: #222;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px;
}

.im-chat-header-title-row {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-bottom: 2px;
}

.im-chat-header-title-row h2 {
    margin: 0;
}

.im-chat-header-icon {
    border-radius: 50%;
    display: block;
    flex-shrink: 0;
    height: 28px;
    object-fit: cover;
    width: 28px;
}

.im-chat-header-info p {
    color: #999;
    font-size: 12px;
    margin: 0;
}

.im-chat-header-status {
    align-items: center;
    color: #52c41a;
    display: flex;
    font-size: 12px;
    gap: 6px;
}

.im-header-divider {
    color: #ddd;
    margin: 0 4px;
}

.im-status-live {
    animation: im-pulse 1.8s ease-in-out infinite;
    background: #52c41a;
    border-radius: 50%;
    height: 8px;
    width: 8px;
}

@keyframes im-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .5; transform: scale(.85); }
}

/* ---- Message list ---- */
.im-message-scroll {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 20px;
    scroll-behavior: smooth;
}

.im-message-scroll::-webkit-scrollbar {
    width: 6px;
}

.im-message-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
    border-radius: 3px;
}

.im-msg-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.im-msg-row.is-system {
    justify-content: center;
    margin-bottom: 12px;
}

.im-msg-avatar {
    background: #fff;
    border-radius: 50%;
    flex-shrink: 0;
    height: 40px;
    object-fit: cover;
    width: 40px;
}

.im-msg-avatar.is-system-avatar {
    background: linear-gradient(135deg, #ff6b6b, #e73b3b);
    box-sizing: border-box;
    object-fit: contain;
    padding: 8px;
}

.im-msg-body {
    max-width: 68%;
    min-width: 0;
}

.im-msg-meta {
    color: #888;
    font-size: 12px;
    line-height: 18px;
    margin-bottom: 4px;
}

.im-msg-meta .im-msg-name {
    color: #555;
    font-weight: 600;
    margin-right: 8px;
}

.im-msg-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    color: #333;
    display: inline-block;
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
    padding: 10px 14px;
    word-break: break-word;
}

.im-msg-row.is-self {
    flex-direction: row-reverse;
}

.im-msg-row.is-self .im-msg-body {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
}

.im-msg-row.is-self .im-msg-meta {
    text-align: right;
}

.im-msg-row.is-self .im-msg-bubble {
    background: #95ec69;
    border-radius: 12px 0 12px 12px;
    color: #1a1a1a;
}

.im-system-tip {
    background: rgba(0, 0, 0, .06);
    border-radius: 12px;
    color: #888;
    font-size: 12px;
    line-height: 1.5;
    max-width: 80%;
    padding: 6px 14px;
    text-align: center;
}

.im-msg-empty {
    color: #aaa;
    font-size: 14px;
    padding: 80px 0;
    text-align: center;
}

/* ---- Composer ---- */
.im-composer {
    background: #fff;
    border-top: 1px solid #e3e8ef;
    flex-shrink: 0;
    padding: 10px 16px 12px;
    position: relative;
}

.im-composer-main {
    align-items: flex-end;
    display: flex;
    gap: 12px;
}

.im-composer-toolbar {
    align-items: center;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 6px;
    padding-bottom: 4px;
}

.im-tool-btn.im-tool-outside {
    flex-shrink: 0;
    margin-bottom: 4px;
}

.im-input-emoji-btn {
    align-items: center;
    background: none;
    border: none;
    border-radius: 6px;
    bottom: 8px;
    color: #999;
    cursor: pointer;
    display: inline-flex;
    height: 28px;
    justify-content: center;
    padding: 0;
    position: absolute;
    right: 10px;
    transition: color .2s;
    width: 28px;
    z-index: 2;
}

.im-input-emoji-btn:hover,
.im-input-emoji-btn.is-active {
    color: #e73b3b;
}

.im-tool-btn {
    align-items: center;
    background: #f5f6f8;
    border: 1px solid #e3e8ef;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    transition: all .2s;
    width: 36px;
}

.im-tool-btn:hover {
    background: #fff;
    border-color: #e73b3b;
    color: #e73b3b;
}

.im-tool-btn.is-active {
    background: #fff5f5;
    border-color: #e73b3b;
    color: #e73b3b;
}

.im-composer-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

.im-composer-input-wrap textarea {
    background: #f5f6f8;
    border: 1px solid #e3e8ef;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    min-height: 44px;
    outline: none;
    padding: 10px 42px 10px 14px;
    resize: none;
    transition: border-color .2s;
    width: 100%;
}

.im-composer-input-wrap textarea:focus {
    background: #fff;
    border-color: #e73b3b;
}

.im-emoji-panel {
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    bottom: calc(100% + 8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    box-sizing: border-box;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    position: absolute;
    right: 0;
    width: 320px;
    z-index: 20;
}

.im-emoji-panel::-webkit-scrollbar {
    width: 5px;
}

.im-emoji-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
    border-radius: 3px;
}

.im-emoji-grid {
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(8, 1fr);
}

.im-emoji-item {
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 22px;
    height: 34px;
    line-height: 34px;
    padding: 0;
    transition: background .15s;
}

.im-emoji-item:hover {
    background: #f5f6f8;
}

.im-msg-bubble.im-msg-image {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.im-msg-bubble.im-msg-image img {
    border-radius: 8px;
    cursor: pointer;
    display: block;
    max-height: 240px;
    max-width: 240px;
    object-fit: cover;
}

.im-msg-row.is-self .im-msg-bubble.im-msg-image {
    background: transparent;
}

.im-msg-bubble .im-msg-emoji {
    font-size: 18px;
    line-height: 1.6;
}

.im-send-btn {
    background: #e73b3b;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    height: 44px;
    min-width: 72px;
    padding: 0 20px;
    transition: background .2s;
}

.im-send-btn:hover {
    background: #d42f2f;
}

.im-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ---- Quick bet panel ---- */
.im-chat-bet-panel {
    background: #f5f6f8;
    border-left: 1px solid #e3e8ef;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
    width: 400px;
}

.im-chat-bet-panel iframe {
    background: #fff;
    border: 0;
    display: block;
    flex: 1;
    height: 100%;
    min-height: 0;
    width: 100%;
}

@media (max-width: 768px) {
    .im-chat-sidebar {
        display: none;
    }

    .im-chat-bet-panel {
        display: none;
    }

    .im-chat-app {
        height: 520px;
        min-height: 520px;
    }

    .im-msg-body {
        max-width: 85%;
    }
}
