* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    list-style: none;
    text-decoration: none;
    outline: none;
    border: none;
    background: none;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

/* ===== 主题变量 ===== */
:root {
    /* 尺寸变量 */
    --header-height: 65px;
    --send-area-height: 87px;
    --chat-functions-width: 250px;
    --sidebar-width: 300px;

    /* 日间模式颜色 */
    --bg-color: #f5f5f5;
    --text-color: #333333;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --primary-color: #2196f3;
    --secondary-color: #757575;

    /* 消息相关颜色 */
    --message-self-bg: #e3f2fd;
    --message-self-border: #bbdefb;
    --message-other-bg: #ffffff;
    --message-other-border: #e0e0e0;
    --system-message-bg: #f5f5f5;
    --system-message-border: #eeeeee;
    --system-message-color: #9e9e9e;
    --message-sender-color: #616161;
    --message-time-color: #9e9e9e;

    /* 侧边栏颜色 */
    --sidebar-bg: #ffffff;
    --sidebar-item-hover: #f5f5f5;
    --sidebar-active-bg: #e3f2fd;
    --sidebar-active-color: #1976d2;
}

/* ===== 夜间模式 ===== */
body.mdui-theme-layout-dark {
    --bg-color: #090707;
    --text-color: #e0e0e0;
    --card-bg: #2d2d2d;
    --border-color: #444444;
    --primary-color: #64b5f6;
    --secondary-color: #aaaaaa;
    --message-self-bg: #1e3a5f;
    --message-self-border: #2d4d7a;
    --message-other-bg: #2d2d2d;
    --message-other-border: #444444;
    --system-message-bg: #2d2d2d;
    --system-message-border: #444444;
    --system-message-color: #aaaaaa;
    --message-sender-color: #cccccc;
    --message-time-color: #aaaaaa;
    --sidebar-bg: #2d2d2d;
    --sidebar-item-hover: #3d3d3d;
    --sidebar-active-bg: #1e3a5f;
    --sidebar-active-color: #64b5f6;
}


/* ===== 基础样式 ===== */
body {
    overflow: hidden;
    height: 100vh;
    padding-top: var(--header-height);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    user-select: none !important;
}

.chat-container {
    height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar-content,
#chat-functions {
    padding: 5px 5px 0 5px;
}

/* ===== 侧边栏样式 ===== */
.sidebar {
    min-height: calc(100vh - var(--header-height));
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 2000;
    overflow: hidden;
}

.sidebar-content {
    flex: 1;
    max-height: calc(100vh - 122px);
    overflow-y: scroll;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
}

/* ===== 用户信息样式 ===== */
.user-info {
    padding: 16px 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    border-radius: 50%;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 12px;
    margin: 0;
    display: flex;
    align-items: center;
}

.user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

.user-status.status-online::before {
    background-color: #4caf50;
}

.user-status.status-offline::before {
    background-color: #f44336;
}

.user-actions {
    display: flex;
    gap: 4px;
}

.user-actions .mdui-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
}

.user-actions .mdui-icon {
    font-size: 18px;
}

/* ===== 聊天室列表样式 ===== */
.chatroom-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chatroom-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chatroom-item:hover {
    background-color: var(--sidebar-item-hover);
}

.chatroom-item.active {
    background-color: var(--sidebar-active-bg);
}

.chatroom-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
    font-size: 16px;
}

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

.chatroom-name {
    font-weight: 500;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatroom-last-message {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatroom-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 8px;
}

.chatroom-time {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.chatroom-unread {
    background-color: #f44336;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.75rem;
    min-width: 18px;
    text-align: center;
}

.chatroom-unread.zero {
    display: none;
}

/* ===== 认证区域样式 ===== */
.auth-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
}

.auth-container {
    max-width: 400px;
    width: 90%;
    padding: 40px 20px;
}

.auth-step {
    animation: fadeInUp 0.3s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h2 {
    margin-bottom: 8px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form .mdui-textfield {
    margin-bottom: 0;
}

.auth-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.auth-actions .mdui-btn {
    flex: 1;
}

/* ===== 聊天区域样式 ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.message-area {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-color);
    position: relative;
    padding: 16px;
}

/* ===== 用户资料卡样式 ===== */
.profile-card-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 确保成员列表头像可点击 */
.mdui-panel-item-body .mdui-list-item-avatar img {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.mdui-panel-item-body .mdui-list-item-avatar img:hover {
    transform: scale(1.1);
}

/* ===== 消息样式 ===== */
.time-node,
.system-event {
    display: flex;
    justify-content: center;
}

.message {
    margin-bottom: 4px;
    display: flex;
    position: relative;
    animation: fadeInUp 0.3s ease-out;
}

.message-self {
    flex-direction: row-reverse;
}

.message-self .message-header {
    justify-content: flex-end;
}

.message-avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 5px;
    flex-shrink: 0;
}

.message-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 50%;
    margin-bottom: 4px;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.message-sender {
    font-size: 14px;
    font-weight: bold;
    color: var(--message-sender-color);
    margin: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 11px;
    color: var(--message-time-color);
    white-space: nowrap;
}

.message-bubble {
    padding: 8px;
    word-break: break-word;
    border-radius: 5px;
    user-select: text !important;
    max-width: 100%;
    width: fit-content;
}

/* 自己发送的消息气泡右对齐 */
.message-self .message-bubble {
    background-color: var(--message-self-bg);
    border: 1px solid var(--message-self-border);
    margin-left: auto;
}

.message-other .message-bubble {
    background-color: var(--message-other-bg);
    border: 1px solid var(--message-other-border);
}

/* 消息右键菜单样式 */
.message-context-menu {
    position: absolute;
    background: white;
    min-width: 160px;
    z-index: 10000;
    border: 1px solid #e0e0e0;
}

.message-context-menu .mdui-list {
    padding: 0;
    margin: 0;
}

.message-context-menu .mdui-list-item {
    padding: 0 16px;
    height: 40px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-context-menu .mdui-list-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.message-context-menu .mdui-list-item-title {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.message-context-menu .mdui-icon {
    font-size: 18px;
    margin-right: 8px;
}

.message-context-menu .mdui-divider {
    margin: 4px 0;
}

/* 消息选择模式样式 */
.selection-mode .message.selectable {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.selection-mode .message.selectable:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.selection-mode .message.selectable.selected {
    background-color: rgba(33, 150, 243, 0.1);
}

.selection-mode .message.selectable.selected::before {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #2196F3;
    font-weight: bold;
    font-size: 14px;
}

/* 选择工具栏样式 */
#messageSelectionToolbar {
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

/* 文件上传面板 */
.file-upload-panel {
    position: fixed;
    top: 64px;
    right: 0px;
    width: 300px;
    z-index: 1000;
}

.upload-queue-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upload-info {
    display: flex;
    justify-content: between;
    align-items: center;
}

.file-name {
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.upload-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.file-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.file-header .mdui-icon {
    font-size: 36px;
    color: #757575;
}

.file-info {
    flex: 1;
}

.file-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.file-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

/* 拖放样式 */
.drag-over {
    border: 2px dashed #2196F3 !important;
    background-color: #E3F2FD !important;
}

/* ===== 发送区域样式 ===== */
.send-area {
    flex-shrink: 0;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.send-area .mdui-card:first-child {
    display: flex;
    align-items: end;
    gap: 8px;
}

.send-area .mdui-textfield {
    flex-grow: 1;
    margin: 0;
}

/* 表情面板对话框样式 */
#emojiPanel .mdui-dialog-content {
    padding: 16px;
}

#emojiPanel .mdui-row {
    margin: 0 -4px;
}

#emojiPanel .mdui-col-xs-3 {
    padding: 0 4px;
}

/* ===== 聊天室App ===== */
#chat-functions {
    position: fixed;
    width: var(--chat-functions-width);
    height: var(--chat-functions-height);
    overflow-y: auto;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.admin-title {
    color: #ff5722;
    font-weight: bold;
    font-size: 0.9em;
}

/* ===== 返回底部按钮 ===== */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 110px;
    right: 30px;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
}

/* 夜间模式适配 */
@media (prefers-color-scheme: dark) {
    .not-found-container .mdui-text-color-theme-icon {
        color: #ff5252 !important;
    }

    .not-found-container .mdui-text-color-theme-secondary {
        color: #b0b0b0 !important;
    }
}

/* ===== 动画效果 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

/* ===== 加载动画样式 ===== */
.loading-spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner-content {
    padding: 24px;
    text-align: center;
    min-width: 200px;
}

.loading-text {
    margin-top: 16px;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 500;
}

/* 确保MDUI彩色旋转器可见 */
.mdui-spinner-colorful {
    width: 40px;
    height: 40px;
}

/* ===== MDUI组件主题适配 ===== */
.mdui-appbar {
    background-color: var(--primary-color) !important;
}

.mdui-card {
    background-color: var(--card-bg);
    color: var(--text-color);
}

.mdui-textfield {
    padding: 0 !important;
}

.mdui-textfield-label {
    color: var(--secondary-color) !important;
}

.mdui-textfield-input {
    color: var(--text-color);
    overflow-y: scroll;
}