﻿/* Quanova 用户网站样式（2026-10-06 OAuth 方案 §12：深色 + 高对比 + 单一强调色；手写 CSS，无框架）
   2026-10-08：加浅色主题——<html data-theme="dark|light"> 由站点主题 Cookie 决定；
   无 data-theme（主题 = 跟随系统）时交给 prefers-color-scheme 媒体查询。缺省深色（保持既有观感）。 */
:root,
html[data-theme="dark"] {
    --bg: #0f1115;
    --panel: #161922;
    --panel-2: #1d212c;
    --text: #e6e8ee;
    --muted: #9aa3b2;
    --accent: #6ea8fe;
    --accent-2: #7ee787;
    --danger: #ff7b72;
    --border: #262b38;
    --radius: 10px;
    --topbar-bg: rgba(15, 17, 21, .9);
    --on-accent: #0b0d12;
    --alert-error-bg: rgba(255, 123, 114, .12);
    --alert-error-border: rgba(255, 123, 114, .4);
    --alert-error-text: #ffb4ad;
    --alert-info-bg: rgba(110, 168, 254, .1);
    --alert-info-border: rgba(110, 168, 254, .35);
    --alert-info-text: #bcd4ff;
}

html[data-theme="light"] {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #eef1f5;
    --text: #1b1f27;
    --muted: #5b6573;
    --accent: #2563eb;
    --accent-2: #15803d;
    --danger: #d93025;
    --border: #dde1e8;
    --topbar-bg: rgba(255, 255, 255, .92);
    --on-accent: #ffffff;
    --alert-error-bg: rgba(217, 48, 37, .08);
    --alert-error-border: rgba(217, 48, 37, .35);
    --alert-error-text: #a52218;
    --alert-info-bg: rgba(37, 99, 235, .08);
    --alert-info-border: rgba(37, 99, 235, .3);
    --alert-info-text: #1d4ed8;
}

/* 主题 = 跟随系统：无 data-theme 时按系统偏好取浅色（深色沿用上面的 :root 默认） */
@media (prefers-color-scheme: light) {
    html:not([data-theme]) {
        --bg: #f6f7f9;
        --panel: #ffffff;
        --panel-2: #eef1f5;
        --text: #1b1f27;
        --muted: #5b6573;
        --accent: #2563eb;
        --accent-2: #15803d;
        --danger: #d93025;
        --border: #dde1e8;
        --topbar-bg: rgba(255, 255, 255, .92);
        --on-accent: #ffffff;
        --alert-error-bg: rgba(217, 48, 37, .08);
        --alert-error-border: rgba(217, 48, 37, .35);
        --alert-error-text: #a52218;
        --alert-info-bg: rgba(37, 99, 235, .08);
        --alert-info-border: rgba(37, 99, 235, .3);
        --alert-info-text: #1d4ed8;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.7;
    font-size: 14px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { border-bottom: 1px solid var(--border); background: var(--topbar-bg); }
.topbar-full .topbar-inner { max-width: none; }   /* 控制台顶栏全撑开（2026-10-09） */
.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-icon { width: 22px; height: 22px; border-radius: 6px; display: block; }

/* 用户名下拉（2026-10-08）：点用户名才展开「个人资料 / 退出登录」 */
.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.user-menu-trigger:hover { background: var(--panel-2); }
.user-menu-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { font-size: 9px; color: var(--muted); }
.user-menu-panel {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 180px; padding: 6px; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.user-menu.open .user-menu-panel { display: block; }
.user-menu-panel form { margin: 0; }
.user-menu-item {
    display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px;
    color: var(--text); font: inherit; font-size: 13px; background: none; border: none; cursor: pointer;
}
.user-menu-item:hover { background: var(--panel-2); text-decoration: none; }
.topbar-nav { display: flex; align-items: center; gap: 18px; font-size: 13px; }
.lang-switch a { color: var(--muted); margin-left: 8px; }
.lang-switch a.active { color: var(--text); font-weight: 600; }
.inline-form { display: inline; }
.link-button {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.link-button:hover { color: var(--text); }

.container {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 48px 28px 64px;
    flex: 1;
}

.auth-card {
    max-width: 420px;
    margin: 0 auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 32px 28px;
}
.auth-card h1 { margin: 0 0 20px; font-size: 20px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
    transition: border-color .15s ease;
}
.field input:focus { outline: none; border-color: var(--accent); }

.field-checkbox { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; color: var(--muted); font-size: 13px; }

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s ease, background .15s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); width: 100%; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--panel-2); }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; font-size: 13px; }
.alert-error { background: var(--alert-error-bg); border: 1px solid var(--alert-error-border); color: var(--alert-error-text); }
.alert-info { background: var(--alert-info-bg); border: 1px solid var(--alert-info-border); color: var(--alert-info-text); }

.hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; text-align: center; }
.hint-left { color: var(--muted); font-size: 12px; margin: 0 0 18px; }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; padding: 18px; }

.auth-card.wide { max-width: 640px; }
.btn-small { padding: 6px 12px; font-size: 12px; }
.hero-actions { justify-content: center; margin-top: 24px; }
.profile-actions { margin-top: 24px; }

.field select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}
.field select:focus { outline: none; border-color: var(--accent); }

.consent-intro { margin-top: 0; }
.scope-list { list-style: none; padding: 0; margin: 20px 0; }
.scope-list li {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.scope-list code { color: var(--accent-2); background: #0b0d12; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.consent-actions { display: flex; gap: 12px; }

/* 邀请卡（2026-10-07）：链接 + 二维码 + 合成邀请海报预览 + 邀请列表 */
.invite-assets { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; margin: 20px 0 8px; }
.invite-asset { display: flex; flex-direction: column; gap: 8px; align-items: center; margin: 0; }
.invite-asset figcaption { color: var(--muted); font-size: 12px; }
.poster-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 6px; }
/* 邀请海报弹窗（页面不展示裸海报，布局恒定；合成图在弹窗里可长按保存/转发） */
.poster-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.poster-modal[hidden] { display: none; }
.poster-modal-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 10, 0.66); }
.poster-modal-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(92vw, 420px);
    max-height: 92vh;
    overflow-y: auto;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}
.poster-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.poster-modal-title { font-size: 14px; }
.poster-modal-card img { width: 100%; height: auto; border-radius: 8px; display: block; }
.poster-modal-actions { display: flex; gap: 10px; }
.poster-modal-actions .btn { flex: 1; }
/* 合成输入素材：仅供 canvas 读取，不直接展示（1px 透明而非 display:none，确保浏览器仍加载） */
.asset-source { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.poster-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; margin: 0; }
.invite-assets input[type="text"], dl.profile-grid input[type="text"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    min-width: 320px;
}
.invite-list-title { font-size: 16px; margin: 32px 0 12px; }
.consent-actions .btn { flex: 1; }

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: 28px; margin: 0 0 10px; }
.hero p { color: var(--muted); margin: 0; }

.profile-grid { display: grid; grid-template-columns: 160px 1fr; gap: 10px 18px; margin: 0 0 22px; font-size: 13px; }
.profile-grid dt { color: var(--muted); }
.profile-grid dd { margin: 0; }
.section-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.section-actions .btn { width: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; }

/* 控制台（2026-10-08 改版）：左导航（头像 + 返回网站/退出 + 收起开关 + 带图标导航）+ 右侧工作区 */
.nav-user { color: var(--text); font-weight: 600; }
.console-body { display: block; }
.console-shell {
    display: grid;
    grid-template-columns: 236px 1fr;
    gap: 0;
    align-items: start;
    min-height: calc(100vh - 61px);
}
.console-shell.collapsed { grid-template-columns: 64px 1fr; }
.console-nav {
    border-right: 1px solid var(--border);
    padding: 16px 12px 28px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: calc(100vh - 61px);
}
/* 身份块：头像（未设置头像 → Quanova 图标）+ 显示名 + 账号 */
.console-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.console-avatar { width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto; background: var(--panel-2); }
.console-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.console-user-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-user-account { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-nav-top { display: flex; align-items: center; gap: 4px; }
.console-nav-top .console-nav-item:first-child { flex: 1; min-width: 0; }
.console-nav-group {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 14px 10px 6px;
}
/* 可折叠导航组（2026-10-09）：组标题即按钮，caret 随状态旋转 */
.console-nav-group-button {
    display: flex; align-items: center; gap: 6px; width: 100%;
    background: none; border: none; cursor: pointer; font: inherit;
    text-align: left;
    /* 显式给色（2026-10-09）：<button> 不继承 body 颜色，深色主题下默认黑字会看不见 */
    color: var(--muted);
}
.console-nav-group-button:hover { color: var(--text); }
.console-nav-group-button:hover { color: var(--text); }
.console-nav-group-button .group-caret { transition: transform .15s ease; font-size: 9px; }
.console-nav-group-button.group-closed .group-caret { transform: rotate(-90deg); }
.console-nav-group-items.group-hidden { display: none; }
/* 侧栏顶部内容与底部 UserBar 之间的弹性占位（2026-10-10 补）：此前该类无任何规则，
   占位高度为 0 → UserBar 只跟着最后一条导航项，没贴到底部（用户反馈）。 */
.console-nav-spacer { flex: 1 1 auto; min-height: 12px; }
/* 底部 UserBar（2026-10-09）：贴侧栏最下面，右侧图标点开账号菜单 */
.console-userbar {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; margin-top: 6px;
    border-top: 1px solid var(--border);
}
.console-userbar-menu-button {
    margin-left: auto; background: none; border: none; color: var(--muted);
    cursor: pointer; padding: 4px; border-radius: 6px; display: flex; align-items: center;
}
.console-userbar-menu-button:hover { background: var(--panel-2); color: var(--text); }
/* 控制台 UserBar 弹窗显形规则（2026-10-13 修「点了没反应」）：
   JS 把 open 加在 .console-userbar 上（见 _ConsoleLayout.qnToggleUserMenu），
   而 .user-menu.open .user-menu-panel 只匹配顶栏的 .user-menu 结构 —— 两者不通用，
   缺这条规则时类切换成功但面板始终 display:none。 */
.console-userbar.open .user-menu-panel { display: block; }
.user-menu-panel-up { top: auto; bottom: calc(100% + 6px); right: 0; }
.console-shell.collapsed .console-nav-top { flex-direction: column; }
.console-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}
.console-nav-item .nav-icon { flex: 0 0 auto; }
.console-nav-item:hover { background: var(--panel-2); text-decoration: none; }
.console-nav-item.active { background: var(--panel-2); color: var(--accent); font-weight: 600; }
.console-nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-nav-button { width: 100%; text-align: left; cursor: pointer; font: inherit; background: none; border: none; color: inherit; }
.console-nav-logout { margin: 0; }
.console-nav-toggle { color: var(--muted); }
.console-nav-toggle .nav-icon-expand { display: none; }
/* 收起态：只留图标（文案隐藏，title 仍可悬停查看） */
.console-shell.collapsed .console-nav-label,
.console-shell.collapsed .console-nav-group,
.console-shell.collapsed .console-user-text { display: none; }
.console-shell.collapsed .console-nav-item { justify-content: center; padding: 8px 6px; }
.console-shell.collapsed .console-user { justify-content: center; padding: 6px 0 14px; }
.console-shell.collapsed .console-userbar { justify-content: center; padding: 10px 0; }
.console-shell.collapsed .console-userbar-menu-button { margin-left: 0; }
.console-shell.collapsed .console-nav-toggle .nav-icon-collapse { display: none; }
.console-shell.collapsed .console-nav-toggle .nav-icon-expand { display: block; }

/* 工作区：内容统一占工作区 --workspace-width（appsettings Quanova:Site:WorkspaceWidthPercent，默认 90%） */
.console-workspace { padding: 28px 32px 48px; }
.console-workspace > * { width: var(--workspace-width, 90%); max-width: none; margin-left: 0; margin-right: 0; }
.console-workspace .auth-card,
.console-workspace .auth-card.wide { max-width: none; }
.console-workspace .console-form { max-width: none; }
.workspace-title { font-size: 20px; margin: 0 0 10px; }
.workspace-subtitle { font-size: 15px; margin: 0 0 14px; }
.console-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 6px 0 20px; }
.console-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    color: var(--text);
    text-decoration: none;
}
.console-card:hover { border-color: var(--accent); text-decoration: none; }
/* 卡片图标（2026-10-10 用户要求）：复用 ConsoleIcons 内联 SVG（.nav-icon），放大到 18px、随主题强调色 */
.console-card-icon { flex: 0 0 auto; display: flex; color: var(--accent); margin-top: 2px; }
.console-card-icon .nav-icon { width: 18px; height: 18px; }
.console-card-text { display: block; min-width: 0; }
.console-card-title { display: block; font-weight: 600; margin-bottom: 6px; }
.console-card-desc { display: block; color: var(--muted); font-size: 12px; }
.console-form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; max-width: 620px; }
.console-form .btn { width: auto; }
/* 工作区标题行（2026-10-08）：标题在左、主操作按钮在右上角（按钮宽度自适应文案） */
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.workspace-head h1 { margin: 0; font-size: 20px; }
.workspace-head .btn { width: auto; }
.console-workspace .btn-primary { width: auto; }
.poster-form-left { justify-content: flex-start; }
.link-danger { color: var(--danger); }
.masked-key { letter-spacing: 1px; }
.row-actions { display: flex; gap: 10px; align-items: center; }
/* 头像编辑器（2026-10-09）：圆形预览 + 选图/缩放控件 */
.avatar-editor { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 22px; flex-wrap: wrap; }
.avatar-preview { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.avatar-controls { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.avatar-controls input[type="range"] { width: 100%; }

/* 对话框（创建 API 密钥等，2026-10-08） */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .5); padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
    width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 24px 20px; box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0 0 10px; font-size: 16px; }
.modal-close {
    background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1;
    cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions .btn { width: auto; }
.console-form-test { border-style: dashed; }
.field-hint { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; }
.field-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.field-inline > span { margin: 0; }
.field input[type="checkbox"] { width: auto; }

@media (max-width: 720px) {
    .console-shell, .console-shell.collapsed { grid-template-columns: 1fr; }
    .console-nav { border-right: none; border-bottom: 1px solid var(--border); min-height: 0; }
    .console-workspace { padding: 20px 18px 40px; }
    .console-shell.collapsed .console-nav-label,
    .console-shell.collapsed .console-nav-group,
    .console-shell.collapsed .console-user-text { display: revert; }
    .console-shell.collapsed .console-nav-item { justify-content: flex-start; padding: 8px 10px; }
}

@media (max-width: 720px) {
    .container { padding: 28px 18px 48px; }
    .auth-card { padding: 24px 20px; }
    .profile-grid { grid-template-columns: 1fr; gap: 2px; }
    .profile-grid dt { margin-top: 10px; }
}
