/* 営業の作業の画面（対応予定・面談の準備・月別売上予定）の並び。面・表・ボタンの見た目は共通の部品のまま。
   表とカードの共通の決まりは prm.css にある。色は styles.css の変数だけを使う。 */

/* ---- 絞り込みの帯（操作の帯の左。選ぶ欄は共通の丸い形） ---- */

.work-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-8);
  min-width: 0;
}

/* 月の欄。欄の名前を左に、丸い入力欄を右に置く */
.work-month {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  min-width: 0;
  font-size: var(--fs-small);
  color: var(--color-muted);
  white-space: nowrap;
}

.work-month__input.input {
  width: auto;
  min-width: 150px;
  height: var(--h-button);
  border-radius: var(--r-pill);
  font-size: var(--fs-body);
}

.work-filters__step {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
}

/* 見出しの行の右の、関連する画面への小さいボタン */
.work-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-8) var(--sp-12);
}

/* ---- 対応予定 ---- */

.work-subject {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* 表の形のとき、顧客の列は社名が1行に収まる幅を保ち、長い対応内容の側を折り返す */
.work-followups td:nth-child(4) {
  min-width: 11em;
}

/* ---- 面談の準備 ---- */

.work-notes {
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.work-notes__item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.work-notes__label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-muted);
}

.work-notes__text {
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.work-notes__text--empty {
  color: var(--color-muted);
}

/* 直近の活動と議事録。左に日付、右に件名と本文 */
.work-history {
  display: flex;
  flex-direction: column;
}

.work-history__item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--sp-4) var(--sp-16);
  padding: 14px 0;
  border-top: 1px solid var(--color-row-divider);
}

.work-history__item:first-child {
  padding-top: 0;
  border-top: 0;
}

.work-history__item:last-child {
  padding-bottom: 0;
}

.work-history__date {
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--color-muted);
  white-space: nowrap;
}

.work-history__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-4);
  min-width: 0;
}

.work-history__title {
  font-weight: 600;
}

.work-history__body {
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- 月別売上予定 ---- */

.work-total {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-12) var(--sp-24);
}

/* ---- 狭い幅 ---- */

@media (max-width: 640px) {
  /* 操作の帯は全画面でそろえた形にする。選ぶ欄は2つずつ等しい幅（1つ余るときは横いっぱい）、ボタンは帯の幅いっぱい */
  .work-bar .action-bar__start,
  .work-bar .action-bar__end {
    flex: 1 1 100%;
  }

  .work-bar .work-filters {
    flex: 1 1 100%;
  }

  /* 選ぶ欄は、言葉が切れない幅（11.5字ぶん）を下回るときは、1つずつ横いっぱいにする（面の中の狭い帯） */
  .work-filters > .select-wrap {
    flex: 1 1 calc((100% - var(--sp-8)) / 2);
    min-width: min(100%, 11.5em);
  }

  .work-filters > .select-wrap > .select {
    width: 100%;
  }

  .work-filters > .work-month {
    flex: 1 1 100%;
  }

  .work-month__input.input {
    flex: 1 1 auto;
    min-width: 0;
  }

  .work-bar .action-bar__end > .btn,
  .work-bar .action-bar__end > .btn-primary {
    flex: 1 1 calc((100% - var(--sp-8)) / 2);
    justify-content: center;
  }

  /* 対応予定のカード。1段目に日付と種類、2段目に対応内容、3段目に顧客と担当、いちばん下に操作。
     段ごとに幅の配分が違うので、折り返す並び（flex）にして、段どうしで列の幅を引きずらないようにする */
  .work-followups tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--sp-8) var(--sp-12);
  }

  .table.work-followups tbody th[scope="row"],
  .table.work-followups tbody td:nth-child(4) {
    flex: 1 1 0;
    font-size: var(--fs-body);
  }

  .table.work-followups tbody td:nth-child(2),
  .table.work-followups tbody td:nth-child(5) {
    flex: 0 0 auto;
  }

  .table.work-followups tbody td:nth-child(3),
  .table.work-followups tbody td:nth-child(6) {
    flex: 1 1 100%;
  }

  .work-followups th[scope="row"] .table__cell {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--sp-12);
  }

  .work-followups th[scope="row"] .table__cell > .nowrap {
    font-weight: 600;
  }

  .table.work-followups tbody td:nth-child(5) {
    white-space: nowrap;
  }

  .work-subject {
    font-size: var(--fs-h3);
    line-height: 1.5;
  }

  /* 顧客が無い行（リストの再連絡、顧客を付けていない ToDo）は、顧客の欄を出さない */
  .work-followups tbody td:nth-child(4):has(> .text-muted) {
    visibility: hidden;
  }

  /* 種類・対応内容・操作は、言葉だけで分かるので、欄の名前を出さない。顧客と担当は、値の前に小さく出す */
  .work-followups td:nth-child(2) .prm-cell-label,
  .work-followups td:nth-child(3) .prm-cell-label,
  .work-followups td:nth-child(6) .prm-cell-label {
    display: none;
  }

  .work-followups td:nth-child(4) .prm-cell-label,
  .work-followups td:nth-child(5) .prm-cell-label {
    display: inline;
    margin: 0 6px 0 0;
  }

  /* 操作のボタンは、カードの幅いっぱいに並べる */
  .work-followups .table__actions > .btn {
    flex: 1 1 0;
    justify-content: center;
    white-space: nowrap;
  }

  .work-history__item {
    grid-template-columns: minmax(0, 1fr);
  }
}
