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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.login-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

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

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px 30px;
    text-align: center;
}

.title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 16px;
    opacity: 0.9;
    font-weight: 300;
}

/* 表单容器 */
.form-container {
    padding: 40px 30px;
    display: none;
}

.form-container.active {
    display: block;
}

.form-container h2 {
    color: #333;
    margin-bottom: 30px;
    font-size: 24px;
    text-align: center;
}

/* 表单组 */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group > label:not(.checkbox-label) {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    pointer-events: none;
}

.icon {
    width: 20px;
    height: 20px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 15px 15px 15px 50px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    outline: none;
}

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

/* 复选框样式 */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    user-select: none;
    position: relative; /* 覆盖 form-group label 的 absolute 定位 */
    pointer-events: auto; /* 确保可以点击 */
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #667eea;
}

/* 按钮样式 */
.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

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

/* 表单底部 */
.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    margin-left: 5px;
}

.link:hover {
    text-decoration: underline;
}

/* 消息提示 */
.message {
    display: none;
    padding: 15px;
    margin: 0 30px 20px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.message.success {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    display: block;
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .login-box {
        border-radius: 15px;
    }

    .header {
        padding: 30px 20px 20px;
    }

    .title {
        font-size: 28px;
    }

    .subtitle {
        font-size: 14px;
    }

    .form-container {
        padding: 30px 20px;
    }

    .form-container h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
}

/* 加载动画 */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* 连接状态提示 */
.connection-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px 20px;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    max-width: 300px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.connection-status-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.connection-status.connecting .connection-icon {
    animation: spin 1s linear infinite;
    color: #667eea;
}

.connection-status.connected .connection-icon {
    color: #28a745;
}

.connection-status.error .connection-icon {
    color: #dc3545;
}

.connection-status.connecting #connectionStatusText {
    color: #667eea;
}

.connection-status.connected #connectionStatusText {
    color: #28a745;
}

.connection-status.error #connectionStatusText {
    color: #dc3545;
}

#connectionStatusText {
    font-size: 14px;
    font-weight: 500;
}
