/**
 * 前台登录 / 注册页样式（仅 /login/ 与 /register/ 加载）。
 * 依赖 app.css 中的设计令牌（--sn-primary / --sn-radius-* / --sn-border）。
 */

.sn-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--sn-header-h, 72px) - 220px);
    padding: 36px 16px 56px;
}

.sn-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--sn-surface);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-radius-lg);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
    padding: 30px 28px 26px;
}

.sn-auth-brand {
    text-align: center;
    margin-bottom: 22px;
}

.sn-auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 700;
    color: var(--sn-text);
}

.sn-auth-logo img {
    max-height: 38px;
    width: auto;
    max-width: 190px;
}

.sn-auth-desc {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--sn-text-muted);
}

/* 登录 / 注册切换 */
.sn-auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: var(--sn-surface-muted);
    border-radius: var(--sn-radius-md);
}

.sn-auth-tab {
    text-align: center;
    padding: 9px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--sn-text-secondary);
    border-radius: calc(var(--sn-radius-md) - 3px);
    transition: background-color 0.16s ease, color 0.16s ease;
}

.sn-auth-tab:hover {
    color: var(--sn-primary);
}

.sn-auth-tab.is-active {
    background: var(--sn-surface);
    color: var(--sn-primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* 错误提示 */
.sn-auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.55;
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    border-radius: var(--sn-radius-sm);
}

.sn-auth-alert svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* 表单 */
.sn-auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sn-auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sn-auth-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--sn-text-secondary);
}

.sn-auth-input {
    width: 100%;
    height: 44px;
    padding: 0 13px;
    font-size: 14px;
    color: var(--sn-text);
    background: var(--sn-surface-muted);
    border: 1px solid var(--sn-border-strong);
    border-radius: var(--sn-radius-sm);
    transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.sn-auth-input::placeholder {
    color: var(--sn-text-muted);
}

.sn-auth-input:focus {
    outline: none;
    background: var(--sn-surface);
    border-color: var(--sn-primary);
    box-shadow: 0 0 0 3px rgba(32, 107, 231, 0.12);
}

/* 密码框 + 显隐按钮 */
.sn-auth-pwd {
    position: relative;
    display: block;
}

.sn-auth-pwd .sn-auth-input {
    padding-right: 44px;
}

.sn-auth-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sn-text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--sn-radius-sm);
    cursor: pointer;
}

.sn-auth-eye:hover,
.sn-auth-eye.is-on {
    color: var(--sn-primary);
}

/* 记住我 / 忘记密码 */
.sn-auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.sn-auth-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--sn-text-secondary);
    cursor: pointer;
    user-select: none;
}

.sn-auth-check input {
    width: 15px;
    height: 15px;
    accent-color: var(--sn-primary);
    cursor: pointer;
}

.sn-auth-link {
    color: var(--sn-primary);
    font-size: 13px;
}

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

.sn-auth-submit {
    width: 100%;
    height: 44px;
    margin-top: 4px;
    font-size: 15px;
    font-weight: 600;
}

/* 底部切换链接 */
.sn-auth-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--sn-border);
    font-size: 13px;
    color: var(--sn-text-muted);
}

.sn-auth-foot a {
    color: var(--sn-primary);
    font-weight: 600;
}

.sn-auth-foot a:hover {
    text-decoration: underline;
}

.sn-auth-back {
    margin-left: 4px;
    padding-left: 12px;
    border-left: 1px solid var(--sn-border);
    color: var(--sn-text-secondary) !important;
    font-weight: 400 !important;
}

.sn-auth-back:hover {
    color: var(--sn-primary) !important;
    text-decoration: none !important;
}

/* 暗色模式 */
html[data-theme="dark"] .sn-auth-card {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .sn-auth-alert {
    color: #ffb4ab;
    background: rgba(180, 35, 24, 0.16);
    border-color: rgba(255, 86, 69, 0.35);
}

html[data-theme="dark"] .sn-auth-tab.is-active {
    background: rgba(255, 255, 255, 0.08);
}

/* 窄屏 */
@media (max-width: 480px) {
    .sn-auth {
        padding: 22px 14px 40px;
        min-height: auto;
        align-items: flex-start;
    }

    .sn-auth-card {
        padding: 24px 18px 22px;
        border-radius: var(--sn-radius-md);
    }

    .sn-auth-input,
    .sn-auth-submit {
        height: 46px;
        font-size: 15px;
    }
}

/* ==========================================================================
   登录弹窗（任意页面唤起）
   ========================================================================== */
.sn-auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100030;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.sn-auth-modal[hidden] {
    display: none;
}

.sn-auth-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(2px);
    animation: sn-auth-fade 0.18s ease;
}

.sn-auth-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--sn-surface);
    border-radius: var(--sn-radius-lg);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
    padding: 28px 26px 22px;
    animation: sn-auth-pop 0.2s ease;
}

body.sn-auth-locked {
    overflow: hidden;
}

.sn-auth-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sn-text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--sn-radius-sm);
    cursor: pointer;
}

.sn-auth-modal-close:hover {
    color: var(--sn-text);
    background: var(--sn-surface-muted);
}

@keyframes sn-auth-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sn-auth-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sn-auth-modal-mask,
    .sn-auth-modal-dialog {
        animation: none;
    }
}

/* 弹窗内的提醒条：区分成功 / 警告 / 错误 */
.sn-auth-alert.is-success {
    color: #067647;
    background: #ecfdf3;
    border-color: #abefc6;
}

.sn-auth-alert.is-warning {
    color: #b54708;
    background: #fffaeb;
    border-color: #fedf89;
}

/* 社交登录 */
.sn-auth-social {
    margin-top: 18px;
}

.sn-social-login {
    margin: 0;
}

.sn-social-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--sn-text-muted);
}

.sn-social-divider::before,
.sn-social-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--sn-border);
}

.sn-social-btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sn-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1 1 auto;
    min-width: 88px;
    padding: 8px 10px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--sn-text);
    background: var(--sn-surface);
    border: 1px solid var(--sn-border-strong);
    border-radius: var(--sn-radius-sm);
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.sn-social-btn:hover {
    color: var(--sn-social-color, var(--sn-primary));
    border-color: var(--sn-social-color, var(--sn-primary));
    background: var(--sn-surface-muted);
}

.sn-social-btn svg {
    flex-shrink: 0;
    color: var(--sn-social-color, var(--sn-primary));
}

/* 弹窗底部切换 */
.sn-auth-switch {
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--sn-primary);
    background: transparent;
    border: 0;
    cursor: pointer;
}

.sn-auth-switch:hover {
    text-decoration: underline;
}

html[data-theme="dark"] .sn-auth-alert.is-success {
    color: #6ce9a6;
    background: rgba(6, 118, 71, 0.18);
    border-color: rgba(108, 233, 166, 0.35);
}

html[data-theme="dark"] .sn-auth-alert.is-warning {
    color: #fec84b;
    background: rgba(181, 71, 8, 0.18);
    border-color: rgba(254, 200, 75, 0.35);
}

@media (max-width: 480px) {
    .sn-auth-modal {
        align-items: flex-start;
        padding: 16px;
    }

    /* 触控热区不小于 40px */
    .sn-auth-modal-close {
        width: 40px;
        height: 40px;
        top: 6px;
        right: 6px;
    }

    .sn-auth-modal-dialog {
        padding: 24px 18px 20px;
        max-height: calc(100vh - 32px);
    }

    .sn-social-btn {
        min-width: 76px;
        font-size: 12px;
        padding: 7px 8px;
    }
}

/* 会员中心顶部的社交结果提示 */
.sn-uc-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin-bottom: 14px;
    padding: 11px 14px;
    font-size: 13px;
    line-height: 1.6;
    border-radius: var(--sn-radius-sm);
    border: 1px solid var(--sn-border-strong);
    background: var(--sn-surface-muted);
    color: var(--sn-text-secondary);
}

.sn-uc-notice strong {
    font-weight: 600;
    color: var(--sn-text);
}

.sn-uc-notice.is-success {
    color: #067647;
    background: #ecfdf3;
    border-color: #abefc6;
}

.sn-uc-notice.is-success strong {
    color: #05603a;
}

.sn-uc-notice.is-warning {
    color: #b54708;
    background: #fffaeb;
    border-color: #fedf89;
}

.sn-uc-notice.is-error {
    color: #b42318;
    background: #fef3f2;
    border-color: #fecdca;
}

html[data-theme="dark"] .sn-uc-notice.is-success {
    color: #6ce9a6;
    background: rgba(6, 118, 71, 0.16);
    border-color: rgba(108, 233, 166, 0.32);
}

html[data-theme="dark"] .sn-uc-notice.is-warning {
    color: #fec84b;
    background: rgba(181, 71, 8, 0.16);
    border-color: rgba(254, 200, 75, 0.32);
}

html[data-theme="dark"] .sn-uc-notice.is-error {
    color: #ffb4ab;
    background: rgba(180, 35, 24, 0.16);
    border-color: rgba(255, 86, 69, 0.32);
}

/* 个人资料页：第三方账号绑定 */
.sn-uc-box-desc {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--sn-text-muted);
}

.sn-social-bind-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sn-social-bind-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--sn-border);
}

.sn-social-bind-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.sn-social-bind-brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 104px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sn-text);
}

.sn-social-bind-brand svg {
    flex-shrink: 0;
    color: var(--sn-social-color, var(--sn-primary));
}

.sn-social-bind-state {
    flex: 1 1 auto;
    font-size: 12.5px;
    color: var(--sn-text-muted);
}

.sn-social-bind-state.is-bound {
    color: #067647;
}

.sn-social-bind-state.is-muted {
    opacity: 0.7;
}

.sn-social-bind-form {
    margin: 0;
}

html[data-theme="dark"] .sn-social-bind-state.is-bound {
    color: #6ce9a6;
}

@media (max-width: 480px) {
    .sn-social-bind-row {
        gap: 8px;
    }

    .sn-social-bind-brand {
        min-width: 84px;
    }
}

/* 关键：author CSS 的 display:flex 会覆盖浏览器对 [hidden] 的 display:none，
   导致登录与注册表单同时显示、空提示条占位。必须显式压制。 */
.sn-auth-modal[hidden],
.sn-auth-form[hidden],
.sn-auth-alert[hidden],
.sn-auth-foot > span[hidden],
.sn-auth-social[hidden] {
    display: none !important;
}
