/* mapping.css - Modified for CodeIQ Integration */

/* Reset and Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Modal Backdrop and Container */
.mapping-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85); /* Darker overlay like validation modal */
  z-index: 100000; /* Keep above the app; validation modal is higher */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mapping-modal-container {
  background: #fff;
  border-radius: 16px; /* Rounder like validation modal */
  width: min(var(--mapping-modal-width, 1200px), 95vw);
  min-width: min(720px, 95vw);
  max-height: min(var(--mapping-modal-height, 900px), 92vh);
  overflow: hidden; /* Change from overflow-y: auto */
  padding: 0; /* Sections manage their own padding */
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); /* Stronger shadow */
  display: flex;
  flex-direction: column;
  border: 3px solid #c4576a; /* CodeIQ pink border */
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.mapping-modal-header {
  background: linear-gradient(135deg, #9a4054 0%, #c4576a 100%);
  border-bottom: 2px solid #c4576a;
  padding: 0.85rem 1rem;
  text-align: center;
  flex-shrink: 0;
}
.mapping-modal-header h2 {
  font-weight: 700;
  color: #ffffff;
  font-size: 1.15rem;
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.01em;
}
.mapping-modal-header p {
  font-size: 0.8rem;
  color: #ffffff;
  margin: 0;
  font-weight: 500;
  opacity: 0.9;
}

/* RiQ Avatar Section */
.mapping-modal-avatar {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: linear-gradient(180deg, #c4576a 0%, white 100%);
}

.mapping-modal-avatar img {
  width: 50px;
  height: 50px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.mapping-close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;
  padding: 0.5rem;
  transition: all 0.2s;
  border-radius: 8px;
  font-weight: 700;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.mapping-close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.1);
}

/* Instruction Notice */
.mapping-instruction {
  text-align: center;
  font-size: 0.8rem;
  color: #831843;
  margin: 0.75rem 1rem;
  line-height: 1.4;
  flex-shrink: 0;
  background: linear-gradient(135deg, #fae8ec 0%, #f5d0d9 100%);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 2px solid #c4576a;
}
.mapping-instruction strong {
    color: #9f1239;
    font-weight: 700;
}

/* Panel Sections */
.mapping-panel-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-grow: 1;
  overflow-x: hidden;
  overflow-y: visible;
  min-height: 0;
}
/* Modal body wrapper - contains all sections and allows scrolling */
.mapping-modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.mapping-section {
  border: 1px solid #d4d0c8;
  border-radius: 6px;
  padding: 0.6rem 0.85rem; /* Slightly reduced padding */
  background-color: #faf8f5;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.mapping-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 0.65rem;
}

/* Credit Card Option */
.credit-card-option {
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, #fae8ec 0%, #f5d0d9 100%);
  border: 2px solid #c4576a;
  border-radius: 6px;
}
.credit-card-option label {
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.8rem;
  color: #831843;
  font-weight: 600;
}
.credit-card-option input[type="checkbox"] {
  margin-right: 0.45rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
  accent-color: #c4576a;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.credit-card-option .help-text {
  display: block;
  font-size: 0.7rem;
  color: #9f1239;
  margin-top: 0.2rem;
  font-weight: 500;
}

/* Toggle Buttons */
.mapping-toggle-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.mapping-toggle-button {
  padding: 0.5rem 0.75rem;
  border: 2px solid #c4c0b8;
  background-color: #fff;
  color: #3d3d3d;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  user-select: none;
}
.mapping-toggle-button:hover {
  background-color: #fae8ec;
  border-color: #c4576a;
  color: #9f1239;
}
.mapping-toggle-button.active {
  background: linear-gradient(135deg, #9a4054 0%, #c4576a 100%);
  border-color: #c4576a;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(196, 87, 106, 0.3);
}

/* Table Wrapper and Positioning */
.mapping-table-wrapper {
  position: relative;
  background-color: #fff;
  border: 1px solid #d4d0c8;
  border-radius: 6px;
  overflow: hidden;
  flex: 1;
  min-height: 260px;
}

.mapping-table-container {
  height: 100%;
  overflow: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 #f7fafc;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior: contain;
}

.mapping-table-container::-webkit-scrollbar {
  height: 8px;
}
.mapping-table-container::-webkit-scrollbar-track {
  background: #f7fafc;
}
.mapping-table-container::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}
.mapping-table-container::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Scroll Indicators */
.mapping-table-container.is-scrollable-left::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
  z-index: 10;
}
.mapping-table-container.is-scrollable-right::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
  z-index: 10;
}

/* Table Styling - Simple and Clean */
#mapping-Table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
#mapping-Table th,
#mapping-Table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #d4d0c8;
  white-space: nowrap;
  min-width: 100px;
}
#mapping-Table th {
  background-color: #faf8f5;
  font-weight: 600;
  color: #3d3d3d;
  position: sticky;
  top: 0;
  z-index: 5;
  border-right: 1px solid #d4d0c8;
}
#mapping-Table th:last-child {
  border-right: none;
}
#mapping-Table td {
  color: #6b6b6b;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sample Rows Styling */
.mapping-sample-rows tr:nth-child(even) {
  background-color: #faf8f5;
}
.mapping-sample-rows tr:hover {
  background-color: #f5f2ed;
}

/* Drag and Drop Overlays */
#mapping-ColumnOverlays {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

.mapping-column-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  background-color: rgba(196, 87, 106, 0.15);
  border: 3px solid #c4576a;
  border-radius: 8px;
  pointer-events: auto;
  cursor: grab;
  transition: all 0.2s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.5rem;
}

.mapping-column-overlay:hover {
  background-color: rgba(196, 87, 106, 0.25);
  border-color: #9a4054;
  box-shadow: 0 4px 12px rgba(196, 87, 106, 0.4);
}

.mapping-column-overlay.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 20;
  transform: rotate(2deg);
  box-shadow: 0 8px 20px rgba(196, 87, 106, 0.5);
}

.mapping-column-overlay::after {
  content: attr(data-type);
  font-size: 0.75rem;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(135deg, #9a4054 0%, #c4576a 100%);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Drop Target Highlighting */
.mapping-drop-target {
  background-color: rgba(196, 87, 106, 0.2) !important;
  border-color: #c4576a !important;
  box-shadow: 0 0 0 3px rgba(196, 87, 106, 0.3) !important;
}

/* Footer */
.mapping-footer {
  flex-shrink: 0;
  padding: 0.85rem 1rem;
  border-top: 1px solid #d4d0c8;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.mapping-error-message {
  color: #dc2626;
  background-color: #fef2f2;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #fecaca;
  font-size: 0.8rem;
  font-weight: 500;
}

.mapping-confirm-mapping {
  background: linear-gradient(135deg, #9a4054 0%, #c4576a 100%);
  color: white;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  align-self: center;
  box-shadow: 0 3px 8px rgba(196, 87, 106, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.mapping-confirm-mapping:hover {
  background: linear-gradient(135deg, #7a3345 0%, #9a4054 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(196, 87, 106, 0.4);
}
.mapping-confirm-mapping:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(196, 87, 106, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  .mapping-modal-container {
    min-width: auto;
    width: 95vw;
    max-height: 92vh;
  }
  
  .mapping-toggle-buttons {
    gap: 0.25rem;
  }
  
  .mapping-toggle-button {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
  
  #mapping-Table th,
  #mapping-Table td {
    padding: 0.5rem;
    min-width: 80px;
  }
}

/* Animation for smooth interactions */
.mapping-column-overlay,
.mapping-toggle-button,
#mapping-Table th {
  transition: all 0.2s ease;
}

/* Focus styles for accessibility */
.mapping-toggle-button:focus,
.mapping-confirm-mapping:focus,
.mapping-close-modal:focus {
  outline: 3px solid #c4576a;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .mapping-modal-overlay {
    display: none !important;
  }
}

/* ========== Description Multi-Select Styles ========== */

/* Description overlay with order badge */
.mapping-description-overlay {
  cursor: pointer !important;
  background-color: rgba(76, 175, 80, 0.15) !important;
  border-color: #4CAF50 !important;
}

.mapping-description-overlay:hover {
  background-color: rgba(76, 175, 80, 0.25) !important;
  border-color: #388E3C !important;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4) !important;
}

.mapping-description-overlay::after {
  background: linear-gradient(135deg, #2E7D32 0%, #4CAF50 100%) !important;
  content: "Description" !important;
}

/* Order number badge */
.mapping-desc-order-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 25;
  border: 2px solid white;
}

/* Selectable headers during multi-select mode */
.mapping-desc-selectable {
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.mapping-desc-selectable:hover {
  background-color: rgba(76, 175, 80, 0.15) !important;
  box-shadow: inset 0 0 0 2px #4CAF50 !important;
}

/* Description hint message */
.mapping-description-hint {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  border: 2px solid #4CAF50;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin: 0 1rem 0.5rem 1rem;
  font-size: 0.8rem;
  color: #1B5E20;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.3s ease-out;
}

.mapping-description-hint .hint-icon {
  font-size: 1rem;
}
