/* ============================================
   Excel Merger — Custom Styles
   ============================================ */

/* ---- Background Orbs ---- */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: linear-gradient(135deg, #2a8cff, #7c3aed);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: linear-gradient(135deg, #06b6d4, #2a8cff);
  bottom: -150px;
  left: -150px;
  animation-delay: -7s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(30px, -30px) scale(1.05);
  }

  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }

  75% {
    transform: translate(15px, 10px) scale(1.02);
  }
}

.orb-3 {
  animation-name: float-center;
}

@keyframes float-center {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }

  25% {
    transform: translate(-45%, -55%) scale(1.05);
  }

  50% {
    transform: translate(-55%, -45%) scale(0.95);
  }

  75% {
    transform: translate(-48%, -52%) scale(1.02);
  }
}

/* ---- Step Indicator ---- */
.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  transition: all 0.3s ease;
  cursor: default;
}

.step-number {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.3);
  transition: color 0.3s ease;
  white-space: nowrap;
}

.step-item.active .step-number {
  background: linear-gradient(135deg, #2a8cff, #0c56e6);
  border-color: #2a8cff;
  color: #fff;
  box-shadow: 0 0 16px rgba(42, 140, 255, 0.3);
}

.step-item.active .step-label {
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 0 10px rgba(42, 140, 255, 0.8), 0 0 20px rgba(42, 140, 255, 0.4);
}

.step-item.completed .step-number {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

.step-item.completed .step-label {
  color: rgba(255, 255, 255, 0.6);
}

.step-connector {
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0 0.25rem;
  min-width: 1.5rem;
}

/* ---- Dropzone ---- */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(42, 140, 255, 0.05), rgba(124, 58, 237, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: rgba(42, 140, 255, 0.25);
  background: rgba(255, 255, 255, 0.03);
}

.dropzone:hover::before,
.dropzone:focus-visible::before {
  opacity: 1;
}

.dropzone.drag-over {
  border-color: #2a8cff;
  background: rgba(42, 140, 255, 0.08);
  transform: scale(1.005);
  box-shadow: 0 0 40px rgba(42, 140, 255, 0.15), inset 0 0 40px rgba(42, 140, 255, 0.05);
}

.dropzone.drag-over::before {
  opacity: 1;
  background: linear-gradient(135deg, rgba(42, 140, 255, 0.1), rgba(124, 58, 237, 0.1));
}

/* ---- File Card ---- */
.file-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s ease;
  animation: slideIn 0.3s ease;
}

.file-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.file-card .btn-remove {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.25);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-card .btn-remove:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #2a8cff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Primary Button ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2a8cff, #0c56e6);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(42, 140, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(42, 140, 255, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- Accordion ---- */
.accordion-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.accordion-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.accordion-chevron {
  width: 1.25rem;
  height: 1.25rem;
  color: rgba(255, 255, 255, 0.3);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.accordion-card.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.accordion-card.open .accordion-body {
  max-height: 600px;
}

.accordion-content {
  padding: 0 1.25rem 1rem;
}

/* ---- Header Table ---- */
.header-table {
  width: 100%;
  border-collapse: collapse;
}

.header-table thead th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-table tbody td {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
}

.header-table tbody tr:last-child td {
  border-bottom: none;
}

.header-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.col-index {
  color: rgba(255, 255, 255, 0.25);
  font-variant-numeric: tabular-nums;
  width: 3rem;
}

.col-name {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

/* ---- Sheet Tabs (Excel-like) ---- */
.sheet-tabs {
  display: flex;
  gap: 0.125rem;
  padding: 0;
  margin-bottom: 0;
  overflow-x: auto;
  align-items: flex-end;
}

.sheet-tab {
  padding: 0.375rem 1rem;
  border-radius: 0.375rem 0.375rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  position: relative;
  top: 1px;
  /* Overlap the bottom border */
}

.sheet-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.sheet-tab.active {
  color: #52aeff;
  /* brand-400 */
  background: #1e293b;
  /* matches surface-800 */
  border-color: rgba(255, 255, 255, 0.1);
  border-top: 2px solid #52aeff;
  z-index: 10;
}

/* ---- Toast Notification ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  backdrop-filter: blur(16px);
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.toast.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

/* ---- Utilities ---- */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---- Mapping Layout ---- */
.mapping-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(380px, 2fr);
  gap: 1.5rem;
  height: 70vh;
}

@media (max-width: 768px) {
  .mapping-layout {
    grid-template-columns: 1fr;
  }
}

.mapping-pane {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

/* ---- Source Chips ---- */
.source-chips-container {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.source-file-group {
  margin-bottom: 1.25rem;
}

.source-file-group:last-child {
  margin-bottom: 0;
}

.source-file-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  cursor: grab;
  transition: all 0.2s ease;
}

.source-file-label:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.source-file-label:active {
  cursor: grabbing;
}

.source-file-label .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: grab;
  transition: all 0.2s ease;
  border: 1px solid;
  user-select: none;
  white-space: nowrap;
}

.source-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.source-chip:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.source-chip.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.source-chip.assigned {
  opacity: 0.35;
  text-decoration: line-through;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.source-chip.assigned:hover {
  opacity: 0.6;
}

/* ---- Target Columns Canvas ---- */
.target-columns-container {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.target-column-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.625rem;
  overflow: hidden;
  transition: all 0.2s ease;
  animation: slideIn 0.25s ease;
  flex-shrink: 0;
}

.target-column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.target-column-header .col-number {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.target-column-header input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.125rem 0;
}

.target-column-header input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.target-column-header .btn-remove-col {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.target-column-header .btn-remove-col:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.target-column-dropzone {
  min-height: 2.5rem;
  padding: 0.5rem 0.875rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
  transition: all 0.2s ease;
  position: relative;
}

.target-column-dropzone.empty::after {
  content: 'ここにヘッダーをドロップ';
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.15);
  font-style: italic;
}

.target-column-dropzone.drag-hover {
  background: rgba(42, 140, 255, 0.08);
  border-color: rgba(42, 140, 255, 0.3);
  box-shadow: inset 0 0 20px rgba(42, 140, 255, 0.05);
}

.target-column-card.drag-hover {
  border-color: rgba(42, 140, 255, 0.4);
  box-shadow: 0 0 20px rgba(42, 140, 255, 0.1);
}

.mapped-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.3rem;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid;
  animation: slideIn 0.2s ease;
  cursor: grab;
  transition: filter 0.2s ease;
}

.mapped-chip:hover {
  filter: brightness(1.2);
}

.mapped-chip:active {
  cursor: grabbing;
}

.mapped-chip .chip-remove {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
  border: none;
  font-size: 0.6rem;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: 0.125rem;
}

.mapped-chip .chip-remove:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ---- Add Column Button ---- */
.btn-add-column {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #2a8cff;
  background: rgba(42, 140, 255, 0.08);
  border: 1px solid rgba(42, 140, 255, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-add-column:hover {
  background: rgba(42, 140, 255, 0.12);
  border-color: rgba(42, 140, 255, 0.3);
}

/* ---- Empty State ---- */
.target-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  flex: 1;
}

.target-empty-state svg {
  width: 2.5rem;
  height: 2.5rem;
  color: rgba(255, 255, 255, 0.1);
  margin-bottom: 0.75rem;
}

.target-empty-state p {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.25);
}

/* ---- Result Table ---- */
.result-table-wrapper {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.result-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.result-table thead th {
  padding: 0.375rem 0.5rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.result-table tbody td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.result-table .row-number {
  color: rgba(255, 255, 255, 0.2);
  font-variant-numeric: tabular-nums;
  width: 3rem;
  text-align: right;
  padding-right: 1rem;
}

/* ---- Export Filename Input ---- */
.export-filename-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  width: 200px;
}

.export-filename-input:focus {
  border-color: rgba(42, 140, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(42, 140, 255, 0.1);
}

.export-filename-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.btn-export {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.btn-export:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.35);
}

/* ---- Danger Action Button (matches auto-map style) ---- */
.btn-danger-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fca5a5;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
  border: 1px solid rgba(239, 68, 68, 0.25);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-danger-action:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(220, 38, 38, 0.2));
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}

.btn-danger-action:active {
  transform: translateY(0);
}

/* ---- Auto-Map Button ---- */
.btn-auto-map {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e9d5ff;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-auto-map:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(168, 85, 247, 0.25));
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2);
  transform: translateY(-1px);
}

.btn-auto-map:active {
  transform: translateY(0);
}

.btn-auto-map svg {
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.15) rotate(10deg);
  }
}

/* ---- Key Toggle UI ---- */
.key-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.key-toggle-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.key-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s ease;
}

.key-checkbox:checked {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.6);
}

.key-checkbox:checked::after {
  content: '🔑';
  position: absolute;
  font-size: 0.55rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.key-label {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
  transition: color 0.15s ease;
  user-select: none;
}

.key-toggle-row:hover .key-label {
  color: rgba(255, 255, 255, 0.55);
}

.key-checkbox:checked~.key-label {
  color: rgba(245, 158, 11, 0.85);
  font-weight: 600;
}

/* Key Column Card Highlight */
.target-column-card.is-key-column {
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.08), inset 0 0 0 1px rgba(245, 158, 11, 0.06);
}

/* ---- Data Preview Popover ---- */
.chip-popover {
  position: fixed;
  z-index: 200;
  padding: 0;
  border-radius: 0.625rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.1);
  min-width: 220px;
  max-width: 360px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chip-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

.popover-header {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.popover-header .popover-col-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.popover-header .popover-file-name {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.35);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.popover-label {
  padding: 0.375rem 0.875rem 0.25rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.25);
}

.popover-rows {
  padding: 0 0.875rem 0.625rem;
}

.popover-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.popover-row:last-child {
  border-bottom: none;
}

.popover-row-num {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.2);
  font-variant-numeric: tabular-nums;
  min-width: 1rem;
  text-align: right;
  flex-shrink: 0;
}

.popover-row-val {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-empty {
  padding: 0.5rem 0.875rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.2);
  font-style: italic;
}

td {
  vertical-align: middle;
  /* Ensures consistency */
}

/* =========================================================================
   7. Live Preview Interactive Mapping Specifics
========================================================================= */

.interactive-headers-table {
  table-layout: fixed;
  /* Ensures column widths are respected */
}

.interactive-headers-table th {
  padding: 0;
  vertical-align: top;
}

.target-column-dropzone {
  min-height: 80px;
  background-color: rgba(255, 255, 255, 0.02);
}

.target-column-dropzone.drag-hover {
  background-color: rgba(59, 130, 246, 0.1);
  box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.2);
}

/* =========================================================================
   8. Form Elements & Custom Scrollbars
========================================================================= */

/* Mapped chip inside <th> drop zone */
.mapped-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.375rem 0.2rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  transition: opacity 0.15s;
}

.mapped-chip.dragging {
  opacity: 0.4;
}

.mapped-chip span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

/* Remove button on mapped chip */
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
  font-size: 0.65rem;
  line-height: 1;
}

.chip-remove:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* Drop zone inside table <th> */
.target-column-dropzone {
  min-height: 56px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  transition: background 0.15s;
  border-radius: 0 0 0.5rem 0.5rem;
}

.target-column-dropzone.empty {
  color: rgba(99, 179, 237, 0.5);
}

.target-column-dropzone.drag-hover {
  background: rgba(99, 179, 237, 0.08);
  outline: 2px dashed rgba(99, 179, 237, 0.4);
  outline-offset: -2px;
  border-radius: 0 0 0.5rem 0.5rem;
}

/* Animated pulse for empty drop zone hint */
.target-column-dropzone.empty>div {
  animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.8;
  }
}

/* drag-hover on <th> level */
th.drag-hover>.target-column-dropzone {
  background: rgba(99, 179, 237, 0.08);
}

/* Mapping preview table row hover */
#mapping-tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}