/**
 * 心晴MHA 前台视觉系统
 * ==================================================================
 * 这一份是「设计令牌 + 通用组件」，被测评页（answer.css）和
 * 登录页（auth.css）共同引用。
 *
 * 为什么要单独抽一层：
 *   如果两个页面各写一份配色和圆角，改一次品牌色就要改两处，
 *   迟早会漂移成两种风格。把令牌集中在这里，两边的按钮、
 *   输入框、卡片才会真正长得一样。
 *
 * 视觉方向：「安静的科技感」。
 *   这是心理服务场景，不能做得像金融大盘那样刺激。
 *   所以取深蓝 → 蓝 → 青的冷色渐变（冷静、可信），
 *   配半透明玻璃卡片和细网格底纹（秩序、精密），
 *   动效一律克制——只做 150~250ms 的淡入与位移。
 *
 * 前缀统一 mha-，避免与前台其他页面（frontend.css）冲突。
 */

/* ── 设计令牌 ───────────────────────────────────────────────── */
:root {
    /* 主色：深蓝到青。--mha-grad 用于重点区域，--mha-grad-soft 用于浅底点缀 */
    --mha-navy: #0b1f4d;
    --mha-primary: #2563eb;
    --mha-primary-dark: #1d4ed8;
    --mha-primary-soft: #e8efff;
    --mha-accent: #06b6d4;
    --mha-accent-soft: #e0f7fb;

    --mha-grad: linear-gradient(135deg, #0b1f4d 0%, #1d4ed8 48%, #06b6d4 100%);
    --mha-grad-btn: linear-gradient(135deg, #2563eb 0%, #1d4ed8 55%, #0891b2 100%);
    --mha-grad-soft: linear-gradient(135deg, rgba(37, 99, 235, .10), rgba(6, 182, 212, .10));

    /* 语义色 */
    --mha-success: #10b981;
    --mha-success-soft: #e7f8f1;
    --mha-warning: #f59e0b;
    --mha-warning-soft: #fef5e7;
    --mha-danger: #ef4444;
    --mha-danger-soft: #fdeced;

    /* 文字层级：正文 / 次要 / 弱化 */
    --mha-text: #111827;
    --mha-text-2: #4b5563;
    --mha-muted: #6b7280;
    --mha-faint: #9ca3af;

    --mha-border: #e5e7eb;
    --mha-border-strong: #d1d5db;
    --mha-bg: #f6f8fc;
    --mha-card-bg: rgba(255, 255, 255, .92);

    /* 圆角阶梯：小控件 / 卡片 / 大容器 */
    --mha-r-sm: 8px;
    --mha-r: 12px;
    --mha-r-lg: 18px;
    --mha-r-pill: 999px;

    /* 阴影：只做两层——贴地的细影 + 抬起的散影 */
    --mha-shadow-sm: 0 1px 2px rgba(11, 31, 77, .06);
    --mha-shadow: 0 4px 20px rgba(11, 31, 77, .07), 0 1px 2px rgba(11, 31, 77, .04);
    --mha-shadow-lg: 0 18px 48px rgba(11, 31, 77, .14), 0 2px 6px rgba(11, 31, 77, .05);
    --mha-shadow-primary: 0 8px 22px rgba(37, 99, 235, .28);

    --mha-ease: cubic-bezier(.4, 0, .2, 1);
}

/* ── 基础 ───────────────────────────────────────────────────── */
* {
    box-sizing: border-box;
}

html, body.mha-body {
    margin: 0;
    padding: 0;
    background: var(--mha-bg);
    color: var(--mha-text);
    font-size: 15px;
    line-height: 1.65;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
}

/* 细网格底纹：固定定位，滚动时不动，产生「背景层」的纵深感。
   用两层线性渐变画网格，不引入任何图片资源。 */
.mha-bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(37, 99, 235, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, .045) 1px, transparent 1px);
    background-size: 26px 26px;
    /* 顶部浓、往下淡出，避免整屏网格显得吵 */
    -webkit-mask-image: radial-gradient(120% 70% at 50% 0%, #000 0%, transparent 78%);
    mask-image: radial-gradient(120% 70% at 50% 0%, #000 0%, transparent 78%);
}

/* 光晕：两个大号径向渐变，制造柔和的冷色辉光 */
.mha-bg-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.mha-bg-glow::before,
.mha-bg-glow::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.mha-bg-glow::before {
    width: 340px;
    height: 340px;
    top: -140px;
    right: -110px;
    background: radial-gradient(circle, rgba(6, 182, 212, .38), transparent 68%);
}

.mha-bg-glow::after {
    width: 300px;
    height: 300px;
    bottom: -130px;
    left: -120px;
    background: radial-gradient(circle, rgba(37, 99, 235, .30), transparent 68%);
}

/* 页面内容要盖在装饰层之上 */
.mha-layer {
    position: relative;
    z-index: 1;
}

/* ── Hero 头部（渐变）───────────────────────────────────────── */
.mha-hero {
    position: relative;
    overflow: hidden;
    background: var(--mha-grad);
    color: #fff;
    padding: 18px 18px 22px;
}

/* 网格纹理 + 顶部高光，让渐变不至于是一块死板的色带 */
.mha-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .10) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
    mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
    pointer-events: none;
}

.mha-hero::after {
    content: '';
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    top: -130px;
    right: -70px;
    background: radial-gradient(circle, rgba(255, 255, 255, .26), transparent 70%);
    pointer-events: none;
}

.mha-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mha-hero-logo {
    height: 42px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: var(--mha-r-sm);
    background: rgba(255, 255, 255, .16);
    padding: 4px;
}

.mha-hero-text {
    min-width: 0;
    flex: 1;
}

.mha-hero-org {
    font-size: 12px;
    letter-spacing: .3px;
    opacity: .82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mha-hero-title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.4;
    margin-top: 2px;
    letter-spacing: .2px;
}

.mha-hero-sub {
    font-size: 12.5px;
    opacity: .82;
    margin-top: 4px;
}

/* Hero 内的小标签（如「游客匿名」「9 题」） */
.mha-hero-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    position: relative;
    z-index: 1;
}

.mha-hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    border-radius: var(--mha-r-pill);
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .26);
    color: #fff;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

/* ── 卡片 ───────────────────────────────────────────────────── */
.mha-card {
    position: relative;
    background: var(--mha-card-bg);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--mha-r-lg);
    box-shadow: var(--mha-shadow);
    padding: 18px;
    margin-bottom: 14px;
    /* 不支持 backdrop-filter 的旧浏览器退化为纯白底，不影响可读性 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mha-card-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
}

/* 标题左侧的渐变竖条：比整行下边框更轻，也更现代 */
.mha-card-head::before {
    content: '';
    width: 3px;
    height: 16px;
    border-radius: 2px;
    background: var(--mha-grad-btn);
    flex-shrink: 0;
}

.mha-card-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: .2px;
    color: var(--mha-text);
}

.mha-card-extra {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: var(--mha-primary);
    background: var(--mha-primary-soft);
    padding: 4px 9px;
    border-radius: var(--mha-r-pill);
    white-space: nowrap;
}

/* ── 统计磁贴（题量 / 时长 / 方式）─────────────────────────── */
.mha-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
}

.mha-stat {
    background: var(--mha-grad-soft);
    border: 1px solid rgba(37, 99, 235, .10);
    border-radius: var(--mha-r);
    padding: 11px 12px;
}

.mha-stat-label {
    font-size: 12px;
    color: var(--mha-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.mha-stat-label i {
    color: var(--mha-primary);
    font-size: 12px;
}

.mha-stat-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 3px;
    color: var(--mha-primary-dark);
    letter-spacing: .3px;
}

.mha-stat-value.is-text {
    font-size: 14px;
    letter-spacing: 0;
}

/* ── 列表（量表清单等）─────────────────────────────────────── */
.mha-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.mha-list-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 0;
    border-bottom: 1px solid var(--mha-border);
}

.mha-list-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mha-list-item:first-child {
    padding-top: 0;
}

.mha-list-index {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--mha-grad-btn);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
    box-shadow: 0 3px 8px rgba(37, 99, 235, .26);
}

.mha-list-body {
    flex: 1;
    min-width: 0;
}

.mha-list-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--mha-text);
}

.mha-list-meta {
    font-size: 12px;
    color: var(--mha-muted);
    margin-top: 2px;
}

/* ── 表单 ───────────────────────────────────────────────────── */
.mha-field {
    margin-bottom: 15px;
}

.mha-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--mha-text-2);
    margin-bottom: 7px;
}

.mha-required {
    color: var(--mha-danger);
    font-weight: 700;
}

/* 输入框外层：用于在左侧叠一个图标 */
.mha-input-wrap {
    position: relative;
}

.mha-input-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mha-faint);
    font-size: 15px;
    pointer-events: none;
    transition: color .18s var(--mha-ease);
}

.mha-input-wrap:focus-within .mha-input-icon {
    color: var(--mha-primary);
}

.mha-input,
.mha-select,
.mha-textarea {
    width: 100%;
    border: 1.5px solid var(--mha-border);
    border-radius: var(--mha-r);
    padding: 11px 13px;
    font-size: 15px;
    color: var(--mha-text);
    background: #fff;
    outline: none;
    font-family: inherit;
    transition: border-color .18s var(--mha-ease), box-shadow .18s var(--mha-ease), background .18s;
    -webkit-appearance: none;
    appearance: none;
}

/* 带左图标时让出位置 */
.mha-input-wrap .mha-input {
    padding-left: 40px;
}

.mha-input,
.mha-select {
    height: 46px;
}

.mha-textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.65;
}

.mha-input::placeholder,
.mha-textarea::placeholder {
    color: var(--mha-faint);
}

.mha-input:focus,
.mha-select:focus,
.mha-textarea:focus {
    border-color: var(--mha-primary);
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, .13);
}

.mha-input:disabled {
    background: #f3f4f6;
    color: var(--mha-faint);
}

.mha-select {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%239ca3af' d='M2 0L0 2h4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 9px 11px;
    padding-right: 34px;
}

.mha-help {
    font-size: 12px;
    color: var(--mha-muted);
    margin-top: 6px;
    line-height: 1.6;
}

/* 字段错误：默认隐藏，父级 .mha-has-error 时显示 */
.mha-error-text {
    font-size: 12px;
    color: var(--mha-danger);
    margin-top: 6px;
    line-height: 1.6;
    display: none;
}

.mha-has-error .mha-error-text {
    display: block;
}

.mha-has-error .mha-input,
.mha-has-error .mha-select,
.mha-has-error .mha-textarea {
    border-color: var(--mha-danger);
    background: #fffafa;
}

.mha-has-error .mha-input:focus,
.mha-has-error .mha-select:focus {
    box-shadow: 0 0 0 3.5px rgba(239, 68, 68, .12);
}

/* 单选（药丸样式）：隐藏原生 radio，用 span 呈现 */
.mha-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mha-radio {
    flex: 1 1 auto;
    min-width: 76px;
    position: relative;
    margin: 0;
}

.mha-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mha-radio span {
    display: block;
    text-align: center;
    padding: 11px 14px;
    border: 1.5px solid var(--mha-border);
    border-radius: var(--mha-r);
    font-size: 14px;
    font-weight: 500;
    color: var(--mha-text-2);
    cursor: pointer;
    background: #fff;
    transition: all .18s var(--mha-ease);
    user-select: none;
}

.mha-radio input:checked + span {
    border-color: var(--mha-primary);
    background: var(--mha-primary-soft);
    color: var(--mha-primary-dark);
    font-weight: 700;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .09);
}

/* 同意勾选 */
.mha-agree {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--mha-text-2);
    margin: 15px 0 5px;
    cursor: pointer;
    user-select: none;
}

.mha-agree input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--mha-primary);
    cursor: pointer;
}

/* ── 按钮 ───────────────────────────────────────────────────── */
.mha-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: var(--mha-r);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: .5px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--mha-grad-btn);
    box-shadow: var(--mha-shadow-primary);
    transition: transform .14s var(--mha-ease), box-shadow .18s var(--mha-ease), opacity .18s;
    -webkit-tap-highlight-color: transparent;
}

.mha-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, .24);
}

.mha-btn[disabled],
.mha-btn.is-disabled {
    background: #cbd5e1;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    color: #fff;
}

.mha-btn-ghost {
    background: #fff;
    color: var(--mha-primary);
    border: 1.5px solid var(--mha-primary);
    box-shadow: none;
}

.mha-btn-ghost:active {
    background: var(--mha-primary-soft);
    box-shadow: none;
}

.mha-btn-sm {
    width: auto;
    height: 38px;
    padding: 0 14px;
    font-size: 13.5px;
    letter-spacing: 0;
    border-radius: var(--mha-r-sm);
}

/* 输入框内嵌按钮（发送验证码）：去掉外阴影，避免与输入框抢视觉 */
.mha-btn-inline {
    width: auto;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    border-radius: var(--mha-r-sm);
    box-shadow: none;
}

.mha-btn-inline:active {
    box-shadow: none;
}

/* ── 提示条 ─────────────────────────────────────────────────── */
.mha-alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border-radius: var(--mha-r);
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.7;
    margin-bottom: 14px;
}

.mha-alert i {
    margin-top: 3px;
    flex-shrink: 0;
}

.mha-alert-info {
    background: var(--mha-primary-soft);
    border: 1px solid rgba(37, 99, 235, .16);
    color: #1e40af;
}

.mha-alert-warning {
    background: var(--mha-warning-soft);
    border: 1px solid rgba(245, 158, 11, .22);
    color: #92400e;
}

.mha-alert-danger {
    background: var(--mha-danger-soft);
    border: 1px solid rgba(239, 68, 68, .20);
    color: #991b1b;
}

.mha-alert-success {
    background: var(--mha-success-soft);
    border: 1px solid rgba(16, 185, 129, .22);
    color: #065f46;
}

/* ── 徽标（等级 / 状态）────────────────────────────────────── */
.mha-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: var(--mha-r-pill);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .2px;
}

.mha-badge-success { background: var(--mha-success-soft); color: #065f46; }
.mha-badge-info    { background: var(--mha-primary-soft); color: #1e40af; }
.mha-badge-warning { background: var(--mha-warning-soft); color: #92400e; }
.mha-badge-danger  { background: var(--mha-danger-soft);  color: #991b1b; }

/* ── 进度条 ─────────────────────────────────────────────────── */
.mha-progress {
    height: 6px;
    background: rgba(37, 99, 235, .10);
    border-radius: var(--mha-r-pill);
    overflow: hidden;
}

.mha-progress-bar {
    height: 100%;
    width: 0;
    border-radius: var(--mha-r-pill);
    background: var(--mha-grad-btn);
    transition: width .35s var(--mha-ease);
}

/* ── 加载指示 ───────────────────────────────────────────────── */
.mha-spinner {
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 3px solid rgba(37, 99, 235, .16);
    border-top-color: var(--mha-primary);
    border-radius: 50%;
    animation: mha-spin .75s linear infinite;
}

@keyframes mha-spin {
    to { transform: rotate(360deg); }
}

.mha-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 34px 16px;
    color: var(--mha-muted);
    font-size: 14px;
}

/* ── 分隔线与工具类 ─────────────────────────────────────────── */
.mha-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--mha-faint);
    font-size: 12px;
}

.mha-divider::before,
.mha-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--mha-border);
}

.mha-text-center { text-align: center; }
.mha-mt-0  { margin-top: 0 !important; }
.mha-mt-8  { margin-top: 8px !important; }
.mha-mt-16 { margin-top: 16px !important; }
.mha-mb-0  { margin-bottom: 0 !important; }
.mha-mb-16 { margin-bottom: 16px !important; }

/* 淡入动画：内容出现时轻微上浮，比突然跳出更柔和 */
.mha-fade-in {
    animation: mha-fade-in .32s var(--mha-ease) both;
}

@keyframes mha-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 尊重系统的「减弱动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
