/* ============================================================
   ZIMO·PANEL — panel.css
   主面板布局 / 组件 / 设备 × 朝向 响应式
   布局原则：桌面（≥1024 宽 × ≥700 高）单页平铺零滚动；
   平板 / 手机按朝向分档，面板协调排布。
   ============================================================ */

body[data-page="panel"] {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0 0 env(safe-area-inset-bottom);
}

/* 顶栏样式见 base.css（面板 / 设置页共享） */

/* ---------------------------------------------
   仪表盘网格
   --------------------------------------------- */
.dash {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-content: start;
  grid-auto-flow: dense;
  width: 100%;
  max-width: 2560px;
  margin: 0 auto;
  padding: var(--gap);
}

/* 基础（手机竖屏）：单列。
   用 :where() 把特异性降为 0，确保各断点的 .p-xxx 跨度规则能够覆盖 */
:where(.dash) > :where(.panel) {
  grid-column: span 12;
}

/* ---------------------------------------------
   时钟面板（纵向绝不溢出：内容自适应缩放由 panel.js 的 fitClock 完成）
   --------------------------------------------- */
.p-clock .panel-body {
  padding: 6px 10px 8px;
  min-height: 120px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.clock-hex {
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  user-select: none;
}

/* ---------------------------------------------
   系统概览
   --------------------------------------------- */
.sys-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.sys-grid .wide {
  grid-column: 1 / -1;
}

.ip-value {
  cursor: help;
  color: var(--orange);
  word-break: break-all;
}

/* ---------------------------------------------
   核心入口导航卡片
   --------------------------------------------- */
.nav-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.nav-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 10px;
  min-height: 96px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.nav-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  transition: background 0.18s;
}

.nav-card:hover,
.nav-card:focus-visible {
  border-color: var(--orange-line);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 69, 0, 0.12);
  outline: none;
}

.nav-card:hover::before,
.nav-card:focus-visible::before {
  background: var(--orange);
}

.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-arrow {
  color: var(--orange);
  font-size: 14px;
  transition: transform 0.18s;
}

.nav-card:hover .nav-arrow {
  transform: translate(2px, -2px);
}

.nav-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}

.nav-cn {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
}

.nav-host {
  margin-top: auto;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------
   图表容器
   --------------------------------------------- */
.chart-box {
  position: relative;
  width: 100%;
  height: clamp(140px, 20vh, 210px);
}

/* chart-lite.js 读取 canvas 的 CSS 尺寸，必须显式铺满容器 */
.chart-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-align: center;
  padding: 10px;
}

/* ---------------------------------------------
   内存 / 存储
   --------------------------------------------- */
.mem-block .row-between {
  font-size: 11px;
  margin-bottom: 6px;
}

.disk-item {
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.disk-item:last-child {
  border-bottom: none;
}

.disk-item .disk-mount {
  font-size: 11px;
  font-weight: 700;
}

.disk-item .disk-io {
  font-size: 10px;
  white-space: nowrap;
}

.disk-io .io-r {
  color: var(--green);
}

.disk-io .io-w {
  color: var(--blue);
}

.disk-item .disk-usage {
  font-size: 10px;
  color: var(--text-soft);
  margin-top: 3px;
}

/* ---------------------------------------------
   联系方式：平台图标瓦片网格（内联 SVG，点击跳转/复制）
   --------------------------------------------- */
.contact-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.contact-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 74px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

a.contact-tile:hover,
button.contact-tile:hover,
.contact-tile:focus-visible {
  border-color: var(--orange-line);
  background: var(--orange-soft);
  transform: translateY(-2px);
  outline: none;
}

.contact-tile.is-copied {
  border-color: var(--green);
  background: rgba(22, 163, 74, 0.08);
}

.contact-ico {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--fill-weak);
  color: var(--text);
  transition: color 0.15s, border-color 0.15s;
}

.contact-ico svg {
  width: 19px;
  height: 19px;
  display: block;
}

.contact-tile:hover .contact-ico,
.contact-tile.is-copied .contact-ico {
  color: var(--orange);
  border-color: var(--orange-line);
}

.contact-name {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  white-space: nowrap;
}

.contact-tile:hover .contact-name,
.contact-tile.is-copied .contact-name {
  color: var(--orange);
}

/* ============================================================
   响应式：手机 / 平板 / 电脑 × 横屏 / 竖屏
   ============================================================ */

/* 小屏手机横屏与大屏手机竖屏：两栏配对 */
@media (min-width: 520px) {
  .p-cpu,
  .p-net,
  .p-mem,
  .p-storage {
    grid-column: span 6;
  }
  .p-clock,
  .p-system,
  .p-nav,
  .p-contact {
    grid-column: span 12;
  }

  /* 联系瓦片一行六个 */
  .contact-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .contact-tile {
    min-height: 64px;
    padding: 6px 2px;
  }
}

/* 平板（竖屏 768+ / 横屏前的过渡档） */
@media (min-width: 768px) {
  :root {
    --gap: 16px;
  }

  .p-clock,
  .p-system {
    grid-column: span 6;
  }
  .p-nav {
    grid-column: span 12;
  }
  .p-cpu,
  .p-net {
    grid-column: span 6;
  }
  .p-mem,
  .p-storage {
    grid-column: span 6;
  }
  .p-contact {
    grid-column: span 12;
  }

  .sys-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chart-box {
    height: clamp(150px, 22vh, 220px);
  }

  /* 宽屏下的联系瓦片回到 3×2 */
  .contact-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .contact-tile {
    min-height: 74px;
  }
}

/* 桌面（横屏宽屏）：12 列网格铺开，单页平铺。
   行序：时钟+概览 → 核心入口 → CPU+网络+内存 → 存储+联系（底行加高）。 */
@media (min-width: 1024px) {
  :root {
    --gap: 16px;
  }

  .p-clock {
    grid-column: span 4;
  }
  .p-system {
    grid-column: span 8;
  }
  .p-nav {
    grid-column: span 12;
  }
  .p-cpu {
    grid-column: span 5;
  }
  .p-net {
    grid-column: span 4;
  }
  .p-mem {
    grid-column: span 3;
  }
  .p-storage {
    grid-column: span 8;
  }
  .p-contact {
    grid-column: span 4;
  }

  .p-clock .panel-body {
    min-height: 140px;
  }

  /* 入口卡片紧凑化（单行三列） */
  .nav-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-card {
    min-height: 84px;
    padding: 10px 12px;
  }

  .nav-title {
    font-size: 15px;
  }

  /* 联系瓦片：3 列 × 2 行 */
  .contact-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .contact-tile {
    min-height: 78px;
  }

  .contact-ico {
    width: 30px;
    height: 30px;
  }
}

/* 桌面一屏布局：视口高度足够时锁定 100dvh，四行网格完整排满一页 */
@media (min-width: 1024px) and (min-height: 700px) {
  body[data-page="panel"] {
    height: 100dvh;
    overflow: hidden;
  }

  .dash {
    flex: 1;
    min-height: 0;
    /* 行高分配：首行适中 / 入口自适应 / 图表行压矮 / 底行加高 */
    grid-template-rows: minmax(150px, 1fr) auto minmax(160px, 0.9fr) minmax(200px, 1.15fr);
  }

  .p-clock .panel-body {
    min-height: 0;
  }

  /* 图表面板：曲线填满剩余高度（整体行已压矮） */
  .p-cpu .panel-body,
  .p-net .panel-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .chart-box {
    height: auto;
    flex: 1;
    min-height: 90px;
  }

  /* 存储面板内部滚动，不撑破一屏 */
  .p-storage .panel-body {
    min-height: 0;
    overflow: auto;
  }

  .p-contact .panel-body {
    display: flex;
    align-items: center;
    min-height: 0;
    overflow: hidden;
  }
}

/* ---------------------------------------------
   浏览器标识（device.js）细化规则
   --------------------------------------------- */
/* 触屏设备：放大触摸目标 */
html[data-touch="true"] .btn {
  min-height: 40px;
}

html[data-touch="true"] .contact-tile {
  min-height: 64px;
}

html[data-touch="true"] .nav-card {
  min-height: 96px;
}

html[data-touch="true"] .field input {
  min-height: 42px;
}

/* 手机横屏：压缩纵向留白，让首屏信息更紧凑 */
html[data-device="mobile"][data-orient="landscape"] .dash {
  --gap: 10px;
  padding: 10px;
}

html[data-device="mobile"][data-orient="landscape"] .p-clock .panel-body {
  min-height: 88px;
}

html[data-device="mobile"][data-orient="landscape"] .chart-box {
  height: 120px;
}

html[data-device="mobile"][data-orient="landscape"] .contact-list {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

html[data-device="mobile"][data-orient="landscape"] .contact-tile {
  min-height: 56px;
  padding: 4px 2px;
}

/* 手机横屏尝试两栏铺开 */
@media (max-width: 1023px) and (orientation: landscape) and (min-width: 620px) {
  .p-cpu,
  .p-net,
  .p-mem,
  .p-storage,
  .p-contact {
    grid-column: span 6;
  }

  /* 横屏矮视口（手机横屏特征）：联系瓦片一行六个 */
  .contact-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .contact-tile {
    min-height: 56px;
    padding: 4px 2px;
  }
}

/* 手机竖屏：入口卡片单列 */
html[data-device="mobile"][data-orient="portrait"] .nav-grid {
  grid-template-columns: 1fr;
}

html[data-device="mobile"][data-orient="portrait"] .nav-card {
  min-height: 72px;
  padding: 10px 12px;
}

/* 手机竖屏联系瓦片 3×2 */
html[data-device="mobile"][data-orient="portrait"] .contact-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 平板：入口卡片三列 */
html[data-device="tablet"] .nav-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 极窄屏兜底 */
@media (max-width: 380px) {
  .nav-grid {
    grid-template-columns: 1fr !important;
  }
  .sys-grid {
    grid-template-columns: 1fr;
  }
  .contact-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================================
   面板点击放大（详情弹窗）
   ============================================================ */

/* 可缩放面板：悬停给出可点击暗示 */
.panel[data-zoom] {
  cursor: pointer;
}

.panel[data-zoom]:hover {
  border-color: var(--orange-line);
}

.panel[data-zoom] .zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.panel[data-zoom]:hover .zoom-btn,
.panel[data-zoom] .zoom-btn:focus-visible {
  opacity: 1;
}

.panel[data-zoom] .zoom-btn:hover {
  color: var(--orange);
  border-color: var(--orange-line);
}

/* 遮罩 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(10, 12, 14, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modal-fade 0.18s ease both;
}

.modal-mask[hidden] {
  display: none;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 弹窗盒子：继承面板质感 + HUD 角标 */
.modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(860px, 100%);
  max-height: min(86dvh, 860px);
  background: var(--panel-solid);
  border: 1px solid var(--orange-line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 0 24px var(--orange-soft);
  animation: modal-pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.modal-box::before,
.modal-box::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 1;
}

.modal-box::before {
  top: 4px;
  left: 4px;
  border-top: 2px solid var(--orange);
  border-left: 2px solid var(--orange);
}

.modal-box::after {
  bottom: 4px;
  right: 4px;
  border-bottom: 2px solid var(--orange);
  border-right: 2px solid var(--orange);
}

@keyframes modal-pop {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange);
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

/* 弹窗内容组件 */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 18px;
}

.kv-grid .wide {
  grid-column: 1 / -1;
}

.modal-time {
  font-family: var(--font-pixel);
  font-size: clamp(44px, 9vw, 96px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}

.modal-date {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--orange);
  margin-bottom: 10px;
}

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

.core-item .bar {
  margin-top: 6px;
}

/* 弹窗内大号进度条 */
.bar.big {
  height: 14px;
}

/* 联系方式详情行 */
.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px dashed var(--border);
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-row .contact-ico {
  width: 38px;
  height: 38px;
}

.contact-row .contact-ico svg {
  width: 21px;
  height: 21px;
}

.contact-row-info {
  flex: 1;
  min-width: 0;
}

.contact-row-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text);
}

.contact-row-val {
  font-size: 12px;
  color: var(--text-soft);
  word-break: break-all;
}

/* 入口详情大卡 */
.nav-row-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  margin-bottom: 10px;
}

.nav-row-card:last-child {
  margin-bottom: 0;
}

.nav-row-card .nav-title {
  font-size: 17px;
}

/* 手机端弹窗全屏化 */
@media (max-width: 519px) {
  .modal-mask {
    padding: 10px;
  }

  .modal-box {
    max-height: 92dvh;
  }

  .modal-body {
    padding: 12px;
  }
}
