/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f2f5;
    color: #333;
}

/* 登录/注册页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0f2f5;
}

.login-box {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    color: #1877f2;
    margin-bottom: 20px;
    text-align: center;
}

.login-box h3 {
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: #1877f2;
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #1877f2;
    color: white;
}

.btn-primary:hover {
    background-color: #166fe5;
}

.btn-secondary {
    background-color: #f0f2f5;
    color: #333;
}

.btn-secondary:hover {
    background-color: #e4e6ea;
}

.btn-danger {
    background-color: #f02849;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.btn-danger:hover {
    background-color: #d61f3f;
}

.error-message {
    color: #f02849;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
}

.success-message {
    color: #2ecc71;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
}

.btn-link {
    background: none;
    border: none;
    color: #1877f2;
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
    padding: 5px 10px;
}

.btn-link:hover {
    color: #166fe5;
}

/* 聊天界面样式 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #1877f2;
    color: white;
    border-bottom: 1px solid #ddd;
}

.chat-header h2 {
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info span {
    font-weight: bold;
    margin-right: 10px;
}

#logout-btn, #admin-btn, #change-password-btn {
    background-color: white;
    color: #1877f2;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#logout-btn:hover, #admin-btn:hover, #change-password-btn:hover {
    background-color: #f0f2f5;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 显示类 */
.visible {
    display: inline-block !important;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: fadeIn 0.3s ease;
}

.message.own {
    align-self: flex-end;
    align-items: flex-end;
}

.message.other {
    align-self: flex-start;
    align-items: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 14px;
}

.message-username {
    font-weight: bold;
    color: #1877f2;
}

.message-time {
    color: #666;
    font-size: 12px;
}

.message-content {
    background-color: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.own .message-content {
    background-color: #1877f2;
    color: white;
}

.message-image {
    max-width: 200px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 5px;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #e9ecef;
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
    text-decoration: none;
    color: #333;
}

.message-file:hover {
    background-color: #dee2e6;
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 15px;
    border-top: 1px solid #ddd;
    background-color: white;
    gap: 10px;
}

.image-preview-container {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 20px;
    min-height: 50px;
    align-items: center;
}

.preview-image, .preview-file {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #1877f2;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
}

.preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-file {
    background-color: #f8f9fa;
}

.file-preview-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5px;
}

.file-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.file-name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #f02849;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-tools {
    display: flex;
    gap: 10px;
}

#file-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

#file-btn:hover {
    background-color: #f0f2f5;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 16px;
    resize: none;
    min-height: 44px;
    max-height: 300px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.4;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}

#message-input::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

#message-input:focus {
    outline: none;
    border-color: #1877f2;
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

#send-btn {
    background-color: #1877f2;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#send-btn:hover {
    background-color: #166fe5;
}

/* 后台管理页面样式 */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #1877f2;
    color: white;
    border-bottom: 1px solid #ddd;
}

.admin-header h2 {
    margin: 0;
}

.admin-actions {
    display: flex;
    gap: 10px;
}

.admin-actions button {
    background-color: white;
    color: #1877f2;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.admin-actions button:hover {
    background-color: #f0f2f5;
}

.admin-tabs {
    display: flex;
    background-color: #f0f2f5;
    border-bottom: 1px solid #ddd;
}

.tab-btn {
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: #666;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #1877f2;
    background-color: white;
    border-bottom-color: #1877f2;
}

.tab-btn:hover {
    color: #1877f2;
}

.admin-content {
    padding: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.users-list, .messages-list {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.user-item, .message-item {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 添加用户表单样式 */
.add-user-form {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.form-header h4 {
    margin-bottom: 0;
    color: #333;
}

.add-user-form h4 {
    color: #333;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.success-message {
    color: #4caf50;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
}

#add-user-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

#add-user-form select:focus {
    outline: none;
    border-color: #1877f2;
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

/* 管理员操作头部样式 */
.admin-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-action-buttons {
    display: flex;
    gap: 10px;
}

/* 用户搜索样式 */
.user-search {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-search h4 {
    margin-bottom: 15px;
    color: #333;
}

.search-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-container input {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.search-container button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
}

#user-search-btn {
    background-color: #1877f2;
    color: white;
}

#user-search-btn:hover {
    background-color: #166fe5;
}

#user-search-reset {
    background-color: #f0f2f5;
    color: #333;
}

#user-search-reset:hover {
    background-color: #e4e6ea;
}

/* 用户权限样式 */
.user-permissions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.permission-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

/* 权限切换开关样式 */
.permission-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.permission-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-label:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-label {
    background-color: #1877f2;
}

input:focus + .toggle-label {
    box-shadow: 0 0 1px #1877f2;
}

input:checked + .toggle-label:before {
    transform: translateX(26px);
}

/* 系统设置样式 */
.settings-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.settings-section h4 {
    margin-bottom: 15px;
    color: #333;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-with-unit .unit {
    color: #666;
    font-weight: bold;
}

.help-text {
    margin: 5px 0 0 0;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

.user-item h4, .message-item h4 {
    margin-bottom: 10px;
    color: #333;
}

/* 用户操作按钮样式 */
.user-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 用户操作按钮内部样式 */
.user-actions button {
    margin-right: 10px;
    margin-bottom: 10px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.user-actions .btn-secondary {
    background-color: #f0f2f5;
    color: #333;
}

.user-actions .btn-secondary:hover {
    background-color: #e4e6ea;
}

.user-actions .btn-danger {
    background-color: #f02849;
    color: white;
}

.user-actions .btn-danger:hover {
    background-color: #d61f3f;
}

.user-actions .btn-primary {
    background-color: #1877f2;
    color: white;
}

.user-actions .btn-primary:hover {
    background-color: #166fe5;
}

.user-item p, .message-item p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 图片放大查看模态框 */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

.image-modal-content {
    position: relative;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.image-modal-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    animation: zoomIn 0.3s ease;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 1001;
}

.image-modal-close:hover {
    color: #ccc;
}

.image-modal-caption {
    color: white;
    text-align: center;
    margin-top: 15px;
    font-size: 18px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        margin: 0;
    }
    
    .message {
        max-width: 85%;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .image-modal-close {
        top: 10px;
        right: 20px;
        font-size: 30px;
    }
}

/* 修改密码弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: zoomIn 0.3s;
    position: relative;
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #333;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}