/* 孙哥科技播放器 —— 用户控制台 / 管理员后台共用样式（原生 CSS，无依赖） */

* { box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(17, 24, 39, .06);
}
.theme-admin {
  --primary: #0f172a;
  --primary-dark: #020617;
  --bg: #f1f5f9;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 顶栏 ---------------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { font-size: 17px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-size: 11px; font-weight: 500; background: #111827; color: #fff; padding: 2px 7px; border-radius: 6px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #22d3ee); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { padding: 7px 13px; border-radius: 8px; color: #4b5563; font-size: 14px; }
.mainnav a:hover { background: #f3f4f6; text-decoration: none; }
.mainnav a.active { background: rgba(37, 99, 235, .1); color: var(--primary); font-weight: 600; }
.theme-admin .mainnav a.active { background: #0f172a; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.user-email { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { color: var(--danger) !important; }

/* ---------------- 页面 / 卡片 ---------------- */
.page { max-width: 1180px; margin: 26px auto 60px; padding: 0 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .desc { color: var(--muted); margin-top: 4px; font-size: 13px; }
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.full { grid-column: 1 / -1; }

/* ---------------- 表单 ---------------- */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
label.fld .tip { font-weight: 400; color: #9ca3af; font-size: 12px; margin-left: 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; padding: 9px 18px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; font-family: inherit; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-ghost:hover { background: #f9fafb; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data .t-nowrap { white-space: nowrap; }
table.data .ua-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { background: #f9fafb; color: #6b7280; font-weight: 600; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data .c-actions { white-space: nowrap; text-align: right; }
table.data .c-actions a, table.data .c-actions button { margin-left: 8px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }

.empty-box { text-align: center; color: var(--muted); padding: 48px 20px; border: 1px dashed #d1d5db; border-radius: var(--radius); background: #fafafa; }

/* ---------------- 播放器卡片（列表） ---------------- */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.player-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.player-card .pname { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.player-card .pid { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); background: #f3f4f6; padding: 2px 8px; border-radius: 6px; }
.player-card .pmeta { font-size: 12.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.player-card .pactions { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 代码 / 嵌入 ---------------- */
.codeblock { position: relative; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 16px 18px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.7; overflow-x: auto; white-space: pre; }
.copy-btn { position: absolute; top: 10px; right: 10px; }

/* ---------------- Toast / Modal ---------------- */
.sg-toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px); z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; align-items: center; opacity: 0; pointer-events: none; transition: .25s; }
.sg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sg-toast .toast-item { background: #111827; color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.sg-toast .toast-ok { background: #047857; }
.sg-toast .toast-err { background: #b91c1c; }

.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; padding: 26px 28px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28); max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-wide { max-width: 760px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; align-items: center; }
.pager a, .pager span { padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 13px; color: #374151; }
.pager .cur { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- 日志过滤条 ---------------- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filterbar label.fld { margin: 0; min-width: 150px; }

/* ---------------- 样式参考页 ---------------- */
.guide-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
@media (max-width: 900px) { .guide-layout { grid-template-columns: 1fr; } .grid2, .grid3 { grid-template-columns: 1fr; } }
.guide-tree { font-size: 13px; line-height: 1.9; }
.guide-tree code { background: #f3f4f6; padding: 1px 6px; border-radius: 5px; color: #1d4ed8; }
.annotated { position: relative; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 18px; background: #f8fafc; }
.anno-line { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.anno-tag { flex: 0 0 180px; font-family: Consolas, monospace; font-size: 12px; color: #7c3aed; background: #f5f3ff;
  border: 1px solid #ddd6fe; padding: 3px 8px; border-radius: 6px; }
.anno-desc { color: var(--muted); font-size: 12.5px; padding-top: 3px; }

/* ---------------- 认证页 ---------------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #e0f2fe 50%, #ecfeff 100%); padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 36px 34px; box-shadow: 0 20px 60px rgba(30, 58, 138, .15); }
.auth-card .logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.code-input-group { display: flex; gap: 8px; }
.code-input-group input { flex: 1; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-box .n { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-box .l { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 720px) {
  /* 顶栏：brand + 安全设置/邮箱/退出 一行；导航另起一行，横向滚动 */
  .topbar-inner { padding: 8px 12px; height: auto; gap: 10px; flex-wrap: wrap; }
  .brand { font-size: 15px; }
  .topbar-right { margin-left: auto; gap: 12px; font-size: 13px; white-space: nowrap; }
  .user-email { max-width: 100px; }
  .mainnav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; gap: 6px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; padding-bottom: 6px; scrollbar-width: thin; }
  .mainnav a { flex: 0 0 auto; padding: 7px 14px; font-size: 13px; text-align: center; white-space: nowrap;
    background: #f3f4f6; border-radius: 999px; }
  .mainnav a:hover { background: #e9ebef; text-decoration: none; }
  .mainnav a.active { background: rgba(37, 99, 235, .12); color: var(--primary); font-weight: 600; }
  /* 导航横向滚动条（iOS 不显示但可滚，Android/桌面可显示） */
  .mainnav::-webkit-scrollbar { height: 4px; }
  .mainnav::-webkit-scrollbar-track { background: transparent; }
  .mainnav::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

  /* 页面边距收窄 */
  .page { padding: 0 12px; margin-top: 16px; margin-bottom: 40px; }
  .page-head h1 { font-size: 18px; }
  .card { padding: 16px 14px; }

  /* 单列布局 */
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .player-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-box { padding: 14px; }
  .stat-box .n { font-size: 21px; }

  /* 表格字体缩小，操作按钮竖排 */
  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 8px 8px; }
  table.data .c-actions a, table.data .c-actions button { display: inline-block; margin: 2px 4px 2px 0; }

  /* 模态框全屏贴底 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 14px 14px 0 0; max-height: 92vh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }

  /* 过滤条竖排 */
  .filterbar { flex-direction: column; align-items: stretch; }
  .filterbar label.fld { min-width: 0; }
  .filterbar .btn { width: 100%; }

  /* 表单按钮通栏更易点 */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  /* 页头按钮区通栏，主操作按钮更好点 */
  .page-head > .btn { flex: 1 1 100%; }
  .page-head .head-actions { width: 100%; display: flex; gap: 10px; }
  .page-head .head-actions .btn { flex: 1; }

  /* 输入控件 16px：避免 iOS 聚焦时页面自动缩放 */
  input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea { font-size: 16px; }

  /* 播放器卡片操作按钮两列排布 */
  .player-card .pactions { display: grid; grid-template-columns: 1fr 1fr; }
  .player-card .pactions .btn { width: 100%; }

  /* 分页条可换行，页码多时不溢出 */
  .pager { flex-wrap: wrap; }

  /* 代码块：复制按钮改为通栏置顶，不再悬浮遮挡代码 */
  .codeblock { padding: 12px 14px; }
  .codeblock .copy-btn { position: static; display: flex; width: 100%; margin-bottom: 10px; }

  /* 卡片内长域名 / 长链接防溢出 */
  .card { overflow-wrap: anywhere; }

  /* 表格卡片化：仅对带 .tf-card 的表格生效（td 需带 data-label），管理后台表格不受影响 */
  table.data.tf-card, table.data.tf-card tbody { display: block; }
  table.data.tf-card thead { display: none; }
  table.data.tf-card tr { display: block; margin-bottom: 12px; padding: 2px 14px;
    border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 2px 8px rgba(17, 24, 39, .04); }
  table.data.tf-card td { display: flex; justify-content: space-between; align-items: center; gap: 14px;
    text-align: right; padding: 9px 0; border-bottom: 1px dashed #eef0f3; max-width: none; }
  table.data.tf-card td:last-child { border-bottom: none; }
  table.data.tf-card td[data-label]::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 12px; }
  /* 无 data-label 的单元格（空状态提示）保持居中整块显示 */
  table.data.tf-card td:not([data-label]) { display: block; }
  /* 多行长内容（歌曲名、链接、域名等）改为上下堆叠 */
  table.data.tf-card td.t-block { display: block; text-align: left; }
  table.data.tf-card td.t-block::before { display: block; margin-bottom: 3px; }
  table.data.tf-card td.t-block a { word-break: break-all; }
  table.data.tf-card .ua-cell { max-width: none; white-space: normal; overflow-wrap: anywhere; }
  table.data.tf-card .t-nowrap { white-space: normal; overflow-wrap: anywhere; }
  table.data.tf-card .c-actions { white-space: normal; }

  /* 代码块字号 */
  .codeblock { font-size: 12px; }

  /* 标注页标签列压缩 */
  .anno-tag { flex: 0 0 120px; font-size: 11px; }
  .anno-line { gap: 8px; }

  /* 认证卡片 */
  .auth-card { padding: 26px 20px; }
  .auth-body { padding: 12px; }
}
@media (max-width: 400px) {
  .stat-row { grid-template-columns: 1fr; }
}
