/* =========================================================
   MoonHoneyMC —— 响应式布局增强
   1. 宽屏双栏（消除两侧空旷）
   2. 移动端底部液态玻璃 Dock
   3. iPad / iPhone 触控与输入适配
   ========================================================= */

/* =========================================================
   1. 首页宽屏双栏主视觉
   ========================================================= */
.hero-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
    gap: 32px;
    align-items: start;
    padding-top: 8px;
}

/* 左栏：主视觉 */
.hero-left {
    text-align: left;
    padding: 40px 0 0;
    min-width: 0;
}

.hero-left .ice-eyebrow { margin-left: 0; }

.hero-left h1 {
    margin: 0 0 20px;
    font-size: clamp(38px, 4.4vw, 66px);
    font-weight: 800;
    line-height: 1.04;
    letter-spacing: -2.2px;
    background: linear-gradient(178deg, #ffffff 6%, rgba(214, 234, 255, 0.72) 96%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-left p {
    margin: 0 0 28px;
    max-width: 520px;
    font-size: 16px;
    line-height: 1.75;
    color: var(--txt-2);
}

/* 快速操作按钮组 */
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
}

/* 特性胶囊网格 */
.hero-feats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    max-width: 560px;
}

.hero-feat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 15px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.055);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18);
    transition: all .34s var(--ease-apple);
}

.hero-feat:hover {
    background: rgba(255, 255, 255, 0.085);
    border-color: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.hero-feat i {
    font-size: 13px;
    color: var(--glacier);
    flex: 0 0 auto;
}

.hero-feat span {
    font-size: 12px;
    font-weight: 600;
    color: var(--txt-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 右栏：状态卡 + 公告卡 */
.hero-right {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

/* 右栏内的服务器卡去掉原先的居中约束 */
.hero-right .ice-server {
    max-width: none;
    margin: 0;
    width: 100%;
}

/* =========================================================
   2. 最新公告 / 更新日志卡片（右栏置顶）
   ========================================================= */
.news-card {
    padding: 20px 22px 16px;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    max-height: 268px;
}

.news-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 13px;
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
}

.news-ico {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 12px;
    color: #fbbf24;
    background: linear-gradient(135deg, rgba(251,191,36,.26), rgba(251,191,36,.09));
    border: 1px solid rgba(251,191,36,.26);
    box-shadow: inset 0 1px 1px rgba(255,255,255,.45);
}

.news-title {
    font-size: 13.5px;
    font-weight: 700;
}

.news-sub {
    font-size: 10px;
    color: var(--txt-3);
    letter-spacing: .6px;
    margin-top: 1px;
}

/* 条数徽标 */
.news-count {
    flex: 0 0 auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.26);
}

.news-list {
    flex: 1 1 auto;
    overflow-y: auto;
    position: relative;
    z-index: 3;
    margin: 0 -6px;
    padding: 0 6px;
    scrollbar-width: thin;
    min-height: 0;
}

.news-list::-webkit-scrollbar { width: 5px; }
.news-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 999px;
}
.news-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.22);
}

.news-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.news-item:first-child { padding-top: 0; }
.news-item:last-child { border-bottom: none; }

.news-item-title {
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--txt);
    margin-bottom: 4px;
}

/* 公告正文 —— 之前漏渲染，现在完整显示 */
.news-item-content {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--txt-2);
    margin-bottom: 5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-item-meta {
    font-size: 10.5px;
    color: var(--txt-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.news-item-meta i { font-size: 9px; }

.news-empty {
    text-align: center;
    padding: 26px 0;
    font-size: 12px;
    color: var(--txt-3);
}

.news-empty i {
    display: block;
    font-size: 22px;
    opacity: .3;
    margin-bottom: 9px;
}

/* =========================================================
   3. 手机 / iPad 竖屏底部 Dock
   ========================================================= */
.bottom-dock {
    display: none;   /* 默认隐藏，仅在 <768px 显示 */
}

@media (max-width: 767px) {
    /* --- 隐藏顶部导航，改用底部 Dock --- */
    .nav-wrap { display: none; }

    /* 给 body 底部留出 Dock 的空间 */
    body.ice-body { padding-bottom: 92px; }

    .bottom-dock {
        display: flex;
        position: fixed;
        bottom: max(14px, env(safe-area-inset-bottom, 14px));
        left: 50%;
        transform: translateX(-50%);
        z-index: 300;
        width: calc(100% - 28px);
        max-width: 460px;
        padding: 8px;
        gap: 4px;
        border-radius: 26px;
        background: rgba(255, 255, 255, 0.10);
        backdrop-filter: blur(28px) saturate(170%);
        -webkit-backdrop-filter: blur(28px) saturate(170%);
        border: 1px solid rgba(255, 255, 255, 0.16);
        box-shadow:
            inset 0 1px 1px rgba(255, 255, 255, 0.6),
            0 10px 40px rgba(0, 0, 0, 0.5);
    }

    .dock-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 9px 4px;
        border-radius: 19px;
        text-decoration: none;
        color: var(--txt-3);
        font-size: 9.5px;
        font-weight: 600;
        -webkit-tap-highlight-color: transparent;
        transition: all .3s var(--ease-apple);
        position: relative;
        min-width: 0;
    }

    .dock-item i {
        font-size: 18px;
        line-height: 1;
        transition: transform .3s var(--ease-apple);
    }

    .dock-item span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .dock-item:active {
        transform: scale(0.94);
    }

    .dock-item.active {
        color: #fff;
        background: linear-gradient(135deg,
            rgba(56, 189, 248, 0.92),
            rgba(129, 140, 248, 0.85));
        box-shadow:
            inset 0 1px 1px rgba(255, 255, 255, 0.55),
            0 4px 16px rgba(56, 189, 248, 0.42);
    }

    .dock-item.active i { transform: scale(1.06); }

    /* 主页内容顶部补偿（顶部导航已隐藏） */
    .ice-main { padding-top: 10px; }
    .ice-hero, .ice-page-head { padding-top: 22px; }
}

/* =========================================================
   4. 宽屏断点
   ========================================================= */
@media (min-width: 1600px) {
    .ice-main, .ice-nav { max-width: 1560px; }
}

/* 中屏：双栏收窄 */
@media (max-width: 1180px) {
    .hero-split {
        grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
        gap: 24px;
    }
    .hero-left h1 { font-size: clamp(34px, 4vw, 52px); }
}

/* 平板横屏 / 小笔记本：改为单栏 */
@media (max-width: 1024px) {
    .hero-split {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .hero-left {
        text-align: center;
        padding-top: 20px;
    }
    .hero-left .ice-eyebrow { margin-left: auto; }
    .hero-left p { margin-left: auto; margin-right: auto; }
    .hero-actions { justify-content: center; }
    .hero-feats { margin: 0 auto; }
    .hero-right .ice-server { max-width: 700px; margin: 0 auto; width: 100%; }
    .news-card { max-height: none; }
}

/* =========================================================
   5. iPad / 手机通用触控适配
   ========================================================= */
@media (max-width: 1024px) {
    /* 输入框统一 16px 以上，防止 iOS Safari 聚焦时自动缩放 */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* 触控目标最小 44px */
    .ice-btn, .ice-cat, .ice-copy, .ice-dl-btn, .auth-submit {
        min-height: 44px;
    }

    .ice-refresh, .ice-copy-sm {
        min-width: 36px;
        min-height: 36px;
    }

    /* 防止横向溢出 */
    html, body { overflow-x: hidden; }

    /* 长地址强制换行 */
    .ice-addr-val, .ice-alt code, .code-break {
        word-break: break-all !important;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 767px) {
    /* 小屏内边距收紧 */
    .ice-main { width: 94%; padding-bottom: 40px; }
    .ice-nav { display: none; }

    .ice-card { border-radius: 22px; }
    .ice-server { padding: 20px 18px; }
    .bento-card { padding: 18px; min-height: auto; }
    .news-card { padding: 18px 18px 14px; }

    .ice-hero h1, .hero-left h1 {
        font-size: clamp(30px, 9vw, 42px);
        letter-spacing: -1.2px;
    }
    .ice-hero p, .hero-left p { font-size: 14px; }

    .ice-page-head { padding: 26px 0 24px; }
    .ice-page-head h1 { font-size: clamp(26px, 7.5vw, 34px); }

    .ice-addr { padding: 13px; }
    .ice-addr-val { font-size: 13.5px; }

    .ice-dl-grid { grid-template-columns: 1fr; gap: 14px; }
    .ice-mod-grid { grid-template-columns: 1fr; gap: 8px; }

    .ice-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .ice-search { max-width: none; }
    .ice-cats {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        margin: 0 -14px;
        padding-left: 14px;
        padding-right: 14px;
        scrollbar-width: none;
    }
    .ice-cats::-webkit-scrollbar { display: none; }
    .ice-cat { flex: 0 0 auto; }

    .ice-mod-badge { display: none; }

    .hero-feats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .hero-feat { padding: 11px 12px; }
    .hero-feat span { font-size: 11px; }

    .ice-footer { padding: 22px 16px; font-size: 11px; }

    /* 登录弹窗在小屏占满宽度 */
    .auth-box { max-width: none; padding: 24px 20px; }
}

/* 超小屏 */
@media (max-width: 400px) {
    .hero-feats { grid-template-columns: 1fr; }
    .ice-main { width: 95%; }
    .dock-item span { font-size: 9px; }
}

/* =========================================================
   6. 控制台（dashboard）移动端适配
   ========================================================= */
@media (max-width: 1024px) {
    /* 侧栏在平板竖屏改为顶部横向滚动的胶囊栏 */
    .dashboard-layout { flex-direction: column; }

    .sidebar {
        width: auto;
        flex: none;
        margin: 12px 12px 0;
        padding: 12px;
        border-radius: 20px;
    }

    .sidebar .logo { padding: 0 6px 12px !important; }

    .menu-group {
        flex-direction: row;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .menu-group::-webkit-scrollbar { display: none; }

    .menu-item {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 9px 15px !important;
        font-size: 12px !important;
    }

    /* 退出登录按钮在移动端也横向排列 */
    .sidebar > div[style*="margin-top: auto"] { margin-top: 12px !important; }

    .main-content { padding: 12px; }

    /* 卡片内的横向 flex 在窄屏换行 */
    .main-content .card > div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    /* 用户管理 / 下载管理列表：允许横向滚动 */
    #user-list, #dl-admin-list, #server-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 用户条目改为纵向堆叠，按钮单独一行 */
    #user-list > div {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* 服务器面板的两栏布局在窄屏堆叠 */
    #server-panel > div[style*="gap: 20px"] {
        flex-direction: column !important;
    }

    #server-panel .card[style*="width: 250px"] {
        width: auto !important;
    }
}

@media (max-width: 767px) {
    .sidebar { margin: 10px 10px 0; padding: 10px; }
    .main-content { padding: 10px; }
    .card { padding: 15px !important; border-radius: 16px !important; }
    .main-content h2 { font-size: 21px !important; }

    /* 添加服务器弹窗在小屏适配 */
    #add-modal > div {
        width: calc(100% - 32px) !important;
        max-width: 400px;
        padding: 22px !important;
    }

    /* 文件上传控件换行 */
    input[type="file"] { width: 100%; }
}

/* =========================================================
   7. 全局长文本与溢出保护
   ========================================================= */
.code-break,
.ice-addr-val,
.ice-alt code,
.news-item-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 表格 / 列表容器横向滚动兜底 */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* iOS 点击高亮去除 */
.ice-btn, .ice-cat, .ice-switcher a, .dock-item, .ice-copy {
    -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   8. 横屏手机（高度很矮）
   ========================================================= */
@media (max-height: 500px) and (orientation: landscape) {
    .ice-hero, .hero-left, .ice-page-head { padding-top: 14px; }
    .bottom-dock {
        bottom: 8px;
        padding: 6px;
        border-radius: 20px;
    }
    .dock-item { padding: 6px 4px; gap: 2px; }
    .dock-item i { font-size: 15px; }
    .dock-item span { font-size: 8.5px; }
}

/* =========================================================
   9. 首页左栏统计数字
   ========================================================= */
.hero-stats {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-top: 26px;
    padding: 16px 20px;
    max-width: 560px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.075);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.14);
}

.hero-stat { flex: 1; text-align: center; min-width: 0; }

.hero-stat-num {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.8px;
    line-height: 1.1;
    background: linear-gradient(160deg, #e8f4ff 10%, rgba(125, 211, 252, 0.75) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-stat-label {
    font-size: 10.5px;
    color: var(--txt-3);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-stat-div {
    width: 1px;
    height: 30px;
    flex: 0 0 auto;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,.14), transparent);
}

/* 右栏整体：公告在上，状态卡在下，两者撑满高度 */
.hero-right {
    align-self: stretch;
}

@media (max-width: 1024px) {
    .hero-stats { margin-left: auto; margin-right: auto; }
    .hero-right { max-width: 700px; margin: 0 auto; width: 100%; }
}

@media (max-width: 767px) {
    .hero-stats { gap: 12px; padding: 13px 14px; margin-top: 20px; }
    .hero-stat-num { font-size: 20px; }
    .hero-stat-label { font-size: 9.5px; }
    .news-card { max-height: none; min-height: 0; }
    .news-item-content { -webkit-line-clamp: 4; }
}

/* =========================================================
   e4mc 公网连接诊断面板
   ========================================================= */
.e4mc-diag {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 3;
}

.e4mc-diag-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 11px;
    font-size: 12px;
    font-weight: 700;
    color: var(--txt-2);
}

.e4mc-diag-head i {
    font-size: 11px;
    color: #38bdf8;
}

.e4mc-badge {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    background: rgba(148, 163, 184, 0.14);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.22);
    white-space: nowrap;
}

.e4mc-badge.ok {
    background: rgba(45, 212, 191, 0.14);
    color: #5eead4;
    border-color: rgba(45, 212, 191, 0.3);
}

.e4mc-badge.warn {
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

.e4mc-badge.bad {
    background: rgba(251, 113, 133, 0.14);
    color: #fda4af;
    border-color: rgba(251, 113, 133, 0.3);
}

.e4mc-rows {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.e4mc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 11.5px;
}

.e4mc-key {
    color: var(--txt-3);
    flex: 0 0 auto;
    white-space: nowrap;
}

.e4mc-val {
    color: var(--txt-2);
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.e4mc-val.mono {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 11px;
}

.e4mc-val.ok   { color: #5eead4; font-weight: 700; }
.e4mc-val.warn { color: #fbbf24; font-weight: 700; }
.e4mc-val.bad  { color: #fda4af; font-weight: 700; }

.e4mc-hint {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    line-height: 1.5;
    color: var(--txt-3);
}

.e4mc-hint.ok   { color: #5eead4; }
.e4mc-hint.warn { color: #fbbf24; }
.e4mc-hint.bad  { color: #fda4af; }

@media (max-width: 767px) {
    .e4mc-diag { padding: 12px 13px; }
    .e4mc-row { font-size: 11px; }
    .e4mc-val.mono { font-size: 10.5px; }
}

/* =========================================================
   导航栏头像链接
   ========================================================= */
.ice-user-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: var(--r-pill);
    text-decoration: none;
    color: var(--txt-2);
    font-size: 12.5px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all .28s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: 190px;
}

.ice-user-link:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.3);
    color: var(--txt);
}

.ice-user-avatar {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
}

.ice-user-avatar-default {
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    color: #04121f;
    background: linear-gradient(135deg, #7dd3fc, #818cf8);
    border: none;
}

.ice-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ice-user-admin {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 800;
    color: #6ee7b7;
    letter-spacing: .5px;
}

@media (max-width: 1024px) {
    .ice-user-name { max-width: 84px; }
}

/* 移动端：Dock 中的账户项 */
@media (max-width: 767px) {
    .dock-item img.dock-avatar {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid rgba(56, 189, 248, 0.4);
    }
}
