/* ==========================================================================
   明枢科技官网 — 后台管理样式
   设计规范：浅色清爽风，主色 #2563EB，渐变点缀 #2563EB -> #06B6D4
   说明：本文件为后台框架基础样式（登录页、布局、侧边栏、卡片、表格）。
         LayUI 组件库在 P2 阶段接入后，组件级样式以 LayUI 为主，本文件保留框架与主题样式。
   ========================================================================== */

:root {
    --brand: #2563EB;
    --brand-light: #3B82F6;
    --brand-dark: #1D4ED8;
    --accent: #06B6D4;
    --gradient: linear-gradient(135deg, #2563EB 0%, #06B6D4 100%);
    --bg-page: #F8FAFC;
    --bg-card: #FFFFFF;
    --border: #E2E8F0;
    --text-main: #1E293B;
    --text-sub: #64748B;
    --text-muted: #94A3B8;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --radius-card: 12px;
    --radius-ctrl: 8px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
    --sidebar-width: 220px;
    --header-height: 60px;

    /**
     * 深色侧边栏配色
     *
     * 为什么改：原来侧边栏是白底 + 灰边 + 平铺菜单，是典型的"管理系统模板"观感。
     * 深色侧边栏是当前主流后台的做法，能立刻拉开层次：
     *   - 侧边栏成为"导航区"，内容区成为"工作区"，两者不再糊在一起
     *   - 深底上的品牌渐变与高亮色更跳，导航更好扫读
     *
     * 取值都带一点蓝（#0F172A 系），与官网首屏的深色同一色系，不显突兀。
     */
    --sider-bg: #0F172A;
    --sider-bg-soft: #1E293B;
    --sider-border: rgba(255, 255, 255, .08);
    --sider-text: rgba(232, 238, 247, .82);
    --sider-text-dim: rgba(232, 238, 247, .58);
    --sider-hover: rgba(255, 255, 255, .07);
    --sider-active-bg: rgba(56, 189, 248, .14);
    --sider-active-text: #7DD3FC;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-dark);
}

/* ===== 渐变文字（Logo 使用） ===== */
.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 700;
}

/* ===================== 登录页 ===================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-page);
    /* 清爽风：极淡的网格纹理，不使用深色块与光效 */
    background-image:
        linear-gradient(to right, rgba(37, 99, 235, .04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(37, 99, 235, .04) 1px, transparent 1px);
    background-size: 32px 32px;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-md);
    padding: 40px 32px 32px;
}

.login-brand {
    text-align: center;
    margin-bottom: 8px;
}

.login-brand-name {
    font-size: 28px;
    letter-spacing: 2px;
}

.login-brand-sub {
    text-align: center;
    color: var(--text-sub);
    font-size: 13px;
    margin-bottom: 28px;
}

.login-form-item {
    margin-bottom: 18px;
}

.login-form-item label {
    display: block;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.login-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-main);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-ctrl);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.login-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.login-btn {
    width: 100%;
    height: 44px;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-ctrl);
    cursor: pointer;
    transition: opacity .2s, transform .15s;
}

.login-btn:hover {
    opacity: .92;
}

.login-btn:active {
    transform: translateY(1px);
}

.login-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 4px;
}

.login-error {
    display: none;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #B91C1C;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-ctrl);
}

.login-error.show {
    display: block;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.7;
}

.login-tips {
    margin-top: 16px;
    padding: 12px;
    font-size: 12px;
    color: var(--text-sub);
    background: #F1F5F9;
    border: 1px dashed var(--border);
    border-radius: var(--radius-ctrl);
    line-height: 1.7;
}

.login-tips code {
    padding: 1px 5px;
    font-size: 12px;
    color: var(--brand-dark);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* ===================== 后台布局 ===================== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- 侧边栏 ---- */
.admin-sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    /* 深色导航区：与浅色内容区形成明确分区，去掉"管理系统模板"观感 */
    background: var(--sider-bg);
    border-right: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--sider-border);
    font-size: 18px;
    letter-spacing: 1px;
    flex-shrink: 0;
    /* 深底上的品牌字用亮色，保证可读 */
    color: #fff;
}

/* 深色侧边栏里的品牌副标题（"管理后台"） */
.sidebar-brand .brand-sub {
    font-size: 12px;
    color: var(--sider-text-dim);
    margin-left: 6px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

/* ============================================================================
   侧边栏菜单：手风琴
   ----------------------------------------------------------------------------
   改造前是"分组标题 + 平铺菜单项"，所有子项一次性铺开：
     - 27 个菜单项堆在一起，找一项要滚半天
     - 分组标题不可点，看不出哪些项属于哪个分组
   现在改为手风琴：点分组标题展开/收起，同时只展开一个分组。
   ============================================================================ */

/* 菜单占位与错误提示（不是分组标题，不要套用按钮样式） */
.menu-empty {
    padding: 14px 10px 6px;
    font-size: 12px;
    color: var(--sider-text-dim);
    letter-spacing: .5px;
}

/* 分组标题：可点击的按钮（原来是不可交互的 div） */
.menu-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 11px 10px;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 500;
    /* 深色侧边栏上的文字 */
    color: var(--sider-text);
    letter-spacing: .3px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-ctrl);
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
}

.menu-group-title:hover {
    background: var(--sider-hover);
    color: #fff;
}

/* 展开中的分组标题 */
.menu-group-title.is-open {
    color: var(--sider-active-text);
}

/* 箭头：默认指向右（收起），展开时转 90 度朝下 */
.menu-group-title .menu-arrow {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    opacity: .55;
    transition: transform .22s ease;
}

.menu-group-title.is-open .menu-arrow {
    transform: rotate(90deg);
    opacity: .9;
}

/* 分组下方的子菜单容器 */
.menu-group {
    margin-bottom: 4px;
}

/*
  折叠动画：用 max-height 过渡
  为什么不用 height:auto：auto 无法参与 transition。
  用 max-height 的代价是要给一个足够大的上限值 ——
  这里取 640px（单个分组最多 11 项 × 42px ≈ 462px，留足余量）。
*/
.menu-group-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height .26s ease;
}

.menu-group.is-open .menu-group-items {
    max-height: 640px;
}

.menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px 0 22px;
    margin-bottom: 2px;
    font-size: 14px;
    /* 深色侧边栏上的次级文字 */
    color: var(--sider-text-dim);
    border-radius: var(--radius-ctrl);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.menu-item:hover {
    background: var(--sider-hover);
    color: #fff;
}

/*
  选中态：左侧品牌色竖条 + 半透明青底 + 亮青字
  与"整块渐变高亮"相比，竖条在 9~11 项的长分组里更容易定位，
  也不会因为大面积高饱和色而显得躁。
*/
.menu-item.active {
    background: var(--sider-active-bg);
    color: var(--sider-active-text);
    font-weight: 500;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 2px;
    background: var(--gradient);
}

.menu-item .menu-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    opacity: .7;
}

.menu-item.active .menu-icon {
    opacity: 1;
}

/* ---- 主区域 ---- */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-header {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--bg-card);
    /* 用极淡投影配合浅分隔线：比纯 1px 硬边线更有层次，也不像表格分栏 */
    border-bottom: 1px solid rgba(226, 232, 240, .7);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
    position: sticky;
    top: 0;
    z-index: 99;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--text-main);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 13px;
    color: var(--text-sub);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.admin-content {
    flex: 1;
    /* 留白比原来宽：拥挤是管理系统观感的主要来源之一 */
    padding: 24px 28px 40px;
    min-width: 0;
}

/* ---- 未读红点（线索保底提醒） ---- */
.badge-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--danger);
    border-radius: 9px;
    line-height: 1;
}

/* ===================== 通用组件 ===================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.card + .card {
    margin-top: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    transition: box-shadow .2s, transform .2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-value.is-brand {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-unit {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-ctrl);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary {
    color: #fff;
    background: var(--gradient);
}

.btn-primary:hover {
    opacity: .92;
    color: #fff;
}

.btn-default {
    color: var(--text-main);
    background: #fff;
    border-color: var(--border);
}

.btn-default:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-danger:hover {
    opacity: .9;
    color: #fff;
}

.btn-sm {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
}

/* ---- 表格 ---- */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-sub);
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F1F5F9;
    color: var(--text-main);
}

.data-table tbody tr:hover {
    background: #F8FAFC;
}

/* ---- 状态标签 ---- */
.tag {
    display: inline-block;
    padding: 2px 9px;
    font-size: 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.tag-green { color: #047857; background: #D1FAE5; }
.tag-blue { color: #1D4ED8; background: #DBEAFE; }
.tag-orange { color: #B45309; background: #FEF3C7; }
.tag-red { color: #B91C1C; background: #FEE2E2; }
.tag-gray { color: #475569; background: #F1F5F9; }

/* ---- 空状态 ---- */
.empty-state {
    padding: 56px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 40px;
    opacity: .35;
    margin-bottom: 12px;
}

/* ---- 提示条 ---- */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    border-radius: var(--radius-ctrl);
    line-height: 1.7;
}

.alert-info { color: #1E40AF; background: #EFF6FF; border: 1px solid #BFDBFE; }
.alert-warn { color: #92400E; background: #FFFBEB; border: 1px solid #FDE68A; }
.alert-danger { color: #991B1B; background: #FEF2F2; border: 1px solid #FECACA; }
.alert-success { color: #065F46; background: #ECFDF5; border: 1px solid #A7F3D0; }

/* ---- 加载中 ---- */
.loading-mask {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, .72);
    z-index: 999;
}

.loading-mask.show {
    display: flex;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: mskj-spin .8s linear infinite;
}

@keyframes mskj-spin {
    to { transform: rotate(360deg); }
}

/* ---- Toast 轻提示 ---- */
.toast-wrap {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    padding: 10px 20px;
    font-size: 13px;
    color: #fff;
    background: #334155;
    border-radius: var(--radius-ctrl);
    box-shadow: var(--shadow-md);
    animation: mskj-toast-in .2s ease-out;
}

.toast.is-success { background: var(--success); }
.toast.is-error { background: var(--danger); }

@keyframes mskj-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- 手机端（后台以 PC 为主，做基础降级） ---- */
@media (max-width: 900px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform .25s;
        box-shadow: var(--shadow-md);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-content {
        padding: 16px;
    }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* ---- 尊重用户的减弱动效偏好 ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
