/* ==========================================================================
   统一门户 · 全局样式
   浅色主题 / 朴素克制 / 卡片轻反馈 / 响应式
   注：主题色变量 --primary 由 js/app.js 从 config.js 的 BRAND.primaryColor 注入
   ========================================================================== */

:root {
  --primary: #2563eb;                 /* 由 JS 覆盖 */
  --primary-soft: rgba(37, 99, 235, .10); /* 由 JS 覆盖 */

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d5d9e0;
  --text: #1f2937;
  --text-sub: #4b5563;
  --text-muted: #8b93a1;
  --success: #16a34a;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-hover: 0 6px 18px rgba(16, 24, 40, .09);
  --topbar-h: 60px;
  --side-w: 208px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input { font: inherit; }
button { cursor: pointer; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { filter: brightness(.94); box-shadow: 0 3px 10px var(--primary-soft); }
.btn-ghost {
  background: transparent;
  color: var(--text-sub);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-sub);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; height: 42px; font-size: 15px; }

/* ---------- Logo 徽标（文字来自 config.js） ---------- */
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  letter-spacing: .5px;
  border-radius: 10px;
  user-select: none;
}
.logo-lg { width: 52px; height: 52px; font-size: 20px; border-radius: 14px; }
.logo-sm { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; }
.logo-xs { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; }
/* 规格 LOGO 图形：有图形时用图片铺满并隐藏徽标文字 */
.logo-mark.has-logo {
  background-color: transparent;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  font-size: 0;
  box-shadow: none;
}

/* ==========================================================================
   登录页
   ========================================================================== */
.view { min-height: 100%; }

.login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 34px 34px 26px;
  position: relative;
  overflow: hidden;
}
/* 顶部一道克制的主题色细条 */
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.login-brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
}
.slogan {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 角色切换 */
.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
}
.role-tab {
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-sub);
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.role-tab:hover { color: var(--text); }
.role-tab.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* 表单 */
.login-form .field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}
.login-form input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.login-form input::placeholder { color: #b6bdc8; }
.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.login-error {
  margin: -4px 0 12px;
  color: #dc2626;
  font-size: 12.5px;
}

.demo-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-sub);
}
.demo-hint-title { font-weight: 600; color: var(--text-sub); margin-bottom: 6px; }
.demo-hint-line { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.demo-hint-line span { display: inline-block; min-width: 30px; color: var(--text-muted); }
.demo-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

.login-footer { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ==========================================================================
   登录后主框架
   ========================================================================== */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 11px; }
.topbar-titles { display: flex; align-items: baseline; gap: 9px; }
.topbar-titles strong { font-size: 16px; font-weight: 700; }
.topbar-titles span {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 9px;
  border-left: 1px solid var(--border-strong);
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.role-badge {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 5px;
  padding: 2px 8px;
  font-weight: 600;
}
.user-name { font-size: 13px; color: var(--text-sub); }

.portal-layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }

/* 侧栏 */
.sidebar {
  width: var(--side-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-sub);
  font-size: 13.5px;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.portal-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* 内容面板 */
.panel { padding: 24px 28px 8px; flex: 1; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.muted { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.page-head-note {
  font-size: 12.5px;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
}

/* 工具栏：搜索 + 分类筛选 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 20px;
}
.search-box {
  position: relative;
  width: 300px;
  max-width: 100%;
}
.search-glyph {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: .7;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-box input::placeholder { color: #b6bdc8; }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 12.5px;
  transition: all .18s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}

/* 课程卡片网格 */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
  padding-bottom: 8px;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 186px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.course-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}
.card-top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.card-icon {
  width: 42px; height: 42px;
  flex: none;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  background: var(--icon-soft, #f0f3f8);
}
.card-titles { min-width: 0; }
.card-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 4px;
}
.card-category {
  display: inline-block;
  font-size: 11px;
  color: var(--text-sub);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
}
.card-desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.65;
  flex: 1;
  /* 两行截断，保持卡片整齐 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.card-tag {
  font-size: 11px;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 1px 6px;
  background: var(--surface-alt);
}
/* 扩展占位：进度 / 课时（config.js 填写后自动显示） */
.card-extra { margin-bottom: 12px; font-size: 11.5px; color: var(--text-muted); }
.progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 5px;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}
.card-enter {
  height: 32px;
  padding: 0 14px;
  font-size: 12.5px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-weight: 500;
  transition: all .18s ease;
}
.card-enter:hover { background: var(--primary); color: #fff; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 16px;
  font-size: 14px;
}

/* 角色扩展占位视图 */
.placeholder-card {
  max-width: 560px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 32px;
  text-align: center;
}
.placeholder-icon { font-size: 40px; margin-bottom: 14px; }
.placeholder-card h3 { margin: 0 0 8px; font-size: 17px; }
.placeholder-card p { margin: 0 0 22px; color: var(--text-sub); font-size: 13px; }

/* ==========================================================================
   课程 iframe 视图
   ========================================================================== */
.frame-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 20px 12px;
}
.frame-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.frame-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 160px;
  font-size: 14px;
}
.frame-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.frame-actions { display: flex; gap: 6px; }
.frame-body {
  position: relative;
  flex: 1;
  min-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.frame-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 0;
  background: #fff;
}
.frame-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 1;
  transition: opacity .2s ease;
}
.frame-loading.is-hidden { opacity: 0; pointer-events: none; }

/* 页脚 */
.portal-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 28px 18px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: transparent;
}

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 860px) {
  :root { --side-w: 62px; }
  .sidebar { padding: 12px 8px; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item > span:not(.nav-icon) { display: none; }
  .sidebar-foot { justify-content: center; padding: 10px 0 2px; }
  .sidebar-foot > span { display: none; }
  .topbar-titles span { display: none; }
  .panel { padding: 18px 16px 6px; }
  .search-box { width: 100%; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; }
  .user-name { display: none; }
  .login-card { padding: 28px 20px 22px; }
  .course-grid { grid-template-columns: 1fr; }
  .frame-toolbar { gap: 8px; }
  .frame-title { order: 3; width: 100%; }
  .portal-footer { padding: 12px 16px 16px; }
}
