* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: env(safe-area-inset-top);
}

.container {
  position: relative;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  max-width: 650px;
  width: 100%;
  overflow: visible; /* let parent modal handle scrolling */
}


h1 {
  color: #4a4a4a;
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 20px;
}

.info-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  text-decoration: none;
  font-size: 1rem;
  color: #2196f3;
  cursor: pointer;
}

.form-container {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 12px;
  max-width: 100%;
  justify-content: center; /* Center the containers */
}

.option-container {
  flex: 0 0 49%; /* Reduced from 50% to avoid overflow */
  min-width: 280px;
  max-width: 300px; /* Reduced from 310px to fit within 650px */
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: visible;
  padding-top: 30px;
}

.option-container.better-deal {
  background-color: #e8f5e9;
  border-color: #4caf50;
}

.deal-label {
  display: block;
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 700;
  color: #4caf50;
  text-align: center;
  visibility: hidden;
  white-space: nowrap;
  background-color: inherit;
  padding: 0 5px;
}

.option-container.better-deal .deal-label {
  visibility: visible;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 15px;
  width: 100%;
}

.input-row label {
  font-size: 1rem;
  color: #555;
}

.input-row input {
  padding: 8px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  width: 100%;
  box-sizing: border-box;
  height: 38px;
}

.input-row div:not(.multipack-group) {
  display: flex;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 5px;
  overflow: visible;
  height: 38px;
}

.input-row div:not(.multipack-group) input {
  flex: 2;
  padding: 8px;
  font-size: 0.9rem;
  border: none;
  border-right: none;
  border-radius: 5px 0 0 5px;
  box-sizing: border-box;
  height: 100%;
}

.input-row div:not(.multipack-group) select {
  flex: 0.3;
  padding: 8px;
  font-size: 0.9rem;
  border: none;
  border-left: none;
  border-radius: 0 5px 5px 0;
  background-color: #fff;
  box-sizing: border-box;
  appearance: none;
  height: 100%;
}

.input-row[hidden] {
  display: none !important;
}

.multipack-row .multipack-group {
  display: flex;
  width: 100%;
  gap: 8px;
}

.multipack-row .multipack-group select {
  width: 100%;
  height: 38px;
  font-size: 0.9rem;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #fff;
  appearance: none;
}

.multipack-row .multipack-group input[type="number"] {
  display: none;
  width: 50%;
  height: 38px;
  font-size: 0.9rem;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.multipack-row .multipack-group.other-active select {
  width: 50%;
}

.multipack-row .multipack-group.other-active input[type="number"] {
  display: inline-block;
}

.quantity-group {
  display: flex;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 5px;
  height: 38px;
  overflow: visible;
}

.quantity-group input {
  flex: 2;
  padding: 8px;
  font-size: 0.9rem;
  border: none;
  border-radius: 5px 0 0 5px;
  box-sizing: border-box;
  height: 100%;
}

.quantity-group select {
  flex: 1;
  padding: 8px;
  font-size: 0.9rem;
  border: none;
  border-left: 1px solid #ccc;
  border-radius: 0 5px 5px 0;
  background-color: #fff;
  box-sizing: border-box;
  appearance: none;
  height: 100%;
}

.price-per-unit {
  font-size: 1.2rem;
  color: #333;
  text-align: center;
  margin-top: 15px;
}

#add-pane-btn {
  position: absolute;
  top: 120px;
  right: 25%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2196f3;
  color: #fff;
  border: none;
  font-size: 1.5rem;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  display: none;
  z-index: 999;
}

dialog {
  width: 90%;
  max-width: 500px;
  border: none;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  background: white;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialog-close-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  background: #ccc;
  border: none;
  cursor: pointer;
  z-index: 1;
}

@media (max-width: 600px) {
  .container {
    width: 90%;
    padding: 10px;
  }

  .option-container {
    flex: 0 0 45%;
    min-width: 150px;
    max-width: 200px;
    padding: 10px;
    padding-top: 30px;
  }

  .form-container {
    gap: 8px;
  }

  .deal-label {
    top: 5px;
    font-size: 0.9rem;
  }

  .input-row label {
    font-size: 0.9rem;
  }

  .input-row input,
  .input-row div:not(.multipack-group) input,
  .quantity-group input {
    font-size: 0.8rem;
  }

  .input-row div:not(.multipack-group) select,
  .quantity-group select {
    font-size: 0.8rem;
  }

  dialog {
    width: 90%;
    height: auto;
    max-width: none;
    max-height: 80vh;
    overflow: auto;
    border-radius: 10px;
  }
}

/* Hide the ⓘ button when running inside the modal demo */
.embedded .info-btn { display: none !important; }

/* Match the parent red close button style for the info dialog */
.dialog-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: #ff4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 30px;
  text-align: center;
  cursor: pointer;
}
.dialog-close-btn:hover { background: #cc0000; }

/* A little extra breathing room in the embedded app */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 20px 28px;
}

/* Hide info button when embedded */
.embedded .info-btn {
  display: none !important;
}
