/* ==================== 全局重置 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f5f5;
    overflow: hidden;
}
input, button { font-family: inherit; outline: none; border: none; }
button { cursor: pointer; }

/* ==================== 登录页 ==================== */
.login-body {
    background: linear-gradient(135deg, #07c160 0%, #10b981 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px 35px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.logo-icon {
    font-size: 48px;
    margin-bottom: 10px;
}
.login-logo h1 {
    font-size: 22px;
    color: #333;
    margin-bottom: 6px;
}
.login-logo p {
    font-size: 13px;
    color: #999;
}
.login-form .form-item {
    margin-bottom: 16px;
}
.login-form input {
    width: 100%;
    height: 44px;
    padding: 0 15px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.login-form input:focus {
    border-color: #07c160;
}
.login-btn {
    width: 100%;
    height: 44px;
    background: #07c160;
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    margin-top: 8px;
    transition: background 0.2s;
}
.login-btn:hover { background: #06ad56; }
.login-btn:active { background: #059a4c; }
.login-msg {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    min-height: 20px;
}
.login-msg.error { color: #ff4d4f; }
.login-msg.success { color: #07c160; }

/* ==================== 主容器 ==================== */
.chat-container {
    display: flex;
    height: 100vh;
    background: #fff;
}

/* ==================== 左侧边栏 ==================== */
.sidebar {
    width: 280px;
    background: #f7f7f7;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    height: 60px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e8e8e8;
    background: #ededed;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #07c160;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    flex-shrink: 0;
}
.user-info .nickname {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}
.header-actions {
    display: flex;
    gap: 8px;
}
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    font-size: 18px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.icon-btn:hover { background: #ddd; }

.search-bar {
    padding: 10px 12px;
    background: #f7f7f7;
}
.search-bar input {
    width: 100%;
    height: 32px;
    padding: 0 12px;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid #e8e8e8;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}
.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
    position: relative;
}
.conversation-item:hover { background: #ececec; }
.conversation-item.active { background: #d6d6d6; }
.conversation-item .avatar {
    width: 42px;
    height: 42px;
    margin-right: 12px;
    font-size: 16px;
}
.conv-info {
    flex: 1;
    min-width: 0;
}
.conv-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-msg {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-right {
    text-align: right;
    flex-shrink: 0;
    margin-left: 8px;
}
.conv-time {
    font-size: 11px;
    color: #b2b2b2;
    margin-bottom: 4px;
}
.unread-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #fa5151;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}
.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #07c160;
    margin-left: 4px;
}
.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    margin-left: 4px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 13px;
}

/* ==================== 右侧聊天区 ==================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    min-width: 0;
}
.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
}
.placeholder-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 聊天头部 */
.chat-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e8e8e8;
    background: #f5f5f5;
    flex-shrink: 0;
}
.chat-header .chat-name {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}
.chat-header .chat-status {
    font-size: 12px;
    color: #999;
    margin-left: 10px;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}
.msg-item {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
}
.msg-item.self {
    flex-direction: row-reverse;
}
.msg-item .avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
    flex-shrink: 0;
}
.msg-bubble {
    max-width: 60%;
    margin: 0 10px;
    position: relative;
}
.msg-content {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.msg-item:not(.self) .msg-content {
    background: #fff;
    color: #333;
}
.msg-item.self .msg-content {
    background: #95ec69;
    color: #333;
}
.msg-time {
    font-size: 11px;
    color: #b2b2b2;
    margin-top: 4px;
    text-align: center;
}
.msg-item.self .msg-time {
    text-align: right;
}
.msg-item:not(.self) .msg-time {
    text-align: left;
}

/* 图片消息 */
.msg-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
}

/* 文件消息 */
.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 8px;
    min-width: 200px;
}
.msg-item.self .msg-file {
    background: #95ec69;
}
.file-icon {
    font-size: 32px;
}
.file-info {
    flex: 1;
    min-width: 0;
}
.file-name {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.file-size {
    font-size: 12px;
    color: #999;
}

/* 系统消息 */
.system-msg {
    text-align: center;
    margin: 12px 0;
}
.system-msg span {
    display: inline-block;
    padding: 4px 12px;
    background: #dcdcdc;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
}

/* 输入区域 */
.chat-input-area {
    border-top: 1px solid #e8e8e8;
    background: #f5f5f5;
    flex-shrink: 0;
}
.input-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    gap: 12px;
}
.tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.tool-btn:hover { background: #e5e5e5; }

.input-box {
    padding: 0 15px 12px;
}
.input-box textarea {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    background: #fff;
    font-family: inherit;
}
.input-box textarea:focus {
    border-color: #07c160;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0 15px 12px;
}
.send-btn {
    padding: 6px 20px;
    background: #07c160;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s;
}
.send-btn:hover { background: #06ad56; }
.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ==================== 表情面板 ==================== */
.emoji-panel {
    position: absolute;
    bottom: 140px;
    left: 20px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    width: 320px;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}
.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}
.emoji-item:hover { background: #f0f0f0; }

/* ==================== 弹窗 ==================== */
.modal-mask {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: #fff;
    border-radius: 10px;
    width: 420px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 500;
}
.close-btn {
    background: transparent;
    font-size: 16px;
    color: #999;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.close-btn:hover { background: #f5f5f5; color: #666; }
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}
.btn-primary {
    padding: 8px 24px;
    background: #07c160;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s;
}
.btn-primary:hover { background: #06ad56; }

.setting-item {
    margin-bottom: 20px;
}
.setting-item label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}
.setting-item input[type="text"] {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    font-size: 14px;
}
.setting-item input:focus {
    border-color: #07c160;
}
.theme-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.theme-option {
    width: 60px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.theme-option.active {
    border-color: #333;
    transform: scale(1.05);
}
.bg-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.bg-option {
    width: 70px;
    height: 50px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    border: 2px solid transparent;
    background: #ddd;
    transition: all 0.2s;
}
.bg-option.active {
    border-color: #07c160;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ==================== 主题适配 ==================== */
body.theme-blue .login-btn,
body.theme-blue .send-btn,
body.theme-blue .btn-primary,
body.theme-blue .avatar { background: #1890ff; }
body.theme-blue .msg-item.self .msg-content { background: #91d5ff; }
body.theme-blue .conversation-item.active { background: #bae7ff; }

body.theme-dark {
    background: #1f1f1f;
    color: #ddd;
}
body.theme-dark .sidebar { background: #2a2a2a; border-right-color: #333; }
body.theme-dark .sidebar-header { background: #2a2a2a; border-bottom-color: #333; }
body.theme-dark .search-bar { background: #2a2a2a; }
body.theme-dark .search-bar input { background: #333; border-color: #444; color: #ddd; }
body.theme-dark .conversation-item { border-bottom-color: #333; }
body.theme-dark .conversation-item:hover { background: #333; }
body.theme-dark .conversation-item.active { background: #444; }
body.theme-dark .conv-name { color: #ddd; }
body.theme-dark .chat-main { background: #1f1f1f; }
body.theme-dark .chat-header { background: #2a2a2a; border-bottom-color: #333; }
body.theme-dark .chat-name { color: #ddd; }
body.theme-dark .chat-messages { background: #1f1f1f; }
body.theme-dark .msg-item:not(.self) .msg-content { background: #333; color: #ddd; }
body.theme-dark .chat-input-area { background: #2a2a2a; border-top-color: #333; }
body.theme-dark .input-box textarea { background: #333; border-color: #444; color: #ddd; }
body.theme-dark .login-box { background: #2a2a2a; }
body.theme-dark .login-logo h1 { color: #ddd; }
body.theme-dark .login-form input { background: #333; border-color: #444; color: #ddd; }

body.theme-pink .login-btn,
body.theme-pink .send-btn,
body.theme-pink .btn-primary,
body.theme-pink .avatar { background: #ff6b9d; }
body.theme-pink .msg-item.self .msg-content { background: #ffc0cb; }
body.theme-pink .conversation-item.active { background: #ffd1dc; }

/* 聊天背景 */
.chat-messages.custom-bg {
    background-size: cover !important;
    background-position: center !important;
}
