:root {
    --primary-color: #ff930c;
    --primary-hover: #e8840b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --gray-25: #fcfcfd;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --purple-600: #7c3aed;
    --orange-600: #ea580c;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Enable automatic spacing between CJK and non-CJK characters where supported */
html, body { text-autospace: normal; }

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--gray-50);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-800);
    line-height: 1.5;
    font-size: 14px;
    
    /* iPhone 刘海屏安全区域处理 */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.login-container {
    width: 100%;
    max-width: 520px;
    padding: 24px;
    /* iPhone 刘海屏安全区域处理 */
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
}

.login-card {
    background: white;
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 48px 44px;
    text-align: center;
    border: 1px solid var(--gray-200);
}

.logo-section {
    margin-bottom: 40px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: transparent;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-icon i {
    font-size: 28px;
    color: white;
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: #ff930c;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.app-subtitle {
    color: var(--gray-500);
    font-size: 16px;
    margin: 0;
    font-weight: 400;
    line-height: 1.4;
}

.security-notice {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--border-radius);
    padding: 16px 20px;
    margin: 20px 0 32px 0;
    font-size: 14px;
    color: var(--info-color);
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.4;
    text-align: left !important;
    white-space: nowrap;
    overflow: hidden;
}

.security-notice i {
    color: var(--info-color);
    font-size: 16px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.security-notice span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-label {
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 8px;
    display: block;
}

.form-control {
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-300);
    padding: 12px 16px;
    font-size: 15px;
    line-height: 22px;
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    background: white;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 147, 12, 0.08);
    outline: none;
}

.password-input-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 200ms ease;
    -webkit-tap-highlight-color: transparent;
}

.password-toggle:hover {
    color: var(--gray-600);
}

.password-toggle:focus {
    outline: none;
    box-shadow: none;
}

.password-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--gray-100), 0 0 0 4px var(--primary-color);
    color: var(--gray-600);
}

.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    padding: 12px 24px;
    border: 1px solid transparent;
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    gap: 8px;
    letter-spacing: -0.01em;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    margin-top: 12px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
    transform: none;
    box-shadow: none;
}

/* 移除所有focus状态的默认样式 */
.btn-primary:focus,
.btn:focus {
    outline: none !important;
    box-shadow: none !important;
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* 只在键盘导航时显示焦点样式 */
.btn-primary:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px var(--gray-100), 0 0 0 6px var(--primary-color) !important;
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.btn-primary:active {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: white !important;
    transform: translateY(0) !important;
    box-shadow: none !important;
}

.error-message {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fca5a5;
    border-radius: var(--border-radius);
    padding: 14px 16px;
    margin-bottom: 24px;
    font-size: 14px;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: errorShake 0.6s ease-in-out;
    text-align: left;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

.error-message i {
    font-size: 16px;
    color: #dc2626;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.success-message {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #86efac;
    border-radius: var(--border-radius);
    padding: 14px 16px;
    margin-bottom: 24px;
    font-size: 14px;
    color: #059669;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.success-message i {
    font-size: 16px;
    color: #059669;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.warning-message {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    border-radius: var(--border-radius);
    padding: 14px 16px;
    margin-bottom: 24px;
    font-size: 14px;
    color: #d97706;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}

.warning-message i {
    font-size: 16px;
    color: #d97706;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-danger {
    background: #fef2f2;
    color: #dc2626;
}

.alert-success {
    background: #f0fdf4;
    color: #059669;
}

.alert-info {
    background: #eff6ff;
    color: var(--info-color);
}

.login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-500);
    font-size: 13px;
}

.footer-text {
    margin: 0;
}

.footer-heart {
    color: #ef4444;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes errorShake {
    0%, 20%, 40%, 60%, 80%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
}

.form-control.error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    animation: errorShake 0.6s ease-in-out;
}

.form-control.error:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

/* 响应式设计 */
@media (max-width: 576px) {
    .login-container {
        padding: 16px;
        max-width: 100%;
    }

    .login-card {
        padding: 32px 24px;
    }
    
    .logo-section {
        margin-bottom: 28px;
    }
    
    .logo-icon {
        width: 56px;
        height: 56px;
        margin: 0 auto 16px;
    }
    
    .app-title {
        font-size: 24px;
    }
    
    .app-subtitle {
        font-size: 15px;
    }
    
    .security-notice {
        padding: 14px 16px;
        font-size: 13px;
        margin: 16px 0 28px 0;
        white-space: nowrap;
        overflow: hidden;
        gap: 10px;
    }
    
    .security-notice i {
        font-size: 14px;
        width: 14px;
    }
    
    .security-notice span {
        font-size: 13px;
    }
    
    .error-message,
    .success-message,
    .warning-message {
        gap: 10px;
    }
    
    .error-message i,
    .success-message i,
    .warning-message i {
        font-size: 14px;
        width: 14px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 12px;
    }

    .security-notice {
        padding: 12px 14px;
        font-size: 12px;
        gap: 8px;
    }
    
    .security-notice i {
        font-size: 12px;
        width: 12px;
    }
    
    .security-notice span {
        font-size: 12px;
    }
    
    .error-message,
    .success-message,
    .warning-message {
        gap: 8px;
        padding: 12px 14px;
        font-size: 12px;
    }
    
    .error-message i,
    .success-message i,
    .warning-message i {
        font-size: 12px;
        width: 12px;
    }
}

/* Phone: the 16px floor. Under 16px, iOS Safari zooms the page when the
   field takes focus and stays zoomed after it is blurred — on the login
   form that means the first thing the app does is misplace itself. */
@media (max-width: 767px) {
    .form-control { font-size: 16px; }
}
