/* NutriPal - 營養好朋友 樣式表 */

:root {
  /* 主要色系 */
  --primary: #4D6849; /* 薄荷綠 - 健康、平靜 */
  --primary-dark: #3A4F37; /* 深薄荷綠 - 懸停狀態 */
  --secondary: #D5C9B3; /* 奶油杏 - 溫暖、舒適 */
  --accent: #FFC04B; /* 溫暖橘 - 活力、行動 */
  --background: #F8F6F2; /* 燕麥白 - 背景色 */
  --text-primary: #333333; /* 主要文字色 */
  --text-secondary: #6D6D6D; /* 次要文字色 */
  --border-color: #24332C; /* 邊框色 */
  
  /* 陰影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05);
  
  /* 圓角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  /* 字體 */
  --font-sans: "Nunito", "思源黑體", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Container 寬度 (RWD) */
  --container-xs: 100%;
  --container-sm: 540px;
  --container-md: 720px;
  --container-lg: 960px;
  --container-xl: 1140px;
  
  /* 斷點值 */
  --breakpoint-xs: 0;
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
}

/* 基礎樣式設定 - Mobile First */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  /* 使用 min-height 允許內容高度超出視窗 */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  overflow-y: auto;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  font-size: 16px;
  overflow-wrap: break-word;
  word-wrap: break-word;
  /* 修復 iOS flexbox 內容溢出問題 */
  min-height: 0;

}

/* 通用容器類 */
.container {
  width: 100%;
  max-width: var(--container-xs);
  margin: 0 auto;
  padding: 0 15px;
}

/* iPhone 外殼模擬 */
.iphone-container {
  width: 100%;
  max-width: 375px;
  height: 812px;
  background-color: #ffffff;
  border-radius: 40px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  border: 12px solid #1a1a1a;
  margin: 20px auto;
}

/* 導航欄 */
.nav-header {
  height: 56px;
  width: 100%;
  background-color: var(--background);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 16px;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
}

/* 標籤頁底部導航 - 固定在瀏覽器底端 */
.tab-bar {
  height: 60px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000;
  will-change: transform;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 10px;
  padding-top: 8px;
  width: 60px;
}

.tab-item i {
  font-size: 22px;
  margin-bottom: 4px;
}

.tab-item.active {
  color: var(--primary);
}

/* 主要內容區 */
.app-content {
  height: calc(100% - 56px); /* 改為減去 nav-header 的高度 */
  overflow-y: auto;
  padding-bottom: calc(60px + max(20px, env(safe-area-inset-bottom))); /* 動態匹配 tab-bar 實際佔用空間 */
  -webkit-overflow-scrolling: touch; /* 增加 iOS 滑動流暢性 */
  /* 修復 iOS flexbox 問題 */
  min-height: 0;
  position: relative;
  -webkit-transform: translateZ(0);
}

/* 按鈕樣式 */
.btn-primary {
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 16px;
  display: inline-block;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  -webkit-appearance: none; /* 移除 iOS 預設按鈕樣式 */
}

.btn-primary:hover, .btn-primary:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: white;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 16px;
  display: inline-block;
  text-align: center;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  -webkit-appearance: none; /* 移除 iOS 預設按鈕樣式 */
}

.btn-secondary:hover, .btn-secondary:focus {
  background-color: rgba(255, 192, 75, 0.05);
}

.btn-secondary:active {
  background-color: rgba(255, 192, 75, 0.1);
}

/* 卡片樣式 */
.card {
  background-color: white;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

/* 頭像和對話氣泡 */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: white;
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}

.chat-bubble {
  background-color: var(--secondary);
  border-radius: 18px 18px 18px 4px;
  padding: 12px 16px;
  max-width: 85%;
  margin-bottom: 12px;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.user {
  background-color: var(--primary);
  color: white;
  border-radius: 18px 18px 4px 18px;
  align-self: flex-end;
}

/* 產品卡片 */
.product-card {
  border-radius: var(--radius-md);
  background-color: white;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 16px;
  width: 100%;
}

.product-card img {
  width: 100%;
  height: auto;
  min-height: 140px;
  max-height: 200px;
  object-fit: cover;
}

.product-info {
  padding: 16px;
}

.product-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}

.product-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.badge {
  background-color: var(--primary);
  color: white;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  display: inline-block;
  margin-right: 4px;
  margin-bottom: 4px;
}

.price {
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}

/* 時間表樣式 */
.timeline {
  margin-top: 16px;
  width: 100%;
}

.timeline-item {
  display: flex;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.timeline-time {
  font-weight: 700;
  width: 80px;
  color: var(--primary);
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
  border-left: 2px solid var(--primary);
  padding-left: 12px;
  padding-bottom: 12px;
  min-width: 0; /* 防止溢出 */
}

/* 首頁特別樣式 */
.feature-section {
  margin-top: 24px;
  width: 100%;
  padding: 20px;
}

.feature-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.feature-item {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  min-height: 0; /* 防止 iOS flexbox 溢出 */
}

.feature-content {
  flex: 1;
  min-width: 0; /* 防止文字溢出 */
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  color: white;
  font-size: 24px;
  flex-shrink: 0;
}

/* 選項按鈕 */
.option-button {
  display: block;
  width: 100%;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  margin-bottom: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 76px;
}

.option-button:hover, .option-button.selected {
  background-color: var(--secondary);
  border-color: var(--primary);
}

/* 表單元素 */
input, select, textarea {
  width: 100%;
  padding: 10px 16px;
  font-size: 16px; /* 防止 iOS 縮放 */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: white;
  transition: border-color 0.2s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(77, 104, 73, 0.1);
}

/* 輔助類 */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.d-flex {
  display: flex;
}

.d-block {
  display: block;
}

.d-inline {
  display: inline;
}

.d-none {
  display: none;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-nowrap {
  flex-wrap: nowrap;
}

.flex-column {
  flex-direction: column;
}

.justify-content-start {
  justify-content: flex-start;
}

.justify-content-center {
  justify-content: center;
}

.justify-content-end {
  justify-content: flex-end;
}

.justify-content-between {
  justify-content: space-between;
}

.justify-content-around {
  justify-content: space-around;
}

.align-items-start {
  align-items: flex-start;
}

.align-items-center {
  align-items: center;
}

.align-items-end {
  align-items: flex-end;
}

.w-100 {
  width: 100%;
}

.w-auto {
  width: auto;
}

.h-100 {
  height: 100%;
}

.m-0 {
  margin: 0;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 16px;
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 16px;
}

.p-0 {
  padding: 0;
}

/* 響應式設計 - Mobile First */
/* 超小螢幕裝置 (手機, 375px 以下) */
@media (max-width: 375px) {
  .chat-bubble {
    max-width: 80%;
  }
  
  .tab-bar {
    height: 60px;
  }
  
  .tab-item i {
    font-size: 18px;
  }
  
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

/* 小螢幕裝置 (手機) */
@media (min-width: 576px) {
  .container {
    max-width: var(--container-sm);
  }
  
  .chat-bubble {
    max-width: 75%;
  }
  
  /* 確保文章頁面中的小帕提醒不受上面寬度限制影響 */
  .article-content .chat-message .chat-bubble {
    max-width: 100% !important;
  }
  
  .btn-primary, .btn-secondary {
    max-width: 280px;
  }
  
  .option-button {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  
  .option-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

/* 中等螢幕 (平板) */
@media (min-width: 768px) {
  .container {
    max-width: var(--container-md);
  }
  
  body {
    font-size: 16px;
  }
  
  .product-card {
    display: flex;
    flex-direction: row;
  }
  
  .product-card img {
    width: 35%;
    height: auto;
    min-height: 140px;
    object-fit: cover;
  }
  
  .product-info {
    width: 65%;
  }
  
  .timeline-item {
    flex-wrap: nowrap;
  }
  
  .chat-bubble {
    max-width: 65%;
  }
  
  /* 確保文章頁面中的小帕提醒不受上面寬度限制影響 */
  .article-content .chat-message .chat-bubble {
    max-width: 100% !important;
  }
  
  .feature-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .feature-item {
    width: 48%;
  }
  
  .iphone-container {
    max-width: 400px;
    height: 840px;
  }
  
  .btn-primary, .btn-secondary {
    font-size: 16px;
  }
}

/* 大螢幕 (桌面) */
@media (min-width: 992px) {
  .container {
    max-width: var(--container-lg);
  }
  
  body {
    font-size: 16px;
  }

  .btn-primary, .btn-secondary {
    max-width: 300px;
    padding: 14px 28px;
  }
  
  .card, .product-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .card:hover, .product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
  }
  
  .feature-item {
    width: 30%;
  }
  
  .iphone-container {
    max-width: 420px;
    height: 860px;
  }
  
  .app-content {
    padding-bottom: calc(60px + max(20px, env(safe-area-inset-bottom)));
  }
}

/* 超大螢幕 */
@media (min-width: 1200px) {
  .container {
    max-width: var(--container-xl);
  }
  
  .iphone-container {
    max-width: 450px;
    height: 900px;
  }
  
  .feature-section {
    margin-top: 32px;
  }
  
  .card, .product-card {
    margin-bottom: 24px;
  }
}

/* 處理 iPhone 容器樣式 */
@media (max-width: 400px) {
  .iphone-container {
    width: 100%;
    height: 100vh;
    border-radius: 0;
    border: none;
    margin: 0;
  }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
  body.auto-dark-mode {
    background-color: #121212;
    color: #f5f5f5;
  }
  
  body.auto-dark-mode .card,
  body.auto-dark-mode .product-card,
  body.auto-dark-mode .option-button,
  body.auto-dark-mode input,
  body.auto-dark-mode select,
  body.auto-dark-mode textarea {
    background-color: #2A2A2A;
    border-color: #444444;
  }
  
  body.auto-dark-mode .btn-secondary {
    background-color: #2A2A2A;
  }
  
  body.auto-dark-mode .tab-bar {
    background-color: rgba(30, 30, 30, 0.95);
    border-top-color: #333;
  }
}

/* 列印樣式 */
@media print {
  .tab-bar {
    display: none;
  }
  
  .app-content {
    height: auto;
    padding: 0;
    overflow: visible;
  }
  
  body {
    font-size: 12pt;
  }
  
  .card, .product-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* 常用布局組件 - 從內聯樣式轉換 */
.chat-message {
  display: flex;
  margin-bottom: 12px;
  opacity: 1; /* 修改：默認可見，不需要 JavaScript 設置 */
  transition: opacity 0.5s ease; /* 保留過渡效果 */
}

/* 特別為動態頁面設計的對話框，需要 JavaScript 控制顯示 */
.chat-message-animated {
  opacity: 0; /* 初始透明度為0，用於漸入動畫 */
}

.chat-message.right {
  justify-content: flex-end;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--background);
  border-radius: 24px;
  padding: 0 16px;
  margin: 12px 0;
}

.input-box {
  position: sticky;
  bottom: 84px; /* 與底部選單保持距離 */
  background-color: white;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  margin: 0 -16px;
  z-index: 15; /* 保持在適當的層級 */
  margin-bottom: 0; /* 移除額外的margin */
}

.gap-1 {
  gap: 4px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

/* 無障礙特性 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* 超寬螢幕支援 - 避免內容過寬 */
@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
  
  body {
    font-size: 18px;
  }
  
  .iphone-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
  }
  
  .iphone-preview-text {
    max-width: 400px;
  }
  
  /* 確保在大螢幕上內容不會變得太寬 */
  .content-max-width {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* 修復超寬螢幕的文字行長問題 */
@media (min-width: 1600px) {
  p, h1, h2, h3, h4, h5, h6, li {
    max-width: 70ch; /* 限制理想閱讀行寬 */
  }
  
  .container {
    max-width: 1400px;
  }
}

/* 加載動畫 */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(77, 104, 73, 0.3);
  border-radius: 50%;
  border-top: 4px solid var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 資訊整理算法相關樣式 */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.error-message {
  text-align: center;
  padding: 20px;
  background-color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin: 20px 0;
}

.error-message i {
  font-size: 48px;
  color: #f44336;
  margin-bottom: 12px;
}

.error-message p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

/* 淡入淡出動畫 */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

/* 選項按鈕選中狀態加強 */
.option-button.selected {
  background-color: rgba(77, 104, 73, 0.1);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* 預設隱藏的元素 */
[data-hidden="true"] {
  display: none !important;
}

/* 產品詳情模態框樣式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

.close-modal {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--primary);
}

.modal-body {
    margin-top: 10px;
}

.product-detail-header {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.product-detail-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
}

.product-detail-info {
    flex: 1;
    min-width: 200px;
}

.product-detail-info h2 {
    margin: 0 0 8px 0;
    font-size: 22px;
}

.detail-brand {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
}

.detail-rating {
    margin-bottom: 8px;
}

.detail-price {
    margin: 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.detail-buy-btn {
    margin-top: 10px;
}

.product-detail-description {
    margin-bottom: 20px;
    line-height: 1.5;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.detail-section ul {
    margin: 0;
    padding-left: 20px;
}

.detail-section li {
    margin-bottom: 4px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 576px) {
    .modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .product-detail-header {
        flex-direction: column;
    }
    
    .product-detail-image {
        width: 100%;
        height: auto;
        max-height: 200px;
    }
}

/* 頂部簡化免責聲明 */
.top-disclaimer {
  background-color: #fff9e6;
  padding: 6px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
  max-height: 24px;
  transition: max-height 0.3s ease;
}

.top-disclaimer.expanded {
  max-height: 100px;
}

.top-disclaimer i {
  color: #F5B17B;
  margin-right: 5px;
  flex-shrink: 0;
}

.top-disclaimer-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-disclaimer-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: rgba(255,255,255,0.6);
}

/* 專業背書與免責聲明樣式 */
.disclaimer-wrapper {
  background-color: rgba(255, 192, 75, 0.1);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0 30px;
  text-align: center;
}

.disclaimer-character {
  width: 100px;
  height: 100px;
  margin: 10px auto;
}

.disclaimer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.disclaimer-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.disclaimer-counter {
  padding: 10px;
  background-color: white;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.disclaimer-counter strong {
  font-weight: 700;
  color: var(--primary);
}

.disclaimer-notices {
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  margin-top: 15px;
  text-align: left;
}

.disclaimer-notice {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.disclaimer-notice:last-child {
  margin-bottom: 0;
}

/* 健康標籤區域和標題 */
.health-tags-section {
  margin: 20px 0;
  position: relative;
  background: rgba(77, 104, 73, 0.04);
  border-radius: 18px;
  padding: 20px 15px;
  border: 1px solid rgba(77, 104, 73, 0.1);
}

.health-tags-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 15px;
  color: var(--primary);
  text-align: center;
  position: relative;
  display: inline-block;
}

.health-tags-title:after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, rgba(77, 104, 73, 0.1), rgba(77, 104, 73, 0.7), rgba(77, 104, 73, 0.1));
  border-radius: 2px;
}

/* 健康標籤容器 */
.health-badges-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 5px 0 10px;
  margin-bottom: 5px;
  position: relative;
}

.health-badge {
  background-color: white;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none !important;
  color: var(--text-primary) !important;
  margin-bottom: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-left-width: 3px;
  border-left-color: var(--primary);
}

.health-badge:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.health-badge i {
  margin-right: 8px;
  color: var(--primary);
  font-size: 16px;
}

/* 健康標籤類別顏色 */
.health-badge[data-category="日常健康"],
.health-badge[data-category="預防保健"],
.health-badge[data-category="腦部健康"],
.health-badge[data-category="骨骼健康"],
.health-badge[data-category="感官健康"],
.health-badge[data-category="消化系統"],
.health-badge[data-category="心血管健康"],
.health-badge[data-category="其他"] {
  border-left: 3px solid var(--primary);
}

.health-badge[data-category="日常健康"] i,
.health-badge[data-category="預防保健"] i,
.health-badge[data-category="腦部健康"] i,
.health-badge[data-category="骨骼健康"] i,
.health-badge[data-category="感官健康"] i,
.health-badge[data-category="消化系統"] i,
.health-badge[data-category="心血管健康"] i,
.health-badge[data-category="其他"] i {
  color: var(--primary);
}

/* 針對移動端的健康標籤調整 */
@media (max-width: 576px) {
  .health-badges-container {
    justify-content: flex-start;
    overflow-x: auto;
    padding: 15px 5px;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    margin: 0 -5px 15px -5px;
    position: relative;
  }
  
  .health-badges-container:after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 30px;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,1));
    pointer-events: none;
    z-index: 1;
  }
  
  .health-badge {
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0 5px;
    padding: 10px 16px;
  }
}

/* 移除波紋效果 */
.ripple-effect {
  display: none;
}

@keyframes ripple {
  to {
    transform: scale(0);
    opacity: 0;
  }
}

/* 小帕貼心提醒樣式 */
.palpal-message-box {
    display: flex;
    align-items: flex-start;
    /* background: #fffbe7; */
    border-radius: 12px;
    /* box-shadow: 0 2px 8px rgba(0,0,0,0.04); */
    padding: 16px;
    margin: 24px 0;
    gap: 12px;
}
.palpal-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #fff;
    border: 2px solid #f5e6b2;
    object-fit: cover;
}
.palpal-bubble {
    background: #fffde2;
    border-radius: 10px;
    padding: 12px 16px;
    color: #7a5c1e;
    font-size: 15px;
    line-height: 1.7;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    flex: 1;
}

/* 相關文章推薦卡片樣式 */
.related-articles {
    margin-top: 36px;
}
.related-articles h2 {
    font-size: 18px;
    margin-bottom: 18px;
}
.article-card {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 16px;
    padding: 12px;
    gap: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.article-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.article-card-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f7f7f7;
}
.article-card-content {
    flex: 1;
}
.article-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: #333;
}
.article-card-meta {
    font-size: 12px;
    color: #a6a6a6;
}

/* 專門針對文章頁面的小帕對話框樣式 */
.article-content .chat-message {
  margin: 24px 0 !important;
  background-color: rgba(255, 250, 230, 0.35);
  padding: 16px !important;
  border-radius: 12px;
  position: relative;
  box-shadow: none !important;
  /* 確保寬度充足 */
  width: 100%;
  display: flex;
  align-items: flex-start;
}

.article-content .chat-message .avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  margin-right: 12px !important;
  background-color: transparent !important;
  border-radius: 50%;
  overflow: hidden;
}

.article-content .chat-message .chat-bubble {
  background-color: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  /* 確保文字容器有足夠空間，避免突然換行 */
  width: calc(100% - 60px) !important;
  max-width: 100% !important; /* 覆蓋所有媒體查詢中的限制 */
  flex: 1;
  margin-right: 0 !important;
}

.article-content .chat-message .chat-bubble p {
  font-size: 14px;
  line-height: 1.6;
  color: #5a5a5a;
  /* 文字自然流動 */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  margin-right: 0 !important;
  padding-right: 0 !important;
  margin-bottom: 0 !important;
}

.article-content .chat-message .chat-bubble p:first-of-type {
  /* 小帕名稱保持原有大小和顏色 */
  font-size: 15px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px !important;
  /* 添加小圖標 */
  display: flex;
  align-items: center;
}

.article-content .chat-message .chat-bubble p:first-of-type::before {
  content: "💡";
  margin-right: 6px;
  font-size: 13px;
}

/* 修復 iOS WebKit 特定問題 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .app-content {
    /* 強制重新計算布局 */
    transform: translateZ(0);
  }
  
  .feature-section,
  .health-badges-container,
  .chat-message {
    /* 防止內容溢出 */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  .health-badge {
    /* 確保標籤正確顯示 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* 修復 iOS Safari 特定的 flexbox 問題 */
@supports (-webkit-touch-callout: none) {
  .app-content {
    /* iOS Safari 特定修復 */
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  
  .feature-container {
    /* 確保 feature 容器在 iOS 上正確顯示 */
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  
  .feature-item {
    /* 防止 flex item 溢出 */
    flex-shrink: 0;
    min-height: 0;
  }
}

/* 通用工具類 - 從行內樣式抽取的常用樣式 */

/* Avatar 相關樣式 */
.avatar-transparent {
  background-color: transparent !important;
  padding: 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  overflow: hidden !important;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 導航標題樣式 */
.nav-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
}

/* 間隔工具類 */
.spacer-24 {
  width: 24px;
}

.spacer-height-30 {
  height: 30px;
}

.spacer-height-50 {
  height: 50px;
}

/* 文字邊距工具類 */
.text-no-margin {
  margin: 0;
}

.text-margin-bottom-8 {
  margin: 0 0 8px;
}

.text-margin-bottom-2 {
  margin: 0 0 2px;
}

.text-title {
  margin: 0 0 2px;
  font-weight: 600;
}

.text-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 圖標樣式 */
.icon-with-margin {
  margin-right: 16px;
  color: var(--primary);
  font-size: 20px;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 邊距工具類 */
.mb-24 {
  margin-bottom: 24px;
}

.mb-40 {
  margin-bottom: 40px;
}

.mb-60 {
  margin-bottom: 60px;
}

.mt-24 {
  margin-top: 24px;
}

/* 顯示/隱藏工具類 */
.display-none {
  display: none;
}

.display-block {
  display: block;
}

/* 按鈕擴展樣式 */
.btn-full-width {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

/* 背景色工具類 */
.bg-background {
  background-color: var(--background);
}

/* padding 工具類 */
.p-16 {
  padding: 16px;
}

/* Flex 工具類擴展 */
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
} 