/* ==========================================
   苹果风格现代登录界面
   支持响应式、暗色模式、流畅动画
   ========================================== */

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 颜色系统 */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    
    /* 中性色 */
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;
    
    /* 背景色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    
    /* 边框和分隔线 */
    --border-color: rgba(0, 0, 0, 0.08);
    --divider-color: rgba(0, 0, 0, 0.06);
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.16);
    
    /* 动画时长 */
    --duration-fast: 0.15s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;
    
    /* 缓动函数 */
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.6, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #636366;
        
        --bg-primary: #1c1c1e;
        --bg-secondary: #2c2c2e;
        --bg-tertiary: #3a3a3c;
        
        --border-color: rgba(255, 255, 255, 0.12);
        --divider-color: rgba(255, 255, 255, 0.08);
        
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.6);
    }
}

/* 全局样式 */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", 
                 "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", 
                 "Microsoft YaHei", sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ==========================================
   动态背景
   ========================================== */
.background-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.gradient-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        #667eea 0%, 
        #764ba2 50%, 
        #f093fb 100%
    );
    opacity: 1;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
        opacity: 0.9;
    }
}

.mesh-gradient {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(240, 147, 251, 0.2) 0%, transparent 50%);
    animation: meshMove 20s ease-in-out infinite;
}

@keyframes meshMove {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(5%, 5%) rotate(120deg);
    }
    66% {
        transform: translate(-5%, 5%) rotate(240deg);
    }
}

#particles-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.4;
}

/* ==========================================
   主容器
   ========================================== */
.login-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
    animation: fadeInUp 0.8s var(--ease-out);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Logo 区域
   ========================================== */
.logo-section {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeIn 1s var(--ease-out) 0.2s both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    animation: logoFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.logo-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.logo-title {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.logo-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* ==========================================
   登录卡片
   ========================================== */
.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: cardSlideIn 0.8s var(--ease-out) 0.3s both;
    transition: transform var(--duration-normal) var(--ease-out);
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-color-scheme: dark) {
    .login-card {
        background: rgba(28, 28, 30, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ==========================================
   表单样式
   ========================================== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    position: relative;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color var(--duration-normal) var(--ease-out);
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    height: 56px;
    padding: 0 48px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 14px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all var(--duration-normal) var(--ease-out);
    outline: none;
    position: relative;
}

.input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.input-wrapper input:focus {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}

.input-wrapper input:focus + .input-focus-border {
    opacity: 1;
    transform: scaleX(1);
}

.input-wrapper input:focus ~ .input-icon {
    color: var(--primary-color);
}

.input-focus-border {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
    border-radius: 2px;
    opacity: 0;
    transform: scaleX(0);
    transition: all var(--duration-normal) var(--ease-out);
    pointer-events: none;
}

/* 密码显示/隐藏按钮 */
.toggle-password {
    position: absolute;
    right: 16px;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast) var(--ease-out);
    z-index: 1;
}

.toggle-password:hover {
    color: var(--text-secondary);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.toggle-password .eye-closed {
    opacity: 0;
}

.toggle-password.active .eye-open {
    opacity: 0;
}

.toggle-password.active .eye-closed {
    opacity: 1;
}

/* ==========================================
   登录按钮
   ========================================== */
.btn-login {
    position: relative;
    width: 100%;
    height: 56px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    overflow: hidden;
    margin-top: 8px;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-login.loading {
    pointer-events: none;
}

.btn-login.loading .btn-text {
    opacity: 0;
}

.btn-login.loading .btn-loader {
    opacity: 1;
}

.btn-text {
    position: relative;
    z-index: 1;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    opacity: 0;
    animation: spin 0.8s linear infinite;
    transition: opacity var(--duration-normal) var(--ease-out);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 按钮波纹效果 */
.btn-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
}

.btn-login:active .btn-ripple {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    to {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* ==========================================
   页脚
   ========================================== */
.login-footer {
    margin-top: 24px;
    text-align: center;
}

.footer-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.copyright {
    margin-top: 32px;
    text-align: center;
    animation: fadeIn 1s var(--ease-out) 0.5s both;
}

.copyright p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* ==========================================
   响应式设计
   ========================================== */

/* 平板 */
@media (max-width: 768px) {
    .login-container {
        max-width: 400px;
    }
    
    .login-card {
        padding: 32px 28px;
        border-radius: 20px;
    }
    
    .logo-icon {
        width: 70px;
        height: 70px;
    }
    
    .logo-title {
        font-size: 28px;
    }
}

/* 手机 */
@media (max-width: 480px) {
    .login-wrapper {
        padding: 16px;
    }
    
    .login-container {
        max-width: 100%;
    }
    
    .logo-section {
        margin-bottom: 32px;
    }
    
    .logo-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 16px;
    }
    
    .logo-title {
        font-size: 26px;
    }
    
    .logo-subtitle {
        font-size: 14px;
    }
    
    .login-card {
        padding: 28px 24px;
        border-radius: 18px;
    }
    
    .input-wrapper input {
        height: 52px;
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }
    
    .btn-login {
        height: 52px;
        font-size: 16px;
    }
    
    .copyright {
        margin-top: 24px;
    }
}

/* 小屏手机 */
@media (max-width: 360px) {
    .login-card {
        padding: 24px 20px;
    }
    
    .input-wrapper input {
        padding: 0 44px;
    }
}

/* ==========================================
   触摸设备优化
   ========================================== */
@media (hover: none) and (pointer: coarse) {
    .btn-login:hover {
        transform: none;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    }
    
    .input-wrapper input:focus {
        transform: none;
    }
}

/* ==========================================
   无障碍支持
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .login-card {
        border: 2px solid var(--text-primary);
    }
    
    .input-wrapper input {
        border: 2px solid var(--text-secondary);
    }
}

/* ==========================================
   加载状态动画
   ========================================== */
.input-wrapper input.auto-filled {
    animation: inputPulse 0.6s var(--ease-out);
}

@keyframes inputPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
    }
}
