/* ========================================================================
 * Python 商务数据分析在线教育平台 - 全局样式
 * 设计系统：教育感蓝色 + 温暖橙色，响应式布局
 * ====================================================================== */

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-border: #e2e8f0;

  --color-text: #1f2937;
  --color-text-muted: #64748b;
  --color-text-inverse: #ffffff;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #dbeafe;

  --color-accent: #f97316;
  --color-accent-hover: #ea580c;

  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #0891b2;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px -12px rgba(0, 0, 0, 0.18);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --content-width: 1120px;
  --header-height: 64px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-nav {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-text);
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 20px;
}
.nav-links a {
  color: var(--color-text);
  font-weight: 500;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
}
.nav-links a:hover {
  background: var(--color-surface-alt);
  text-decoration: none;
}

/* ---------- Main ---------- */
.app-main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px 20px 56px;
  min-height: calc(100vh - var(--header-height) - 80px);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 20px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  color: var(--color-text);
  line-height: 1.3;
}

.page-title {
  font-size: 1.8rem;
  margin: 0 0 8px;
}

.page-subtitle {
  color: var(--color-text-muted);
  margin: 0 0 24px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: var(--color-text-inverse);
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin-bottom: 32px;
}

.hero h1 {
  color: #fff;
  margin: 0 0 12px;
  font-size: 2rem;
}

.hero p {
  margin: 0 0 20px;
  opacity: 0.92;
  max-width: 640px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 16px;
  backdrop-filter: blur(8px);
}

.hero-stat .label {
  font-size: 0.85rem;
  opacity: 0.85;
}
.hero-stat .value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }

.btn-accent {
  background: var(--color-accent);
  color: #fff;
}
.btn-accent:hover { background: var(--color-accent-hover); color: #fff; }

.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}
.btn-ghost:hover { background: var(--color-primary-soft); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; }

/* ---------- Cards ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-title {
  margin: 0;
  font-size: 1.1rem;
}

.card-subtitle {
  color: var(--color-text-muted);
  margin: 4px 0 12px;
  font-size: 0.95rem;
}

.card-body {
  margin: 12px 0;
}

.card-footer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.card-id {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* ---------- Tags / Skills ---------- */
.tag {
  display: inline-block;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  margin: 2px 4px 2px 0;
}
.tag-accent {
  background: #ffedd5;
  color: var(--color-accent);
}
.tag-success { background: #dcfce7; color: var(--color-success); }
.tag-muted { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* ---------- Progress ---------- */
.progress-track {
  background: var(--color-surface-alt);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  background: var(--color-primary);
  height: 100%;
  transition: width 0.3s;
}
.progress-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  gap: 0;
  flex-wrap: wrap;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-muted);
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.badge-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.badge.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* ---------- Form ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
  border-color: var(--color-primary);
}

/* ---------- Code display (非编辑器) ---------- */
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 12px 0;
}

.code-runner {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  margin: 16px 0;
}

.code-runner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.code-runner-editor {
  position: relative;
}

.code-runner-editor textarea,
.code-editor-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px 16px;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
  background: #0b1220;
  color: #f1f5f9;
  resize: vertical;
  tab-size: 4;
}

.code-runner-output {
  background: #f8fafc;
  border-top: 1px solid var(--color-border);
  padding: 14px 16px;
  min-height: 80px;
  max-height: 420px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  color: #334155;
}
.code-runner-output.error {
  background: #fef2f2;
  color: #991b1b;
}
.code-runner-output img {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px;
  max-width: 100%;
}

/* ---------- Quiz ---------- */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.quiz-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.quiz-option:hover { background: #e2e8f0; }
.quiz-option input { margin: 0; }
.quiz-explain {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--color-info);
  background: #ecfeff;
  font-size: 0.92rem;
  color: #155e75;
  border-radius: 4px;
}

.quiz-score-box {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  margin: 20px 0;
  text-align: center;
}
.quiz-score-box .score-big {
  font-size: 2.2rem;
  font-weight: 700;
  color: #92400e;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  animation: toast-in 0.25s ease-out;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--color-success); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.danger  { border-left-color: var(--color-danger); }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-body  { font-size: 0.9rem; color: var(--color-text-muted); }

@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---------- Loader ---------- */
.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Not Found ---------- */
.not-found {
  max-width: 560px;
  margin: 80px auto;
  text-align: center;
}
.not-found h1 {
  font-size: 4rem;
  color: var(--color-primary);
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .site-nav { padding: 0 14px; }
  .nav-links { gap: 12px; }
  .nav-links a { padding: 6px 2px; font-size: 0.95rem; }

  .hero { padding: 28px 20px; }
  .hero h1 { font-size: 1.5rem; }

  .cards-grid { grid-template-columns: 1fr; }
  .badges-grid { grid-template-columns: 1fr 1fr; }

  .tab-btn { padding: 10px 12px; font-size: 0.95rem; }
}

@media (max-width: 480px) {
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .hero-stat .value { font-size: 1.3rem; }
  .badges-grid { grid-template-columns: 1fr; }
  .app-main { padding: 20px 14px 40px; }
}

/* ---------- Utility ---------- */
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; gap: 12px; }
.gap-2 { gap: 8px; }

.block { display: block; }
.inline-block { display: inline-block; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
