/**
 * 聊天系统样式 - QQ风格
 */

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #12B7F5;
    --primary-dark: #0099CC;
    --secondary-color: #2C3E50;
    --success-color: #67C23A;
    --warning-color: #E6A23C;
    --danger-color: #F56C6C;
    --text-primary: #303133;
    --text-secondary: #606266;
    --text-muted: #909399;
    --border-color: #DCDFE6;
    --bg-color: #F5F7FA;
    --white: #FFFFFF;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(18, 183, 245, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* 登录/注册页面 */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #667eea 100%);
    padding: 20px;
}

.auth-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

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

.auth-header .logo {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
}

.auth-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-muted);
    margin-top: 5px;
}

.auth-form .form-group {
    position: relative;
}

.auth-form .input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.auth-form .form-control {
    padding-left: 45px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: #12B7F5;
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 15px;
    transition: background 0.3s;
}

.oauth-btn:hover {
    background: #0099CC;
}

.oauth-btn img {
    width: 20px;
    height: 20px;
}

/* 聊天主界面 */
.chat-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.user-info {
    flex: 1;
}

.user-info .name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-info .status {
    font-size: 12px;
    color: var(--success-color);
}

.sidebar-search {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.sidebar-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.sidebar-tab:hover {
    background: var(--bg-color);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.3s;
    border-left: 3px solid transparent;
}

.chat-item:hover {
    background: var(--bg-color);
}

.chat-item.active {
    background: #E8F4FC;
    border-left-color: var(--primary-color);
}

.chat-item .avatar {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 12px;
}

.chat-item .info {
    flex: 1;
    overflow: hidden;
}

.chat-item .info .name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item .info .preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.chat-item .time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-item .badge {
    background: var(--danger-color);
    color: var(--white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-header {
    padding: 15px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header .title h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header .title .member-count {
    font-size: 13px;
    color: var(--text-muted);
}

.chat-header .actions {
    display: flex;
    gap: 10px;
}

.chat-header .actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s;
}

.chat-header .actions button:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
}

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

.message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message .content {
    display: flex;
    flex-direction: column;
}

.message.self .content {
    align-items: flex-end;
}

.message .sender {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.message .bubble {
    background: var(--white);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    position: relative;
    word-break: break-word;
}

.message.self .bubble {
    background: var(--primary-color);
    color: var(--white);
}

.message .bubble img {
    max-width: 200px;
    border-radius: 4px;
    cursor: pointer;
}

.message .time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 输入区域 */
.chat-input {
    padding: 15px 20px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
}

.chat-input .toolbar {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.chat-input .toolbar button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 20px;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s;
}

.chat-input .toolbar button:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.chat-input .input-wrapper {
    display: flex;
    gap: 10px;
}

.chat-input textarea {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: none;
    font-size: 14px;
    min-height: 40px;
    max-height: 120px;
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-input .send-btn {
    padding: 10px 25px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

.chat-input .send-btn:hover {
    background: var(--primary-dark);
}

/* 成员列表 */
.member-panel {
    width: 250px;
    background: var(--white);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.member-panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.member-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.member-item:hover {
    background: var(--bg-color);
}

.member-item .avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.member-item .name {
    flex: 1;
    font-size: 14px;
}

.member-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

/* 空状态 */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state img {
    width: 150px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
}

/* 提示消息 */
.alert {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-success {
    background: #F0F9EB;
    color: var(--success-color);
    border: 1px solid #E1F3D8;
}

.alert-danger {
    background: #FEF0F0;
    color: var(--danger-color);
    border: 1px solid #FDE2E2;
}

.alert-warning {
    background: #FDF6EC;
    color: var(--warning-color);
    border: 1px solid #FAECD8;
}

/* 模态框 */
.modal-overlay {
    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;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
}

.modal-header .close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 120px);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 80%;
        max-width: 300px;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .member-panel {
        display: none !important;
    }
    
    .chat-main {
        width: 100%;
    }
    
    .chat-item .avatar {
        width: 40px;
        height: 40px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .auth-box {
        padding: 30px 20px;
    }
    
    .mobile-header {
        display: flex !important;
        align-items: center;
        padding: 10px 15px;
        background: var(--white);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 50;
    }
    
    .mobile-header .menu-btn {
        background: none;
        border: none;
        cursor: pointer;
        font-size: 24px;
        margin-right: 15px;
        color: var(--text-primary);
        padding: 5px;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .chat-messages {
        padding: 15px 10px;
    }
    
    .chat-input {
        padding: 10px 15px;
    }
    
    .chat-input textarea {
        min-height: 36px;
        font-size: 14px;
    }
    
    .chat-input .send-btn {
        padding: 8px 20px;
    }
    
    .message .bubble {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .message .bubble img {
        max-width: 150px;
    }
    
    /* 侧边栏遮罩层 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #C0C4CC;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #909399;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 图片预览 */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
}

.image-preview img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* QQ头像预览 */
.qq-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
    margin-top: 10px;
}
