:root {
  --primary: #4f46e5; /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --primary-light: #e0e7ff; /* Indigo 100 */
  --secondary: #64748b; /* Slate 500 */
  --bg-body: #f8fafc; /* Slate 50 */
  --bg-card: #ffffff;
  --text-main: #1e293b; /* Slate 800 */
  --text-muted: #64748b; /* Slate 500 */
  --border: #e2e8f0; /* Slate 200 */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 0.75rem;
}

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

body {
  font-family: 'Inter', "Microsoft JhengHeiUI", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  padding: 2rem 1rem;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
}

h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, var(--primary), #818cf8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  border: 1px solid var(--border);
}

/* Controls Section */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tabs */
.tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 9999px;
  gap: 0.25rem;
}

.tab {
  border: none;
  background: transparent;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.tab .flag {
  font-size: 1.1em;
}

/* Tables */
.tables-container {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.table-section {
  animation: fadeIn 0.5s ease-out;
}

.table-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.table-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-weight: 600;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  
  /* 新增：固定高度與垂直捲動 */
  max-height: 450px;
  overflow-y: auto;
  position: relative;
}

table {
  width: 100%;
  border-collapse: separate; /* 改為 separate 以支援 sticky header */
  border-spacing: 0;
  background: var(--bg-card);
  min-width: 800px;
}

thead {
  background: #f8fafc;
  /* 移除 border-bottom，改用 th 的 box-shadow 或 border */
}

th {
  text-align: left;
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  
  /* 新增：Sticky Header */
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  vertical-align: top;
  color: var(--text-main);
}

/* 新增：互動列樣式 */
tbody tr {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  background-color: #f1f5f9;
}

tbody tr.expanded {
  background-color: #eff6ff; /* 展開時的背景色 */
}

/* 新增：內容預覽與展開 (適用於所有文字欄位) */
.cell-content {
  display: -webkit-box;
  -webkit-line-clamp: 2; /* 預設只顯示 2 行 */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.6;
  color: inherit;
  word-break: break-word; /* 確保長單字會換行 */
}

/* 展開狀態 */
tr.expanded .cell-content {
  -webkit-line-clamp: unset;
  overflow: visible;
}

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

/* Column Widths */
.col-question { width: 25%; }
.col-asr { width: 25%; }
.col-llm { width: 35%; }
.col-audio { width: 15%; text-align: center; }

/* Audio Button */
.play-btn {
  background: var(--primary-light);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
}

.play-btn:hover {
  background: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.play-btn:hover svg {
  color: white;
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
  transition: color 0.2s;
}

/* Visual correction for play icon specifically */
.play-btn svg.icon-play {
  margin-left: 3px; 
}

.play-btn.playing {
  background: var(--primary);
  animation: pulse 2s infinite;
}
.play-btn.playing svg {
  color: white;
}

/* States */
.loading, .error, .no-data {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  background: #f8fafc;
  border-radius: var(--radius);
}

.error {
  color: #ef4444;
  background: #fef2f2;
}

/* Footer */
footer {
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

footer a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

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

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

/* Responsive */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .tabs {
    width: 100%;
    overflow-x: auto;
  }
  
  .tab {
    flex: 1;
    justify-content: center;
  }
  
  .card {
    padding: 1rem;
  }
}
