/* --- Base Styles --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: #f7fafc; /* Lighter background for the iframe */
  min-height: 100vh;
  padding: 1rem; /* Reduced padding */
}

.container {
  max-width: 100%; /* Fill the iframe */
  margin: 0 auto;
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

h1 {
  color: #1a202c;
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
}

/* --- Controls & Info --- */
.control-panel {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.control-panel button {
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.clear-btn-front,
.clear-btn-back,
.clear-btn-all {
  background: #edf2f7;
  color: #4a5568;
  border: 2px solid #e2e8f0;
}
.clear-btn-front:hover,
.clear-btn-back:hover,
.clear-btn-all:hover {
  background: #e2e8f0;
}

.info-box {
  background: #ebf8ff;
  border-left: 4px solid #4299e1;
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #2c5282;
}

.info-box.invalid {
  background: #fff5f5;
  border-left-color: #c53030;
  color: #9b2c2c;
}

/* --- Row & Column Layout --- */
.pairs-container {
  margin-bottom: 2rem;
}

.draggable-row,
.fixed-row {
  display: flex; /* Use Flexbox for layout */
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem; /* Add some start padding */
}

.pair-column {
  margin-right: 1rem;
  width: 150px; /* Fixed width for the column */
  flex-shrink: 0; /* Prevent columns from shrinking */
}

/* --- Image Preview Sections --- */
.draggable-section,
.fixed-section {
  border-radius: 0.5rem;
  overflow: hidden;
  width: 150px;
  height: 210px; /* ADJUSTED: Reduced height */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  background: #f7fafc;
}

.draggable-section {
  border: 2px solid #48bb78;
}

.fixed-section {
  border: 2px solid #a0aec0;
  justify-content: flex-start; /* ALIGNMENT FIX */
}

/* --- Section Controls (Drag handle, copies, delete) --- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #f0fff4;
  border-bottom: 1px solid #c6f6d5;
  flex-shrink: 0;
}

.pair-number {
  width: 30px;
  height: 30px;
  background: #48bb78;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
  cursor: move;
}

.copies-control input {
  width: 3rem;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  padding: 0.25rem;
}

.delete-btn {
  padding: 0.25rem 0.5rem;
  background: #fff5f5;
  color: #c53030;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}

/* --- Image & Placeholders --- */
.image-preview {
  width: 100%;
  height: 150px; /* ADJUSTED: Fixed height for the image */
  object-fit: contain;
  display: block;
  background: #f7fafc;
  flex-grow: 1;
}

.placeholder-text {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7fafc;
  color: #a0aec0;
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
  flex-grow: 1;
}

.placeholder-text.front-missing {
  background: #fed7d7;
  color: #c53030;
}

.placeholder-text.back-missing {
  background: #ffeccf;
  color: #dd6b20;
}

.placeholder-text.shared-back {
  height: 30px;
  background: #e0f2f1;
  color: #00796b;
  font-weight: bold;
  flex-shrink: 0;
}

.image-preview.shared-back-image {
  height: 120px; /* 150px total height - 30px for the text */
}

/* --- States --- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #718096;
}

.sortable-ghost {
  opacity: 0.5;
  background: #edf2f7;
}

.pair-column.placeholder-front .draggable-section {
  border-color: #a0aec0;
}

.pair-column.placeholder-front .controls {
  background: #e2e8f0;
  border-bottom-color: #cbd5e0;
}

.pair-column.placeholder-front .pair-number {
  background: #a0aec0;
  cursor: default;
}
