/* ============================================================
 * tools/userinfo.css — 工具模块「用户信息」按钮 + 弹框（输入信息/修改信息）
 * 借鉴 uni_app 设计语言：暖色胶囊按钮、单字段浮层、清晰分区。
 * 由 footer 全模块引入；仅作用于含 #btnSample 的工具页（运行时替换为按钮）。
 * ============================================================ */

/* 激活后隐藏内联输入行（性别/历法/出生/地区/各测算字段等），统一收进弹框 */
.qy-ui-active .filter-input-row,
.qy-ui-active .nm-extra-row,
.qy-ui-active .gm-input-row,
.qy-ui-active .gm-input-row-2 { display: none !important; }

/* 用户信息按钮 + 摘要容器（替换原「查看示例」按钮的位置） */
.qy-userinfo {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.qy-ui-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    border: 1px solid var(--sun-red, #eb1313);
    border-radius: 999px;
    background: var(--sun-red, #eb1313);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s ease, box-shadow .2s ease, transform .1s ease;
    box-shadow: 0 2px 8px rgba(235,19,19,.16);
}
.qy-ui-btn:hover { background: var(--sun-red-dark, #c40e0e); }
.qy-ui-btn:active { transform: translateY(1px); }
.qy-ui-btn.is-filled { background: #fff; color: var(--sun-red, #eb1313); }
.qy-ui-btn.is-filled:hover { background: #fff5f5; }

.qy-ui-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary, #555);
    background: var(--bg-light, #fff8f5);
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 10px;
    padding: 8px 12px;
    margin: 6px 0 10px;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.qy-ui-summary:empty { display: none; }
/* 每个回显值单独成卡片，自动换行、绝不溢出父容器（多行固定行显示不同内容） */
.qy-ui-chip {
    display: inline-flex; align-items: center;
    background: #fff;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    color: var(--text-secondary, #555);
    white-space: nowrap;
}

/* ============ 弹框 ============ */
.qy-ui-mask {
    position: fixed; inset: 0;
    background: rgba(40, 20, 15, .45);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 9990;
    animation: qyUiFade .18s ease;
}
@keyframes qyUiFade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 680px) {
    .qy-ui-mask { align-items: center; }
}
.qy-ui-modal {
    width: 100%;
    max-width: 600px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.18);
    animation: qyUiUp .22s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 680px) {
    .qy-ui-modal { border-radius: 18px; animation: qyUiPop .22s cubic-bezier(.2,.8,.2,1); }
}
@keyframes qyUiUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes qyUiPop { from { transform: scale(.96); opacity: .6; } to { transform: none; opacity: 1; } }

.qy-ui-head {
    display: flex; align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color, #f0e0d0);
}
.qy-ui-head .qy-ui-title { font-size: 16px; font-weight: 700; color: var(--text-primary, #2a2420); }
.qy-ui-head .qy-ui-title .qy-ui-sub { font-size: 12px; font-weight: 400; color: var(--text-muted, #999); margin-left: 8px; }
.qy-ui-head .qy-ui-close {
    margin-left: auto;
    width: 30px; height: 30px;
    border: none; background: #f4ece6; border-radius: 50%;
    font-size: 16px; color: #8a7a70; cursor: pointer;
}
.qy-ui-head .qy-ui-close:hover { background: #ecdcd2; }

.qy-ui-body {
    padding: 8px 18px 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 字段行：label 与控件同一行（不换行），label 居左、控件占满剩余宽度；无分隔线、紧凑间距 */
.qy-ui-field {
    display: flex;
    flex-wrap: nowrap;            /* 始终保证 label + 控件 同一行，不允许整体换行 */
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}
.qy-ui-field > .qy-ui-label {
    flex: 0 0 72px;
    margin: 0;
    font-size: 13px; font-weight: 600; color: var(--text-secondary, #555);
    white-space: nowrap;
}
.qy-ui-field > .qy-ui-label .qy-ui-req { color: var(--sun-red, #eb1313); margin-left: 2px; }
.qy-ui-field > .qy-ui-label .qy-ui-opt { color: var(--text-muted, #999); font-weight: 400; margin-left: 4px; }

/* 单控件（select / text / number / 固定值）占满剩余宽度，与 label 同行 */
.qy-ui-field > select,
.qy-ui-field > input[type=text],
.qy-ui-field > input[type=number] { flex: 1; width: auto; min-width: 0; }
.qy-ui-field > .qy-ui-fixed { flex: 0 0 auto; }

/* 复合控件（日期 4 列 / 地区 3 列 / 胶囊单选 / 多选标签）占满剩余宽度 */
.qy-ui-field > .qy-ui-date,
.qy-ui-field > .qy-ui-region,
.qy-ui-field > .qy-ui-seg,
.qy-ui-field > .qy-ui-chips { flex: 1; min-width: 0; }

/* 窄屏：仅收紧间距、收缩 label 宽度，但 label 与控件始终保持同一行（不堆叠） */
@media (max-width: 480px) {
    .qy-ui-field { gap: 8px; }
    .qy-ui-field > .qy-ui-label { flex: 0 0 60px; }
    .qy-ui-modal { max-width: 100%; border-radius: 14px; }
    .qy-ui-body { padding: 4px 14px 2px; }
}

/* 通用控件 */
.qy-ui-field select,
.qy-ui-field input[type=text],
.qy-ui-field input[type=number] {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 10px;
    background: #fff;
    font-size: 14px; color: var(--text-primary, #2a2420);
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.qy-ui-field select:focus,
.qy-ui-field input:focus { border-color: var(--sun-red, #eb1313); box-shadow: 0 0 0 3px rgba(235,19,19,.12); }

/* 日期 4 列（无时辰时由 JS 改为 3 列）；minmax(0,1fr) 保证可压缩不溢出；始终单行不换行 */
.qy-ui-date { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; white-space: nowrap; }
.qy-ui-date.qy-ui-date--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qy-ui-date select { padding: 0 4px; text-align: center; }

/* 地区 3 列 */
.qy-ui-region { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qy-ui-region select:disabled { background: #f6f2ee; color: #bbb; }

/* 固定值（历法=阳历） */
.qy-ui-fixed {
    display: inline-flex; align-items: center; gap: 6px;
    height: 42px; padding: 0 14px;
    background: var(--bg-light, #fff8f5);
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 10px;
    color: var(--text-secondary, #555); font-size: 14px;
}
.qy-ui-fixed .qy-ui-lock { color: var(--sun-red, #eb1313); }

/* 固定值（历法=阳历）紧凑态，用于与性别合并行 */
.qy-ui-fixed--sm { height: 38px; padding: 0 12px; font-size: 13px; }

/* 历法(固定阳历) + 性别 合并行：两个子单元在同一行 */
.qy-ui-field--merged { gap: 18px; }
.qy-ui-field--merged > .qy-ui-subcell {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 0; min-width: 0;
}
.qy-ui-field--merged > .qy-ui-subcell > .qy-ui-sublabel {
    flex: 0 0 auto; margin: 0;
    font-size: 13px; font-weight: 600; color: var(--text-secondary, #555);
    white-space: nowrap;
}
.qy-ui-field--merged > .qy-ui-subcell > .qy-ui-fixed { flex: 0 0 auto; }
.qy-ui-field--merged > .qy-ui-subcell > .qy-ui-seg { flex: 1 1 0; min-width: 0; }
/* 极窄屏允许两个子单元换行各占一行，避免拥挤 */
@media (max-width: 380px) {
    .qy-ui-field--merged { flex-wrap: wrap; gap: 8px; }
    .qy-ui-field--merged > .qy-ui-subcell { flex: 1 0 100%; }
}

/* 胶囊单选（性别等） */
.qy-ui-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.qy-ui-seg label {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 64px; height: 40px; padding: 0 16px;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 999px;
    font-size: 14px; color: var(--text-secondary, #555);
    cursor: pointer; user-select: none;
    transition: all .18s ease;
}
.qy-ui-seg input { position: absolute; opacity: 0; pointer-events: none; }
.qy-ui-seg label.on {
    background: var(--sun-red, #eb1313); border-color: var(--sun-red, #eb1313);
    color: #fff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(235,19,19,.18);
}

/* 多选标签（五行 / 砂方位） */
.qy-ui-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qy-ui-chips label {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 52px; height: 38px; padding: 0 14px;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 999px;
    font-size: 13px; color: var(--text-secondary, #555);
    cursor: pointer; user-select: none;
    transition: all .18s ease;
}
.qy-ui-chips input { position: absolute; opacity: 0; pointer-events: none; }
.qy-ui-chips label.on {
    background: rgba(235,19,19,.08); border-color: var(--sun-red, #eb1313);
    color: var(--sun-red, #eb1313); font-weight: 600;
}

/* 下拉单选 → 3 列选项网格（uni_app 风格：去掉原生下拉，直接平铺成方块） */
.qy-ui-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qy-ui-grid label {
    display: flex; align-items: center; justify-content: center;
    min-height: 38px; padding: 4px 6px;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 10px;
    background: #fff;
    font-size: 13px; color: var(--text-secondary, #555);
    cursor: pointer; user-select: none; text-align: center;
    transition: all .16s ease;
}
.qy-ui-grid input { position: absolute; opacity: 0; pointer-events: none; }
.qy-ui-grid label.on {
    background: var(--sun-red, #eb1313); border-color: var(--sun-red, #eb1313);
    color: #fff; font-weight: 600;
    box-shadow: 0 3px 10px rgba(235,19,19,.18);
}
/* 下拉单选与 label 合并：label 占定宽，选项网格占满剩余；(其他 label+选项框合并同理) */
.qy-ui-field > .qy-ui-grid { flex: 1; min-width: 0; }

/* 原生单选下拉合并：一行 3 列，每格 label 在左、select 在右，紧凑同格 */
.qy-ui-triple {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 14px;
    align-items: center;
    padding: 8px 0;
}
.qy-ui-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.qy-ui-cell > .qy-ui-cell-label {
    flex: 0 0 auto;
    font-size: 12px; font-weight: 600; color: var(--text-secondary, #555);
    white-space: nowrap;
}
.qy-ui-cell > select {
    flex: 1 1 0; min-width: 0;
    height: 38px; padding: 0 6px;
    border: 1px solid var(--border-color, #f0e0d0);
    border-radius: 9px;
    background: #fff;
    font-size: 13px; color: var(--text-primary, #2a2420);
    box-sizing: border-box; outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.qy-ui-cell > select:focus { border-color: var(--sun-red, #eb1313); box-shadow: 0 0 0 3px rgba(235,19,19,.12); }
@media (max-width: 560px) { .qy-ui-triple { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .qy-ui-triple { grid-template-columns: 1fr; } }

/* 砂方位等较高字段：label 顶部对齐（避免在高的多选块中垂直居中显得悬空） */
.qy-ui-field--top { align-items: flex-start; }
.qy-ui-field--top > .qy-ui-label { padding-top: 9px; }

/* 福主复合字段（性别 + 出生年份 合并一行）整块占满宽度 */
.qy-ui-field--block { display: block; }
/* 多个福主（福主一/福主二）合并到同一行显示 */
.qy-ui-fuzhu-pair { display: flex; flex-wrap: wrap; gap: 16px 22px; padding: 8px 0; }
.qy-ui-fuzhu-pair > .qy-ui-fuzhu-item { flex: 1 1 220px; min-width: 0; }
.qy-ui-fuzhu { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.qy-ui-fuzhu-label { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--text-secondary, #555); white-space: nowrap; }
.qy-ui-fuzhu-date { display: flex; gap: 6px; flex-wrap: wrap; }
.qy-ui-fuzhu-date select {
    width: auto; min-width: 92px; height: 38px; padding: 0 6px;
    border: 1px solid var(--border-color, #f0e0d0); border-radius: 9px;
    background: #fff; font-size: 13px; color: var(--text-primary, #2a2420);
    box-sizing: border-box; outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.qy-ui-fuzhu-date select:focus { border-color: var(--sun-red, #eb1313); box-shadow: 0 0 0 3px rgba(235,19,19,.12); }
/* 福主性别胶囊紧凑化，避免与年份下拉并排时过高 */
.qy-ui-seg--sm label { min-width: 52px; height: 34px; padding: 0 12px; font-size: 13px; }

/* 风水页：把「修改信息」按钮放到标题「风水综合分析 · xx派」同一行右侧，不换行、不错位 */
.qy-userinfo--title { display: inline-flex; align-items: center; flex: 0 0 auto; }
.qy-title-with-userinfo { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.qy-title-with-userinfo .gm-title-text { white-space: nowrap; min-width: 0; }
.qy-title-with-userinfo .qy-userinfo--title { margin-left: auto; flex: 0 0 auto; }
/* 极窄屏（手机）允许换行，避免标题被挤压 */
@media (max-width: 480px) {
    .qy-title-with-userinfo { flex-wrap: wrap; }
    .qy-title-with-userinfo .qy-userinfo--title { margin-left: 0; }
}

/* 弹框底部 */
.qy-ui-foot {
    display: flex; gap: 12px;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color, #f0e0d0);
}
.qy-ui-foot .qy-ui-cancel,
.qy-ui-foot .qy-ui-save {
    flex: 1; height: 46px; border-radius: 999px;
    font-size: 15px; font-weight: 600; cursor: pointer; border: none;
    transition: background .2s ease, transform .1s ease;
}
.qy-ui-foot .qy-ui-cancel { background: #f4ece6; color: #6a5a50; }
.qy-ui-foot .qy-ui-cancel:hover { background: #ecdcd2; }
.qy-ui-foot .qy-ui-save { background: var(--sun-red, #eb1313); color: #fff; box-shadow: 0 6px 16px rgba(235,19,19,.22); }
.qy-ui-foot .qy-ui-save:hover { background: var(--sun-red-dark, #c40e0e); }
.qy-ui-foot .qy-ui-save:active { transform: translateY(1px); }
