/**
 * SSG 公共样式 - 登录/注册弹窗 + 用户区域
 *
 * 抽取自 ArticleContentTemplate / TutorialOverviewTemplate / VipPageTemplate 中高度重复的 modal-* 与 user-area 样式。
 * 默认主色为蓝色(#1677ff)；VIP 页等需切换主色时，在页面 <style> 中覆盖 :root 变量即可。
 *
 * 依赖：无
 * 引入：SharedSnippet.cssTags()
 */

/* ---- 主题色变量（页面可在 <style> 中覆盖以切换主题） ---- */
:root {
    /* 品牌色 — 暖黄色系（全站主色） */
    --primary-color: #FA8C16;      /* 主色：橙-暖黄（antd 金盏花色） */
    --primary-hover: #D46B08;      /* hover/深色状态 */
    --primary-light: #FFF7E6;      /* 浅色背景 */
    --primary-border: #FFE7BA;     /* 边框色 */

    /* ===== 通用主题色（全站统一配色，改一处可全局切换） =====
     * 若需切换全站主色调，只需修改下方 --theme-* 一组变量即可
     * 当前：暖黄温馨主题（温暖舒适，学习/阅读场景）
     */
    --theme-primary: #FA8C16;      /* 品牌主色：按钮、链接、标签、高亮 */
    --theme-hover: #D46B08;        /* hover/深色状态：按钮按下、链接hover */
    --theme-light: #FFF7E6;        /* 浅色背景：hover背景、标签底、高亮块 */
    --theme-border: #FFD591;       /* 边框色：浅黄分割线、选中边框 */
    --theme-accent: #FFC069;       /* 亮色调：渐变过渡色、图标亮色 */
    --theme-gradient: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-accent) 100%); /* 主渐变 */
    --theme-shadow: 0 8px 24px rgba(250, 140, 22, 0.15); /* 主题色阴影 */
    --theme-glow: 0 0 0 3px rgba(250, 140, 22, 0.12);   /* 主题色外发光（focus状态） */

    /* 语义色 */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #FA8C16;
    --warning-light: #FFF7E6;
    --danger: #EF4444;
    --danger-light: #FEE2E2;

    /* 中性色 - 暖黄温馨风：整体底色、卡片底色改为暖白 */
    --bg: #FFFBF3;                 /* 页面底色：极浅暖白（奶咖色） */
    --surface: #FFFFFF;            /* 卡片底色：纯白（上面叠暖阴影即可） */
    --surface-alt: #FFF7E6;        /* 备选表面：浅米黄（标签、侧栏选中背景） */
    --border: #FFE7BA;             /* 边框色：暖黄浅边 */
    --text-primary: #1d2129;       /* 主文字色：接近黑但不刺眼 */
    --text-secondary: #4e5969;
    --text-tertiary: #86909c;
}

/* ---- 登录/注册弹窗 ---- */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-overlay.active { display: flex; }
.modal-box { background: var(--surface); border-radius: 12px; padding: 32px; width: 400px; max-width: 90vw; position: relative; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 24px; color: var(--text-tertiary); cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }
.modal-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 24px; text-align: center; }
.modal-field { margin-bottom: 16px; }
.modal-field label { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }
.modal-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; box-sizing: border-box; }
.modal-field input:focus { border-color: var(--primary-color); outline: none; }

/* ---- 表单字段：输入框 + 按钮（如短信验证码） ---- */
.field-with-btn {
    display: flex;
    align-items: center;
    gap: 10px;
}
.field-with-btn input {
    flex: 1;
    min-width: 0;
}
.field-btn {
    flex-shrink: 0;
    padding: 10px 14px;
    background: var(--brand-soft, #E8FBF2);
    color: var(--brand, #07C160);
    border: 1px solid var(--brand, #07C160);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.field-btn:hover:not(:disabled) {
    background: var(--brand, #07C160);
    color: #fff;
}
.field-btn:disabled {
    background: var(--border);
    color: var(--text-caption);
    border-color: var(--border);
    cursor: not-allowed;
}
.modal-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.modal-btn { width: 100%; padding: 10px; background: var(--primary-color); color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; }
.modal-btn:hover { background: var(--primary-hover); }
.modal-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; }
.modal-link { color: var(--primary-color); cursor: pointer; font-size: 13px; text-decoration: none; }
.modal-link:hover { text-decoration: underline; }
.modal-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-tertiary); }

/* ---- 登录/注册同意协议勾选区 ---- */
.modal-agree-area {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.modal-agree-area input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
}
.modal-agree-area label {
    cursor: pointer;
}
.modal-agree-area a {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
}
.modal-agree-area a:hover {
    text-decoration: underline;
}
.modal-agree-area.error label {
    color: var(--danger);
}

/* ---- 微信扫码登录按钮（弹窗内，放在账号密码表单上方） ---- */
.modal-wechat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: #07c160;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 16px;
}
.modal-wechat-btn:hover { background: #06ad56; }
.modal-wechat-btn:disabled { background: #a0d8b4; cursor: not-allowed; }
.modal-wechat-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ---- 登录弹窗：掘金风格左右分栏（左微信扫码 + 右账号密码） ---- */
.modal-box-login {
    width: 620px;
    max-width: 95vw;
    padding: 28px 32px;
}

/* 左右分栏容器 */
.login-split {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 12px;
}

/* ---- 左侧：微信扫码区域 (38% 黄金分割) ---- */
.login-qr-side {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 0;
}

/* ---- 全宽模式（仅微信扫码登录时使用）---- */
.login-qr-side-full {
    flex: 1 1 auto;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    padding: 8px 0;
}
.login-qr-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 12px;
    padding: 8px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
/* 加载状态 */
.login-qr-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-tertiary);
    font-size: 13px;
    background: #fff;
    z-index: 1;
}
.modal-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: #07c160;
    border-radius: 50%;
    animation: qrcode-spin 0.8s linear infinite;
}
@keyframes qrcode-spin {
    to { transform: rotate(360deg); }
}
/* 二维码图片 */
.login-qr-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}
/* 微信LOGO水印（叠加在二维码中心） */
.login-qr-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}
.login-qr-logo svg {
    width: 32px;
    height: 32px;
}
/* 二维码过期/失败遮罩（仅过期时显示） */
.login-qr-mask {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    z-index: 4;
    transition: background 0.2s;
    border-radius: 12px;
}
.login-qr-mask:hover {
    background: rgba(255, 255, 255, 0.9);
}
.login-qr-mask-icon {
    font-size: 32px;
    color: var(--text-tertiary);
    line-height: 1;
}
.login-qr-mask-text {
    font-size: 14px;
    color: var(--text-secondary);
}
.login-qr-mask-refresh {
    font-size: 13px;
    color: #07c160;
    font-weight: 500;
}
/* 二维码下方提示文字 */
.login-qr-tip {
    margin-top: 16px;
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}
.login-qr-tip strong {
    color: #07c160;
    font-weight: 600;
    font-size: 16px;
}
.login-qr-subtip {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

/* ---- 垂直分隔线 ---- */
.login-divider-v {
    width: 1px;
    background: linear-gradient(180deg, transparent, var(--border) 20%, var(--border) 80%, transparent);
    margin: 0 20px;
    flex-shrink: 0;
}

/* ---- 右侧：账号密码表单 ---- */
.login-form-side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 4px;
}
.login-form-side .modal-field {
    margin-bottom: 14px;
}
.login-form-side .modal-field label {
    font-size: 13px;
}
.login-form-side .modal-field input {
    padding: 10px 12px;
    font-size: 14px;
}

/* ---- 记住我/忘记密码行 ---- */
.login-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 12px;
    gap: 8px;
}
.login-remember {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.login-remember input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #07c160;
    cursor: pointer;
    flex-shrink: 0;
}
.login-forgot {
    color: var(--text-tertiary);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.login-forgot:hover {
    color: #07c160;
}

/* ---- 底部注册链接 ---- */
.login-footer-split {
    text-align: center;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-tertiary);
}
.login-footer-split .modal-link {
    color: #07c160;
    font-weight: 500;
}

/* ---- 响应式：窄屏切换为上下布局 ---- */
@media (max-width: 660px) {
    .modal-box-login { width: 95vw; padding: 20px; }
    .login-split {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .login-qr-side {
        flex: none;
        padding: 0;
    }
    .login-qr-wrap {
        width: 180px;
        height: 180px;
    }
    .login-divider-v {
        width: 80%;
        height: 1px;
        margin: 0;
    }
    .login-form-side {
        width: 100%;
        padding-top: 0;
    }
}

/* ---- 顶部用户区（参照 imooc.com：水平文字链接 "登录 / 注册"） ---- */
.user-area { display: flex; align-items: center; gap: 0; margin-left: auto; flex-shrink: 0; }
/* 水平文字链接样式 */
.user-auth-link { color: var(--text-secondary); text-decoration: none; padding: 0 8px; font-size: 15px; cursor: pointer; transition: color 0.2s; white-space: nowrap; line-height: 72px; }
.user-auth-link:hover { color: var(--primary-color); }
.user-auth-divider { color: var(--border); font-size: 14px; user-select: none; }
/* 兼容旧版按钮样式（仅在其他页面使用按钮时生效） */
.top-btn { padding: 8px 22px; font-size: 15px; color: var(--text-secondary); background: var(--surface-alt); border: none; border-radius: 20px; cursor: pointer; transition: all 0.2s; }
.top-btn:hover { background: var(--primary-light); color: var(--primary-color); }
.top-btn-primary { background: var(--primary-color); color: #fff; }
.top-btn-primary:hover { background: var(--primary-hover); color: #fff; }
.user-info-wrapper { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--primary-light); color: var(--primary-color); font-size: 18px; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-nickname { font-size: 15px; color: var(--text-primary); font-weight: 500; cursor: pointer; }

/* ---- 用户下拉菜单（参照第二张图：头像+下拉箭头→弹出菜单） ---- */
.user-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}
.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px 4px 4px;
    border-radius: 20px;
    transition: background 0.2s;
}
.user-dropdown-trigger:hover {
    background: var(--primary-light);
}
/* 下拉箭头 */
.user-dropdown-arrow {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}
.user-dropdown-trigger:hover .user-dropdown-arrow {
    color: var(--primary-color);
}
/* 下拉菜单面板 */
.user-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border);
    z-index: 300;
    overflow: hidden;
    animation: userMenuFadeIn 0.18s ease;
}
.user-dropdown-menu.active {
    display: block;
}
@keyframes userMenuFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
/* 下拉菜单顶部 — 大头像+昵称 */
.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}
.user-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--primary-color);
    font-size: 18px;
    flex-shrink: 0;
}
.user-dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-dropdown-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 下拉菜单项 */
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}
.user-dropdown-item:hover {
    background: var(--surface-alt);
    color: var(--primary-color);
}
.user-dropdown-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 15px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.user-dropdown-item:hover .user-dropdown-icon {
    color: var(--primary-color);
}
/* 分隔线 */
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
/* 退出登录项 — 红色文字 */
.user-dropdown-logout {
    color: var(--danger);
}
.user-dropdown-logout:hover {
    background: var(--danger-light);
    color: var(--danger);
}
.user-dropdown-logout .user-dropdown-icon {
    color: var(--danger);
}
