body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif; color: #1f2430; }

h1, h2, h3, h4, h5 { font-weight: 600; color: #1a1a2e; }
h3 { font-size: 22px; }

h6 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
}

dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6b7280;
}

dd {
  font-size: 14px;
  color: #1f2430;
}

.card-body { font-size: 14px; }

/* 品牌主色按鈕（#1b2748，與登入頁、客戶入口頂列同色） */
.btn-brand { background: #1b2748; border-color: #1b2748; color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: #2a3a66; border-color: #2a3a66; color: #fff; }
.text-brand { color: #1b2748; }

/* Jira 匯入內容裡的標題（h1~h6）用 CRM 自己的字級，不要沿用 Jira 原本很大的標題樣式（CRM01P2601-54 A1）。
   子專案④的 Quill 編輯器輸出的標題也套用這個 class，兩邊要一致。 */
.rich-content h1, .rich-content h2, .rich-content h3,
.rich-content h4, .rich-content h5, .rich-content h6 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: .75rem 0 .25rem;
}

/* 富文本編輯器（Quill 2，CRM01P2601-54 ④）：前後台描述、留言共用 */
.rich-editor .ql-container { min-height: var(--rich-editor-min-height, 160px); font-size: 14px; }
.rich-editor .ql-editor img { max-width: 100%; height: auto; }
.rich-content img { max-width: 100%; height: auto; }

/* 表格顯示端樣式（CRM01P2601-69）：Quill 2 table-better 輸出的表格 */
.rich-content { overflow-x: auto; }
.rich-content table {
  border-collapse: collapse;
  min-width: max-content;
  max-width: 100%;
}
.rich-content table td, .rich-content table th {
  border: 1px solid #ced4da;
  padding: .375rem .5rem;
}
.rich-content table th {
  background-color: #f8f9fa;
  font-weight: 600;
}
@media (max-width: 575.98px) {
  .rich-editor .ql-toolbar { padding: 4px; }
  .rich-editor .ql-toolbar .ql-formats { margin-right: 6px; }
}

/* 工單附件拖曳上傳區（CRM01P2601-66），class 由 static/js/attachment_dropzone.js 套用 */
.attachment-dropzone {
  max-width: 100%;
  padding: 1.5rem 1rem;
  border: 2px dashed #ced4da;
  border-radius: .5rem;
  text-align: center;
  cursor: pointer;
  background-color: #f8f9fa;
  transition: border-color .15s ease-in-out, background-color .15s ease-in-out;
}
.attachment-dropzone.is-dragover {
  border-color: #1b2748;
  background-color: #eef1f8;
}
.attachment-dropzone:focus,
.attachment-dropzone:focus-visible {
  outline: 2px solid #1b2748;
  outline-offset: 2px;
}

.attachment-dropzone-hint {
  color: #6c757d;
  font-size: .9rem;
  text-align: center;
}

.attachment-dropzone-list {
  list-style: none;
  padding-left: 0;
  margin: .75rem 0 0;
  text-align: left;
}
.attachment-dropzone-list:empty { margin-top: 0; }
.attachment-dropzone-list .attachment-dropzone-item + .attachment-dropzone-item {
  margin-top: .5rem;
}

.attachment-dropzone-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  padding: .375rem .5rem;
  background-color: #fff;
  border: 1px solid #e9ecef;
  border-radius: .375rem;
}

.attachment-dropzone-item-name {
  font-weight: 500;
  word-break: break-all;
}

.attachment-dropzone-item-size {
  color: #6c757d;
  font-size: .85rem;
}

.attachment-dropzone-item-status {
  font-size: .85rem;
  font-weight: 500;
}
.attachment-dropzone-item-status.is-uploading { color: #6c757d; }
.attachment-dropzone-item-status.is-success { color: #198754; }
.attachment-dropzone-item-status.is-error { color: #dc3545; }

.attachment-dropzone-item-remove {
  margin-left: auto;
  padding: .125rem .5rem;
  font-size: .8rem;
  color: #6c757d;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  cursor: pointer;
}
.attachment-dropzone-item-remove:hover { color: #1f2430; background-color: #f1f3f5; }
.attachment-dropzone-item-remove:disabled { opacity: .6; cursor: default; }

/* 工單詳情頁各區塊收合/展開（CRM01P2601-86）：按鈕本身沿用 h6 的樣式，只是多一顆可點擊的箭頭。 */
.collapsible-toggle .collapse-arrow {
  font-size: .75rem;
  color: #6b7280;
  display: inline-block;
  width: 1em;
}
.collapsible-toggle h6 { color: inherit; }
.collapsible-toggle:hover h6,
.collapsible-toggle:hover .collapse-arrow { color: #1b2748; }
.collapsible-toggle:focus-visible {
  outline: 2px solid #1b2748;
  outline-offset: 2px;
}
.collapse-count-badge:empty { display: none; }

/* 自訂狀態管理：顏色色塊選單（CRM01P2601-139）。底層仍是 radio input，
   只是用 CSS 把它藏起來、改用後面的色塊 span 當可點擊的視覺呈現。 */
.color-swatch-option { cursor: pointer; }
.color-swatch-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.color-swatch-chip {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: .25rem;
  border: 1px solid rgba(0, 0, 0, .15);
}
.color-swatch-chip--default { background: #fff; border-style: dashed; }
.color-swatch-chip--nonstandard {
  background: repeating-linear-gradient(45deg, #f8d7da, #f8d7da 4px, #fff 4px, #fff 8px);
  border-color: #dc3545;
}
.color-swatch-option input[type="radio"]:checked + .color-swatch-chip {
  outline: 2px solid #1b2748;
  outline-offset: 2px;
}
.color-swatch-option input[type="radio"]:focus-visible + .color-swatch-chip {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* 折疊狀態只影響螢幕顯示，列印時一律展開（CRM01P2601-86 需求 6）。 */
@media print {
  .collapsible-section .collapse:not(.show) {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
  }
}

/* 工單詳情頁各區塊依「性質」分色（CRM01P2601-82），避免各卡片視覺上連成一片。
   配色刻意避開紅/綠/黃/橘，因為那幾色已用於 SLA 與狀態徽章語意，不應被區塊底色混淆。 */
.ticket-detail-page {
  background: #f3f5f7;
  padding: 1rem;
  border-radius: 14px;
}

.section-card {
  border-radius: 14px;
  overflow: hidden;
}

.section-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  color: #1f1f1f;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}
/* Bootstrap 的 .text-dark（套在 collapsible_toggle 按鈕上）會蓋掉繼承色，
   這兩行要留著才能讓折疊箭頭／標題文字跟區塊標題列同色（#1f1f1f），不是死碼。
   margin-bottom 才是真的死碼：h6 本身（collapsible_toggle.html 與 SLA/詳情兩處手寫）
   都已經有 mb-0 class，這裡不需要再設一次。 */
.section-card-header h6 { color: #1f1f1f; }
.section-card-header .collapse-arrow { color: #1f1f1f; }

:root {
  --section-internal-bg: #fae6f4;
  --section-internal-border: #d48bb9;
}

.section-card--content { border: 1px solid #8fb5f2; }
.section-card--content > .section-card-header { background: #bcd4fa; }

.section-card--attachment { border: 1px solid #86cbc3; }
.section-card--attachment > .section-card-header { background: #b4e3dd; }

.section-card--status { border: 1px solid #b6a3ea; }
.section-card--status > .section-card-header { background: #d8cbf6; }

.section-card--history { border: 1px solid #a9adb1; }
.section-card--history > .section-card-header { background: #d5d9df; }

.section-card--internal { border: 1px dashed var(--section-internal-border); }
.section-card--internal > .section-card-header { background: var(--section-internal-bg); }

.section-internal-label {
  font-size: .7rem;
  font-weight: 700;
  color: #9c3d78;
  border: 1px dashed var(--section-internal-border);
  border-radius: 4px;
  padding: .1rem .4rem;
  white-space: nowrap;
}

/* 內部備註留言：CRM01P2601-56 曾誤把內部備註當客戶可見，色彩不可作為唯一判斷依據，
   因此沿用既有的「內部備註」文字徽章之外，再疊加虛線框＋底色強化辨識度。 */
.comment-internal {
  background: var(--section-internal-bg);
  border: 1px dashed var(--section-internal-border);
  border-radius: 8px;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
}

/* SLA 設定頁（CRM01P2601-54 手機版修復）：欄位是同一個 <form> 內共用 name 的 input，
   不能像唯讀清單那樣另外重複一份手機版卡片 markup（會變成同一個 name 兩個 input，
   送出時究竟採用桌面版還是手機版的值要看 DOM 順序，使用者編輯哪一欄都可能被悄悄蓋掉）。
   改用純 CSS 把 table 在窄螢幕下轉成逐列堆疊，欄位值前用 data-label 顯示對應欄名。 */
@media (max-width: 767.98px) {
  .responsive-form-table thead { display: none; }
  .responsive-form-table, .responsive-form-table tbody, .responsive-form-table tr, .responsive-form-table td {
    display: block; width: 100%;
  }
  .responsive-form-table tr {
    margin-bottom: .75rem;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    padding: .5rem;
  }
  .responsive-form-table td {
    border: none;
    padding: .35rem 0;
  }
  .responsive-form-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .75rem;
    color: #6c757d;
    margin-bottom: .15rem;
  }
}
