/* ===== Report Forge v2.1 — Refined Theme and Workspace Styles ===== */

:root {
  /* 配色系統 — 現代科技深藍與柔和藍紫漸層 */
  --bg-primary: #0a0f1d;
  --bg-secondary: #121829;
  --bg-card: #1b233a;
  --bg-glass: rgba(18, 24, 41, 0.7);
  --border-glass: rgba(88, 166, 255, 0.15);
  
  --accent: #4f8ff7;
  --accent-hover: #72a5ff;
  --accent-glow: rgba(79, 143, 247, 0.35);
  
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #4f8ff7;
  
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 5px;
  
  --font-sans: 'Inter', 'Noto Sans TC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 全域與 Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 0%, #1e294b 0%, var(--bg-primary) 70%);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(88, 166, 255, 0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ===== 頂部導航列 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  height: 56px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 0 15px var(--accent-glow);
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.5px;
}
.brand-sub {
  font-size: 0.65rem;
  color: var(--text-secondary);
}
.topbar-actions {
  display: flex;
  gap: 8px;
}
.topbar-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition);
}
.topbar-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--accent);
}
.topbar-btn.secondary {
  color: var(--text-secondary);
}

/* ===== 步驟指示器 ===== */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 0 5px 0;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: var(--transition);
}
.step-item.active {
  background: rgba(79, 143, 247, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(79, 143, 247, 0.2);
}
.step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: var(--transition);
}
.step-item.active .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.step-item.completed .step-circle {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.step-info {
  text-align: left;
}
.step-title {
  font-size: 0.8rem;
  font-weight: 700;
}
.step-desc {
  font-size: 0.65rem;
  color: var(--text-secondary);
}
.step-connector {
  width: 50px;
  height: 2px;
  background: var(--border-glass);
  position: relative;
}
.step-connector-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ===== 主要容器 ===== */
.main-container {
  flex: 1;
  overflow: hidden;
  padding: 5px 20px 15px 20px;
  display: flex;
  flex-direction: column;
}
.step-panel {
  display: none;
  height: 100%;
  animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.step-panel.active {
  display: flex;
  flex-direction: column;
}

/* ===== 步驟一：上傳與選擇 ===== */
.step-content-centered {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  padding: 10px 10px 30px 10px;
}
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(88, 166, 255, 0.3);
  border-radius: var(--radius);
  padding: 40px 20px;
  background: var(--bg-glass);
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(79, 143, 247, 0.05);
  box-shadow: 0 0 20px rgba(79, 143, 247, 0.15);
}
.upload-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}
.upload-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.upload-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.file-types {
  display: flex;
  gap: 8px;
}

/* 掃描進度 */
.scan-progress {
  text-align: center;
  padding: 30px;
  background: var(--bg-glass);
  border-radius: var(--radius);
  border: 1px solid var(--border-glass);
}
.scan-animation {
  width: 70px;
  height: 90px;
  border: 2px solid var(--text-secondary);
  border-radius: 6px;
  margin: 0 auto 15px auto;
  position: relative;
  overflow: hidden;
}
.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: scanLine 2s linear infinite;
}
.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--bg-card);
  border-radius: 3px;
  margin-top: 15px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transition: width 0.2s ease;
}

/* 掃描結果卡片 */
.scan-result {
  padding: 24px;
  text-align: center;
}
.scan-result h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--green);
}
.scan-stats {
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border-glass);
}
.scan-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* 模板卡片 */
.divider {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin: 10px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glass);
}
.divider:not(:empty)::before { margin-right: 15px; }
.divider:not(:empty)::after { margin-left: 15px; }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.template-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.template-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.template-card-icon {
  font-size: 1.6rem;
  padding: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
}
.template-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.template-card-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ===== 步驟二：工作區雙欄佈局 ===== */
.workspace-layout {
  display: grid;
  grid-template-columns: 4.5fr 5.5fr;
  gap: 20px;
  flex: 1;
  overflow: hidden;
}

/* 左側：編輯區（標籤頁切換） */
.workspace-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workspace-tabs {
  display: flex;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border-glass);
}
.ws-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}
.ws-tab:hover {
  color: var(--text-primary);
}
.ws-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255,255,255,0.02);
}
.workspace-tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}
.workspace-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* 表單與代碼樣式 */
.form-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.form-input, .form-textarea, .form-select {
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  transition: var(--transition);
}
.form-textarea {
  min-height: 70px;
}
.code-editor {
  flex: 1;
  overflow: hidden;
}
.code-area {
  width: 100%;
  height: 100%;
  background: #060913;
  color: #a5d6ff;
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}
.code-tabs {
  display: flex;
  gap: 4px;
}
.code-tab {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
}
.code-tab.active {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
  border-color: var(--border-glass);
}

/* 右側：實時預覽區 */
.workspace-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 10px 0;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 10px;
}
.preview-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.preview-actions {
  display: flex;
  gap: 8px;
}
.pdf-preview-scroll {
  flex: 1;
  overflow-y: auto;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius);
  border: 1px solid var(--border-glass);
  padding: 20px;
  display: flex;
  justify-content: center;
}
.pdf-paper-container {
  width: 100%;
  max-width: 595px; /* A4 寬度等比 */
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* A4 白色頁面容器 */
.pdf-page-sheet {
  width: 100%;
  background: #ffffff;
  color: #1e293b;
  box-shadow: var(--shadow);
  padding: 45px 35px;
  border-radius: 4px;
  min-height: 842px; /* A4 高度等比 */
  box-sizing: border-box;
  page-break-after: always;
}

/* 簡報 16:9 投影片 */
.slide-sheet {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #ffffff;
  color: #1e293b;
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  page-break-after: always;
}

/* ===== 共用按鈕與樣式 ===== */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.05);
}

.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
}

/* ===== 底部狀態列 ===== */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  height: 36px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-glass);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
.status-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.bottom-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateX(150%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
}
.toast.show {
  transform: translateX(0);
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--accent); }

/* ===== 動態 @keyframes ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes scanLine {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 響應式 */
@media (max-width: 900px) {
  .workspace-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .workspace-left, .pdf-preview-scroll {
    height: 480px;
  }
  body {
    overflow-y: auto;
    height: auto;
  }
}
