/* Team salary field + rule modal (index shell + inhouseModalsContainer) */
.team-field-rule-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 11000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.team-field-rule-overlay.open {
  display: flex;
}

.team-field-rule-dialog {
  background: #fff;
  border-radius: 14px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.team-field-rule-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #ececec;
  background: #fff;
}

.team-field-rule-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
  background: linear-gradient(135deg, #ed2047, #f26225);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.team-field-rule-header-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #e5e7eb;
  color: #4b5563;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s, color 0.2s;
}

.team-field-rule-header-close:hover {
  background: #d1d5db;
  color: #1f2937;
}

.team-field-rule-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 24px 20px;
  -webkit-overflow-scrolling: touch;
}

.team-field-rule-lead {
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
  margin: 0 0 16px;
}

.team-field-rule-footer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 16px 24px 20px;
  border-top: 1px solid #ececec;
  background: #fff;
}

.team-field-rule-hint-min {
  font-size: 11px;
  color: #94a3b8;
  margin: 6px 0 8px;
  line-height: 1.35;
}

.team-field-rule-advanced {
  margin: 4px 0 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fafbfc;
}

.team-field-rule-advanced summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  list-style: none;
}

.team-field-rule-advanced summary::-webkit-details-marker {
  display: none;
}

.team-field-rule-advanced summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s ease;
}

.team-field-rule-advanced[open] summary::before {
  transform: rotate(90deg);
}

.team-field-rule-advanced-inner {
  padding-top: 12px;
}

.team-field-at-chips-compact .team-field-at-label {
  font-size: 11px;
  margin-bottom: 6px;
}

.team-field-at-chips-compact .team-field-at-chip {
  padding: 5px 10px;
  font-size: 11px;
}

.team-salary-fields-heading {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin: 0 0 10px;
}

.team-field-rule-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.team-field-rule-form input[type="text"],
.team-field-rule-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  box-sizing: border-box;
}

.team-field-rule-form textarea {
  min-height: 72px;
  resize: vertical;
}

.team-field-rule-dialog button.primary-close {
  background: linear-gradient(to right, #ed2047, #f26225);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.team-field-rule-dialog button.secondary-close {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.team-field-rule-dialog button.primary-close:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.team-field-rule-error {
  color: #b91c1c;
  font-size: 13px;
  margin-bottom: 10px;
  display: none;
}

.team-field-rule-form select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  box-sizing: border-box;
  background: #fff;
}

.team-field-rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.team-field-rule-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  cursor: pointer;
  font-weight: 500;
}

.team-field-rule-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-field-rule-sort input[type="number"] {
  width: 72px;
  padding: 8px 10px;
  margin-bottom: 0;
}

.team-field-rule-sort label {
  margin-bottom: 0;
}

.team-field-rule-checkbox-label {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}

#teamFieldRuleFormulaWrap {
  margin-bottom: 8px;
}

.team-field-at-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.team-field-at-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  width: 100%;
  margin-bottom: 4px;
}

.team-field-at-chip {
  border: 1px solid rgba(237, 32, 71, 0.35);
  background: rgba(237, 32, 71, 0.06);
  color: #c9183e;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.team-field-at-chip:hover {
  background: linear-gradient(to right, #ed2047, #f26225);
  color: #fff;
  border-color: transparent;
}

.team-field-at-dropdown {
  position: absolute;
  z-index: 12001;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: min(50vh, 360px);
  overflow-y: auto;
  min-width: 260px;
}

.team-field-at-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.team-field-at-dropdown button:hover {
  background: rgba(237, 32, 71, 0.08);
}

.team-field-formula-wrap-inner {
  position: relative;
}

.team-field-formula-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.team-field-formula-editor {
  position: relative;
  width: 100%;
  display: block;
  margin-bottom: 14px;
}

/* Same idea as gropro AI chat composer: one contenteditable + non-editable mention spans = aligned caret. */
.team-field-formula-input-editable {
  width: 100%;
  box-sizing: border-box;
  min-height: 72px;
  max-height: 240px;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  overflow-y: auto;
  background: #fff;
  color: #1e293b;
  caret-color: #334155;
  -webkit-text-fill-color: #1e293b;
  resize: vertical;
}

.team-field-formula-input-editable:focus {
  outline: none;
  border-color: rgba(237, 32, 71, 0.45);
  box-shadow: 0 0 0 3px rgba(237, 32, 71, 0.12);
}

.team-field-formula-input-editable.team-field-formula-input--empty:not(:focus):before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

/* Match gropro-ai-composer-mention: inline-flex pill, cursor follows real layout. */
.team-formula-mention {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 5px;
  background: rgba(237, 32, 71, 0.12);
  color: #c41845;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid rgba(237, 32, 71, 0.35);
  vertical-align: baseline;
  user-select: text;
  cursor: default;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

.team-formula-mention:focus {
  outline: none;
}

.team-salary-fields-list {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #ececec;
}

.team-salary-field-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  background: #fafafa;
  margin-bottom: 10px;
}

.team-salary-field-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.team-salary-field-card-main strong {
  font-size: 15px;
  color: #222;
}

.team-salary-field-type-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  background: #ececec;
  padding: 4px 10px;
  border-radius: 6px;
}

.team-salary-field-meta {
  font-size: 12px;
  color: #666;
  width: 100%;
  margin-top: 4px;
}

.team-salary-field-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.team-salary-field-actions button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #444;
}

.team-salary-field-actions button:hover {
  border-color: #ed2047;
  color: #ed2047;
}

.team-salary-field-system-tag {
  background: rgba(237, 32, 71, 0.1);
  color: #c9183e;
}

.team-salary-field-actions-locked {
  border: none;
  background: transparent;
  min-width: 72px;
  justify-content: flex-end;
}

.team-salary-field-locked-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
}

.team-salary-fields-empty {
  font-size: 14px;
  color: #777;
  padding: 8px 0;
}

.team-field-save-btn i {
  margin-right: 8px;
}
