* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    font-size: 16px;
}

@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }
}

@media (min-width: 1200px) {
    :root {
        font-size: 18px;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.admin-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

.sidebar {
    width: clamp(200px, 30vw, 280px);
    background: #fff;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.sidebar-header {
    padding: clamp(12px, 2.5vw, 16px);
    background: #07c160;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 500;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.empty-users {
    padding: clamp(20px, 5vw, 30px);
    text-align: center;
    color: #999;
    font-size: clamp(13px, 3.5vw, 14px);
}

.user-item {
    padding: clamp(10px, 2.5vw, 12px) clamp(12px, 3vw, 16px);
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.user-item:hover {
    background: #f5f5f5;
}

.user-item.active {
    background: #e8f5e9;
    border-left: 3px solid #07c160;
}

.user-info {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.user-name {
    font-size: clamp(14px, 3.5vw, 15px);
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: clamp(11px, 2.5vw, 12px);
    color: #999;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 8px);
    flex-shrink: 0;
}

.unread-badge {
    background: #ff4444;
    color: #fff;
    border-radius: 10px;
    padding: 2px clamp(6px, 1.5vw, 8px);
    font-size: clamp(11px, 2.5vw, 12px);
    min-width: 20px;
    text-align: center;
}

.delete-btn {
    width: clamp(20px, 5vw, 24px);
    height: clamp(20px, 5vw, 24px);
    border-radius: 50%;
    background: #ff4444;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

.delete-btn:hover {
    background: #ff0000;
    transform: scale(1.1);
}

.delete-btn:active {
    transform: scale(0.95);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-width: 0;
}

.chat-header {
    padding: clamp(10px, 2.5vw, 12px) clamp(12px, 3vw, 16px);
    background: #07c160;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
    min-height: 56px;
}

.header-info {
    flex: 1;
}

.name {
    font-size: clamp(14px, 4vw, 16px);
    font-weight: 500;
    margin-bottom: 2px;
}

.status {
    font-size: clamp(11px, 2.5vw, 12px);
    opacity: 0.9;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(12px, 3vw, 16px);
    background: #ededed;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.welcome-message {
    text-align: center;
    color: #999;
    padding: clamp(20px, 5vw, 40px);
    font-size: clamp(13px, 3.5vw, 14px);
}

.message {
    display: flex;
    margin-bottom: clamp(12px, 3vw, 16px);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    justify-content: flex-end;
}

.message.other {
    justify-content: flex-start;
}

.message-content {
    max-width: min(70%, 500px);
    padding: clamp(8px, 2vw, 14px);
    border-radius: 8px;
    word-wrap: break-word;
    position: relative;
}

.message.own .message-content {
    background: #95ec69;
    border-top-right-radius: 2px;
}

.message.other .message-content {
    background: #fff;
    border-top-left-radius: 2px;
}

.message-text {
    font-size: clamp(14px, 3.5vw, 15px);
    line-height: 1.5;
    color: #333;
    word-break: break-word;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    margin-top: 4px;
    cursor: pointer;
    object-fit: contain;
}

.message-time {
    font-size: clamp(10px, 2.5vw, 11px);
    color: #999;
    margin-top: 4px;
}

.chat-input-container {
    display: flex;
    align-items: center;
    padding: clamp(8px, 2vw, 12px);
    background: #fff;
    border-top: 1px solid #e5e5e5;
    gap: clamp(6px, 1.5vw, 8px);
    flex-shrink: 0;
    min-height: 60px;
}

.input-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.image-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(32px, 8vw, 36px);
    height: clamp(32px, 8vw, 36px);
    color: #07c160;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.image-btn:hover {
    background: #f0f0f0;
}

.image-btn:active {
    background: #e0e0e0;
}

.image-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
}

#messageInput {
    flex: 1;
    padding: clamp(8px, 2vw, 12px);
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: clamp(14px, 3.5vw, 15px);
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

#messageInput:focus {
    border-color: #07c160;
}

#messageInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

#sendBtn {
    padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 20px);
    background: #07c160;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: clamp(14px, 3.5vw, 15px);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

#sendBtn:hover:not(:disabled) {
    background: #06ad56;
}

#sendBtn:active:not(:disabled) {
    background: #059c4d;
}

#sendBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Toast弹窗样式 */
.toast-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s;
}

.toast-content {
    background: #fff;
    border-radius: 8px;
    padding: clamp(20px, 5vw, 24px);
    min-width: min(280px, 80vw);
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-message {
    font-size: clamp(15px, 4vw, 16px);
    color: #333;
    margin-bottom: clamp(16px, 4vw, 20px);
    text-align: center;
}

.toast-actions {
    display: flex;
    gap: clamp(10px, 2.5vw, 12px);
    justify-content: center;
}

.toast-btn {
    padding: clamp(8px, 2vw, 10px) clamp(20px, 5vw, 24px);
    border: none;
    border-radius: 6px;
    font-size: clamp(14px, 3.5vw, 15px);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 80px;
}

.toast-btn-cancel {
    background: #f5f5f5;
    color: #333;
}

.toast-btn-cancel:hover {
    background: #e0e0e0;
}

.toast-btn-confirm {
    background: #ff4444;
    color: #fff;
}

.toast-btn-confirm:hover {
    background: #ff0000;
}

.toast-btn:active {
    transform: scale(0.95);
}

/* 登录界面样式 */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: clamp(30px, 6vw, 40px);
    width: min(90%, 400px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s;
}

.login-header {
    text-align: center;
    margin-bottom: clamp(24px, 5vw, 30px);
}

.login-header h2 {
    font-size: clamp(20px, 5vw, 24px);
    color: #333;
    margin-bottom: 8px;
    font-weight: 600;
}

.login-header p {
    font-size: clamp(13px, 3.5vw, 14px);
    color: #666;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 4vw, 20px);
}

.login-form input {
    padding: clamp(12px, 3vw, 14px);
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: clamp(14px, 3.5vw, 16px);
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.login-form input:focus {
    border-color: #07c160;
}

.login-form button {
    padding: clamp(12px, 3vw, 14px);
    background: #07c160;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: clamp(15px, 4vw, 16px);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.login-form button:hover {
    background: #06ad56;
}

.login-form button:active {
    background: #059c4d;
    transform: scale(0.98);
}

.login-error {
    color: #ff4444;
    font-size: clamp(12px, 3vw, 13px);
    text-align: center;
    padding: 8px;
    background: #fff5f5;
    border-radius: 6px;
    display: none;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .admin-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: clamp(150px, 25vh, 200px);
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
        flex-shrink: 0;
    }
    
    .user-list {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .user-item {
        min-width: clamp(100px, 25vw, 120px);
        border-bottom: none;
        border-right: 1px solid #f0f0f0;
        flex-shrink: 0;
    }
    
    .message-content {
        max-width: min(85%, 400px);
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: min(90%, 350px);
    }
    
    .chat-messages {
        padding: clamp(10px, 2.5vw, 12px);
    }
}

/* 横屏适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        height: 100%;
        width: clamp(180px, 25vw, 220px);
    }
    
    .chat-header {
        padding: 8px 12px;
        min-height: 48px;
    }
    
    .chat-input-container {
        padding: 6px 8px;
        min-height: 50px;
    }
}
