/* =========================================================
   365 每日生活美語 - 學校網頁側邊欄精簡嵌入微件樣式 (widget.css)
   專門針對 280px ~ 450px 窄側邊欄空間設計，極致輕盈、零多餘負擔
   ========================================================= */

:root {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --primary-light: #fef3c7;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --card-bg: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: transparent;
  color: var(--text-main);
  line-height: 1.45;
}

/* 嵌入卡片外層包裝 */
.widget-card {
  width: 100%;
  max-width: 460px;
  min-height: 100%;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 18px;
  border: 2px solid #fde68a;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 卡片滾動內容區 */
.widget-content-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 80px; /* 預留底部播放器空間 */
  -webkit-overflow-scrolling: touch;
}

/* 頂部看板區 (溫暖黃橘漸層) */
.widget-hero {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  padding: 16px 14px 14px 14px;
  border-bottom: 2px solid #fde68a;
}

/* 日期導航按鈕列 (置中膠囊) */
.widget-nav-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}

.date-nav-group {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 3px 6px;
  border-radius: 999px;
  border: 1.5px solid #fcd34d;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.12);
  gap: 4px;
}

.nav-day-btn {
  background: transparent;
  border: none;
  font-size: 0.82rem;
  font-weight: 700;
  color: #78350f;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-day-btn:hover {
  background: #fef3c7;
  color: #b45309;
}

.today-badge-btn {
  background: #fff;
  border: 1px solid #fbbf24;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.12);
}

.today-pill {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.hidden {
  display: none !important;
}

/* 標籤群組 (難度學層 + 主題分類) */
.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* 標題區 */
.topic-title-en {
  font-size: 1.3rem;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 2px;
  line-height: 1.25;
}

.topic-title-zh {
  font-size: 0.96rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 10px;
}

/* 情境引導框 */
.situation-box {
  background: rgba(255, 255, 255, 0.85);
  border-left: 3.5px solid var(--primary);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.84rem;
  color: #713f12;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.45;
}

/* 對話泡泡容器 */
.dialogue-container {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 單句對話泡泡卡片 */
.sentence-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.sentence-bubble:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}

.sentence-bubble.active-reading {
  background: #fefce8;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.25);
}

.speaker-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.speaker-avatar {
  font-size: 1.7rem;
  width: 42px;
  height: 42px;
  background: #fff;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.speaker-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

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

.sentence-en {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.38;
  word-break: break-word;
}

.sentence-zh {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.35;
  word-break: break-word;
}

/* 生詞底線強調 */
.vocab-highlight {
  color: #b45309;
  border-bottom: 2px dashed #f59e0b;
  font-weight: 800;
  cursor: pointer;
}

/* 底部精簡懸浮播放器 */
.widget-player-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 2px solid #fed7aa;
  padding: 6px 12px 8px 12px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  z-index: 100;
  transition: all 0.25s ease;
}

/* 播放器頂部標題與收合列 */
.player-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.current-playing-badge {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  font-size: 0.76rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 78%;
}

.player-collapse-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.player-collapse-btn:hover {
  background: #e2e8f0;
}

/* 播放器主要控制列 */
.player-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.25s ease;
}

/* 收合模式 */
.widget-player-bar.is-collapsed {
  padding: 6px 12px;
}

.widget-player-bar.is-collapsed .player-top-row {
  margin-bottom: 0;
}

.widget-player-bar.is-collapsed .player-main-row {
  display: none !important;
}

/* 播放控制按鈕 */
.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-btn {
  border: none;
  background: #e0f2fe;
  color: #0284c7;
  border-radius: 6px;
  font-size: 0.78rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.control-btn:hover {
  background: #bae6fd;
}

.control-btn.main-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #ffffff;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.control-btn.main-play:hover {
  transform: scale(1.05);
}

/* 語速調節按鈕群 */
.speed-control-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.speed-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #475569;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.speed-btn:hover {
  background: #e2e8f0;
}

.speed-btn.active {
  background: #f59e0b;
  color: #ffffff;
}

/* 外連完整版極簡標籤 */
.widget-footer-link {
  text-align: center;
  padding: 6px 0 10px 0;
  background: #ffffff;
}

.widget-footer-link a {
  font-size: 0.72rem;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s;
}

.widget-footer-link a:hover {
  color: #f59e0b;
}
