/* ============================================
   祝福小幫手 - 簡潔長輩友善樣式 v4
   ============================================ */

/* LINE Seed TW 字體 */
@font-face {
  font-family: 'LINE Seed TW';
  src: url('/fonts/LINESeedTW-Thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LINE Seed TW';
  src: url('/fonts/LINESeedTW-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LINE Seed TW';
  src: url('/fonts/LINESeedTW-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LINE Seed TW';
  src: url('/fonts/LINESeedTW-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* CSS Variables */
:root {
  --color-primary: #C62828;
  --color-primary-light: #EF5350;
  --color-secondary: #00897B;
  --color-accent: #F9A825;

  --bg-main: #FAFAFA;
  --bg-card: #FFFFFF;

  --text-primary: #212121;
  --text-secondary: #616161;
  --text-light: #9E9E9E;
  --text-white: #FFFFFF;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* 基礎重置 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
  min-height: 100vh;
  min-height: 100dvh;
}

/* 容器 */
.container {
  max-width: 440px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================
   首頁
   ============================================ */
.home-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header - 兩行格式 */
.header.compact {
  text-align: center;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

.greeting-line1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

.greeting-line2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

/* 智慧推薦 */
.smart-suggestion.compact {
  margin: 0;
  margin-top: -8px;
}

.smart-btn {
  width: 100%;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #FF6B6B 0%, #E94560 50%, #D32F2F 100%);
  color: var(--text-white);
  border: none;
  border-radius: 16px;
  font-size: 22px;
  font-weight: 700;
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.smart-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

.smart-btn:active {
  transform: scale(0.98);
  box-shadow: 0 3px 10px rgba(233, 69, 96, 0.3);
}

.smart-btn .emoji {
  font-size: 28px;
}

.smart-btn .arrow {
  font-size: 20px;
  margin-left: 4px;
  animation: bounce-right 1s infinite;
}

@keyframes bounce-right {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(4px);
  }
}

/* 主題選擇區 - 2列 */
.theme-section.compact {
  margin-top: 8px;
}

.theme-section-title {
  text-align: center;
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 12px;
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

.theme-grid.compact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.theme-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 2px solid #E0E0E0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  font-size: 20px;
  font-weight: 700;
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

/* 自訂文字按鈕 */
.theme-btn[data-theme="custom"] {
  padding: 12px 16px;
}

.theme-btn:active {
  transform: scale(0.96);
  border-color: var(--color-primary);
}

.theme-btn .emoji {
  font-size: 22px;
}

.theme-btn .label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  font-family: "LINE Seed TW", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, sans-serif;
}

/* 送禮按鈕 */
.btn-gift {
  display: block;
  width: 100%;
  padding: 16px 20px;
  margin-top: 8px;
  background: var(--color-secondary);
  color: white;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.btn-gift:active {
  transform: scale(0.98);
}

.home-gift-btn {
  margin-top: 12px;
}

/* 使用次數提示 */
.usage-hint {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-top: 12px;
  padding: 8px;
}

/* userId 顯示（點擊可複製） */
.user-id-hint {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  padding: 4px 8px;
  cursor: pointer;
  font-family: monospace;
}

.user-id-hint:active {
  color: #00897B;
}

/* ============================================
   文字編輯區
   ============================================ */
.edit-section {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 24px;
}

.edit-section.active {
  display: flex;
}

.edit-header.compact {
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.edit-theme-badge {
  display: inline-block;
  padding: 6px 16px;
  background: #FFF3E0;
  color: #E65100;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.edit-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.edit-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.blessing-textarea {
  width: 100%;
  min-height: 300px;
  padding: 18px;
  border: 2px solid #E0E0E0;
  border-radius: var(--radius-md);
  font-size: 28px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-primary);
  resize: none;
}

.blessing-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.blessing-textarea::placeholder {
  color: var(--text-light);
}

.char-count {
  text-align: right;
  font-size: 14px;
  color: var(--text-light);
  margin-top: 8px;
}

.edit-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-secondary {
  display: flex;
  gap: 12px;
}

.edit-secondary .btn {
  flex: 1;
}

/* ============================================
   預覽區
   ============================================ */
.preview-section {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 24px;
}

.preview-section.active {
  display: flex;
}

.preview-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.preview-image {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.preview-actions {
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-secondary-actions {
  display: flex;
  gap: 10px;
}

.preview-secondary-actions .btn {
  flex: 1;
}

/* ============================================
   按鈕系統
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--text-white);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-large {
  padding: 18px 28px;
  font-size: 20px;
}

.btn-outline-sm {
  padding: 12px 8px;
  font-size: 15px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid #E0E0E0;
}

.btn-outline-sm.btn-back {
  font-size: 16px;
  font-weight: 600;
  padding: 12px 16px;
}

.btn-outline-sm:active {
  background: #F5F5F5;
}

/* ============================================
   Loading - 進度條樣式
   ============================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  padding: 40px 20px;
}

.loading-overlay.active {
  display: flex;
}

.loading-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 廣告區塊 - 放在有內容的頁面 */
.ad-container {
  width: 100%;
  min-height: 100px;
  margin-top: 16px;
  padding: 8px 0;
}

/* 進度條容器 */
.loading-progress-container {
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
}

.loading-progress-bar {
  width: 100%;
  height: 12px;
  background: #E0E0E0;
  border-radius: 6px;
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 6px;
  width: 0%;
  transition: width 0.3s ease;
}

.loading-progress-text {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  margin-top: 8px;
}

/* 隱藏舊的轉圈動畫 */
.loading-animation {
  display: none;
}

.loading-text {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 15px;
  color: var(--text-light);
  text-align: center;
}

/* ============================================
   動畫
   ============================================ */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   隱藏非活動區塊
   ============================================ */
section:not(.active) {
  display: none !important;
}

section.active {
  display: flex !important;
}

/* ============================================
   使用額度顯示
   ============================================ */
.usage-info {
  text-align: center;
  margin-top: 4px;
  transition: opacity 0.2s;
}

.usage-info[style*="cursor: pointer"] {
  opacity: 1 !important;
}

.usage-hint {
  font-size: 14px;
  color: var(--text-light);
  display: inline;
}

.usage-hint #remaining-count {
  font-weight: 700;
  color: #00B900;
  font-size: 16px;
}

.usage-detail {
  font-size: 13px;
  color: #888;
  margin-left: 4px;
}

/* 首頁加值區塊 */
.home-upgrade-section {
  margin-top: 4px;
}

.home-upgrade-title {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 8px;
}

.home-upgrade-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-home-upgrade {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 14px 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.btn-home-upgrade:active {
  background: #f5f5f5;
}

.btn-home-upgrade.coffee {
  width: 100%;
  font-size: 15px;
}

/* ============================================
   預覽頁剩餘次數
   ============================================ */
.preview-remaining {
  background: #f5f5f5;
  border-radius: 16px;
  padding: 6px 12px;
  text-align: center;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.remaining-label {
  font-size: 12px;
  color: var(--text-light);
}

.remaining-value {
  font-size: 14px;
  font-weight: 700;
  color: #00B900;
}

/* ============================================
   付款選項
   ============================================ */
.payment-options {
  width: 100%;
  margin-top: 8px;
}

.payment-divider {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.payment-divider::before,
.payment-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #eee;
}

.payment-divider span {
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-light);
}

.payment-credits {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-credits {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid #ddd;
  color: var(--text-primary);
  padding: 14px 12px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-credits:active {
  background: #f5f5f5;
}

.btn-coffee {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid #ddd;
  color: var(--text-primary);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-coffee:active {
  background: #f5f5f5;
}

/* ============================================
   咖啡彈窗
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #333;
}

.modal-desc {
  font-size: 14px;
  color: #666;
  margin-bottom: 20px;
}

.coffee-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-coffee-option {
  background: linear-gradient(135deg, #8D6E63, #6D4C41);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-coffee-option:active {
  transform: scale(0.98);
}

.custom-amount-section {
  border-top: 1px solid #eee;
  padding-top: 16px;
  margin-bottom: 16px;
}

.custom-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 10px;
}

.custom-amount-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.currency {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.custom-amount-input {
  width: 120px;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 12px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.custom-amount-input:focus {
  outline: none;
  border-color: #00B900;
}

.btn-custom-pay {
  background: linear-gradient(135deg, #8D6E63, #6D4C41);
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.custom-hint {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 8px;
}

.btn-modal-close {
  width: 100%;
  background: #f5f5f5;
  color: #666;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}

/* ============================================
   額度用完彈窗
   ============================================ */
.quota-exhausted-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-quota-action {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-quota-left {
  background: #f5f5f5;
  color: #666;
}

.btn-quota-left:active {
  background: #e0e0e0;
}

.btn-quota-right {
  background: linear-gradient(135deg, #FF6B6B 0%, #E94560 50%, #D32F2F 100%);
  color: #fff;
}

.btn-quota-right:active {
  transform: scale(0.98);
}

/* ============================================
   購買次數彈窗
   ============================================ */
.credits-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.btn-credits-option {
  width: 100%;
  background: linear-gradient(135deg, #FF6B6B 0%, #E94560 50%, #D32F2F 100%);
  color: #fff;
  border: none;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-credits-option:active {
  transform: scale(0.98);
}

/* ============================================
   Footer
   ============================================ */
.footer {
  margin-top: 60px;
  padding: 30px 0 50px;
  text-align: center;
  border-top: 1px solid #eee;
  width: 100%;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-copyright {
  font-size: 12px;
  color: var(--text-light);
}

/* ============================================
   Secondary Button
   ============================================ */
.btn-secondary {
  background: #f5f5f5;
  color: #333;
  box-shadow: none;
  border: 1px solid #e0e0e0;
}

.btn-secondary:active {
  background: #e0e0e0;
}
/* ============================================
   Loading Animation
   ============================================ */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 2s linear infinite;
}
