/* =========================================================
   NHome 全站公共样式
   三个站点（NHomeWeb / NHomeMCWeb / NHomeSCPSLWeb）各放一份，
   内容保持完全一致。新页面直接引入本文件，不要另写一套头部。
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
.site-header, .site-footer { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }

:root {
    --nh-brand: #10b981;
    --nh-brand-dark: #059669;
    --nh-brand-soft: #ecfdf5;
    --nh-line: #e5e7eb;
    --nh-ink: #111827;
    --nh-muted: #6b7280;
}

body { overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; }

/* ---------- 顶部栏 ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--nh-line);
}
.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: .6rem 1rem;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-right: auto;
    flex-shrink: 0;
    color: var(--nh-ink);
    text-decoration: none;
}
.brand:hover { color: var(--nh-ink); }
.brand-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.brand-name { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.header-nav { display: flex; align-items: center; gap: .4rem; min-width: 0; flex-shrink: 0; }
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    height: 40px;
    padding: 0 .75rem;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    text-decoration: none;
    white-space: nowrap;
    transition: background .18s ease, color .18s ease;
}
.nav-link:hover { background: var(--nh-brand-soft); color: #065f46; }
.nav-link.active { background: var(--nh-brand-soft); color: #065f46; }
.auth-slot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 40px;
    width: 88px;
    min-width: 88px;
    flex-shrink: 0;
}
.auth-slot a { display: inline-flex; align-items: center; text-decoration: none; }
.auth-slot img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #a7f3d0;
}
.auth-slot .login-btn {
    width: 100%;
    justify-content: center;
    height: 40px;
    padding: 0 .75rem;
    border-radius: 10px;
    background: #6ee7b7;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .18s ease;
}
.auth-slot .login-btn:hover { background: var(--nh-brand); }
.auth-loading { font-size: .85rem; color: var(--nh-muted); }

/* ---------- 底部栏 ---------- */
.site-footer { background: #1f2937; color: #cbd5e1; }
.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: .8rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .3rem 1.35rem;
    font-size: .85rem;
}
.footer-link { display: inline-flex; align-items: center; gap: .4rem; color: #cbd5e1; text-decoration: none; transition: color .18s ease; }
.footer-link i { color: #6ee7b7; }
.footer-link:hover { color: #6ee7b7; }
.footer-icp { font-size: .75rem; color: #9ca3af; }
.footer-icp:hover { color: #6ee7b7; }

/* ---------- 手机端头部 ---------- */
@media (max-width: 900px) {
    .nav-link span { display: none; }
    .nav-link { width: 40px; padding: 0; }
}
@media (max-width: 380px) {
    .header-inner { padding: .55rem .65rem; gap: .4rem; }
    .auth-slot { width: 72px; min-width: 72px; }
    .auth-slot .login-btn { padding: 0 .55rem; }
    .brand-logo { width: 36px; height: 36px; }
    .nav-link { width: 34px; height: 36px; border-radius: 8px; }
    .auth-slot .login-btn { height: 36px; padding: 0 .7rem; font-size: .82rem; }
    .auth-slot img { width: 36px; height: 36px; }
}

/* ---------- 手机端侧边导航 ---------- */
/* 分类导航收进 Header：site.js 在 Logo 文本右边插一个右箭头，
   点开后导航块从 Header 下方展开（箭头转成向下）。桌面端样式不受影响。 */
.nh-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    font-size: .85rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}
.nh-nav-toggle i { display: block; transition: transform .2s ease; }
.nh-nav-toggle:hover { background: var(--nh-brand-soft); color: #065f46; }
.nh-nav-global { display: none; }

/* Toast 只做提示、不可点，别挡住下面的菜单按钮和页面操作 */
#notificationContainer { pointer-events: none; }
/* 加载遮罩淡出那 300ms 还在页面上，别让它吃掉底下的点击 */
.loader-container.opacity-0 { pointer-events: none; }

@media (max-width: 767.98px) {
    body.nh-has-mobile-nav .nh-nav-toggle { display: inline-flex; }
    body.nh-nav-open .nh-nav-toggle i { transform: rotate(90deg); }

    body.nh-has-mobile-nav .nh-mobile-nav {
        position: fixed;
        top: 65px;
        left: 0;
        right: 0;
        z-index: 45;
        display: block;
        width: auto;
        max-width: none;
        height: auto;
        max-height: calc(100dvh - 65px);
        margin: 0;
        padding: 3.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
        background: #fff;
        border: 0;
        border-bottom: 1px solid var(--nh-line);
        box-shadow: 0 18px 30px -24px rgba(17, 24, 39, .5);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        pointer-events: none;
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }
    body.nh-nav-open .nh-mobile-nav {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    /* 展开时贴在 Header 下面的两个全站入口，面板内容从它下面开始 */
    body.nh-nav-open .nh-nav-global {
        display: flex;
        align-items: center;
        gap: .5rem;
        position: fixed;
        top: 65px;
        left: 0;
        right: 0;
        z-index: 46;
        padding: .5rem 1rem;
        background: #fff;
        border-bottom: 1px solid var(--nh-line);
    }
    .nh-nav-global-link {
        flex: 1 1 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;
        height: 38px;
        padding: 0 .5rem;
        border-radius: 9px;
        background: #f3f4f6;
        color: #374151;
        font-size: .85rem;
        font-weight: 500;
        white-space: nowrap;
        transition: background .18s ease, color .18s ease;
    }
    .nh-nav-global-link:hover { background: var(--nh-brand-soft); color: #065f46; }

    /* 展开后的分类一律单列、靠左，不再复用桌面/平板的两列布局 */
    body.nh-has-mobile-nav .nh-mobile-nav #sidebar { display: block; }
    body.nh-has-mobile-nav .nh-mobile-nav #profileNav,
    body.nh-has-mobile-nav .nh-mobile-nav #roundNav,
    body.nh-has-mobile-nav .nh-mobile-nav .nh-nav-list { display: flex; flex-direction: column; gap: .4rem; }
    body.nh-has-mobile-nav .nh-mobile-nav .nh-nav-list > li { width: 100%; }
    body.nh-has-mobile-nav .nh-mobile-nav .nh-nav-list button,
    body.nh-has-mobile-nav .nh-mobile-nav .nh-nav-list .nav-item { width: 100%; justify-content: flex-start; }
    body.nh-has-mobile-nav .nh-mobile-nav #profileNav .nav-item,
    body.nh-has-mobile-nav .nh-mobile-nav #roundNav .side-item,
    body.nh-has-mobile-nav .nh-mobile-nav #sidebar .nav-item {
        justify-content: flex-start;
        text-align: left;
        padding: .7rem .8rem;
        font-size: .9rem;
    }
    body.nh-has-mobile-nav .nh-mobile-nav #profileNav .nav-item.logout { margin-top: .4rem; }
    body.nh-has-mobile-nav .nh-mobile-nav #adminSidebarToggle,
    body.nh-has-mobile-nav .nh-mobile-nav #sidebarToggle { display: none; }
    body.nh-has-mobile-nav .nh-mobile-nav .portal { display: block; padding: 0; }
    body.nh-has-mobile-nav .nh-mobile-nav .portal-title {
        margin: 0 0 .6rem;
        text-align: left;
        font-size: .9rem;
        color: var(--nh-muted);
    }
    body.nh-has-mobile-nav .nh-mobile-nav .service-strip {
        display: flex;
        flex-direction: column;
        gap: .5rem;
        width: 100%;
        max-width: none;
        margin: 0;
    }
    body.nh-has-mobile-nav .nh-mobile-nav .service-link { height: 48px; justify-content: flex-start; }
}
@media (max-width: 380px) {
    .nh-menu-btn { width: 36px; height: 36px; }
}

/* ---------- 通用手机修正 ---------- */
@media (max-width: 640px) {
    html { -webkit-text-size-adjust: 100%; }
    a, button, input, select, textarea, label { -webkit-tap-highlight-color: transparent; }
}

/* ---------- 表格：手机上改成卡片，禁止横向拖动 ---------- */
@media (max-width: 900px) {
    .table-wrap,
    .table-scroll { overflow-x: visible !important; }

    table.responsive-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: auto !important;
    }
    table.responsive-table thead { display: none; }
    table.responsive-table tbody { display: block; }
    table.responsive-table tr {
        display: block;
        padding: .7rem .85rem;
        border-bottom: 1px solid var(--nh-line);
    }
    table.responsive-table tr:last-child { border-bottom: 0; }
    table.responsive-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: .75rem;
        width: auto !important;
        min-width: 0 !important;
        padding: .18rem 0 !important;
        border: 0 !important;
        text-align: right;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    table.responsive-table td::before {
        content: attr(data-label);
        flex: 0 0 34%;
        max-width: 34%;
        font-weight: 600;
        font-size: .78rem;
        color: var(--nh-muted);
        text-align: left;
        white-space: normal;
    }
    table.responsive-table td[data-label=""]::before { display: none; }
    table.responsive-table td[colspan] {
        display: block;
        text-align: center;
        padding: .5rem 0 !important;
    }
    table.responsive-table td[colspan]::before { display: none; }
}

/* ---------- 大屏 / 高分辨率（1K、2K、4K） ----------
   屏幕越宽，容器越宽；列表网格本身是 auto-fill，
   会自动多出列，一屏看到更多内容。 */
@media (min-width: 1600px) {
    .header-inner, .footer-inner, .container { max-width: 1536px !important; }
    .portal, .mc-wrap, .scp-wrap { max-width: 1536px; }
    .scp-wrap { grid-template-columns: minmax(0, 1fr) 280px; }
    .quick-grid { width: min(46%, 480px); }
    .hero-art { width: min(42%, 380px); }
    .hero-art img { max-height: 380px; }
}
@media (min-width: 2200px) {
    .header-inner, .footer-inner, .container { max-width: 1760px !important; }
    .portal, .mc-wrap, .scp-wrap { max-width: 1760px; }
    .scp-wrap { grid-template-columns: minmax(0, 1fr) 300px; }
    .quick-grid { width: min(46%, 560px); }
    .hero-art { width: min(42%, 440px); }
    .hero-art img { max-height: 440px; }
}
@media (min-width: 3000px) {
    .header-inner, .footer-inner, .container { max-width: 2000px !important; }
    .portal, .mc-wrap, .scp-wrap { max-width: 2000px; }
    .quick-grid { width: min(46%, 640px); }
    .hero-art { width: min(42%, 520px); }
    .hero-art img { max-height: 520px; }
}

/* ---------- 与 Tailwind container 对齐的分级宽度 ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
    .header-inner, .footer-inner, .portal, .mc-wrap, .scp-wrap { max-width: 1024px; }
}
@media (min-width: 1280px) and (max-width: 1535px) {
    .header-inner, .footer-inner, .portal, .mc-wrap, .scp-wrap { max-width: 1280px; }
}
@media (min-width: 1536px) {
    .header-inner, .footer-inner, .portal, .mc-wrap, .scp-wrap { max-width: 1536px; }
}

/* 简单页面（登录/验证/重置/404 等）在视口里垂直居中，避免下方一大片空白 */
.simple-main { min-height: calc(100vh - 65px); display: flex; flex-direction: column; }
.simple-main > .max-w-md { margin-top: auto; margin-bottom: auto; }

/* 没有表头的操作列：内容靠右，和其它列的值对齐 */
table.responsive-table td[data-label=""] { justify-content: flex-end; }

/* ---------- 自绘确认 / 表单弹窗 ---------- */
.nh-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .5);
}
.nh-modal {
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow: auto;
    padding: 1.25rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .45);
}
.nh-modal-title { margin: 0; font-size: 1.05rem; font-weight: 700; color: #111827; }
.nh-modal-message {
    margin: .55rem 0 0;
    font-size: .875rem;
    line-height: 1.55;
    color: #6b7280;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.nh-modal-form { margin-top: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.nh-field-label { display: block; font-size: .8rem; color: #6b7280; margin-bottom: .3rem; }
.nh-field-input,
.nh-field-textarea,
.nh-field-select {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    background: #fff;
    color: #111827;
    font-size: .875rem;
    font-family: inherit;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.nh-field-textarea { min-height: 84px; resize: vertical; }
.nh-field-input:focus,
.nh-field-textarea:focus,
.nh-field-select:focus {
    border-color: #a7f3d0;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .12);
}
.nh-field-input.nh-invalid,
.nh-field-textarea.nh-invalid,
.nh-field-select.nh-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
.nh-modal-actions { display: flex; gap: .6rem; margin-top: 1.15rem; }
.nh-btn {
    flex: 1 1 0;
    height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.nh-btn-cancel { background: #fff; border-color: #e5e7eb; color: #374151; }
.nh-btn-cancel:hover { background: #f9fafb; }
.nh-btn-confirm { background: #10b981; color: #fff; }
.nh-btn-confirm:hover { background: #059669; }
.nh-btn-danger { background: #ef4444; color: #fff; }
.nh-btn-danger:hover { background: #dc2626; }

@media (max-width: 480px) {
    .nh-modal { padding: 1.1rem; }
}
