/**
 * 顧客選択コンポーネント (S3 日報入力 / S4 タスク作成で共用)
 * Phase 2-B-1.1 追記: マスタ登録フォームスタイル
 */

.cp-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cp-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--mobile-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cp-required {
  color: #e24b4a;
  font-size: 12px;
}

.cp-optional {
  font-size: 11px;
  color: var(--mobile-text-tertiary);
  font-weight: 400;
  margin-left: 4px;
}

/* 選択済み顧客の表示 */
.cp-selected {
  background: var(--mobile-accent-light);
  border: 1px solid var(--mobile-accent);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cp-selected-info {
  flex: 1;
  min-width: 0;
}

.cp-selected-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--mobile-accent-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-selected-meta {
  font-size: 13px;
  color: var(--mobile-accent-dark);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 18px;
}

.cp-selected-meta-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  opacity: 0.85;
}

.cp-selected-meta-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.cp-selected-meta-empty {
  font-weight: 400;
  opacity: 0.6;
  font-style: italic;
}

.cp-selected-meta.is-warning {
  color: #8a5a0a;
}

.cp-selected-meta.is-warning .cp-selected-meta-text {
  font-weight: 400;
}

.cp-selected-new-badge {
  display: inline-block;
  background: #ef9f27;
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  font-weight: 700;
}

.cp-clear-btn {
  background: rgba(15, 110, 86, 0.15);
  border: none;
  color: var(--mobile-accent-dark);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

/* 入力フィールド */
.cp-input-row {
  position: relative;
}

.cp-input {
  width: 100%;
  padding: 12px 36px 12px 12px;
  border: 1px solid var(--mobile-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--mobile-surface);
  color: var(--mobile-text);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.cp-input:focus {
  outline: none;
  border-color: var(--mobile-accent);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

.cp-input-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.1);
  border: none;
  color: var(--mobile-text-secondary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

/* サジェスト */
.cp-suggestions {
  margin-top: 6px;
  background: var(--mobile-surface);
  border: 1px solid var(--mobile-border);
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cp-group-title {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--mobile-text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cp-suggestion {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--mobile-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid #f3f3f0;
}

.cp-suggestion:first-child {
  border-top: none;
}

.cp-suggestion:active {
  background: var(--mobile-accent-light);
}

.cp-suggestion-name {
  font-size: 14px;
  font-weight: 500;
}

.cp-suggestion-meta {
  font-size: 11px;
  color: var(--mobile-text-tertiary);
}

/* "マスタに登録" (推奨アクション) */
.cp-suggestion-register {
  color: var(--mobile-accent-dark);
  font-weight: 500;
  background: rgba(29, 158, 117, 0.08);
  border-top: 1px solid var(--mobile-accent-light);
}

/* "マスタ登録せず記録のみ" (副次アクション) */
.cp-suggestion-new {
  color: var(--mobile-text-secondary);
  font-weight: 400;
  background: #fafaf6;
  border-top: 1px solid #f3f3f0;
}

.cp-suggestion-new .cp-suggestion-name {
  font-size: 13px;
}

.cp-empty-hint {
  padding: 16px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--mobile-text-tertiary);
}

.cp-more-hint {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--mobile-text-tertiary);
  text-align: center;
  border-top: 1px solid #f3f3f0;
}

.cp-loading {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--mobile-text-tertiary);
}

/* ============================================================
   マスタ登録フォーム (インライン展開)
   ============================================================ */

.cp-register {
  margin-top: 6px;
}

.cp-register-card {
  background: var(--mobile-surface);
  border: 1px solid var(--mobile-accent);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cp-register-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--mobile-accent-dark);
}

.cp-register-error {
  background: #FCEBEB;
  border: 1px solid #F09595;
  color: #791F1F;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.cp-register-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cp-register-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--mobile-text-secondary);
}

.cp-register-name-fixed {
  padding: 10px 12px;
  background: var(--mobile-bg);
  border: 1px solid var(--mobile-border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--mobile-text);
}

.cp-register-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--mobile-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--mobile-surface);
  color: var(--mobile-text);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.cp-register-input:focus {
  outline: none;
  border-color: var(--mobile-accent);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

.cp-register-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.cp-register-cancel {
  flex: 0 0 auto;
  background: var(--mobile-bg);
  color: var(--mobile-text-secondary);
  border: 1px solid var(--mobile-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.cp-register-submit {
  flex: 1;
  background: var(--mobile-accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.cp-register-submit:active {
  background: var(--mobile-accent-dark);
}

.cp-register-submit:disabled {
  background: #c8c7c0;
  cursor: not-allowed;
}
