/* ================================================================
   文件操作监控管理系统 — 主样式表  v2
   强制浅色主题，不依赖 CSS 变量继承
   ================================================================ */

/* ── 强制覆盖 Bootstrap 5.3 暗色模式 ──────────────────────────── */
html, html[data-bs-theme="light"] {
  color-scheme: light !important;
}

/* ── 全局 ──────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  color: #1e293b !important;
  background-color: #f0f2f5 !important;
  margin: 0;
}

/* ── 尺寸变量 ─────────────────────────────────────────────────── */
:root {
  --topbar-h: 56px;
  --sidebar-w: 220px;
}

/* ================================================================
   顶部导航栏
   ================================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #1a3c61 !important;
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1030;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}

.topbar-brand {
  display: flex;
  align-items: center;
  color: #ffffff !important;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .4px;
  flex: 1;
  gap: 8px;
  text-decoration: none;
}

.topbar-brand i { font-size: 20px; color: #7ec8f4 !important; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-version {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  font-family: monospace;
}

.topbar-user-btn {
  color: rgba(255,255,255,.85) !important;
  font-size: 13px;
  text-decoration: none !important;
  padding: 4px 10px;
  border: none;
  background: transparent;
}

.topbar-user-btn:hover { color: #ffffff !important; }

/* dropdown 在深色 topbar 上 */
.topbar .dropdown-menu {
  background: #ffffff !important;
  border: 1px solid #dee2e8;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

.topbar .dropdown-item { color: #1e293b !important; }
.topbar .dropdown-item:hover { background: #f0f4fa !important; }
.topbar .dropdown-item.text-danger { color: #dc2626 !important; }

/* ================================================================
   页面骨架（sidebar + main）
   ================================================================ */
.page-wrapper {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-h);
}

/* ================================================================
   侧边栏
   ================================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #ffffff !important;
  border-right: 1px solid #dee2e8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-nav { padding: 14px 0; flex: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: #475569 !important;
  text-decoration: none !important;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
  white-space: nowrap;
}

.sidebar-link i { font-size: 17px; flex-shrink: 0; }

.sidebar-link:hover {
  background: #f0f4fa !important;
  color: #2563eb !important;
  border-left-color: #c7d9f7;
}

.sidebar-link.active {
  background: #e8f0fe !important;
  color: #1d4ed8 !important;
  border-left-color: #2563eb;
  font-weight: 600;
}

.sidebar-footer {
  padding: 10px 18px;
  font-size: 12px;
  border-top: 1px solid #dee2e8;
  color: #94a3b8 !important;
}

/* ================================================================
   主内容区
   ================================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  background: #f0f2f5 !important;
}

.content-inner {
  padding: 24px 28px;
  max-width: 1600px;
}

.page-header { margin-bottom: 20px; }

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a3c61 !important;
  margin: 0;
}

/* ================================================================
   卡片面板
   ================================================================ */
.card-panel {
  background: #ffffff !important;
  border: 1px solid #dee2e8 !important;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.card-header-custom {
  padding: 11px 16px;
  background: #f8fafc !important;
  border-bottom: 1px solid #dee2e8;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: 13.5px;
  color: #1a3c61 !important;
  display: flex;
  align-items: center;
}

.card-footer {
  background: #f8fafc !important;
  border-top: 1px solid #dee2e8;
  padding: 10px 16px;
}

/* ================================================================
   统计卡片
   ================================================================ */
.stat-card {
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  border: none !important;
}

.stat-card-primary { background: linear-gradient(135deg,#1a3c61,#2563eb) !important; color:#fff !important; }
.stat-card-info    { background: linear-gradient(135deg,#0e7490,#06b6d4) !important; color:#fff !important; }
.stat-card-success { background: linear-gradient(135deg,#166534,#16a34a) !important; color:#fff !important; }
.stat-card-warning { background: linear-gradient(135deg,#92400e,#d97706) !important; color:#fff !important; }

.stat-card .stat-icon  { font-size: 38px; opacity: .85; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1; color:#fff !important; }
.stat-card .stat-label { font-size: 12px; opacity: .85; margin-top: 4px; color:#fff !important; }

/* ================================================================
   条形图（7日趋势）
   ================================================================ */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding: 0 8px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.bar-label-top { font-size: 10px; color: #64748b; min-height: 14px; text-align: center; }

.bar-track {
  flex: 1;
  width: 100%;
  background: #e2e8f0;
  border-radius: 3px 3px 0 0;
  display: flex;
  align-items: flex-end;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(to top, #2563eb, #93c5fd);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.bar-label-bot { font-size: 10px; color: #64748b; white-space: nowrap; }

/* ================================================================
   排行榜
   ================================================================ */
.rank-list { list-style: none; padding: 0; margin: 0; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  color: #1e293b !important;
}

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

.rank-no {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.rank-1 { background: #f59e0b; color: #fff !important; }
.rank-2 { background: #9ca3af; color: #fff !important; }
.rank-3 { background: #cd7c3e; color: #fff !important; }
.rank-n { background: #e8ecf1; color: #64748b !important; }

.rank-name { flex: 1; overflow: hidden; color: #1e293b !important; }
.rank-cnt  { font-weight: 600; color: #2563eb !important; }

/* ================================================================
   数据表格
   ================================================================ */
.data-table { font-size: 13px; }

.data-table thead th {
  background: #f8fafc !important;
  color: #1a3c61 !important;
  font-weight: 600;
  border-bottom: 2px solid #dee2e8 !important;
  white-space: nowrap;
  padding: 9px 12px;
}

.data-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
  color: #1e293b !important;
  background: #ffffff !important;
  border-bottom: 1px solid #f1f5f9 !important;
}

.data-table tbody tr:hover td { background: #f0f5ff !important; }

.table-row-disabled td { opacity: .45; }

/* ================================================================
   徽章（文件类型 / 操作类型）
   ================================================================ */
.badge-ext-img   { background: #dcfce7 !important; color: #166534 !important; }
.badge-ext-video { background: #fef3c7 !important; color: #92400e !important; }
.badge-ext-audio { background: #dbeafe !important; color: #1e40af !important; }
.badge-ext-doc   { background: #ede9fe !important; color: #5b21b6 !important; }
.badge-ext-arch  { background: #ffedd5 !important; color: #9a3412 !important; }
.badge-ext-other { background: #f1f5f9 !important; color: #475569 !important; }

.badge-op-open   { background: #dbeafe !important; color: #1d4ed8 !important; }
.badge-op-create { background: #dcfce7 !important; color: #15803d !important; }
.badge-op-rename { background: #fef9c3 !important; color: #854d0e !important; }
.badge-op-unlink { background: #fee2e2 !important; color: #b91c1c !important; }

.proc-badge {
  display: inline-block;
  background: #f0f4fa !important;
  color: #1a3c61 !important;
  border: 1px solid #c9d8ef;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: "SF Mono","Cascadia Code","Consolas",monospace;
  white-space: nowrap;
}

.proc-badge-off { opacity: .45; }

/* ================================================================
   通用工具
   ================================================================ */
.text-mono { font-family: "SF Mono","Cascadia Code","Consolas",monospace; }

.link-muted { color: #64748b !important; text-decoration: none; }
.link-muted:hover { color: #2563eb !important; }

.btn-xs {
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 4px;
}

/* 详情弹窗 DL */
.detail-dl { margin: 0; }
.detail-dl dt { font-weight: 600; color: #64748b !important; font-size: 12px; }
.detail-dl dd { font-size: 13px; color: #1e293b !important; word-break: break-all; }

/* Nav Tabs */
.nav-tabs {
  border-bottom: 2px solid #dee2e8;
}

.nav-tabs .nav-link {
  color: #64748b !important;
  font-size: 13.5px;
  border: none;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.nav-tabs .nav-link:hover {
  color: #2563eb !important;
  border-bottom-color: #93c5fd;
  background: transparent;
}

.nav-tabs .nav-link.active {
  color: #2563eb !important;
  font-weight: 600;
  border-bottom: 2px solid #2563eb;
  background: transparent;
}

/* Alert */
.alert { font-size: 13.5px; }

/* Form elements */
.form-label { color: #374151 !important; }
.form-control, .form-select {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border-color: #d1d5db !important;
}
.form-control:focus, .form-select:focus {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15) !important;
}

/* ================================================================
   API 密钥行
   ================================================================ */
.key-row .key-input {
  cursor: text;
  user-select: all;
}

.key-row .key-input:focus {
  box-shadow: none !important;
  border-color: #2563eb !important;
}

/* ================================================================
   登录页
   ================================================================ */
.login-body {
  min-height: 100vh;
  background: #081a34 !important;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 32px clamp(20px, 6vw, 86px);
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../PostShield_login.png") center center / cover no-repeat;
  z-index: 0;
}

.login-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(4, 16, 34, 0.72) 0%,
    rgba(4, 16, 34, 0.54) 32%,
    rgba(4, 16, 34, 0.2) 64%,
    rgba(4, 16, 34, 0.12) 100%
  );
  z-index: 1;
}

.login-wrapper {
  width: 100%;
  position: relative;
  z-index: 2;
}

.login-left {
  width: clamp(340px, 33vw, 620px);
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vw, 18px);
  margin-top: clamp(60px, 10vh, 130px);
}

.login-card {
  background: rgba(9, 20, 40, 0.82) !important;
  border: 1px solid rgba(147, 197, 253, 0.32);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: clamp(18px, 2vw, 36px) clamp(16px, 1.8vw, 32px);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.56);
}

.login-brand { text-align: left; }

.login-site-name {
  font-size: clamp(40px, 4.2vw, 56px);
  font-weight: 700;
  color: #ffffff !important;
  margin: 0 0 8px;
  letter-spacing: .02em;
}

.login-site-sub {
  font-size: clamp(18px, 1.8vw, 24px);
  color: #d2e8ff !important;
  margin: 0;
  line-height: 1.35;
}

.login-btn {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9) !important;
  border: none !important;
  font-size: clamp(14px, 0.9vw, 16px);
  font-weight: 600;
  min-height: clamp(40px, 2.6vw, 48px);
  padding: 11px;
  letter-spacing: .5px;
  color: #ffffff !important;
}

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

.login-footer-text {
  text-align: left;
  color: rgba(233, 243, 255, .72);
  font-size: clamp(11px, 0.75vw, 13px);
  margin-top: 2px;
}

/* ── 登录页 input 特别处理 ──── */
.login-card .form-label {
  color: #d5e8ff !important;
  font-size: clamp(12px, 0.85vw, 14px);
}

.login-card .input-group-text {
  background: rgba(15, 30, 58, 0.88) !important;
  color: #b3d8ff !important;
  border-color: rgba(148, 188, 255, 0.32) !important;
}

.login-card .form-control {
  background: rgba(10, 25, 48, 0.78) !important;
  border-color: rgba(148, 188, 255, 0.32) !important;
  color: #f4f8ff !important;
  min-height: clamp(38px, 2.4vw, 46px);
  font-size: clamp(13px, 0.86vw, 15px);
}

.login-card .form-control::placeholder {
  color: #8fabd4 !important;
}

.login-card .form-control:focus {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

.login-card .alert-warning {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: rgba(251, 191, 36, 0.42) !important;
  color: #ffefc2 !important;
}

.login-card .alert-danger {
  background: rgba(220, 38, 38, 0.22) !important;
  border-color: rgba(252, 165, 165, 0.38) !important;
  color: #ffe0e0 !important;
}

/* ================================================================
   响应式
   ================================================================ */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content-inner { padding: 14px; }
}

@media (max-width: 576px) {
  .stat-value { font-size: 22px !important; }
  .topbar-brand span { font-size: 14px; }

  .login-body {
    justify-content: center;
    padding: 16px;
  }

  .login-body::after {
    background: linear-gradient(
      180deg,
      rgba(4, 16, 34, 0.68) 0%,
      rgba(4, 16, 34, 0.42) 60%,
      rgba(4, 16, 34, 0.28) 100%
    );
  }

  .login-left {
    width: min(620px, 100%);
    margin-top: clamp(22px, 6vh, 60px);
  }

  .login-card {
    padding: 20px 16px;
  }
}
