/**
 * Login Page - Apple-inspired Design
 * 遵循站点设计语言和苹果 Human Interface Guidelines
 */

/* Container */
.auth-container {
    min-height: 100vh;
    background-color: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 5vw, 40px);
}

/* Card */
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface-overlay);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: clamp(28px, 6vw, 40px);
    transition: all 0.3s var(--ease-1);
}

.auth-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Title */
.auth-title {
    font-size: clamp(24px, 4vw, 28px);
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin: 0 0 28px 0;
    letter-spacing: -0.022em;
    line-height: 1.2;
}

/* Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-input-group {
    position: relative;
}

/* Input */
.auth-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-surface);
    color: var(--text-primary);
    caret-color: var(--text-primary);
    letter-spacing: -0.016em;
    transition: all 0.2s var(--ease-1);
}

.auth-input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px var(--accent-tint-10);
    background-color: var(--color-surface);
}

.auth-input::placeholder {
    color: var(--text-gray);
    opacity: 0.6;
}

/* Submit Button */
.auth-submit-btn {
    width: 100%;
    background-color: var(--brand-blue);
    color: var(--text-light);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.016em;
    padding: 12px 24px;
    border: none;
    border-radius: 980px;
    cursor: pointer;
    transition: all 0.3s var(--ease-1);
    margin-top: 8px;
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

.auth-submit-btn:hover {
    background-color: var(--brand-blue-strong);
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.auth-submit-btn:active {
    transform: scale(0.98);
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-gray);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 0.5px solid var(--color-border);
}

.auth-divider span {
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.016em;
}

/* Social Buttons */
.auth-social-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-surface);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.016em;
    cursor: pointer;
    transition: all 0.2s var(--ease-1);
    -webkit-tap-highlight-color: transparent;
}

.auth-social-btn:hover {
    background-color: var(--surface-subtle);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.auth-social-btn i {
    font-size: 20px;
}

.auth-social-btn.google i {
    color: #ea4335;
}

.auth-social-btn.facebook i {
    color: #1877f2;
}

.auth-social-btn.reddit i {
    color: #FF4500;
}

/* Options (Remember Me & Forgot Password) */
.auth-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.auth-options .auth-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-blue);
    text-decoration: none;
    letter-spacing: -0.016em;
    transition: all 0.2s var(--ease-1);
    padding: 4px 8px;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}

.auth-options .auth-link:hover {
    color: var(--brand-blue-strong);
    background: var(--surface-subtle);
}

.auth-remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

.auth-remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.auth-remember-me label {
    font-size: 13px;
    color: var(--text-gray);
    font-weight: 500;
    letter-spacing: -0.016em;
    cursor: pointer;
    user-select: none;
}

/* Terms/Policies consent */
.auth-terms {
    margin: 12px 0 0;
    padding: 12px;
    background: var(--surface-subtle);
    border-radius: 8px;
    border: none;
}

.auth-terms-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
    color: var(--text-gray);
}
.auth-terms-item input[type="checkbox"] {
    /* Remove offset to align neatly with multi-line text */
    margin-top: 0;
    width: 18px;
    height: 18px;
    min-width: 18px; /* prevent flex shrink */
    min-height: 18px; /* prevent flex shrink */
    flex: 0 0 18px;   /* keep fixed size */
    flex-shrink: 0;   /* do not shrink when text wraps */
    align-self: flex-start;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    cursor: pointer;
}

/* Normalize checkbox appearance and size across browsers on auth pages */
.auth-card input[type="checkbox"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    accent-color: initial;
    width: 18px;
    height: 18px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background-color: var(--color-surface);
    background-image: none;
    display: inline-block;
    position: relative;
    vertical-align: middle;
    box-sizing: border-box;
    background-clip: padding-box;
    transform: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-card input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint-10);
}

.auth-card input[type="checkbox"]:checked {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
}

.auth-card input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 9px;
    border: solid var(--text-light);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Extra specificity to defeat UA/native styles that might sneak in */
.auth-remember-me input[type="checkbox"],
.auth-terms-item input[type="checkbox"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
    accent-color: initial !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 6px !important;
}
.auth-terms-item span,
.auth-terms-item label {
    font-size: 13px;
    letter-spacing: -0.016em;
}

/* Let text occupy remaining width and wrap without squeezing the checkbox */
.auth-terms-item span {
    flex: 1 1 auto;
    word-break: break-word;
}

.auth-terms-item a {
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s var(--ease-1);
}

.auth-terms-item a:hover {
    color: var(--brand-blue-strong);
    text-decoration: underline;
}

.auth-forgot-password {
    display: flex;
    align-items: center;
}

.auth-forgot-password .auth-link {
    font-size: 14px;
    color: var(--brand-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-forgot-password .auth-link:hover {
    color: var(--brand-blue-strong);
    text-decoration: underline;
}

.auth-input-group {
    position: relative;
}

/* Password Toggle */
.auth-password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-gray);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s var(--ease-1);
    -webkit-tap-highlight-color: transparent;
}

.auth-password-toggle:hover {
    color: var(--text-primary);
    background: var(--surface-subtle);
}

.auth-password-toggle i {
    font-size: 18px;
}

/* 确保密码输入框右侧有足够空间放置图标 */
.auth-input[type="password"],
.auth-input-group input[type="password"] {
    padding-right: 46px;
}

/* Prevent dark autofill background and ensure readable text */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text) !important;
    caret-color: var(--color-text);
    transition: background-color 9999s ease-in-out 0s;
    box-shadow: 0 0 0px 1000px var(--color-surface) inset;
}

/* Add error message styling */
.auth-error-message {
    color: var(--status-danger);
    background-color: var(--status-danger-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
    transition: opacity 0.3s ease;
}

/* Add loading state for buttons */
.auth-submit-btn.loading,
.auth-social-btn.loading {
    position: relative;
    color: transparent !important;
}

.auth-submit-btn.loading::after,
.auth-social-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--text-light);
    border-radius: 50%;
    border-right-color: transparent;
    animation: button-loading-spinner 0.75s linear infinite;
}

@keyframes button-loading-spinner {
    from {
        transform: rotate(0turn);
    }
    to {
        transform: rotate(1turn);
    }
}

/* 在现有的社交按钮样式后添加 TikTok 样式 */
.auth-social-btn.tiktok i {
    color: #000000; /* TikTok 图标颜色 */
}

/* 可选：添加 TikTok 特殊样式 */
.auth-social-btn.tiktok {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
}

.auth-social-btn.tiktok:hover {
    background-color: var(--bg-dark-secondary);
}

/* 添加成功消息样式 */
.auth-success-message {
    color: var(--status-success);
    background-color: var(--status-success-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
}

/* 添加输入框错误样式 */
.auth-input-error {
    border-color: var(--status-danger) !important;
    box-shadow: 0 0 0 4px var(--status-danger-bg) !important;
    animation: shake 0.5s linear;
}

/* 为字段级别的错误消息添加样式 */
.field-error {
    color: var(--status-danger);
    font-size: 13px;
    margin-top: 4px;
    padding-left: 4px;
    display: block;
    animation: fadeIn 0.3s ease;
}

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

@keyframes shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

/* 确保错误消息显示在表单下方 */
#errorMessage {
    margin-top: 1rem;
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    width: 90%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    z-index: 100;
}

/* 为forgot_password和reset_password页面的消息容器添加样式 */
.auth-message-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 400px;
    min-width: 300px;
    padding: 20px 24px;
    border-radius: 12px;
    font-size: 16px;
    text-align: center;
    transition: all 0.3s ease;
    display: none;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    font-weight: 500;
    line-height: 1.4;
}

.auth-message-info {
    color: var(--status-info);
    background-color: var(--status-info-bg);
    border: 1px solid var(--color-border);
}

.auth-message-success {
    color: var(--status-success);
    background-color: var(--status-success-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
}

.auth-message-error {
    color: var(--status-danger);
    background-color: var(--status-danger-bg);
    border: 1px solid var(--color-border);
}

.auth-message-container.show {
    display: block !important;
    animation: messageSlideIn 0.3s ease-out;
}

.auth-message-container.hide {
    animation: messageSlideOut 0.3s ease-in;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes messageSlideOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

.auth-description {
    font-size: 16px;
    color: var(--color-muted);
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
}

.auth-links .auth-link {
    color: var(--brand-blue);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.auth-links .auth-link:hover {
    color: var(--brand-blue-strong);
    text-decoration: underline;
}

/* Consent Modal */
.auth-modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    padding: 20px;
}

.auth-modal-card {
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    background: var(--surface-overlay);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    color: var(--text-primary);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.auth-modal-title {
    font-size: 19px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.022em;
    margin: 0 0 12px;
    flex-shrink: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.auth-modal-message {
    font-size: 15px;
    color: var(--text-gray);
    letter-spacing: -0.016em;
    margin: 0 0 20px;
    line-height: 1.47;
    flex: 1;
    min-height: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-y: auto;
}

.auth-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.auth-modal-btn {
    border-radius: 980px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.016em;
    padding: 8px 20px;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--surface-subtle);
    color: var(--text-primary);
    transition: all 0.2s var(--ease-1);
    -webkit-tap-highlight-color: transparent;
}

.auth-modal-primary {
    background: var(--brand-blue);
    color: var(--text-light);
    border-color: var(--brand-blue);
    font-weight: 600;
}

.auth-modal-primary:hover {
    background: var(--brand-blue-strong);
    transform: scale(1.02);
}

.auth-modal-secondary:hover {
    background: var(--surface-hover);
}

/* Responsive Design */
@media (max-width: 734px) {
    .auth-container {
        padding: clamp(20px, 4vw, 32px);
    }

    .auth-card {
        padding: clamp(24px, 5vw, 32px);
    }

    .auth-title {
        font-size: 24px;
        margin-bottom: 24px;
    }

    .auth-form {
        gap: 14px;
    }

    .auth-divider {
        margin: 20px 0;
    }

    .auth-social-buttons {
        gap: 10px;
    }

    .auth-terms {
        padding: 10px;
    }

    /* Modal 响应式 */
    .auth-modal-card {
        max-height: 80vh;
        padding: 20px;
    }

    .auth-modal-title {
        font-size: 17px;
    }

    .auth-modal-message {
        font-size: 14px;
    }

    .auth-modal-actions {
        gap: 8px;
    }

    .auth-modal-btn {
        font-size: 14px;
        padding: 8px 16px;
    }
}

@media (max-width: 374px) {
    .auth-card {
        padding: 20px;
    }

    .auth-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .auth-input[type="password"],
    .auth-input-group input[type="password"] {
        padding-right: 42px;
    }

    .auth-submit-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .auth-social-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Modal 小屏优化 */
    .auth-modal-card {
        max-height: 75vh;
        padding: 16px;
        margin: 16px;
    }

    .auth-modal-title {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .auth-modal-message {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .auth-modal-btn {
        font-size: 13px;
        padding: 7px 14px;
    }

    .auth-modal-actions {
        flex-direction: column;
    }

    .auth-modal-actions .auth-modal-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .auth-message-container {
        max-width: 90vw;
        min-width: 280px;
        padding: 16px 20px;
        font-size: 15px;
        margin: 0 16px;
    }
}

/* Accessibility */
*:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
