/* ═══════════════════════════════════════════
   DevOps 学习系统 · 样式表
   Flask 动态服务版 · 端口 8867
   ═══════════════════════════════════════════ */

/* ─── CSS 变量 ─── */
:root {
  --primary:        #2563eb;
  --primary-light:  #dbeafe;
  --primary-dark:   #1d4ed8;
  --accent:         #0ea5e9;
  --warning:        #f97316;
  --warning-bg:     #fff7ed;
  --bg:             #f8fafc;
  --card-bg:        #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --shadow:         0 1px 4px rgba(0,0,0,.07);
  --shadow-md:      0 4px 16px rgba(0,0,0,.1);
  --radius:         12px;
  --radius-sm:      8px;
  --font-main:      -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  --font-mono:      "SF Mono","Cascadia Code","JetBrains Mono",Consolas,monospace;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── 布局容器 ─── */
.app-container { max-width: 820px; margin: 0 auto; padding: 0 12px 80px; }

/* ═══ 顶部导航 ═══ */
.site-header {
  background: var(--card-bg);
  border-bottom: 2px solid var(--primary);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 820px; margin: 0 auto;
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-logo {
  font-size: 16px; font-weight: 700; color: var(--primary-dark);
  white-space: nowrap;
}
.header-nav { display: flex; gap: 14px; font-size: 14px; flex-shrink: 0; }
.header-nav a { color: var(--text-muted); min-width: 30px; text-align: center; }
.header-nav a:hover { color: var(--primary); text-decoration: none; }

/* ═══ 主内容 ═══ */
.main-content { padding-top: 16px; }

/* ═══ 底部 Tab 导航（移动端） ═══ */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 999;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  padding-bottom: var(--safe-bottom);
}
.mobile-tab-bar .tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 0 8px;
  color: var(--text-muted);
  font-size: 10px;
  text-decoration: none;
  min-height: 52px;
  transition: color .15s;
}
.mobile-tab-bar .tab-item:active { background: var(--bg); }
.mobile-tab-bar .tab-item.active { color: var(--primary); }
.mobile-tab-bar .tab-icon { font-size: 22px; line-height: 1; margin-bottom: 1px; }
.mobile-tab-bar .tab-label { font-weight: 500; line-height: 1.2; }

/* ═══ 首页 ═══ */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 20px; color: var(--primary-dark); margin-bottom: 6px; }
.page-desc { font-size: 13px; color: var(--text-muted); }

/* ─── 文章卡片列表 ─── */
.article-list { display: flex; flex-direction: column; gap: 10px; }

.article-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow);
  /* 移动端优化：全宽、防缩放 */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}
.article-card:active {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: scale(0.995);
}

.card-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 6px; align-items: center;
}
.card-day    { background: var(--primary-light); color: var(--primary-dark); padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.card-module { background: #f0fdf4; color: #15803d; padding: 1px 8px; border-radius: 99px; font-weight: 500; }
.card-badge  { padding: 1px 8px; border-radius: 99px; font-weight: 500; }
.card-badge.易 { background: #f0fdf4; color: #15803d; }
.card-badge.中 { background: #fefce8; color: #a16207; }
.card-badge.难 { background: #fef2f2; color: #b91c1c; }

.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.card-summary { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }

.card-keywords { display: flex; flex-wrap: wrap; gap: 3px; }
.kw-tag {
  font-size: 11px; padding: 1px 6px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 4px;
}

/* ─── 空状态 ─── */
.empty-state {
  text-align: center; padding: 48px 16px;
  color: var(--text-muted); font-size: 15px;
}
.empty-state p + p { margin-top: 8px; font-size: 13px; }

/* ═══ 详情页 ═══ */
.detail-container { position: relative; }

.back-link {
  display: inline-block; font-size: 13px; color: var(--primary);
  margin-bottom: 12px;
}

.detail-header { margin-bottom: 20px; }
.detail-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 8px; align-items: center;
}
.detail-day { background: var(--primary-light); color: var(--primary-dark); padding: 1px 10px; border-radius: 99px; font-weight: 700; }
.detail-module { background: #f0fdf4; color: #15803d; padding: 1px 10px; border-radius: 99px; font-weight: 600; }
.detail-badge { padding: 1px 10px; border-radius: 99px; font-weight: 500; }
.detail-badge.易 { background: #f0fdf4; color: #15803d; }
.detail-badge.中 { background: #fefce8; color: #a16207; }
.detail-badge.难 { background: #fef2f2; color: #b91c1c; }

.detail-title { font-size: 20px; font-weight: 700; color: var(--primary-dark); line-height: 1.4; margin-bottom: 8px; }
.detail-keywords { display: flex; flex-wrap: wrap; gap: 3px; }

/* ═══ 正文样式 ═══ */
.detail-body { font-size: 15px; line-height: 1.85; }

/* ─── 关键词/命令底纹 ─── */
.kw-cmd {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92em;
  white-space: nowrap;
}

/* ─── 易错点橙色高亮 ─── */
.hl-warn {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning);
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95em;
}

/* ─── 面试题蓝色标注 ─── */
.interview-q {
  font-weight: 700;
  color: var(--primary-dark);
}

/* ─── 简历话术斜体 ─── */
.resume-text {
  font-style: italic;
  color: var(--text-muted);
}

/* ─── Markdown 元素 ─── */
.detail-body h2 { font-size: 17px; color: var(--primary-dark); margin: 20px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.detail-body h3 { font-size: 15px; color: var(--primary-dark); margin: 16px 0 6px; }
.detail-body h4 { font-size: 14px; color: var(--text); margin: 12px 0 5px; font-weight: 600; }
.detail-body p  { margin-bottom: 10px; }
.detail-body ul, .detail-body ol { margin: 6px 0 10px 20px; }
.detail-body li { margin-bottom: 3px; }
.detail-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 8px 12px;
  margin: 8px 0;
  background: #f0f9ff;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: 0.93em;
}
.detail-body code:not(.kw-cmd) {
  font-family: var(--font-mono);
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #be123c;
}
.detail-body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0;
}
.detail-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.detail-body table {
  width: 100%; border-collapse: collapse;
  margin: 10px 0; font-size: 13px;
}
.detail-body th, .detail-body td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.detail-body th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.detail-body tr:nth-child(even) { background: #f8fafc; }

/* ═══ 课堂作业 ═══ */
.homework-section { margin-top: 28px; padding-top: 18px; border-top: 2px dashed var(--border); }
.section-title { font-size: 15px; color: var(--primary-dark); margin-bottom: 10px; }

.hw-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--primary-dark);
  cursor: pointer;
  user-select: none;
  margin-bottom: 6px;
}
.hw-card:active { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); }

.hw-detail-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 14px 16px;
  margin-top: 6px;
}
.hw-detail-wrapper details.hw-detail { margin-bottom: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.hw-detail-wrapper details.hw-detail summary { background: var(--primary-light); padding: 8px 12px; font-weight: 600; color: var(--primary-dark); cursor: pointer; list-style: none; user-select: none; }
.hw-detail-wrapper details.hw-detail summary::before { content: "▶ "; font-size: 10px; transition: transform .2s; }
.hw-detail-wrapper details.hw-detail[open] summary::before { transform: rotate(90deg); }
.hw-detail-wrapper details.hw-detail[open] summary { border-bottom: 1px solid var(--border); }
.hw-detail-wrapper details.hw-detail > *:not(summary) { padding: 10px 12px; }

/* ═══ 导航按钮 ═══ */
.nav-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 2px dashed var(--border);
}
.nav-link {
  flex: 1;
  text-align: center;
  padding: 11px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  transition: background .15s;
  /* 移动端最小触控区域 */
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.nav-link:active { background: var(--primary-dark); text-decoration: none; }

/* ═══ 底部 ═══ */
.site-footer {
  text-align: center;
  padding: 24px 16px 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 32px;
  padding-bottom: calc(8px + var(--safe-bottom));
}
.footer-note { margin-top: 4px; font-size: 11px; }

/* ═══ 打卡按钮 ═══ */
.checkin-btn {
  display: inline-block; padding: 10px 20px;
  background: #15803d; color: #fff;
  border-radius: 99px; font-weight: 600;
  font-size: 14px; border: none; cursor: pointer;
  min-height: 44px; min-width: 88px;
}
.checkin-btn:active { background: #166534; transform: scale(0.97); }

/* ═══ 通用按钮 ═══ */
.btn {
  display: inline-block; padding: 9px 18px;
  border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer;
  border: none; text-decoration: none;
  transition: all .15s; text-align: center;
  min-height: 40px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-danger:active  { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; min-height: 32px; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:active { background: var(--bg); }

/* ═══ 管理后台 ═══ */
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--primary);
  flex-wrap: wrap; gap: 10px;
}
.admin-header h1 { font-size: 18px; color: var(--primary-dark); }
.admin-header a { font-size: 13px; color: var(--text-muted); }
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 12px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { background: var(--primary-light); color: var(--primary-dark); padding: 9px 10px; font-size: 11px; text-align: left; border-bottom: 2px solid var(--primary); }
.admin-table td { padding: 9px 10px; font-size: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover { background: var(--bg); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; font-weight: 500; }
.tag-easy { background: #f0fdf4; color: #15803d; }
.tag-mid  { background: #fefce8; color: #a16207; }
.tag-hard { background: #fef2f2; color: #b91c1c; }
.empty-msg { text-align: center; padding: 32px; color: var(--text-muted); font-size: 14px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font-main);
  transition: border-color .15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--primary); }
.form-group textarea { min-height: 280px; line-height: 1.7; font-family: var(--font-mono); font-size: 13px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.flash-ok  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.flash-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.search-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.search-bar input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.search-bar input:focus { outline: none; border-color: var(--primary); }
.keyword-list { display: flex; flex-wrap: wrap; gap: 3px; }
.keyword-list span { font-size: 11px; padding: 2px 6px; background: var(--primary-light); color: var(--primary); border-radius: 4px; }

/* 桌面端隐藏移动端专属元素 */
.mobile-auth-bar { display: none; }

/* ═══ 移动端优先 ═══ */
@media (max-width: 768px) {
  .app-container { padding: 0 10px 72px; }

  /* 卡片全宽无左右间距 */
  .article-card { padding: 14px 14px; border-radius: 10px; }
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 18px; }

  /* 详情页 */
  .detail-title { font-size: 18px; }
  .detail-body  { font-size: 15px; }
  .detail-meta  { font-size: 11px; }

  /* 导航按钮全宽 */
  .nav-links { flex-direction: column; }
  .nav-link { width: 100%; }

  /* 统计卡片 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-num { font-size: 22px; }

  /* 顶部导航隐藏：移动端用底部 Tab Bar */
  .site-header { display: none; }

  /* 底部 Tab 导航启用 */
  .mobile-tab-bar {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 0 0 calc(var(--safe-bottom) + 4px);
  }
  .site-footer { margin-bottom: 0; padding-bottom: calc(8px + 60px + var(--safe-bottom)); }

  /* 管理后台表格横向滚动 */
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* 打卡区 */
  .checkin-note { width: 100%; min-width: 0; }

  /* 移动端登录/退出入口 */
  .mobile-auth-bar {
    display: block;
    text-align: center;
    padding: 16px 0 8px;
    font-size: 14px;
  }
  .mobile-auth-bar a {
    color: var(--primary);
    font-weight: 600;
  }
}
}
}

/* ═══ 超小屏 ═══ */
@media (max-width: 380px) {
  .card-title { font-size: 14px; }
  .card-summary { font-size: 12px; }
  .page-header h1 { font-size: 17px; }
  .header-logo { font-size: 15px; }
  .mobile-tab-bar .tab-label { font-size: 9px; }
  .mobile-tab-bar .tab-icon { font-size: 20px; }
}
