/* ===== 全局终端主题 - Linux命令学习系统 ===== */

@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --text-bright: #f0f6fc;
  --green: #3fb950;
  --green-dim: #238636;
  --yellow: #d29922;
  --orange: #f0883e;
  --red: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --cyan: #39d353;
  --pink: #f778ba;
  --prompt-user: #3fb950;
  --prompt-path: #58a6ff;
  --prompt-symbol: #d29922;
  --font-mono:
    "JetBrains Mono", "Fira Code", "Cascadia Code", "Courier New", monospace;
  --radius: 8px;
  --sidebar-width: 320px;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 全屏容器 - 两列布局 ===== */
.terminal-fullscreen {
  display: flex;
  height: 100vh;
  background: var(--bg);
}

/* ===== 左侧信息面板 ===== */
.sidebar-panel {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 标题栏 (左侧面板顶部) */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-header-dots {
  display: flex;
  gap: 6px;
}

.sidebar-header-dots .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  cursor: pointer;
  transition: filter 0.2s;
}
.sidebar-header-dots .dot:hover {
  filter: brightness(1.3);
}
.sidebar-header-dots .dot.red {
  background: #ff5f57;
}
.sidebar-header-dots .dot.yellow {
  background: #febc2e;
}
.sidebar-header-dots .dot.green {
  background: #28c840;
}

.sidebar-header-title {
  flex: 1;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  text-align: center;
}

.sidebar-header-badge {
  background: var(--green-dim);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
}

/* 场景切换区 */
.sidebar-scene-nav {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.scene-nav-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: all 0.2s;
}

.scene-nav-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.scene-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.scene-nav-label {
  flex: 1;
  text-align: center;
}

.scene-nav-label .scene-icon {
  font-size: 14px;
  margin-right: 4px;
}

.scene-nav-label .scene-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 0.3px;
}

.scene-nav-label .scene-id {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* 场景描述/故事 */
.sidebar-story {
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* 进度区域 */
.sidebar-progress {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-progress-title {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-progress-title .pct {
  color: var(--green);
  font-weight: 700;
}

.progress-bar-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* 任务列表 */
.sidebar-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 4px;
}

.sidebar-tasks-header .label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-task-nav {
  display: flex;
  gap: 4px;
}

.task-nav-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 1px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.2s;
}

.task-nav-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.task-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.task-item:hover {
  background: var(--bg-tertiary);
}

.task-item.active {
  background: rgba(88, 166, 255, 0.08);
  border-left-color: var(--blue);
}

.task-item.completed {
  opacity: 0.6;
}

.task-item-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 12px;
  padding-top: 2px;
}

.task-item-icon.done {
  color: var(--green);
}
.task-item-icon.current {
  color: var(--yellow);
}
.task-item-icon.pending {
  color: var(--text-dim);
}

.task-item-content {
  flex: 1;
  min-width: 0;
}

.task-item-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item.active .task-item-title {
  color: var(--text-bright);
  font-weight: 700;
}

.task-item-goal {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 底部操作区 */
.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sidebar-action-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.2s;
}

.sidebar-action-btn:hover {
  background: var(--border);
  color: var(--text);
}

.sidebar-action-btn.primary {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.sidebar-action-btn.primary:hover {
  background: var(--green);
  color: var(--bg);
}

/* ===== 右侧终端区域 ===== */
.terminal-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

#terminalContainer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* macOS 风格标题栏 */
.terminal-titlebar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
  gap: 8px;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: filter 0.2s;
}

.dot:hover {
  filter: brightness(1.3);
}
.dot.red {
  background: #ff5f57;
}
.dot.yellow {
  background: #febc2e;
}
.dot.green {
  background: #28c840;
}

.terminal-titletext {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.titlebar-badge {
  background: var(--green-dim);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
}

/* 右上角链接 */
.header-links {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.header-link {
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.header-link:hover {
  color: var(--text-bright);
  background: var(--bg-tertiary);
  border-color: var(--text-dim);
}

/* ===== 终端主体 ===== */
.terminal {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ===== 输出区域包裹层 (可滚动) ===== */
.terminal-output-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ===== 输出区域 ===== */
.terminal-output {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1.7em;
}

.terminal-line.empty {
  min-height: 0.8em;
}

.terminal-line.command-line {
  color: var(--text-bright);
}

.terminal-line.command-line .prompt-user {
  color: var(--prompt-user);
  font-weight: 700;
}
.terminal-line.command-line .prompt-path {
  color: var(--prompt-path);
  font-weight: 700;
}
.terminal-line.command-line .prompt-symbol {
  color: var(--prompt-symbol);
  font-weight: 700;
}

.terminal-line.output {
  color: var(--text);
}

.terminal-line.success {
  color: var(--green);
  font-weight: 600;
}

.terminal-line.error {
  color: var(--red);
}

.terminal-line.info {
  color: var(--blue);
}

.terminal-line.warning {
  color: var(--yellow);
}

.terminal-line.system {
  color: var(--purple);
  font-style: italic;
}

.terminal-line.highlight {
  color: var(--yellow);
  font-weight: 700;
}

.terminal-line.ascii-art {
  color: var(--green);
  font-weight: 700;
  line-height: 1.2;
}

.terminal-line.dim {
  color: var(--text-dim);
}

/* 分隔线 */
.terminal-line.separator {
  color: var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  margin: 6px 0;
  font-size: 12px;
  overflow: hidden;
}

.terminal-line.separator .sep-line {
  flex: 1;
  overflow: hidden;
  letter-spacing: -2px;
  color: var(--border);
}

.terminal-line.separator .sep-label {
  color: var(--text-dim);
  padding: 0 8px;
  white-space: nowrap;
  font-size: 11px;
}

/* 任务详情卡片 */
.terminal-line.highlight {
  color: var(--border);
}

.terminal-line .cmd-name {
  color: var(--cyan);
  font-weight: 600;
}

.terminal-line .cmd-desc {
  color: var(--text-dim);
}

/* 菜单卡片 (首页) */
.terminal-menu {
  margin: 4px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin: 2px 0;
}

.menu-item:hover {
  background: var(--bg-tertiary);
}

.menu-item-key {
  color: var(--green);
  font-weight: 700;
  min-width: 24px;
}

.menu-item-arrow {
  color: var(--text-dim);
  margin-left: auto;
}

.menu-item-label {
  color: var(--text-bright);
  font-weight: 500;
}

.menu-item-desc {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 8px;
}

/* ===== 状态栏 ===== */
.terminal-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  user-select: none;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-item.path {
  color: var(--blue);
}
.status-item.mode {
  color: var(--purple);
}
.status-sep {
  color: var(--border);
}

/* ===== 输入行 (固定底部) ===== */
.terminal-input-line {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0;
}

.terminal-prompt {
  white-space: nowrap;
  flex-shrink: 0;
}

.prompt-user {
  color: var(--prompt-user);
  font-weight: 700;
}
.prompt-at {
  color: var(--text-dim);
}
.prompt-host {
  color: var(--prompt-user);
  font-weight: 700;
}
.prompt-colon {
  color: var(--text-dim);
}
.prompt-path {
  color: var(--prompt-path);
  font-weight: 700;
}
.prompt-symbol {
  color: var(--prompt-symbol);
  font-weight: 700;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  caret-color: var(--green);
  padding: 0;
  margin-left: 0;
}

.terminal-input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.vim-mode-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--green-dim) 0%, #1a4d2e 100%);
  border-radius: 4px;
  margin-right: 12px;
  animation: vim-pulse 2s ease-in-out infinite;
}

.vim-badge {
  background: var(--green);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 1px;
}

.vim-mode-indicator span:not(.vim-badge) {
  color: var(--green);
  font-size: 12px;
}

@keyframes vim-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.terminal.vim-active {
  border: 2px solid var(--green);
  box-shadow: 0 0 20px rgba(63, 185, 80, 0.3);
}

/* ===== 首页侧边栏内容 ===== */
.sidebar-home-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-home-logo {
  text-align: center;
  margin-bottom: 16px;
}

.sidebar-home-logo pre {
  font-size: 8px;
  line-height: 1.1;
  color: var(--green);
  font-weight: 700;
}

.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-section-title {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.sidebar-level-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
}

.sidebar-level-item:hover {
  background: var(--bg-tertiary);
}

.sidebar-level-item .icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.sidebar-level-item .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.sidebar-level-item .icon.done {
  color: var(--green);
}
.sidebar-level-item .icon.pending {
  color: var(--text-dim);
}

.sidebar-level-item.completed .name {
  color: var(--text-dim);
  text-decoration: line-through;
}

/* ===== 旧版兼容样式 ===== */
.terminal-header {
  display: none;
}
.terminal-dot {
  display: none;
}
.terminal-scene-panel {
  display: none;
}
.terminal-task-fixed {
  display: none;
}
.terminal-mode-bar {
  display: none;
}
.terminal-mode-title {
  display: none;
}
.terminal-mode-actions {
  display: none;
}
.terminal-footer {
  display: none;
}
.footer-hint {
  display: none;
}
.hint-key {
  display: none;
}
.terminal-task-info {
  display: none;
}
.terminal-task-title {
  display: none;
}
.terminal-task-goal {
  display: none;
}
.terminal-task-hint {
  display: none;
}
.terminal-task-progress {
  display: none;
}
.terminal-task-nav {
  display: none;
}
.terminal-task-nav-btn {
  display: none;
}
.terminal-task-wrapper {
  display: none;
}
.home-container {
  display: none;
}
.home-title {
  display: none;
}
.home-description {
  display: none;
}
.mode-selector {
  display: none;
}
.mode-card {
  display: none;
}
.mode-icon {
  display: none;
}
.mode-title {
  display: none;
}
.mode-desc {
  display: none;
}
.progress-info {
  display: none;
}
.progress-title {
  display: none;
}
.progress-stats {
  display: none;
}
.progress-stat {
  display: none;
}
.progress-stat-value {
  display: none;
}
.progress-stat-label {
  display: none;
}
.navbar {
  display: none !important;
}
.sidebar {
  display: none !important;
}
.level-list {
  display: none !important;
}
.level-item {
  display: none !important;
}
.container {
  display: none !important;
}
.main-content {
  display: none !important;
}
.terminal-container {
  display: none !important;
}
.feedback-container {
  display: none !important;
}
.terminal-progress-bar {
  display: none;
}
.progress-track {
  display: none;
}
.progress-fill {
  display: none;
}
.progress-text {
  display: none;
}
.terminal-link {
  display: none;
}
.status-dot {
  display: none;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.terminal-output-wrapper::-webkit-scrollbar {
  width: 6px;
}
.terminal-output-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.terminal-output-wrapper::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-tasks::-webkit-scrollbar {
  width: 4px;
}
.sidebar-tasks::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-tasks::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ===== 动画 ===== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 240px;
  }
  .sidebar-panel {
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-width: 0px;
  }
  .sidebar-panel {
    display: none;
  }
  html,
  body {
    font-size: 13px;
  }
  .terminal-output {
    padding: 8px 12px;
    font-size: 13px;
  }
  .terminal-input-line {
    padding: 6px 12px;
  }
  .terminal-input {
    font-size: 13px;
  }
}

/* ===== 选中文本 ===== */
::selection {
  background: rgba(88, 166, 255, 0.3);
  color: var(--text-bright);
}
