/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 登录注册页面容器 */
.container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.form-box {
    background: white;
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.form-box h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 28px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* 按钮样式 */
.btn {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 提示消息 */
.alert {
    padding: 12px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c33;
}

.alert-success {
    background-color: #efe;
    border: 1px solid #cfc;
    color: #3c3;
}

.register-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.register-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.register-link a:hover {
    text-decoration: underline;
}

/* 聊天室容器 */
.chat-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    background: white;
}

/* 用户列表 */
.user-list {
    width: 300px;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.user-list-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-list-header h2 {
    margin-bottom: 10px;
    font-size: 24px;
}

.current-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.logout-btn {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-list-body {
    flex: 1;
    overflow-y: auto;
}

.user-list-body h3 {
    padding: 15px 20px;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.user-list-body ul {
    list-style: none;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.3s;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.user-item:hover {
    background: #e8e8e8;
}

.user-item.active {
    background: #667eea;
    color: white;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    margin-right: 12px;
    position: relative;
}

/* 未读消息徽章 */
.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.user-item.active .user-avatar {
    background: white;
    color: #667eea;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.user-time {
    font-size: 12px;
    color: #999;
}

.user-item.active .user-time {
    color: rgba(255, 255, 255, 0.8);
}

.no-users {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #ddd;
}

.chat-header h2 {
    color: #333;
    font-size: 20px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafafa;
}

/* 消息样式 */
.message {
    margin-bottom: 15px;
    display: flex;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 10px;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.received .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
}

.message-sender {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 5px;
}

.message.sent .message-sender {
    color: rgba(255, 255, 255, 0.9);
}

.message.received .message-sender {
    color: #667eea;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 5px;
}

.message-time {
    font-size: 11px;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message.received .message-time {
    color: #999;
}

/* 输入区域 */
.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
}

.chat-input textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    resize: none;
    height: 60px;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #667eea;
}

.chat-input button {
    width: 100px;
}

/* 错误页面 */
.error-message {
    text-align: center;
    color: #666;
    margin: 20px 0;
    font-size: 16px;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar,
.user-list-body::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.user-list-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.user-list-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.user-list-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 消息加载动画 */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.new-message {
    animation: messageSlideIn 0.3s ease-out;
}

/* 发送中状态 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 在线状态指示器 */
.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4caf50;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

/* 打字指示器 */
.typing-indicator {
    display: none;
    padding: 10px 15px;
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.typing-indicator.active {
    display: block;
}

.typing-dots {
    display: inline-block;
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background: #999;
    border-radius: 50%;
    animation: typingDots 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDots {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 好友管理样式 */
.friend-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.friend-actions .btn {
    flex: 1;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    background: white;
    color: #667eea;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.friend-actions .btn:hover {
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.badge {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* 模态框样式 */
.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;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* 搜索框样式 */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.search-box .btn {
    width: auto;
    padding: 10px 20px;
}

/* 搜索结果样式 */
.search-results,
.requests-list {
    margin-top: 10px;
}

.user-search-list,
.request-list {
    list-style: none;
}

.user-search-item,
.request-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    transition: background 0.3s;
}

.user-search-item:hover,
.request-item:hover {
    background: #f5f5f5;
}

.user-search-item .user-avatar,
.request-item .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

.user-search-item .user-info,
.request-item .user-info {
    flex: 1;
}

.user-username {
    font-size: 12px;
    color: #999;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    width: auto;
}

.request-actions {
    display: flex;
    gap: 8px;
}

.no-results {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .user-list {
        width: 100%;
        max-height: 200px;
    }
    
    .message-bubble {
        max-width: 80%;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
}

/* ===== 好友管理页面样式 ===== */
.friends-container {
    width: 100vw;
    height: 100vh;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
}

/* 头部导航 */
.friends-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.friends-header h1 {
    margin: 0 0 5px 0;
    font-size: 28px;
}

.friends-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.header-right {
    display: flex;
    gap: 10px;
}

.header-right .btn {
    padding: 10px 20px;
    width: auto;
}

/* 标签页导航 */
.tabs-container {
    background: white;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 40px;
}

.tabs {
    display: flex;
    gap: 5px;
}

.tab-btn {
    padding: 15px 30px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
    position: relative;
}

.tab-btn:hover {
    color: #667eea;
    background: #f5f5f5;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.count-badge {
    display: none;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    margin-left: 8px;
    font-weight: bold;
}

/* 标签页内容 */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
}

.tab-content.active {
    display: block;
}

/* 区块头部 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

/* 好友网格布局 */
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.friend-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.friend-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.friend-card .friend-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 15px;
}

.friend-card .friend-info {
    margin-bottom: 15px;
    width: 100%;
}

.friend-card h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 18px;
}

.friend-username {
    color: #999;
    font-size: 14px;
    margin: 5px 0;
}

.friend-time {
    color: #bbb;
    font-size: 12px;
    margin: 5px 0;
}

.friend-card .friend-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.friend-card .friend-actions .btn {
    flex: 1;
    padding: 8px;
    font-size: 14px;
}

/* 搜索区域 */
.search-section {
    max-width: 800px;
    margin: 0 auto;
}

.search-box-large {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-box-large input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.search-box-large input:focus {
    outline: none;
    border-color: #667eea;
}

.search-box-large .btn {
    width: auto;
    padding: 12px 30px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 搜索结果容器 */
.search-results-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 200px;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.user-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s;
}

.user-card:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.user-card .user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.user-card .user-info {
    margin-bottom: 10px;
}

.user-card h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333;
}

.user-card .user-username {
    color: #999;
    font-size: 13px;
}

.user-card .btn {
    width: 100%;
    padding: 8px;
    font-size: 13px;
}

/* 好友请求区域 */
.requests-section {
    max-width: 900px;
    margin: 0 auto;
}

.requests-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.requests-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.request-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
}

.request-card:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.request-card .request-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.request-card .request-info {
    flex: 1;
}

.request-card h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    color: #333;
}

.request-card .request-username {
    color: #999;
    font-size: 14px;
    margin: 5px 0;
}

.request-card .request-time {
    color: #bbb;
    font-size: 12px;
}

.request-card .request-actions {
    display: flex;
    gap: 10px;
}

.request-card .request-actions .btn {
    padding: 8px 20px;
    width: auto;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    font-size: 18px;
    margin: 0;
}

.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #ff4444;
}

.error-state p {
    font-size: 16px;
    margin: 0;
}

/* 按钮样式补充 */
.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

/* 响应式设计 - 好友管理页面 */
@media (max-width: 768px) {
    .friends-header {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .friends-header h1 {
        font-size: 22px;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .tabs-container {
        padding: 0 20px;
    }
    
    .tab-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .friends-grid,
    .search-results-grid {
        grid-template-columns: 1fr;
    }
    
    .search-box-large {
        flex-direction: column;
    }
    
    .request-card {
        flex-direction: column;
        text-align: center;
    }
    
    .request-card .request-actions {
        width: 100%;
    }
    
    .request-card .request-actions .btn {
        flex: 1;
    }
}
