/* apps/vibe-coder/css/style.css */
/* Vibe Coder 現代開發者風格設計系統 */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* 暗色主題 (預設) */
  --bg-body: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #21262d;
  --bg-card: #1c2128;
  --bg-input: #090d13;
  --bg-code: #0b0f15;

  --border-subtle: #272d36;
  --border-default: #30363d;
  --border-focus: #58a6ff;

  --text-primary: #f0f6fc;
  --text-secondary: #c9d1d9;
  --text-muted: #8b949e;
  --text-inverse: #0d1117;

  --accent-blue: #388bfd;
  --accent-blue-hover: #58a6ff;
  --accent-cyan: #39c5cf;
  --accent-green: #2ea043;
  --accent-green-bg: rgba(46, 160, 67, 0.15);
  --accent-amber: #d29922;
  --accent-amber-bg: rgba(210, 153, 34, 0.15);
  --accent-red: #f85149;
  --accent-red-bg: rgba(248, 81, 73, 0.15);
  --accent-purple: #bc8cff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --sidebar-width: 320px;
  --header-height: 64px;
}

[data-theme="light"] {
  --bg-body: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f2f5;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-code: #f3f4f6;

  --border-subtle: #e1e4e8;
  --border-default: #d0d7de;
  --border-focus: #0969da;

  --text-primary: #1f2328;
  --text-secondary: #424a53;
  --text-muted: #656d76;
  --text-inverse: #ffffff;

  --accent-blue: #0969da;
  --accent-blue-hover: #218bff;
  --accent-cyan: #059669;
  --accent-green: #1a7f37;
  --accent-green-bg: rgba(26, 127, 55, 0.1);
  --accent-amber: #9a6700;
  --accent-amber-bg: rgba(154, 103, 0, 0.1);
  --accent-red: #cf222e;
  --accent-red-bg: rgba(207, 34, 46, 0.1);
  --accent-purple: #8250df;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* 頂部導覽列 */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  backdrop-filter: blur(12px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.4rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid rgba(46, 160, 67, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.search-container {
  position: relative;
  width: 260px;
}

.search-input {
  width: 100%;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 2rem 0 0.75rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.2);
}

.search-shortcut {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text-muted);
  pointer-events: none;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.progress-bar-mini {
  width: 48px;
  height: 6px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill-mini {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.3s ease;
}

.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  height: 34px;
  width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.portal-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.portal-link:hover {
  color: var(--accent-blue-hover);
  background: var(--bg-elevated);
}

.mobile-nav-toggle {
  display: none;
}

/* 主版面佈局 */
.app-container {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* 左側邊欄 */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  padding: 1rem 0;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 0 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.track-group {
  margin-bottom: 0.5rem;
}

.track-button {
  width: 100%;
  background: none;
  border: none;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.15s;
}

.track-button:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.track-button-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.track-icon {
  font-size: 1rem;
}

.track-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.track-group.open .track-chevron {
  transform: rotate(90deg);
}

.unit-list {
  list-style: none;
  padding: 0.2rem 0.75rem 0.5rem 2rem;
  display: none;
}

.track-group.open .unit-list {
  display: block;
}

.unit-item {
  margin-bottom: 2px;
}

.unit-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.35;
  transition: all 0.15s ease;
}

.unit-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.unit-item.active .unit-link {
  background: rgba(56, 139, 253, 0.15);
  color: var(--accent-blue-hover);
  font-weight: 600;
}

.unit-check {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.unit-item.completed .unit-check {
  color: var(--accent-green);
}

/* 主內容工作區 */
.main-content {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 2.5rem 5rem;
  overflow-x: hidden;
}

/* 單元頂部資訊標籤 */
.unit-hero {
  margin-bottom: 1.5rem;
}

.unit-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.unit-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.unit-main-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.25;
}

.unit-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.unit-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-default);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* 標籤頁導覽 */
.unit-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 1.75rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.unit-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-blue-hover);
  border-bottom-color: var(--accent-blue-hover);
}

/* 標籤分頁內容 */
.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 觀念區塊卡片 */
.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.concept-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.concept-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 1rem;
}

.concept-points {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.concept-point {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.concept-point::before {
  content: "✦";
  color: var(--accent-blue-hover);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* 新手地雷卡片 */
.pitfall-card {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-red);
  border-top: 1px solid var(--border-default);
  border-right: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.pitfall-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-red);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pitfall-why {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}

.pitfall-fix {
  background: var(--accent-green-bg);
  border: 1px solid rgba(46, 160, 67, 0.3);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.pitfall-fix strong {
  color: var(--accent-green);
}

/* 指令速查表 */
.cheatsheet-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.cheatsheet-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.cheatsheet-table th {
  background: var(--bg-elevated);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
}

.cheatsheet-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.cheatsheet-table tr:last-child td {
  border-bottom: none;
}

.code-badge {
  font-family: var(--font-mono);
  background: var(--bg-code);
  border: 1px solid var(--border-default);
  color: var(--accent-cyan);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-size: 0.85rem;
  display: inline-block;
}

/* 互動實戰沙盒容器 */
.widget-sandbox-container {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

.widget-sandbox-header {
  background: var(--bg-elevated);
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.widget-sandbox-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.widget-sandbox-body {
  padding: 1.5rem;
  min-height: 320px;
}

/* 測驗區塊 */
.quiz-container {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.quiz-question-card {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.quiz-question-card:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.quiz-question-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-option-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: left;
  color: var(--text-primary);
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.quiz-option-btn:hover:not(:disabled) {
  border-color: var(--border-focus);
  background: var(--border-subtle);
}

.quiz-option-btn.selected {
  border-color: var(--accent-blue);
  background: rgba(56, 139, 253, 0.15);
}

.quiz-option-btn.correct {
  border-color: var(--accent-green);
  background: var(--accent-green-bg);
  color: var(--text-primary);
}

.quiz-option-btn.wrong {
  border-color: var(--accent-red);
  background: var(--accent-red-bg);
}

.quiz-explanation {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent-blue);
  color: var(--text-secondary);
}

/* 底部換頁按鈕 */
.unit-nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-default);
}

.btn-nav {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  min-width: 180px;
}

.btn-nav:hover {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
}

.btn-nav-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.btn-nav-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 0.2rem;
}

.btn-nav.prev {
  text-align: left;
}

.btn-nav.next {
  text-align: right;
  margin-left: auto;
}

/* 響應式佈局 */
@media (max-width: 880px) {
  .mobile-nav-toggle {
    display: flex;
  }

  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    z-index: 100;
    width: 280px;
    height: calc(100vh - var(--header-height));
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
  }

  .app-sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
  }

  .search-container {
    width: 150px;
  }

  .search-shortcut {
    display: none;
  }

  .main-content {
    padding: 1.5rem 1rem 4rem;
  }

  .unit-nav-footer {
    flex-direction: column;
  }

  .btn-nav {
    width: 100%;
  }
}
