/* =============================================================================
   FantasyOS · 系统应用窗口交互框架 (fd-os-app.css)
   为所有前台业务页面提供统一的桌面原生应用壳层：
   顶部工具栏 (.os-toolbar) + 左侧导航栏 (.os-sidebar) + 主工作区 (.os-main) + 状态栏 (.os-statusbar)
   严格复用 FantasyOS 配色（深渊黑 + 霓虹青/洋红 + 磨砂玻璃），同时完美适配 iframe 嵌入与独立访问。
   ============================================================================= */

:root {
  --os-app-bg: rgba(5, 9, 18, 0.94);
  --os-app-panel: rgba(11, 17, 32, 0.78);
  --os-app-panel-hover: rgba(16, 26, 48, 0.9);
  --os-app-sidebar: rgba(7, 11, 22, 0.86);
  --os-app-toolbar: rgba(8, 13, 25, 0.9);
  --os-app-border: rgba(0, 240, 255, 0.14);
  --os-app-border-strong: rgba(0, 240, 255, 0.34);
  --os-app-accent: #00f0ff;
  --os-app-accent-soft: rgba(0, 240, 255, 0.12);
  --os-app-pink: #ff007f;
  --os-app-text: #e2e8f0;
  --os-app-muted: #94a3b8;
  --os-app-dim: #64748b;
  --os-app-radius: 12px;
  --os-app-radius-sm: 8px;
}

/* ── 嵌入桌面窗口模式：消除外层滚动与留白，应用直接铺满整个窗口视口 ──────────── */
html.fd-embedded body.fd-apple {
  overflow: hidden !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  background: #050912 !important;
}

html.fd-embedded .fd-app-window,
html.fd-embedded .fd-app-body {
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

html.fd-embedded .fd-app-body > main {
  height: 100dvh !important;
  overflow: auto !important;
  padding: 0 !important;
}

/* 当页面自身使用 .os-app 容器时，由 .os-main 接管内部滚动，避免出现双滚动条 */
html.fd-embedded .fd-app-body > main:has(> .os-app) {
  overflow: hidden !important;
}

/* ── 1. 系统应用主壳层 (.os-app) ────────────────────────────────────────────── */
.os-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: calc(100dvh - 56px);
  background: var(--os-app-bg);
  color: var(--os-app-text);
  position: relative;
}

html.fd-embedded .os-app {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

/* ── 2. 顶部系统工具栏 (.os-toolbar) ────────────────────────────────────────── */
.os-toolbar {
  flex-shrink: 0;
  min-height: 50px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--os-app-toolbar);
  border-bottom: 1px solid var(--os-app-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 20;
}

.os-toolbar-left,
.os-toolbar-center,
.os-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.os-toolbar-center {
  flex: 1 1 240px;
  max-width: 460px;
  justify-content: center;
}

.os-app-badge {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--os-app-border-strong);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.14);
  flex-shrink: 0;
}

.os-app-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.os-app-sub {
  font-size: 11px;
  color: var(--os-app-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  white-space: nowrap;
}

.os-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--os-app-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: all 0.15s ease;
  text-decoration: none;
  cursor: pointer;
}

.os-back-btn:hover {
  color: #fff;
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--os-app-border-strong);
}

/* 工具栏紧凑搜索框 */
.os-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.os-search-icon {
  position: absolute;
  left: 10px;
  color: var(--os-app-dim);
  font-size: 12px;
  pointer-events: none;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.os-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 30px;
  border-radius: 9px;
  background: rgba(2, 6, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.os-search input::placeholder {
  color: var(--os-app-dim);
}

.os-search input:focus {
  border-color: var(--os-app-accent);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
}

/* ── 3. 主体工作区 (.os-body = .os-sidebar + .os-main) ─────────────────────── */
.os-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.os-sidebar {
  width: 224px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 10px;
  background: var(--os-app-sidebar);
  border-right: 1px solid var(--os-app-border);
  overflow-y: auto;
}

.os-nav-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.os-nav-label {
  padding: 0 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--os-app-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.os-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--os-app-muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.os-nav-item:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

.os-nav-item.is-active,
.os-nav-item.active,
.os-nav-item.is-on {
  color: #67e8f9;
  background: var(--os-app-accent-soft);
  border-color: rgba(0, 240, 255, 0.28);
  font-weight: 600;
}

.os-nav-item.is-active::before,
.os-nav-item.active::before,
.os-nav-item.is-on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--os-app-accent);
  box-shadow: 0 0 8px var(--os-app-accent);
}

.os-nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--os-app-muted);
}

.os-nav-item.is-active .os-nav-badge,
.os-nav-item.active .os-nav-badge {
  background: rgba(0, 240, 255, 0.18);
  color: #a5f3fc;
}

.os-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 22px 28px;
}

.os-main-narrow {
  max-width: 960px;
  margin: 0 auto;
}

/* 自定义系统细滚动条 */
.os-sidebar::-webkit-scrollbar,
.os-main::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.os-sidebar::-webkit-scrollbar-thumb,
.os-main::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.24);
  border-radius: 999px;
}

.os-sidebar::-webkit-scrollbar-thumb:hover,
.os-main::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.42);
}

/* ── 4. 底部系统状态栏 (.os-statusbar) ──────────────────────────────────────── */
.os-statusbar {
  flex-shrink: 0;
  height: 28px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(4, 7, 15, 0.94);
  border-top: 1px solid var(--os-app-border);
  font-size: 11px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--os-app-dim);
}

.os-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  margin-right: 6px;
}

/* ── 5. 通用系统控件与卡片 ──────────────────────────────────────────────────── */
.os-segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: rgba(2, 6, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.os-seg-btn {
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--os-app-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.os-seg-btn:hover {
  color: #f8fafc;
}

.os-seg-btn.is-active,
.os-seg-btn.active {
  color: #03111c;
  background: linear-gradient(135deg, #22d3ee, #38bdf8);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.os-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.os-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: var(--os-app-border-strong);
  color: #fff;
}

.os-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: #02111d;
  background: linear-gradient(135deg, #00f0ff, #38bdf8);
  border: 1px solid rgba(0, 240, 255, 0.6);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.24);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.os-btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.42);
}

.os-panel {
  background: var(--os-app-panel);
  border: 1px solid var(--os-app-border);
  border-radius: var(--os-app-radius);
  padding: 16px 18px;
  backdrop-filter: blur(14px);
}

.os-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.os-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.os-kv-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.os-kv-card {
  background: var(--os-app-panel);
  border: 1px solid var(--os-app-border);
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.os-kv-label {
  font-size: 11px;
  color: var(--os-app-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.os-kv-value {
  font-size: 20px;
  font-weight: 800;
  color: #f8fafc;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.os-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 240, 255, 0.1);
  color: #67e8f9;
  border: 1px solid rgba(0, 240, 255, 0.22);
}

.os-empty {
  text-align: center;
  padding: 48px 20px;
  border-radius: var(--os-app-radius);
  border: 1px dashed rgba(148, 163, 184, 0.22);
  background: rgba(8, 13, 25, 0.45);
  color: var(--os-app-muted);
}

/* ── 6. 响应式：移动端自动将左侧栏折为顶部横向导航条 ────────────────────────── */
@media (max-width: 860px) {
  .os-body {
    flex-direction: column;
  }

  .os-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 12px;
    gap: 8px;
    border-right: none;
    border-bottom: 1px solid var(--os-app-border);
  }

  .os-nav-section {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .os-nav-label {
    display: none;
  }

  .os-nav-item {
    width: auto;
    padding: 6px 10px;
    white-space: nowrap;
  }

  .os-nav-item.is-active::before,
  .os-nav-item.active::before,
  .os-nav-item.is-on::before {
    display: none;
  }

  .os-main {
    padding: 14px 12px 24px;
  }

  .os-toolbar {
    padding: 8px 12px;
  }

  .os-toolbar-center {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
}
