/* ===========================================
   管理后台样式（复用 style.css 的 CSS 变量）
   =========================================== */

/* 关键修复：确保 HTML 的 hidden 属性始终生效。
   否则 .admin-login{display:flex} / .modal{display:flex} 会覆盖 [hidden]，
   导致登录框/注册框/弹窗永远可见、× 关不掉、视图切换失效。 */
[hidden] { display: none !important; }

.admin-body { background: var(--bg-alt); min-height: 100vh; }

.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.admin-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--brand-700); }
.admin-logo { height: 36px; width: auto; border-radius: 8px; }
.ver { font-size: 12px; color: var(--ink-3); font-weight: 600; }

/* 登录 */
.admin-login { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-card {
  width: 360px; max-width: 90vw; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(27,94,32,.08);
}
.login-card h2 { margin: 0 0 6px; color: var(--brand-700); }
.login-tip { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }
.login-err { color: #c0392b; font-size: 13px; margin: 10px 0 0; }

/* 仪表盘 */
.admin-main { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
.admin-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.dash-hint { color: var(--ink-3); font-size: 13px; }
/* 返回首页等工具栏幽灵按钮：原 .btn-ghost 为白字白边（给深色 hero 用），
   在浅色后台会隐形；此处改为品牌色描边+文字，确保可见且与主按钮区分 */
.admin-toolbar .btn-ghost {
  background: var(--brand-100); color: var(--brand-900);
  border: 1.5px solid var(--brand-700); font-weight: 700;
  box-shadow: 0 1px 4px rgba(27,94,32,.12);
}
.admin-toolbar .btn-ghost:hover { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.admin-toolbar .btn-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* 课程行操作按钮（编辑/章节管理）原 .btn-ghost 为白字白边(给深色 hero)，在白卡片上隐形；
   改为浅绿底+深绿字+深绿描边，清晰可见且与主操作层级分明 */
.admin-course-list .btn-ghost {
  background: var(--brand-50); color: var(--brand-700);
  border: 1px solid var(--brand-700); font-weight: 600;
}
.admin-course-list .btn-ghost:hover { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

.admin-course-list { display: grid; gap: 16px; }
.course-row {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(27,94,32,.05);
}
.course-row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.course-row-title { font-weight: 700; font-size: 17px; color: var(--ink); }
.course-row-meta { color: var(--ink-3); font-size: 13px; }
.tag-on  { background: #e8f5e9; color: var(--brand-700); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.tag-off { background: #f0f0f0; color: var(--ink-3); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.tag-paid{ background: #fff3e0; color: #b26a00; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.tag-paid-partial{ background: #F3E5F5; color: #6A1B9A; border-radius: 999px; padding: 2px 10px; font-size: 12px; }   /* 三态付费：部分付费（2026-09-07）*/
.tag-soon{ background: #fff8e1; color: #8a6d1a; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.course-row-actions { margin-left: auto; display: flex; gap: 8px; }

.chapter-panel { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.lesson-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
.lesson-item .lt { font-weight: 600; color: var(--ink); }
.lesson-item .lf { font-size: 12px; color: var(--brand-600); }
.lesson-item .lv { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.lesson-item .la { display: flex; gap: 6px; }
/* 上传分步状态（持久可见，失败信息不自动消失，便于截图反馈） */
.upstat { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--ink-3); word-break: break-all; }
.upstat.bad { color: #c0392b; font-weight: 600; }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand-600); transition: width .2s; }

/* 表单 */
.in {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; color: var(--ink); background: #fff;
}
.in:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(27,94,32,.12); }
/* 下拉框与文本框视觉统一：重置原生外观、固定等高(与文本框一致)、右侧箭头，整行上下协调 */
select.in {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  height: 44px; line-height: 1.2; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%237a8a7f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
}
/* 封面图上传行与预览 */
.cover-upload-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cover-upload-hint { font-size: 12px; color: var(--ink-3); }
.cover-preview { margin-top: 10px; }
.cover-preview img { max-width: 160px; max-height: 110px; border-radius: 10px; border: 1px solid var(--line); display: block; }
/* 上传封面图按钮：原 .btn-ghost 为白字白边(给深色 hero)，在浅色弹窗内隐形；
   改为浅绿底+深绿字+深绿描边，与课程列表按钮风格一致，清晰可见 */
.cover-upload-row .btn-ghost { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-700); font-weight: 600; }
.cover-upload-row .btn-ghost:hover { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
/* 登录/注册按钮：占满卡片宽度，且与上方输入框保持协调间距 */
.btn-block { display: flex; width: 100%; margin-top: 18px; }
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-2); }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(15,30,20,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { width: 520px; max-width: 96vw; max-height: 92vh; overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-lg { width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--brand-700); }
.modal-x { border: none; background: none; font-size: 26px; line-height: 1; color: var(--ink-3); cursor: pointer; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }

.lesson-add { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.lesson-add .in { flex: 1; min-width: 180px; }

/* 原生文件选择框（配合 <label for=...> 触发）。
   刻意不用 display:none / visibility:hidden / 离屏定位 —— Safari 对不可见 file input 的
   响应不稳定；这里用「保留 1px 布局 + 完全透明」的视觉隐藏，跨浏览器最可靠。 */
.af-file-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
/* label 当按钮用时：禁止选中文字，避免双击把文字刷蓝 */
label.btn { user-select: none; -webkit-user-select: none; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .course-row-actions { margin-left: 0; width: 100%; }
}
