.template-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  overflow-x: auto;
}

.template-layout-controls {
  margin-top: 12px;
  width: 100%;
}

.template-action-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #4c6fff;
  background: #4c6fff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.template-action-btn.ghost {
  background: #f5f7fb;
  color: #1f2937;
  border-color: #d7dce5;
}

.template-add-row {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #4c6fff, #7c8bff);
  border: none;
  box-shadow: 0 8px 18px rgba(76, 111, 255, 0.25);
}

.template-add-row .plus {
  font-size: 18px;
  font-weight: 800;
}

.template-toolbar {
  background: #f5f7fb;
  border: 1px solid #d7dce5;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.08);
  margin-bottom: 12px;
}

.template-toolbar-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 14px;
}

.template-toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-toolbar-group label {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
}

.template-toolbar-group input,
.template-toolbar-group select {
  padding: 8px 10px;
  border: 1px solid #cdd4df;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.template-row {
  display: grid;
  gap: 10px;
  width: 100%;
  align-items: stretch;
}

.template-row-wrapper {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.template-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px 4px;
  font-weight: 600;
  color: #1f2937;
}

.template-row-controls {
  display: flex;
  gap: 8px;
}

.template-slot {
  background: #f7f9fc;
  border: 1px solid #d7dce5;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 170px;
  position: relative;
  min-width: 120px;
}

.slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: linear-gradient(135deg, #9ca6ff, #6f7bff);
  border-radius: 999px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 4px 10px rgba(111, 123, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.slot-remove:hover {
  box-shadow: 0 6px 12px rgba(111, 123, 255, 0.28);
  transform: translateY(-1px) scale(1.02);
  opacity: 0.95;
}

.slot-remove-icon {
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.row-enter-animate {
  animation: rowEnterPop 0.4s ease forwards;
}

.row-exit-animate {
  animation: rowExitSlide 0.35s ease forwards;
}

@keyframes rowEnterPop {
  0% {
    transform: translateY(10px) scale(0.97);
    opacity: 0;
  }
  60% {
    transform: translateY(-3px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes rowExitSlide {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(-12px) scale(0.95);
    opacity: 0;
  }
}

.placeholder-slot {
  visibility: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
  box-shadow: none;
}

.template-slot.dragging {
  opacity: 0.75;
}

.template-slot.drag-over {
  outline: 2px dashed #4c6fff;
}

.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #1f2937;
}

.slot-selection-input {
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #cdd4df;
  border-radius: 6px;
  font-size: 13px;
  width: 80px;
}

.slot-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-product {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  border: 1px dashed #cdd4df;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.slot-product-image {
  max-height: 70px;
  max-width: 100%;
  object-fit: contain;
}

.slot-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cdd4df;
  border-radius: 6px;
  font-size: 13px;
}
.slot-input-compact {
  padding: 7px 8px !important;
  font-size: 13px !important;
  text-align: center !important;
  aspect-ratio: 1 / 1 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
.slot-input-price {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
}

.slot-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 6px 10px;
}

.slot-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #374151;
  width: 100%;
}

.slot-field input {
  font-size: 13px;
}

.slot-footer {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

.slot-footer-line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
  width: 100%;
}

.slot-price-row {
  margin-top: 6px;
}

.slot-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #4c6fff;
  background: #4c6fff;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.slot-btn.secondary {
  background: #fff;
  color: #1f2937;
  border-color: #cdd4df;
}

.slot-btn:hover {
  opacity: 0.9;
}

.productMenu {
  position: absolute;
  z-index: 12;
  background: #fff;
  border: 1px solid #cdd4df;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  padding: 8px;
  width: 280px;
  max-height: 340px;
  overflow: hidden;
  top: 10px;
  right: 10px;
}

.template-product-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.template-product-modal {
  width: min(900px, 90vw);
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.template-product-toolbar {
  display: grid;
  grid-template-columns: repeat(3, max-content) 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.template-tab {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #d7dce5;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: #1f2937;
}

.template-tab.active {
  background: #4c6fff;
  color: #fff;
  border-color: #4c6fff;
}

.template-hcg-sub {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0 12px;
}

.template-hcg-sub.hidden {
  display: none;
}

.template-hcg-btn.active {
  background: #e5ecff;
  color: #1f2937;
}

.template-product-search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cdd4df;
  border-radius: 8px;
  font-size: 14px;
}

.template-product-list-modal {
  padding: 12px;
  overflow-y: auto;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-product-search {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cdd4df;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.template-product-list {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.template-product-row:hover {
  background: #f2f5fb;
  border-color: #d7dce5;
}

.template-product-row img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
}

.template-product-footer {
  padding: 12px;
  border-top: 1px solid #e5e7eb;
}

.template-product-close {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: #4c6fff;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
