/* ═══════════════════════════════════════════════════════════════
   Field Mapper — Three-panel click-to-map UI
   Design: warm minimal (DM Sans + JetBrains Mono)
   ═══════════════════════════════════════════════════════════════ */

/* ── Header ── */
.fm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.fm-header-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.fm-header-subtitle { font-size: 12px; color: #8a8a8a; }
.fm-table-badge {
  font-family: 'JetBrains Mono', monospace;
  background: #f0eeea;
  padding: 1px 6px;
  border-radius: 3px;
}
.fm-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Buttons ── */
.fm-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #d4d2cd;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #555;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s;
}
.fm-btn:hover { border-color: #1a1a1a; }
.fm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.fm-btn-active { background: #f0eeea; border-color: #1a1a1a; }

.fm-btn-ai {
  border: none;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
}
.fm-btn-ai:hover { opacity: 0.85; }

.fm-btn-save {
  border: none;
  background: #e54d2e;
  color: #fff;
}
.fm-btn-save:hover { opacity: 0.85; }

.fm-btn-danger {
  border: 1px solid #fecaca;
  color: #dc2626;
  background: #fff;
}
.fm-btn-danger:hover { background: #fef2f2; }

/* ── Connection Config ── */
.fm-config {
  background: #fff;
  border: 1px solid #e8e6e1;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.fm-config-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
}
.fm-config-field { flex: 1; }
.fm-config-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8a8a8a;
  margin-bottom: 6px;
}
.fm-config-select-wrap { position: relative; }
.fm-config-select {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border-radius: 8px;
  border: 1px solid #e8e6e1;
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  appearance: none;
  background: #fff;
  cursor: pointer;
  outline: none;
}
.fm-config-select:focus { border-color: #1a1a1a; box-shadow: 0 0 0 2px rgba(26,26,26,0.08); }
.fm-config-select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a8a8a;
  pointer-events: none;
}
.fm-config-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
}
.fm-config-checkbox-wrap label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Banners ── */
.fm-banner-required {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #991b1b;
}
.fm-banner-required svg { color: #dc2626; flex-shrink: 0; }

.fm-banner-hint {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #1e40af;
}
.fm-banner-hint-left { display: flex; align-items: center; gap: 8px; }
.fm-banner-hint-cancel {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid #93c5fd;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  color: #2563eb;
}

/* ── Three-Panel Grid ── */
.fm-panels {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 12px;
  min-height: 600px;
}
@media (max-width: 1200px) {
  .fm-panels { grid-template-columns: 1fr 1.6fr 1fr; }
}

/* ── Panel Shared ── */
.fm-panel-left,
.fm-panel-center,
.fm-panel-right {
  border: 1px solid #e8e6e1;
  border-radius: 10px;
  overflow: hidden;
}
.fm-panel-left { background: #fff; }
.fm-panel-center { background: #fafaf8; }
.fm-panel-right { background: #fff; }

.fm-panel-header {
  padding: 14px 16px;
  background: #fafaf8;
}
.fm-panel-left .fm-panel-header { border-bottom: 2px solid #3b82f6; }
.fm-panel-center .fm-panel-header { border-bottom: 2px solid #e8e6e1; }
.fm-panel-right .fm-panel-header { border-bottom: 2px solid #16a34a; }
.fm-panel-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.fm-panel-header-row:last-child { margin-bottom: 0; }
.fm-panel-title-source { font-size: 12px; font-weight: 700; color: #3b82f6; }
.fm-panel-title-target { font-size: 12px; font-weight: 700; color: #16a34a; }
.fm-panel-title-center { font-size: 12px; font-weight: 700; color: #1a1a1a; }
.fm-panel-count {
  font-size: 10px;
  color: #8a8a8a;
  margin-left: auto;
}

/* ── Search ── */
.fm-search-wrap {
  position: relative;
  margin-bottom: 6px;
}
.fm-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #b0aead;
  pointer-events: none;
}
.fm-search {
  width: 100%;
  padding: 6px 8px 6px 28px;
  border-radius: 6px;
  border: 1px solid #e8e6e1;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.fm-search:focus { border-color: #1a1a1a; box-shadow: 0 0 0 2px rgba(26,26,26,0.08); }

/* ── Filter Pills ── */
.fm-filter-row { display: flex; gap: 4px; }
.fm-filter-pill {
  flex: 1;
  padding: 3px 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: #f0eeea;
  color: #8a8a8a;
  text-transform: capitalize;
  text-align: center;
}
.fm-filter-active-source { background: #3b82f6; color: #fff; }
.fm-filter-active-target { background: #16a34a; color: #fff; }

/* ── Field List ── */
.fm-field-list {
  max-height: 595px;
  overflow-y: auto;
}
.fm-field-list-with-preview {
  max-height: 415px;
}

/* ── Field Row ── */
.fm-field-row {
  padding: 8px 14px;
  border-bottom: 1px solid #f5f4f2;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
  background: #fff;
}
.fm-field-row:hover { background: #fafaf8; }
.fm-field-mapped { background: #fafaf8; }
.fm-field-selected-source { background: #dbeafe !important; }
.fm-field-selected-target { background: #dcfce7 !important; }
.fm-field-hover-source { background: #eff6ff !important; }
.fm-field-hover-target { background: #f0fdf4 !important; }

/* ── Status Dots ── */
.fm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fm-dot-unmapped {
  background: #e8e6e1;
  border: 1px solid #d4d2cd;
}
.fm-dot-source-mapped {
  background: #3b82f6;
  border: none;
}
.fm-dot-target-mapped {
  background: #16a34a;
  border: none;
}
.fm-dot-required {
  background: #fecaca;
  border: 1px solid #dc2626;
}

/* ── Field Name ── */
.fm-field-name {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.fm-field-name-mapped {
  font-weight: 400;
  color: #8a8a8a;
}
.fm-field-info {
  flex: 1;
  min-width: 0;
}
.fm-field-label {
  font-size: 10px;
  color: #b0aead;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-mapped-to-label {
  font-size: 10px;
  color: #6b7280;
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Type Pills ── */
.fm-type-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.fm-type-string, .fm-type-text { background: #dbeafe; color: #1e40af; }
.fm-type-integer, .fm-type-decimal { background: #dcfce7; color: #166534; }
.fm-type-boolean { background: #f5f3ff; color: #5b21b6; }
.fm-type-datetime { background: #fef3c7; color: #92400e; }
.fm-type-json { background: #fce7f3; color: #9d174d; }

/* ── Type Compatibility Indicators ── */
.fm-type-warning {
  flex-shrink: 0;
  color: #d97706;
  display: flex;
  align-items: center;
  cursor: help;
}
.fm-type-warning svg { color: #d97706; }
.fm-type-error {
  flex-shrink: 0;
  color: #dc2626;
  display: flex;
  align-items: center;
  cursor: help;
}
.fm-type-error svg { color: #dc2626; }

/* ── Type Validation Banners ── */
.fm-banner-type-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #991b1b;
}
.fm-banner-type-error svg { color: #dc2626; flex-shrink: 0; }
.fm-banner-type-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #92400e;
}
.fm-banner-type-warning svg { color: #d97706; flex-shrink: 0; }

/* ── Required Badge ── */
.fm-req-badge {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.fm-req-mapped { background: #dcfce7; color: #16a34a; }
.fm-req-unmapped { background: #fef2f2; color: #dc2626; }

/* ── Quick Rule Buttons ── */
.fm-quick-rules { display: flex; gap: 2px; flex-shrink: 0; }
.fm-quick-rule-btn {
  width: 22px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #e8e6e1;
  background: #fff;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  color: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.fm-quick-rule-btn:hover { background: #f5f3ff; border-color: #7c3aed; }

/* ── Source Data Preview ── */
.fm-source-preview {
  border-top: 1px solid #e8e6e1;
  display: none;
}
.fm-source-preview-header {
  padding: 8px 14px;
  background: #fafaf8;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3b82f6;
}
.fm-source-preview-content {
  overflow: auto;
  max-height: 160px;
}

/* ── Mapping Rows ── */
.fm-mapping-list {
  max-height: 627px;
  overflow-y: auto;
}
.fm-mapping-row {
  padding: 8px 12px;
  border-bottom: 1px solid #f0eeea;
  background: transparent;
  transition: background 0.1s;
}
.fm-mapping-row:hover,
.fm-mapping-row-hovered { background: #eff6ff; }

/* Flash highlight for newly added mapping rows */
@keyframes fm-row-flash {
  0%   { background-color: #d4edda; }
  100% { background-color: transparent; }
}
.fm-mapping-row-flash {
  animation: fm-row-flash 1.2s ease-out;
}
.fm-mapping-row-selected {
  background: #dbeafe !important;
  border-left: 3px solid #3b82f6;
  cursor: pointer;
}
.fm-mapping-row:hover .fm-mapping-remove { opacity: 1; }
.fm-mapping-cells {
  display: flex;
  align-items: center;
  gap: 6px;
}
.fm-mapping-source {
  flex: 1;
  min-width: 0;
}
.fm-mapping-source-name {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: #3b82f6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-mapping-rule {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #7c3aed;
  font-size: 11px;
  font-weight: 600;
  font-style: italic;
}
.fm-mapping-rule svg { color: #7c3aed; }
.fm-mapping-arrow {
  flex-shrink: 0;
  color: #b0aead;
  display: flex;
  align-items: center;
}
.fm-mapping-target {
  flex: 1;
  min-width: 0;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.fm-mapping-target-name {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-mapping-remove {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s;
  color: #dc2626;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
}
.fm-mapping-remove:hover { background: #fef2f2; }

/* ── Mappings Empty State ── */
.fm-mappings-empty {
  padding: 40px 20px;
  text-align: center;
  color: #b0aead;
  font-size: 12px;
}
.fm-mappings-empty svg { margin-bottom: 8px; opacity: 0.4; }

/* ── Transform Pill ── */
.fm-transform-wrap {
  flex-shrink: 0;
  position: relative;
}
.fm-transform-pill {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid #e8e6e1;
  background: #fff;
  color: #8a8a8a;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.fm-transform-pill:hover { border-color: #b0aead; }
.fm-transform-active {
  background: #fffbeb;
  color: #92400e;
}

/* ── Transform Dropdown ── */
.fm-transform-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e8e6e1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
}
.fm-transform-dropdown-up {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 4px;
}
.fm-transform-option {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}
.fm-transform-option:hover { background: #fafaf8; }
.fm-transform-option-active { background: #eff6ff; }
.fm-transform-option-active:hover { background: #eff6ff; }
.fm-transform-option-label { font-weight: 400; }
.fm-transform-option-active .fm-transform-option-label { font-weight: 700; }
.fm-transform-option-desc { font-size: 9px; color: #b0aead; }

/* ── Transform Config Inputs ── */
.fm-config-row-inline { margin-top: 6px; }
.fm-config-inline-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #8a8a8a;
  margin-bottom: 3px;
}
.fm-config-inline-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #b0aead;
}
.fm-static-input {
  width: 100%;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e8e6e1;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  box-sizing: border-box;
}
.fm-static-input:focus { border-color: #1a1a1a; box-shadow: 0 0 0 2px rgba(26,26,26,0.08); }
.fm-map-textarea {
  min-height: 56px;
  resize: vertical;
  line-height: 1.5;
}

/* ── Preview Panel ── */
.fm-preview-panel {
  margin-top: 16px;
  background: #fff;
  border: 1px solid #e8e6e1;
  border-radius: 12px;
  overflow: hidden;
}
.fm-preview-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e8e6e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafaf8;
}
.fm-preview-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fm-preview-header-title { font-size: 13px; font-weight: 700; }
.fm-preview-header-subtitle { font-size: 10px; color: #8a8a8a; }
.fm-preview-content { padding: 0; }
.fm-preview-empty { padding: 20px; text-align: center; color: #b0aead; font-size: 12px; }
.fm-preview-error { padding: 12px 16px; color: #dc2626; font-size: 12px; }

/* ── Preview Table (shared for source + bottom preview) ── */
.fm-preview-table-wrap { overflow-x: auto; }
.fm-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}
.fm-preview-table th {
  padding: 5px 8px;
  text-align: left;
  font-weight: 700;
  color: #8a8a8a;
  border-bottom: 1px solid #e8e6e1;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #f0eeea;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.fm-preview-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f5f4f2;
  white-space: nowrap;
  color: #555;
}
.fm-preview-table tbody tr:hover td { background: #fafaf8; }

/* ── Footer ── */
.fm-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fm-footer-actions { display: flex; gap: 8px; }
.fm-footer-tip { font-size: 11px; color: #b0aead; }

/* ── Source Preview Toggle Button ── */
.fm-source-preview-btn {
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #dbeafe;
  background: #fff;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #3b82f6;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.fm-source-preview-btn:hover,
.fm-source-preview-btn.fm-btn-active { background: #dbeafe; }

/* ── Test Import ── */
.fm-btn-test {
  border-color: #a3e635;
  color: #3f6212;
  background: #f7fee7;
}
.fm-btn-test:hover { border-color: #65a30d; background: #ecfccb; }

.test-import-results {
  margin-top: 16px;
  border: 1px solid #e8e6e1;
  border-radius: 12px;
  background: #fff;
  padding: 16px 20px;
  font-size: 13px;
}
.test-import-header {
  margin-bottom: 12px;
}
.test-import-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.test-import-badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.test-import-pass {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.test-import-fail {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}
.test-import-summary {
  font-size: 13px;
  color: #555;
  font-weight: 600;
}
.test-import-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  color: #aaa;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.test-import-close:hover { color: #333; }
.test-import-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: #991b1b;
  font-size: 12px;
}
.test-import-errors ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.test-import-errors li { margin-bottom: 2px; }
.test-import-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 16px;
  color: #991b1b;
  font-size: 13px;
}
.test-import-sample {
  margin-bottom: 12px;
}
.test-import-sample strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #555;
}
.test-import-table-wrap {
  overflow-x: auto;
  border: 1px solid #e8e6e1;
  border-radius: 8px;
}
.test-import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}
.test-import-table th {
  background: #f5f4f0;
  text-align: left;
  padding: 6px 10px;
  font-weight: 700;
  color: #555;
  border-bottom: 1px solid #e8e6e1;
  white-space: nowrap;
}
.test-import-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f0eeea;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.test-import-table tr:last-child td { border-bottom: none; }
.test-import-null {
  color: #ccc;
  font-style: italic;
}
.test-import-note {
  margin-top: 12px;
  font-size: 11px;
  color: #8a8a8a;
  font-style: italic;
}
