/**
 * オフィス UI｜フォーム部品テンプレ（select / radio / checkbox / combobox）
 *
 * 正本テンプレ: templates/office-ui/office-forms.css
 * 実行コピー: apps/office(-dev)/public/css/office-forms.css
 * 契約: docs/設計資料/根底資料/08_laravel構築/ui/オフィスUIコンポーネント契約.md
 *
 * トークンは layouts/admin の :root（--line / --ink / --accent 等）に依存。
 */

/* —— ネイティブ select（全体を揃える） —— */
select,
.office-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 100%;
  padding: .55rem 2.1rem .55rem .7rem;
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted, #5c574f) 50%),
    linear-gradient(135deg, var(--muted, #5c574f) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--ink, #1c1b19);
  font-family: inherit;
  font-size: .9rem;
  line-height: 1.35;
  margin-bottom: .35rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

select:hover,
.office-select:hover {
  border-color: color-mix(in srgb, var(--accent, #0f5c4c) 45%, var(--line, #d4cfc4));
}

select:focus,
.office-select:focus {
  outline: none;
  border-color: var(--accent, #0f5c4c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #0f5c4c) 22%, transparent);
}

select:disabled,
.office-select:disabled {
  opacity: .55;
  cursor: not-allowed;
  background-color: #f7f4ee;
}

select.office-select-sm {
  padding: .4rem 1.85rem .4rem .55rem;
  font-size: .8rem;
  margin-bottom: .25rem;
}

/* —— radio / checkbox —— */
.office-choice {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .65rem;
  margin: .15rem 0 .55rem;
}

.office-choice-item {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  padding: .4rem .7rem;
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 999px;
  background: #fff;
  color: var(--ink, #1c1b19);
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.office-choice-item:hover {
  border-color: color-mix(in srgb, var(--accent, #0f5c4c) 40%, var(--line, #d4cfc4));
  background: #f7fbf9;
}

.office-choice-item:has(input:checked) {
  border-color: var(--accent, #0f5c4c);
  background: color-mix(in srgb, var(--accent, #0f5c4c) 10%, #fff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #0f5c4c) 16%, transparent);
  font-weight: 600;
}

.office-choice-item input[type="radio"],
.office-choice-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex: 0 0 auto;
  border: 1.5px solid var(--line, #d4cfc4);
  background: #fff;
  display: grid;
  place-content: center;
  cursor: pointer;
}

.office-choice-item input[type="radio"] {
  border-radius: 50%;
}

.office-choice-item input[type="checkbox"] {
  border-radius: 4px;
}

.office-choice-item input[type="radio"]::before,
.office-choice-item input[type="checkbox"]::before {
  content: "";
  width: .45rem;
  height: .45rem;
  transform: scale(0);
  transition: transform .12s ease;
  background: var(--accent, #0f5c4c);
}

.office-choice-item input[type="radio"]::before {
  border-radius: 50%;
}

.office-choice-item input[type="checkbox"]::before {
  width: .55rem;
  height: .55rem;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  background: var(--accent, #0f5c4c);
}

.office-choice-item input:checked {
  border-color: var(--accent, #0f5c4c);
}

.office-choice-item input:checked::before {
  transform: scale(1);
}

.office-choice-item input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent, #0f5c4c) 55%, transparent);
  outline-offset: 2px;
}

/* 単独の radio/checkbox（ピル無し）も最低限揃える */
input[type="radio"]:not(.office-choice-item input),
input[type="checkbox"]:not(.office-choice-item input) {
  accent-color: var(--accent, #0f5c4c);
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
}

/* —— 検索可能コンボボックス —— */
.office-combobox {
  position: relative;
  width: 100%;
  margin-bottom: .35rem;
}

.office-combobox-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  appearance: none !important;
  background: none !important;
}

.office-combobox-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #1c1b19);
  font-family: inherit;
  font-size: .88rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.office-combobox-trigger:hover {
  border-color: color-mix(in srgb, var(--accent, #0f5c4c) 45%, var(--line, #d4cfc4));
}

.office-combobox.is-open .office-combobox-trigger,
.office-combobox-trigger:focus {
  outline: none;
  border-color: var(--accent, #0f5c4c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #0f5c4c) 22%, transparent);
}

.office-combobox-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-combobox-trigger-label.is-placeholder {
  color: var(--muted, #5c574f);
}

.office-combobox-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted, #5c574f);
}

.office-combobox-panel {
  position: absolute;
  z-index: 90;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: none;
  flex-direction: column;
  max-height: min(280px, 50vh);
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 10px;
  background: #fffcf7;
  box-shadow: 0 12px 32px rgba(28, 27, 25, .14);
  overflow: hidden;
}

.office-combobox.is-open .office-combobox-panel {
  display: flex;
}

.office-combobox-search {
  width: 100%;
  margin: 0 !important;
  padding: .55rem .7rem !important;
  border: 0 !important;
  border-bottom: 1px solid var(--line, #d4cfc4) !important;
  border-radius: 0 !important;
  background: #fff !important;
  font-size: .88rem !important;
  box-shadow: none !important;
}

.office-combobox-list {
  list-style: none;
  margin: 0;
  padding: .25rem;
  overflow: auto;
  max-height: 220px;
}

.office-combobox-option {
  display: block;
  width: 100%;
  padding: .45rem .55rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink, #1c1b19);
  font-family: inherit;
  font-size: .84rem;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
}

.office-combobox-option:hover,
.office-combobox-option.is-active {
  background: color-mix(in srgb, var(--accent, #0f5c4c) 12%, #fff);
}

.office-combobox-option.is-selected {
  font-weight: 650;
  color: var(--accent, #0f5c4c);
}

.office-combobox-option.is-hidden {
  display: none;
}

.office-combobox-empty {
  padding: .65rem .7rem;
  color: var(--muted, #5c574f);
  font-size: .82rem;
}

.office-combobox.is-sm .office-combobox-trigger {
  padding: .4rem .55rem;
  font-size: .8rem;
}

/* 狭いポップ内でもはみ出しにくく */
.xcal-actions .office-combobox,
.xcal-pop .office-combobox {
  margin-bottom: .45rem;
}

.xcal-actions select,
.xcal-pop select {
  font-size: .8rem;
}

/* オフィスチャット固定タスク行: フォーム用余白を付けない（高さ固定1行） */
.emp-chat-chips select,
select.emp-chat-chip-select {
  width: auto;
  max-width: none;
  margin-bottom: 0;
  padding: 0 1.5rem 0 .55rem;
  height: 1.75rem;
  line-height: 1.7rem;
  font-size: .78rem;
  border-radius: 10px;
}

/* コンボ展開中はポップの overflow でパネルを切らない */
.xcal-pop:has(.office-combobox.is-open),
.office-pop:has(.office-combobox.is-open),
.xcal-pop:has(.office-tag-combobox.is-open),
.office-pop:has(.office-tag-combobox.is-open) {
  overflow: visible;
}

/* ============================================================
   検索＋タグ登録の複数選択コンボ（office-tag-combobox.js と対）
   ============================================================ */
.office-tag-combobox {
  position: relative;
  width: 100%;
}

.office-tag-combobox-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  min-height: 2.55rem;
  padding: .35rem .55rem .35rem .45rem;
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 8px;
  background: #fff;
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.office-tag-combobox-shell:hover {
  border-color: color-mix(in srgb, var(--accent, #0f5c4c) 45%, var(--line, #d4cfc4));
}

.office-tag-combobox.is-open .office-tag-combobox-shell,
.office-tag-combobox-shell:focus-within {
  border-color: var(--accent, #0f5c4c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #0f5c4c) 22%, transparent);
}

.office-tag-combobox-tags {
  display: contents;
}

.office-tag-combobox-tag {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  max-width: 100%;
  padding: .2rem .3rem .2rem .5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #0f5c4c) 12%, #fff);
  color: var(--accent, #0f5c4c);
  font-size: .8rem;
  line-height: 1.3;
}

.office-tag-combobox-tag-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-tag-combobox-tag-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
}

.office-tag-combobox-tag-remove:hover {
  background: color-mix(in srgb, var(--accent, #0f5c4c) 22%, #fff);
}

.office-tag-combobox-search {
  flex: 1 1 7rem;
  min-width: 6rem;
  width: auto !important;
  margin: 0 !important;
  padding: .3rem .2rem !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: .88rem !important;
  line-height: 1.35;
}

.office-tag-combobox-search:focus {
  outline: none !important;
  box-shadow: none !important;
}

.office-tag-combobox-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-left: auto;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted, #5c574f);
}

.office-tag-combobox-values {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.office-tag-combobox-panel {
  position: absolute;
  z-index: 90;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: none;
  flex-direction: column;
  max-height: min(280px, 50vh);
  border: 1px solid var(--line, #d4cfc4);
  border-radius: 10px;
  background: #fffcf7;
  box-shadow: 0 12px 32px rgba(28, 27, 25, .14);
  overflow: hidden;
}

.office-tag-combobox.is-open .office-tag-combobox-panel {
  display: flex;
}

.office-tag-combobox-list {
  list-style: none;
  margin: 0;
  padding: .25rem;
  overflow: auto;
  max-height: 220px;
}

.office-tag-combobox-option {
  display: block;
  width: 100%;
  padding: .45rem .55rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink, #1c1b19);
  font-family: inherit;
  font-size: .84rem;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
}

.office-tag-combobox-option:hover {
  background: color-mix(in srgb, var(--accent, #0f5c4c) 12%, #fff);
}

.office-tag-combobox-option.is-selected {
  font-weight: 650;
  color: var(--accent, #0f5c4c);
}

.office-tag-combobox-empty,
.office-tag-combobox-empty-static {
  padding: .65rem .7rem;
  color: var(--muted, #5c574f);
  font-size: .82rem;
}

.office-tag-combobox.is-sm .office-tag-combobox-shell {
  min-height: 2.2rem;
  padding: .25rem .45rem;
}

.office-tag-combobox.is-sm .office-tag-combobox-search {
  font-size: .8rem !important;
}

/* ============================================================
   オフィス共通モーダル（office-modal.js と対）
   骨格はホスト。中身はプラグインが書く。
   ============================================================ */
.office-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  overflow: auto;
  overscroll-behavior: contain;
}

.office-modal[hidden] { display: none; }

.office-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  transition: opacity .18s ease;
}

.office-modal.is-open .office-modal-backdrop { opacity: 1; }

.office-modal-panel {
  position: relative;
  width: min(34rem, calc(100vw - 1.5rem));
  margin: min(8vh, 4rem) auto 2rem;
  display: flex;
  flex-direction: column;
  max-height: min(84vh, 48rem);
  background: #fff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(.985);
  transition: opacity .18s ease, transform .2s cubic-bezier(.22, 1.2, .36, 1);
}

.office-modal.is-open .office-modal-panel {
  opacity: 1;
  transform: none;
}

.office-modal-panel.is-sm { width: min(24rem, calc(100vw - 1.5rem)); }
.office-modal-panel.is-lg { width: min(48rem, calc(100vw - 1.5rem)); }

.office-modal-head {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .85rem 1rem .65rem;
  border-bottom: 1px solid var(--line, #e5e7eb);
}

.office-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.office-modal-lead {
  margin: .2rem 0 0;
  font-size: .78rem;
  color: #6b7280;
  line-height: 1.55;
}

.office-modal-x {
  margin-left: auto;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 1.2rem;
  line-height: 1;
  padding: .2rem .35rem;
  border-radius: 8px;
  cursor: pointer;
}

.office-modal-x:hover { background: #f3f4f6; color: #111827; }

.office-modal-body {
  padding: .85rem 1rem;
  overflow: auto;
  min-height: 0;
}

.office-modal-body > form { margin: 0; }

/* パネル直下のフォームは、ヘッダ／本文／フッタを縦に組む器になる */
.office-modal-panel > .office-modal-form {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.office-modal-field {
  display: block;
  font-size: .78rem;
  margin-bottom: .55rem;
}

.office-modal-field > input[type="text"],
.office-modal-field > textarea,
.office-modal-field > input[type="file"] {
  width: 100%;
  margin-top: .25rem;
}

.office-modal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  justify-content: flex-end;
  align-items: center;
  padding: .7rem 1rem .85rem;
  border-top: 1px solid var(--line, #e5e7eb);
  background: #f8fafc;
}

.office-modal-foot.is-split { justify-content: space-between; }
.office-modal-foot .office-modal-foot-note { margin: 0; font-size: .72rem; color: #6b7280; }

body.office-modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .office-modal-backdrop,
  .office-modal-panel { transition: none; }
}

/* 画像ライトボックス（office-image-lightbox.js） */
.office-img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.office-img-lightbox[hidden] { display: none; }

.office-img-lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.82);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.office-img-lightbox.is-open .office-img-lightbox-backdrop { opacity: 1; }

.office-img-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.office-img-lightbox.is-open .office-img-lightbox-panel {
  opacity: 1;
  transform: none;
}

.office-img-lightbox-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.office-img-lightbox-title {
  flex: 1;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.office-img-lightbox-counter {
  font-size: 0.78rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.office-img-lightbox-x {
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.office-img-lightbox-x:hover { background: #e5e7eb; color: #111827; }

.office-img-lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  background: #0f172a;
}

.office-img-lightbox-figure {
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 8rem);
  padding: 0.75rem 2.75rem;
}

.office-img-lightbox-img {
  max-width: 100%;
  max-height: calc(100vh - 10rem);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.office-img-lightbox-caption {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: #cbd5e1;
  text-align: center;
}

.office-img-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.25rem;
  height: 2.75rem;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.office-img-lightbox-nav:hover:not(:disabled) { background: #fff; }
.office-img-lightbox-nav:disabled { opacity: 0.35; cursor: default; }
.office-img-lightbox-nav.is-prev { left: 0.5rem; }
.office-img-lightbox-nav.is-next { right: 0.5rem; }

.office-img-lightbox-trigger {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  width: 100%;
  text-align: left;
}

.office-img-lightbox-trigger:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

body.office-img-lightbox-open { overflow: hidden; }

.ximg-card .office-img-lightbox-trigger,
.ximg-strip .office-img-lightbox-trigger { border-radius: inherit; }

@media (prefers-reduced-motion: reduce) {
  .office-img-lightbox-backdrop,
  .office-img-lightbox-panel { transition: none; }
}
