/* ============================================
   utilities.css — 全站工具類樣式
   -------------------------------------------------
   內容：
     1. 名稱截斷
     2. 手機卡片化表格
     3. Tab 切換
     4. 間距工具
     5. Flex / 對齊
     6. 文字
     7. 顯示
     8. 分隔線
     9. 快速摘要卡
    10. 內容區最小高度
   ============================================ */

/* ============================================
   1. 名稱截斷（桌面 12 字元 / 手機 6 字元）
   ============================================ */
.truncate {
  display: inline-block;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .truncate {
    max-width: 6em;
  }
}

/* 可展開版本（點擊展開全名） */
.truncate-expandable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.35);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.truncate-expandable:hover {
  color: var(--neon-cyan);
  border-bottom-color: var(--neon-cyan);
}

.truncate-expandable.expanded {
  max-width: none;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
}

/* ============================================
   2. 手機卡片化表格（.data-table.mobile-cards）
   -------------------------------------------------
   用法：HTML 表格加 class="data-table mobile-cards"
         每個 <td> 加 data-label="欄位名"
         主欄位加 data-primary（不顯示 label）
   ============================================ */
@media (max-width: 640px) {
  .data-table.mobile-cards {
    display: block;
    border: none;
    min-width: 0 !important;
  }

  .data-table.mobile-cards thead {
    display: none;
  }

  .data-table.mobile-cards tbody {
    display: block;
  }

  .data-table.mobile-cards tbody tr {
    display: block;
    margin-bottom: 10px;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
  }

  .data-table.mobile-cards tbody tr:hover td {
    background: transparent;
  }

  .data-table.mobile-cards td {
    display: block;
    padding: 4px 0;
    border: none;
    font-size: 13px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .data-table.mobile-cards td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 70px;
    color: var(--text-muted);
    font-size: 11px;
    margin-right: 8px;
  }

  /* 隱藏欄位（行動版不需顯示） */
  .data-table.mobile-cards td.hide-mobile,
  .data-table.mobile-cards th.hide-mobile {
    display: none !important;
  }

  /* 主要欄位（成員 + 項目名）放大 */
  .data-table.mobile-cards td[data-primary] {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
  }

  .data-table.mobile-cards td[data-primary]::before {
    display: none;
  }

  /* 金額欄位右對齊 */
  .data-table.mobile-cards td[data-label="金額"],
  .data-table.mobile-cards td.num {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 700;
  }

  /* 操作按鈕群組 */
  .data-table.mobile-cards td[data-label="操作"] {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .data-table.mobile-cards td[data-label="操作"]::before {
    display: none;
  }

  /* 狀態 badge 放行 */
  .data-table.mobile-cards td[data-label="狀態"] {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

/* ============================================
   3. Tab 切換
   ============================================ */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: thin;
}

.tab-bar .tab-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: inherit;
}

.tab-bar .tab-btn:hover {
  color: var(--neon-cyan);
}

.tab-bar .tab-btn.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* 多行 Tab（8 Tab 用） */
.tab-bar.tab-bar-wrap {
  flex-wrap: wrap;
}

.tab-bar.tab-bar-wrap .tab-btn {
  flex: 0 0 auto;
  min-width: auto;
}

@media (max-width: 640px) {
  .tab-bar {
    gap: 2px;
    padding: 3px;
  }
  .tab-bar .tab-btn {
    padding: 7px 10px;
    font-size: 12px;
    min-width: 80px;
  }
  .tab-bar.tab-bar-wrap .tab-btn {
    min-width: auto;
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* ============================================
   4. 間距工具
   ============================================ */
.mt-0  { margin-top: 0 !important; }
.mt-4  { margin-top: 4px !important; }
.mt-8  { margin-top: 8px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-24 { margin-top: 24px !important; }

.mb-0  { margin-bottom: 0 !important; }
.mb-4  { margin-bottom: 4px !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }

.ml-4  { margin-left: 4px !important; }
.ml-8  { margin-left: 8px !important; }
.mr-4  { margin-right: 4px !important; }
.mr-8  { margin-right: 8px !important; }

.p-0  { padding: 0 !important; }
.p-4  { padding: 4px !important; }
.p-8  { padding: 8px !important; }
.p-12 { padding: 12px !important; }
.p-16 { padding: 16px !important; }
.p-20 { padding: 20px !important; }

.gap-4  { gap: 4px !important; }
.gap-6  { gap: 6px !important; }
.gap-8  { gap: 8px !important; }
.gap-12 { gap: 12px !important; }
.gap-16 { gap: 16px !important; }
.gap-20 { gap: 20px !important; }

/* ============================================
   5. Flex / 對齊
   ============================================ */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-end   { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1        { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ============================================
   6. 文字
   ============================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-xs     { font-size: 11px; }
.text-sm     { font-size: 12px; }
.text-base   { font-size: 14px; }
.text-lg     { font-size: 16px; }
.text-xl     { font-size: 18px; }
.text-bold   { font-weight: 700; }
.text-mono   { font-family: var(--font-mono); }

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

/* ============================================
   7. 顯示
   ============================================ */
.hidden       { display: none !important; }
.block        { display: block !important; }
.inline-block { display: inline-block !important; }

/* ============================================
   8. 分隔線
   ============================================ */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 16px 0;
}

.divider-dashed {
  height: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  margin: 16px 0;
}

/* ============================================
   9. 快速摘要卡
   ============================================ */
.quick-summary-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
}

.quick-summary-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--neon-cyan);
  letter-spacing: 1px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.quick-summary-row .label {
  color: var(--text-secondary);
}

.quick-summary-row .value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .quick-summary-card { padding: 16px; }
  .quick-summary-row { font-size: 12px; }
}

/* ============================================
   10. 內容區最小高度（填補底部空白）
   ============================================ */
.content-min-height {
  min-height: calc(100vh - 64px - 48px);
}

@media (max-width: 640px) {
  .content-min-height {
    min-height: calc(100vh - 64px - 32px);
  }
}
/* data-card 卡片樣式（若尚未加入 utilities.css） */
.data-card { padding: 16px; }
.data-card-primary {
  font-size: 15px;
  font-weight: 700;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  line-height: 1.35;
}
.data-card-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.data-card-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.data-card-label {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}
.data-card-value {
  text-align: right;
  word-break: break-word;
}
.data-card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}