/* ===== 青龙脚本库 - 三端自适应样式 ===== */
:root {
  --primary-dark: #3b5de7;
  --success: #22c55e;
  --danger: #ef4444;
  --muted: #64748b;
  --line: #e2e8f0;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ===== 导航 ===== */
.topbar {
  background: var(--nav-bg, var(--white));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.topbar .nav a { color: var(--ink); }
.topbar .nav a:hover, .topbar .nav a.active { color: var(--white); background: var(--primary); }
.topbar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: auto;
  padding: 6px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 900;
  font-size: 28px;
  margin: 6px 0;
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
}
.brand-mark img { height: 40px; width: auto; border-radius: 6px; object-fit: contain; display: block; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.nav a:hover, .nav a.active { color: var(--primary); background: color-mix(in srgb, var(--primary) 15%, transparent); font-weight: 600; }

/* ===== 内容区 ===== */
.page-content { padding: 14px 0; }

/* ===== 统计卡片 ===== */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.muted { color: var(--muted); font-size: 12px; }
.overview-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* ===== 面板 ===== */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 8px;
}
.panel-sm {
  padding: 14px 16px;
  margin-bottom: 12px;
}
.panel-sm .section-title { font-size: 15px; margin-bottom: 10px; }
.panel-sm .filter-bar { align-items: center; }
.panel-sm .field input, .panel-sm .field select { padding: 7px 10px; font-size: 13px; }
.panel-sm .button { padding: 7px 16px; font-size: 13px; }
.section-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; color: var(--ink); text-align: center; }

/* ===== 表单 ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: end;
}
/* 类型筛选弹窗 */
.type-popup { position: absolute; top: 100%; left: 0; right: 0; z-index: 500; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 220px; overflow-y: auto; }
.type-opt { display: block; padding: 8px 14px; text-decoration: none; color: var(--ink); font-size: 14px; transition: background .15s; }
.type-opt:hover, .type-opt.active { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--primary); }
.type-opt + .type-opt { border-top: 1px solid var(--line); }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label { font-weight: 600; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: var(--white);
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
small { font-size: 12px; color: var(--muted); }

/* ===== 按钮 ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent); }
.button-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent); }
.button-secondary { background: #e2e8f0; color: var(--ink); }
.button-secondary:hover { background: #cbd5e1; }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: #dc2626; }
.button-ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.button-ghost:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.button-compact { padding: 6px 12px; font-size: 13px; }
.full { width: 100%; }

/* ===== 脚本列表 ===== */
.script-list { display: flex; flex-direction: column; }
.script-row {
  display: grid;
  grid-template-columns: 1.5fr 70px 60px 140px 60px 80px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  margin-bottom: 6px;
  transition: box-shadow .15s;
}
.script-row:hover { box-shadow: var(--shadow); }
.script-row-head {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  margin-bottom: 0;
}
.script-main { min-width: 0; }
.row-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.script-cell { font-size: 13px; }
.cell-label { display: none; font-size: 12px; color: var(--muted); }
.script-actions { text-align: center; }

/* 徽章 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: rgba(34,197,94,.12); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.badge-danger { background: rgba(239,68,68,.1); color: var(--danger); }

/* ===== 友情链接 ===== */
.friends-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.friends-item a {
  display: block;
  padding: 16px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: #fff;
  transition: all .2s;
}
.friends-item a:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.friends-item .title { display: block; font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.friends-item .content { display: flex; align-items: center; gap: 10px; }
.friends-item .desc { font-size: 13px; opacity: .9; flex: 1; }
.friends-item .avatar { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; border: 2px solid rgba(255,255,255,.3); flex-shrink: 0; }

/* ===== 公告 ===== */
.announcement-list { list-style: none; padding: 0; }
.announcement-list li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.announcement-list li:last-child { border-bottom: none; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* ===== 详情页 ===== */
.detail-shell { max-width: 800px; margin: 0 auto; }
.detail-card { padding: 20px; }
.detail-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.detail-title { font-size: 20px; }
.detail-specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.spec-card { padding: 10px 6px; font-size: 12px; }
.spec-card strong { display: block; margin-top: 2px; font-size: 14px; }
.detail-intro { margin-bottom: 20px; }
.detail-intro h3 { margin-bottom: 8px; font-size: 15px; }
.detail-file-info pre { background: #0f172a; color: #93c5fd; padding: 14px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; font-size: 13px; }
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.shot-card { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.shot-card img { width: 100%; height: 140px; object-fit: cover; display: block; }

/* ===== 上传页 ===== */
.upload-shell { display: flex; justify-content: center; }
.upload-panel { max-width: 640px; width: 100%; }
.upload-title { text-align: center; font-size: 22px; }
.upload-intro { text-align: center; margin-bottom: 20px; }
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ===== 消息 ===== */
.message { padding: 12px 16px; border-radius: 8px; margin-top: 12px; font-size: 14px; }
.message-success { background: rgba(34,197,94,.1); color: var(--success); }
.message-error { background: rgba(239,68,68,.1); color: var(--danger); }

/* Toast 提示 */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); padding: 12px 24px; border-radius: 10px; font-size: 14px; font-weight: 500; color: #fff; z-index: 10000; opacity: 0; transition: all .3s ease; box-shadow: 0 4px 20px rgba(0,0,0,.15); white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ===== 页脚 ===== */
.footer { padding: 14px 0; margin-top: 20px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.footer-copyright, .footer-icp { margin: 4px 0; }
.footer-icp a { color: var(--muted); text-decoration: none; }
.footer-icp a:hover { color: var(--primary); }
.footer-custom { margin-bottom: 8px; }

/* ===== 回到顶部 ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 99;
  transition: all .2s;
}
.back-to-top:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { max-width: 380px; width: 100%; }

/* ===== 管理后台 ===== */
.admin-body { background: color-mix(in srgb, var(--bg) 90%, var(--primary) 10%); }
.admin-topbar { background: var(--nav-bg); border-bottom: none; min-height: 50px; }
.admin-topbar .topbar-inner { flex-direction: row; height: auto; padding: 6px 12px; gap: 4px; }
.admin-logo { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; margin-right: 4px; }
.admin-logo img { width: 100%; height: 100%; object-fit: contain; }
.admin-topbar .nav a { color: #fff !important; opacity: .85; font-size: 14px; padding: 5px 10px; border-left: 1px solid rgba(255,255,255,.2); border-right: 1px solid rgba(255,255,255,.2); }
.admin-topbar .nav a:first-child { border-left: none; }
.admin-topbar .nav a:last-child { border-right: none; }
.admin-topbar .nav a:hover, .admin-topbar .nav a.active { color: #fff !important; opacity: 1; background: color-mix(in srgb, var(--primary) 40%, transparent); }
.admin-user { display: flex; align-items: center; }
.admin-topbar .admin-user .button { color: #94a3b8; border-color: rgba(255,255,255,.15); font-size: 13px; padding: 5px 12px; }
/* 手机底部导航（桌面端隐藏） */
.mnav { display: none; }
.mmenu { display: none; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* 后台脚本表格 */
.script-table-admin { width: 100%; }
.script-thead-admin, .script-trow-admin {
  display: grid;
  grid-template-columns: 1.3fr 70px 55px 90px 70px 55px 60px;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
}
.script-thead-admin {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom: none;
}
.script-trow-admin {
  border: 1px solid var(--line);
  border-top: none;
  background: var(--white);
}
.script-trow-admin:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.script-trow-admin:hover { background: #f8fafc; }
.script-trow-admin { cursor: pointer; }
.script-trow-admin .st-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.st-title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.st-date { font-size: 12px; color: var(--muted); }

/* 列表项 */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; background: var(--white); }
.item-content, .item-info { flex: 1; min-width: 0; }
.item-actions { display: flex; gap: 8px; }

/* 链接项 */
.link-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; background: var(--white); cursor: move; }
.link-logo { width: 52px; height: 52px; border-radius: 10px; object-fit: contain; flex-shrink: 0; background: var(--bg); padding: 4px; }
.link-info { flex: 1; min-width: 0; }
.link-actions { display: flex; gap: 6px; }

/* 广告项 */
.ad-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: var(--white); }
.ad-preview { width: 140px; height: 70px; object-fit: cover; border-radius: 8px; }
.ad-info { flex: 1; }
.ad-actions { display: flex; gap: 6px; }

/* 模态框 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-content { background: var(--white); padding: 24px; border-radius: var(--radius-lg); max-width: 480px; width: 100%; max-height: 85vh; overflow-y: auto; }
.modal-content h2 { margin-bottom: 16px; font-size: 18px; }

/* 确认弹窗 */
.cofm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 10000; }
.cofm-box { background: var(--white); padding: 24px; border-radius: var(--radius-lg); max-width: 360px; width: 90%; text-align: center; }
.cofm-msg { font-size: 15px; color: var(--ink); margin-bottom: 16px; line-height: 1.5; }
.cofm-btns { display: flex; gap: 10px; justify-content: center; }
.cofm-btns .button { min-width: 80px; }

/* 通知 */
.notice { padding: 12px 16px; border-left: 3px solid var(--primary); border-radius: 8px; background: color-mix(in srgb, var(--primary) 6%, transparent); font-size: 13px; }

/* ===== 平板适配 ===== */
@media (max-width: 900px) {
  .detail-specs { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .script-thead-admin, .script-trow-admin { grid-template-columns: 1.2fr 60px 50px 90px 70px 50px 60px; font-size: 12px; }
}

/* ===== 手机适配 ===== */
@media (max-width: 640px) {
  .container { padding: 0 12px; }

  .topbar-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 6px; justify-content: center; }
  .nav { width: 100%; justify-content: center; flex-wrap: wrap; }
  .nav a { font-size: 13px; padding: 5px 8px; white-space: nowrap; }
  .admin-topbar .topbar-inner { flex-wrap: wrap; gap: 4px; padding: 6px 8px; justify-content: center; }
  .admin-topbar .nav { flex: 0 0 auto; display:flex; gap:4px; flex-wrap:wrap; justify-content:center; }
  .admin-topbar .nav a { font-size: 14px; padding: 5px 8px; white-space: nowrap; border-left: 1px solid rgba(255,255,255,.2); border-right: 1px solid rgba(255,255,255,.2); }
  .admin-topbar .nav a:first-child { border-left: none; }
  .admin-topbar .nav a:last-child { border-right: none; }
  .admin-topbar .nav-sub { flex: 0 0 100%; justify-content: center; }
  .admin-topbar .topbar-inner { overflow-x: hidden; }
  /* 手机端底部导航 */
  .admin-topbar { display: none !important; }
  .mnav { display: flex !important; align-items: center; justify-content: space-between; position: fixed; bottom: 0; left: 0; right: 0; z-index: 200; padding: 4px 12px; min-height: 40px; }
  .admin-body { padding-bottom: 44px; }
  .mnav-btn { background: none; border: none; color: #fff; font-size: 14px; cursor: pointer; padding: 2px 6px; }
  .mnav-right { display: flex; gap: 0; }
  .mnav-right a { color: #fff !important; text-decoration: none; font-size: 14px; padding: 2px 10px; border-left: 2px solid rgba(255,255,255,.5); border-right: 2px solid rgba(255,255,255,.5); }
  .mnav-right a:first-child { border-left: none; }
  .mmenu { display: none; position: fixed; bottom: 40px; left: 0; right: 0; z-index: 199; padding: 4px 10px; border-radius: 12px 12px 0 0; }
  .mmenu a { display: block; color: #fff !important; text-decoration: none; padding: 8px 16px; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
  .mmenu a:last-child { border-bottom: none; }
  .moverlay { display: none; position: fixed; inset: 0; z-index: 198; background: rgba(0,0,0,.3); }
  .section-head { flex-direction: column; }
  .section-head > div { width: 100%; }
  .section-head button { flex: 1; }

  .script-actions .button { width: 100%; display: block !important; }
  .st-actions { flex-direction: column; }
  .st-actions .button { width: 100%; margin: 1px 0; }

  .page-content { padding: 12px 0; }

  .overview-value { font-size: 24px; }

  .panel { padding: 14px; margin-bottom: 12px; border-radius: var(--radius); }

  .filter-bar { flex-wrap: wrap; }
  .filter-bar .field { width: 100%; }
  .filter-bar .field:first-child { flex: 3; width: auto; }
  .filter-bar .field:nth-child(2) { flex: 2; width: auto; }
  .filter-bar .button { width: 100%; margin-top: 6px; }
  .sort-btn { width: 100%; justify-content: center; }

  /* 脚本列表手机端 */
  .script-row-head { display: none; }
  .script-row {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 10px;
    font-size: 12px;
  }
  .script-row .script-main { grid-column: 1/-1; }
  .script-cell .cell-label { display: inline; margin-right: 6px; }
  .script-actions { grid-column: 1/-1; text-align: center; }
  .script-actions .button { width: 100%; display: block; }

  /* 后台脚本列表手机端 */
  .script-thead-admin { display: none; }
  .script-trow-admin {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 12px;
  }
  .script-trow-admin > span:first-child {
    flex: 0 0 100% !important;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .script-trow-admin .row-cb { flex-shrink: 0; }
  .script-trow-admin > span:nth-child(2) { flex: 1; }
  .script-trow-admin > span:nth-child(3) { flex: 1; }
  .script-trow-admin > span:nth-child(4) { flex: 2; white-space: nowrap; }
  .script-trow-admin > span:nth-child(5) { flex: 1; }
  .script-trow-admin .st-actions {
    flex: 0 0 100% !important;
    display: flex !important;
    gap: 4px;
    flex-wrap: nowrap !important;
    margin-top: 8px;
  }
  .script-trow-admin .st-actions .button {
    flex: 1;
    text-align: center;
    font-size: 11px;
    padding: 6px 2px;
    min-width: 0;
  }
  .script-trow-admin > span:first-child {
    display: block !important;
    font-weight: 600;
    margin-bottom: 4px;
  }
  .script-trow-admin .st-actions {
    display: flex !important;
    gap: 4px;
    flex-wrap: nowrap !important;
    margin-top: 8px;
    width: 100%;
  }
  .script-trow-admin .st-actions .button {
    flex: 1;
    text-align: center;
    font-size: 11px;
    padding: 6px 2px;
    min-width: 0;
  }
  .script-trow-admin .st-actions .button-primary,
  .script-trow-admin .st-actions .button-ghost {
    flex: 2;
  }

  /* 其他手机适配 */
  .detail-heading { flex-direction: column; }
  .detail-heading .detail-title { text-align: center; }
  .detail-specs { gap: 4px; }
  .spec-card { padding: 8px 4px; }
  .spec-card .muted { font-size: 10px; }
  .spec-card strong { font-size: 13px; }
  .detail-specs { grid-template-columns: repeat(2, 1fr); }
  .section-head { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .list-item { flex-direction: column; align-items: stretch; }
  .item-actions { margin-top: 10px; }
  .ad-item { flex-direction: column; align-items: stretch; }
  .ad-actions { margin-top: 10px; }
  .ad-preview { width: 100%; height: auto; }

  .friends-list { grid-template-columns: 1fr; }

  .modal-content { padding: 16px; }
}
