/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3498db;
    --primary-light: #5dade2;
    --primary-dark: #2980b9;
    --secondary: #ecf0f1;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --success: #27ae60;
    --error: #e74c3c;
    --warning: #f39c12;
    --bg-light: #f5fbff;
    --bg-white: #ffffff;
    --border: #d4e6f1;
    --shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

/* 认证页面 */
.container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-card {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
    margin: 15px 0 5px;
}

.logo .tagline {
    color: var(--text-light);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    background: var(--bg-light);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--bg-white);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.message.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
    display: block;
}

.message.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
    display: block;
}

/* 聊天页面 */
body.chat-page {
    background: var(--bg-light);
}

.chat-container {
    width: 100%;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 320px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.user-details h3 {
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    color: var(--text-light);
}

.status.online {
    color: var(--success);
}

.status.offline {
    color: var(--text-light);
}

.sidebar-actions {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.search-box {
    padding: 15px 20px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--bg-light);
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-item:hover {
    background: var(--bg-light);
}

.conversation-item.active {
    background: rgba(52, 152, 219, 0.1);
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.conversation-preview {
    font-size: 12px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.conversation-time {
    font-size: 11px;
    color: var(--text-light);
}

.unread-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-white);
}

.chat-user-info h3 {
    font-size: 18px;
    font-weight: 600;
}

.chat-user-info .status {
    font-size: 12px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-light);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-light);
}

.empty-state h3 {
    margin: 20px 0 10px;
    font-size: 18px;
}

.empty-state p {
    font-size: 14px;
}

.message-bubble {
    display: flex;
    margin-bottom: 20px;
}

.message-bubble.sent {
    justify-content: flex-end;
}

.message-bubble.received {
    justify-content: flex-start;
}

.message-content {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble.sent .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.received .message-content {
    background: var(--bg-white);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    text-align: right;
}

.message-bubble.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* 文件消息 */
.file-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
}

.file-message.image {
    padding: 0;
}

.file-message img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.file-size {
    font-size: 11px;
    color: var(--text-light);
}

.download-btn {
    padding: 6px 12px;
    font-size: 12px;
}

/* 聊天输入区域 */
.chat-input-area {
    padding: 20px;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
}

.file-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.message-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input-wrapper textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: all 0.3s ease;
}

.message-input-wrapper textarea:focus {
    border-color: var(--primary);
}

.message-input-wrapper .btn-primary {
    padding: 12px;
    border-radius: 12px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-light);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-results {
    margin-top: 15px;
}

.search-result-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.search-result-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-size: 14px;
    font-weight: 600;
}

.search-result-email {
    font-size: 12px;
    color: var(--text-light);
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        display: flex;
    }
    
    .chat-main {
        display: none;
    }
    
    .chat-main.active {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
    }
    
    .mobile-back-btn {
        display: block;
    }
}

.mobile-back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}
