/* ==========================================================================
   MES.Web 站点布局样式（本地，无 CDN）
   ========================================================================== */

/* ---- 顶栏 ---- */
.app-header {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 48px;
    padding: 0 20px;
    background: var(--colorNeutralBackground1);
    border-bottom: 1px solid var(--colorNeutralStroke2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-brand { display: flex; align-items: center; gap: 8px; }
.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--borderRadiusMedium);
    background: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
    font-weight: var(--fontWeightSemibold);
    font-size: var(--fontSizeBase500);
}
.app-brand-mark.large { width: 40px; height: 40px; font-size: 22px; border-radius: var(--borderRadiusXLarge); }
.app-brand-title { font-size: var(--fontSizeBase500); font-weight: var(--fontWeightSemibold); }

.app-nav { display: flex; gap: 4px; flex: 1; }
.app-nav-link {
    padding: 6px 12px;
    border-radius: var(--borderRadiusMedium);
    color: var(--colorNeutralForeground2);
    font-weight: var(--fontWeightSemibold);
}
.app-nav-link:hover:not(.is-disabled) { background: var(--colorNeutralBackground3); text-decoration: none; }
.app-nav-link.is-disabled { color: var(--colorNeutralForegroundDisabled); cursor: default; }
.app-nav-link.active { color: var(--colorBrandForeground1); background: var(--colorPaletteBlueBackground1); }

.app-header-user { display: flex; align-items: center; gap: 12px; }
.app-user-name { color: var(--colorNeutralForeground2); font-weight: var(--fontWeightSemibold); }
.inline-form { display: inline; }

/* ---- 顶栏：汉堡按钮 / 圆形头像 / 弹出菜单 ---- */
.app-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--colorNeutralForeground1);
    border-radius: var(--borderRadiusMedium);
}
.app-menu-btn:hover { background: var(--colorNeutralBackground3); }

.app-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
    font-size: 15px;
    font-weight: var(--fontWeightSemibold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.app-avatar:hover { background: var(--colorBrandBackgroundHover); }

.app-user-menu { position: relative; margin-left: auto; }
.app-user-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 180px;
    background: var(--colorNeutralBackground1);
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    box-shadow: var(--shadow8);
    padding: 12px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.app-user-pop-name { font-weight: var(--fontWeightSemibold); color: var(--colorNeutralForeground1); }
.app-user-pop-sub { color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase300); margin-top: -4px; }
.app-user-pop a { color: var(--colorNeutralForeground2); padding: 6px 8px; border-radius: var(--borderRadiusMedium); }
.app-user-pop a:hover { background: var(--colorNeutralBackground3); text-decoration: none; }
.app-user-pop .app-button.full { margin-top: 4px; }
/* display:flex 会覆盖 hidden 属性的默认隐藏，需显式恢复 */
.app-user-pop[hidden] { display: none; }

/* ---- 抽屉导航（移动端） ---- */
.app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    background: var(--colorNeutralBackground1);
    box-shadow: var(--shadow8);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 300;
    display: flex;
    flex-direction: column;
    padding: 16px;
}
.app-drawer.open { transform: translateX(0); }
.app-drawer-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 290; }
.app-drawer-head {
    font-size: var(--fontSizeBase500);
    font-weight: var(--fontWeightSemibold);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--colorNeutralStroke2);
    margin-bottom: 8px;
}
.app-drawer-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.app-drawer-nav a {
    padding: 10px 12px;
    border-radius: var(--borderRadiusMedium);
    color: var(--colorNeutralForeground2);
    font-weight: var(--fontWeightSemibold);
}
.app-drawer-nav a:hover { background: var(--colorNeutralBackground3); text-decoration: none; }
.app-drawer-nav a.active { color: var(--colorBrandForeground1); background: var(--colorPaletteBlueBackground1); }
.app-drawer-user { border-top: 1px solid var(--colorNeutralStroke2); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.drawer-name { font-weight: var(--fontWeightSemibold); font-size: var(--fontSizeBase400); }
/* 桌面端抽屉不可唤起，彻底移除避免焦点落入屏外元素 */
@media (min-width: 769px) {
    .app-drawer, .app-drawer-mask { display: none; }
}

/* ---- 面包屑条（移动端显示在顶栏下方） ---- */
.app-crumbs {
    display: none;
    align-items: center;
    gap: 6px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 8px 20px;
    font-size: var(--fontSizeBase400);
}
.crumb-sep { color: var(--colorNeutralForeground3); }
.crumb-current { color: var(--colorNeutralForeground1); font-weight: var(--fontWeightSemibold); white-space: nowrap; }

/* ---- 主体 ---- */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 48px - 40px);
}

.app-footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    color: var(--colorNeutralForeground3);
    font-size: var(--fontSizeBase300);
}

.page-head { margin-bottom: 16px; }
.page-title { font-size: var(--fontSizeBase600); font-weight: var(--fontWeightSemibold); line-height: var(--lineHeightBase600); margin: 0 0 4px; }
.page-desc { color: var(--colorNeutralForeground3); margin: 0; }

/* ---- 认证页（登录/改密/错误） ---- */
.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 48px - 40px);
    padding: 24px;
}
.auth-card {
    width: 380px;
    background: var(--colorNeutralBackground1);
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusXLarge);
    box-shadow: var(--shadow8);
    padding: 32px 28px;
    text-align: center;
}
.auth-card form { text-align: left; margin-top: 16px; }
.auth-brand { margin-bottom: 12px; }
.auth-title { font-size: var(--fontSizeBase600); font-weight: var(--fontWeightSemibold); margin: 0 0 6px; }
.auth-subtitle { color: var(--colorNeutralForeground3); margin: 0; }
.auth-card .app-button.full { margin-top: 12px; }
.error-request-id { color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase300); }

/* ---- 概览统计卡片 ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--colorNeutralBackground1);
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    box-shadow: var(--shadow2);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-label { color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase400); }
.stat-value { font-size: 28px; font-weight: var(--fontWeightSemibold); color: var(--colorNeutralForeground1); }
.stat-value.small { font-size: var(--fontSizeBase500); }

/* ---- 可折叠卡片（筛选条件/新建用户等信息容器） ---- */
details.filter-card {
    background: var(--colorNeutralBackground1);
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    box-shadow: var(--shadow2);
    padding: 0;
    margin-bottom: 16px;
}
details.filter-card > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 20px;
    cursor: pointer;
    list-style: none;
    font-size: var(--fontSizeBase500);
    font-weight: var(--fontWeightSemibold);
    user-select: none;
}
details.filter-card > summary::-webkit-details-marker { display: none; }
details.filter-card > summary::after {
    content: "▾";
    color: var(--colorNeutralForeground3);
    transition: transform 0.15s ease;
}
details.filter-card[open] > summary::after { transform: rotate(180deg); }
.filter-body { padding: 0 20px 16px; }
.filter-body form { margin: 0; }

/* ---- 通用布局（自内联 style 收敛，便于断点控制） ---- */
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
/* 字段等宽弹性，保证筛选行各列对齐；按钮与输入行底对齐 */
.filter-row > .field { flex: 1 1 180px; min-width: 170px; margin-bottom: 0; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.card-head-actions { display: flex; gap: 12px; align-items: center; }
.check-all { display: flex; gap: 4px; align-items: center; color: var(--colorNeutralForeground2); cursor: pointer; }

/* ---- 面包屑（桌面隐藏，移动端替代导航行） ---- */
.app-crumbs { display: none; }

/* ---- 首页常用功能入口 ---- */
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.quick-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    color: var(--colorNeutralForeground1);
    background: var(--colorNeutralBackground1);
}
.quick-link:hover { border-color: var(--colorBrandForeground1); text-decoration: none; box-shadow: var(--shadow2); }
.quick-title { font-weight: var(--fontWeightSemibold); }
.quick-desc { color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase300); }

/* ---- 键值对表格（Detail/Status 信息表） ---- */
table.kv-table th { width: 140px; text-align: left; }

/* ==========================================================================
   移动端适配（≤768px）：数据表格转卡片、键值表转卡片、导航横滚
   ========================================================================== */
@media (max-width: 768px) {
    /* 顶栏：汉堡按钮 + 品牌 + 头像；完整导航入抽屉；面包屑为顶栏下方面板条 */
    .app-header { padding: 8px 12px; gap: 12px; }
    .app-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .app-nav { display: none; }
    .app-crumbs {
        display: flex;
        max-width: none;
        padding: 8px 12px;
        background: var(--colorNeutralBackground1);
        border-bottom: 1px solid var(--colorNeutralStroke2);
        overflow-x: auto;
        scrollbar-width: none;
    }
    .app-crumbs::-webkit-scrollbar { display: none; }
    .app-crumbs a { color: var(--colorNeutralForeground2); white-space: nowrap; }
    .app-main { padding: 12px; }
    .app-footer { padding: 8px 12px; }
    .auth-wrap { padding: 12px; }
    .auth-card { width: min(380px, 100%); }

    /* 筛选行：两列网格，字段对齐；查询/提交按钮通栏 */
    .filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
    .filter-row > .app-button { grid-column: 1 / -1; width: 100%; }

    /* 数据表格 → 卡片列表（每行一卡，字段名在左、值在右） */
    table.data-table thead { display: none; }
    table.data-table, table.data-table tbody { display: block; }
    table.data-table tr {
        display: block;
        background: var(--colorNeutralBackground1);
        border: 1px solid var(--colorNeutralStroke2);
        border-radius: var(--borderRadiusLarge);
        box-shadow: var(--shadow2);
        padding: 6px 14px;
        margin-bottom: 12px;
    }
    table.data-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        border-bottom: none;
        padding: 6px 0;
        text-align: right;
        word-break: break-all;
        white-space: normal !important;
    }
    table.data-table td::before {
        content: attr(data-label);
        color: var(--colorNeutralForeground3);
        font-weight: var(--fontWeightSemibold);
        text-align: left;
        flex-shrink: 0;
    }
    table.data-table td.no-label::before { content: none; }
    table.data-table tr.empty-row td { justify-content: center; text-align: center; }

    /* 键值对表格 → 卡片（标签在上一行、值在下一行） */
    table.kv-table, table.kv-table tbody { display: block; }
    table.kv-table tr {
        display: block;
        background: var(--colorNeutralBackground1);
        border: 1px solid var(--colorNeutralStroke2);
        border-radius: var(--borderRadiusLarge);
        box-shadow: var(--shadow2);
        padding: 4px 14px;
        margin-bottom: 12px;
    }
    table.kv-table th, table.kv-table td {
        display: block;
        width: auto;
        border-bottom: none;
        padding: 4px 0;
    }
    table.kv-table th { color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase300); }
}
