* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
}

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

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 35px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.logo {
    font-size: 48px;
    margin-bottom: 15px;
    animation: bounce 1s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.auth-header p {
    color: #888;
    font-size: 14px;
}

.error-msg {
    background: #fff1f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
    font-weight: 500;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    outline: none;
}

.auth-form input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 14px;
    color: #888;
}

.auth-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.auth-footer a:hover {
    color: #764ba2;
}

/* ========== 聊天室 ========== */
.chat-body {
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    height: 100vh;
}

.chat-sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-title {
    font-size: 20px;
    font-weight: 600;
}

.user-info {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    margin: 0 auto 12px;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.user-status {
    font-size: 13px;
    color: #52c41a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #52c41a;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.online-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

.list-title {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.online-users {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.online-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background 0.3s;
    font-size: 14px;
}

.online-user:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-admin, .btn-logout {
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-admin {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-admin:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-logout {
    background: rgba(255, 77, 79, 0.2);
    color: #ff4d4f;
}

.btn-logout:hover {
    background: rgba(255, 77, 79, 0.3);
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

.chat-header {
    padding: 18px 25px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

.chat-subtitle {
    font-size: 13px;
    color: #999;
    margin-top: 2px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
    scroll-behavior: smooth;
}

.welcome-msg {
    text-align: center;
    padding: 30px 0;
    color: #999;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.welcome-text {
    font-size: 14px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: msgIn 0.3s ease;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message-self .msg-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 18px 4px 18px 18px;
}

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 60%;
}

.msg-name {
    font-size: 12px;
    color: #999;
    padding: 0 8px;
}

.msg-bubble {
    background: #fff;
    padding: 12px 16px;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
}

.msg-time {
    font-size: 11px;
    color: #bbb;
    padding: 0 8px;
}

/* 输入区域 */
.chat-input-area {
    padding: 15px 25px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
}

.msg-form {
    display: flex;
    gap: 12px;
}

.msg-form input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e8e8e8;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
}

.msg-form input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.btn-send {
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* ========== 管理后台 ========== */
.admin-body {
    background: #f0f2f5;
    min-height: 100vh;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.admin-header h1 {
    font-size: 28px;
    color: #1a1a2e;
}

.btn-back {
    padding: 10px 20px;
    background: #fff;
    color: #667eea;
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #e8e8e8;
    transition: all 0.3s;
}

.btn-back:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 14px;
    color: #888;
    margin-top: 6px;
}

.admin-section {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.admin-section h2 {
    font-size: 20px;
    color: #1a1a2e;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #fafafa;
    padding: 14px 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #f0f0f0;
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
}

.data-table tr:hover td {
    background: #fafafa;
}

.ip-cell {
    font-family: monospace;
    color: #667eea;
    font-size: 13px;
}

.msg-cell {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 响应式 */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 200px;
    }
    
    .msg-content {
        max-width: 70%;
    }
    
    .admin-stats {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        display: none;
    }
    
    .auth-card {
        padding: 30px 25px;
    }
    
    .admin-stats {
        grid-template-columns: 1fr;
    }
}
