/* ================================================================
   ch-style.css — 顧客抱怨處理工具樣式
   ================================================================ */

/* --- 容器 --- */
.ch-wrapper {
  max-width: 820px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  font-size: 15px;
  color: #222;
  line-height: 1.6;
}

.ch-loading {
  padding: 40px;
  text-align: center;
  color: #888;
}

/* --- Header --- */
.ch-header {
  background: linear-gradient(135deg, #1a6b9a 0%, #2d9cdb 100%);
  color: #fff;
  padding: 28px 32px 24px;
  border-radius: 12px 12px 0 0;
}
.ch-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}
.ch-subtitle {
  margin: 0;
  opacity: .8;
  font-size: 13px;
}

/* --- Body --- */
.ch-body {
  background: #f7f9fc;
  border: 1px solid #dde4ef;
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

/* --- Tabs --- */
.ch-tabs {
  display: flex;
  border-bottom: 2px solid #dde4ef;
  background: #fff;
}
.ch-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: center;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ch-tab:hover { background: #f0f4fa; }
.ch-tab.active {
  border-bottom-color: #1a6b9a;
  background: #f0f7ff;
}
.ch-tab-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}
.ch-tab.active .ch-tab-label { color: #1a6b9a; }
.ch-tab-sub {
  font-size: 11px;
  color: #888;
}

/* --- Content --- */
.ch-content {
  padding: 24px;
}

/* --- 步驟指示器 --- */
.ch-steps {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 4px;
}
.ch-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.ch-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.ch-step.done .ch-step-num   { background: #27ae60; color: #fff; }
.ch-step.current .ch-step-num{ background: #1a6b9a; color: #fff; }
.ch-step.pending .ch-step-num { background: #dde4ef; color: #999; }
.ch-step-label { color: #666; font-size: 12px; }
.ch-step-val   { color: #1a6b9a; font-weight: 600; font-size: 12px; }
.ch-step-divider {
  width: 24px;
  height: 1px;
  background: #dde4ef;
  margin: 0 4px;
}

/* --- 問題區 --- */
.ch-question { }
.ch-q-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 16px;
  color: #1a3a5c;
}
.ch-hint {
  font-size: 13px;
  color: #666;
  margin: 0 0 12px;
}

/* --- 選項按鈕 --- */
.ch-options {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.ch-options-3 { grid-template-columns: repeat(3, 1fr); }
.ch-options-4 { grid-template-columns: repeat(4, 1fr); }

.ch-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border: 2px solid #dde4ef;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.ch-opt:hover {
  border-color: #2d9cdb;
  background: #f0f7ff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(26,107,154,.12);
}
.ch-opt-icon { font-size: 26px; }
.ch-opt-name { font-size: 13px; font-weight: 600; color: #222; }
.ch-opt-desc { font-size: 11px; color: #666; line-height: 1.4; }

/* --- 按鈕 --- */
.ch-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.ch-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ch-btn:disabled { opacity: .6; cursor: not-allowed; }
.ch-btn-primary   { background: #1a6b9a; color: #fff; }
.ch-btn-primary:hover:not(:disabled) { background: #155880; }
.ch-btn-secondary { background: #fff; color: #1a6b9a; border: 2px solid #1a6b9a; }
.ch-btn-secondary:hover:not(:disabled) { background: #f0f7ff; }
.ch-btn-lg { padding: 13px 26px; font-size: 15px; }
.ch-btn-link {
  background: transparent;
  border: none;
  color: #2d9cdb;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
  margin-top: 8px;
}
.ch-btn-link:hover { text-decoration: underline; }

.ch-cost-badge {
  background: rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 400;
}

/* --- 卡片 --- */
.ch-card {
  background: #fff;
  border: 1px solid #dde4ef;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.ch-card h4 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #1a3a5c;
}
.ch-card ol, .ch-card ul {
  margin: 0;
  padding-left: 20px;
}
.ch-card li { margin-bottom: 6px; font-size: 14px; }
.ch-card p  { margin: 0 0 8px; font-size: 14px; }

.ch-card-warn    { border-color: #f39c12; background: #fffbf0; }
.ch-card-warn h4 { color: #b7770d; }
.ch-card-danger  { border-color: #e74c3c; background: #fff8f8; }
.ch-card-danger h4 { color: #c0392b; }
.ch-card-script  { border-color: #27ae60; background: #f0fff5; }
.ch-card-script h4 { color: #1e8449; }
.ch-card-emotion { border-color: #9b59b6; background: #fdf5ff; }
.ch-card-emotion h4 { color: #7d3c98; }
.ch-card-ai      { border-color: #2d9cdb; background: #f0f7ff; }
.ch-card-ai h4   { color: #1a6b9a; }
.ch-card-info    { border-color: #3498db; background: #eaf4fd; }

/* --- 結果標籤列 --- */
.ch-result-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ch-tag {
  background: #e8f2fa;
  color: #1a6b9a;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* --- 徽章 --- */
.ch-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
}
.ch-badge-warn { background: #f39c12; color: #fff; }

/* --- 話術 --- */
.ch-script-text {
  background: #f5fdf7;
  border-left: 4px solid #27ae60;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  margin-bottom: 8px;
  color: #1a3a1e;
  line-height: 1.7;
}

/* --- 提示 --- */
.ch-channel-note { color: #2d9cdb; font-weight: 600; margin-top: 12px !important; }
.ch-warn-note    { color: #b7770d; font-weight: 600; margin-top: 10px !important; }

/* --- 勾選清單 --- */
.ch-checklist { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ch-check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}
.ch-check { margin-top: 2px; width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }

/* --- 第一層 footer --- */
.ch-l1-footer { text-align: center; padding: 16px 0 4px; }
.ch-l1-footer .ch-hint { margin-bottom: 12px; }

/* --- Textarea --- */
.ch-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dde4ef;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color .15s;
}
.ch-textarea:focus {
  outline: none;
  border-color: #2d9cdb;
  box-shadow: 0 0 0 3px rgba(45,156,219,.12);
}

/* --- AI 內容 --- */
.ch-ai-content { font-size: 14px; line-height: 1.75; }
.ch-ai-content h3, .ch-ai-content h4, .ch-ai-content h5, .ch-ai-content h6,
.ch-ai-content .ch-md-h {
  margin: 14px 0 8px;
  color: #1a3a5c;
  font-weight: 700;
  line-height: 1.35;
}
.ch-ai-content h3 { font-size: 1.05rem; }
.ch-ai-content h4 { font-size: 1rem; }
.ch-ai-content h5, .ch-ai-content h6 { font-size: 0.95rem; }
.ch-ai-content p, .ch-ai-content .ch-md-p { margin: 0 0 10px; }
.ch-ai-content ol, .ch-ai-content ul, .ch-ai-content .ch-md-list {
  padding-left: 22px;
  margin: 0 0 12px;
}
.ch-ai-content li { margin-bottom: 6px; }
.ch-ai-content strong { color: #1a3a5c; }
.ch-ai-content .ch-md-hr {
  border: none;
  border-top: 1px solid #dde4ef;
  margin: 16px 0;
}

/* --- PDF 匯出按鈕 --- */
.ch-pdf-row {
  margin: 16px 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ch-pdf-row-top { margin-top: 0; }
.ch-btn-pdf { font-size: 13px; }
.ch-btn-pdf-sm { font-size: 12px; padding: 6px 12px; }

/* --- PDF 產生用（離屏容器繼承） --- */
.ch-pdf-sheet .ch-pdf-doc-title {
  font-size: 18px;
  margin: 0 0 8px;
  color: #1a3a5c;
}
.ch-pdf-sheet .ch-pdf-meta {
  font-size: 11px;
  color: #666;
  margin: 0 0 16px;
  border-bottom: 1px solid #dde4ef;
  padding-bottom: 10px;
}
.ch-pdf-sheet .ch-pdf-text-block {
  white-space: pre-wrap;
  padding: 8px 10px;
  background: #f5f7fa;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 12px;
}
.ch-pdf-sheet .ch-card {
  break-inside: avoid;
  page-break-inside: avoid;
}

/* 預覽／列印 PDF：標題與標籤開頭 emoji 勿被系統字體放得過大 */
.ch-pdf-preview-inner .ch-pdf-emoji,
.ch-pdf-print-root .ch-pdf-emoji {
  font-size: 18px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  vertical-align: middle;
  margin-right: 0.2em;
  flex-shrink: 0;
  overflow: hidden;
}
.ch-pdf-preview-inner img.emoji,
.ch-pdf-preview-inner img.wp-smiley,
.ch-pdf-print-root img.emoji,
.ch-pdf-print-root img.wp-smiley,
.ch-pdf-preview-inner .ch-pdf-emoji-img,
.ch-pdf-print-root .ch-pdf-emoji-img {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  display: inline-block !important;
  vertical-align: middle !important;
  object-fit: contain;
  margin-right: 0.2em;
}

/* --- PDF 預覽視窗 --- */
.ch-pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
}
.ch-pdf-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
}
.ch-pdf-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(920px, 100%);
  max-height: min(90vh, 900px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.ch-pdf-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #dde4ef;
  background: #f7f9fc;
  flex-shrink: 0;
}
.ch-pdf-modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #1a3a5c;
}
.ch-pdf-modal-x {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.ch-pdf-modal-x:hover {
  color: #111;
  background: #e8ecf2;
}
.ch-pdf-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: #e8ecf4;
  -webkit-overflow-scrolling: touch;
}
.ch-pdf-preview-inner {
  max-width: 210mm;
  margin: 0 auto;
  background: #fff;
  color: #222;
  padding: 20px 24px;
  border-radius: 8px;
  box-sizing: border-box;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}
.ch-pdf-modal-foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #dde4ef;
  background: #fff;
  flex-shrink: 0;
}
.ch-pdf-modal-foot .ch-pdf-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.ch-pdf-modal-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #666;
}

.ch-l2-footer { text-align: center; margin-top: 8px; }

/* --- 第三層 / 模擬對話 --- */
.ch-sim-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.ch-sim-history {
  background: #fff;
  border: 1px solid #dde4ef;
  border-radius: 10px;
  padding: 16px;
  min-height: 200px;
  max-height: 440px;
  overflow-y: auto;
  margin-bottom: 14px;
}
.ch-sim-start { text-align: center; padding: 20px; color: #666; }
.ch-sim-start p { margin: 4px 0; }
.ch-sim-msg { margin-bottom: 16px; }
.ch-sim-role {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.ch-sim-user   .ch-sim-role { color: #1a6b9a; }
.ch-sim-assistant .ch-sim-role { color: #c0392b; }
.ch-sim-text {
  background: #f7f9fc;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.7;
}
.ch-sim-user .ch-sim-text { background: #e8f2fa; }
.ch-coach-note {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fff9e6;
  border-left: 3px solid #f39c12;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  line-height: 1.7;
  color: #4a4a2a;
}
.ch-coach-label {
  display: block;
  font-weight: 700;
  color: #b7791f;
  margin-bottom: 6px;
}
.ch-coach-body {
  font-size: 13px;
  line-height: 1.65;
}
.ch-coach-body strong {
  font-weight: 700;
  color: #1a3a5c;
}
.ch-sim-loading { text-align: center; padding: 12px; color: #888; font-size: 13px; }
.ch-sim-input   { resize: none; }
.ch-sim-input-area { }

/* --- Spinner --- */
.ch-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ch-spin .6s linear infinite;
}
@keyframes ch-spin { to { transform: rotate(360deg); } }

/* --- 連結 --- */
.ch-link { color: #2d9cdb; text-decoration: underline; }

/* --- 響應式 --- */
@media (max-width: 600px) {
  .ch-header       { padding: 20px 16px; }
  .ch-content      { padding: 16px; }
  .ch-tabs         { flex-wrap: wrap; }
  .ch-tab          { padding: 10px 6px; }
  .ch-tab-label    { font-size: 12px; }
  .ch-options-3    { grid-template-columns: 1fr; }
  .ch-options-4    { grid-template-columns: repeat(2, 1fr); }
  .ch-btn-lg       { padding: 11px 18px; font-size: 14px; }
}
