*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #fdfdfd;
  color: #333;
  padding: 22px;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: hidden;
  min-height: 100vh;
  font-family: "Montserrat", sans-serif;
}

h1 {
  text-align: center;
  margin: 0 0 18px;
  font-size: clamp(20px, 2.8vw, 30px);
}

h2 {
  margin: 18px 0 10px;
  font-size: 1.2rem;
  color: #444;
}

.container {
  max-width: 700px;
  text-align: center;
  margin: 0 auto;
}

.top-card {
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
@media (min-width: 700px) {
  .top-card {
    display: flex;
    gap: 10px;
  }
  .top-card .field:first-child {
    flex-grow: 1;
  }
  .top-card .field:last-child {
    display: flex;
    justify-content: flex-end;
  }
}

.blend-type .btn {
  margin-top: 10px;
  margin-bottom: 10px;
}

.field {
  margin-bottom: 10px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
}
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

.btn {
  background: rgb(241, 202, 130);
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.4s ease-out all;
}
.btn:hover {
  background: #56f0cc;
}
.btn span {
  position: absolute;
  left: -1000rem;
}
.btn-ghost {
  background: #eee;
}
.btn-danger {
  background: #f6b6b6;
}
.btn-accent {
  background: #a8dadc;
}

.btn-close-wrapper {
  text-align: right;
}

.btn-delete {
  background: #f6b6b6;
}
.btn-delete:hover {
  background-color: #f6b6b6;
}

.btn-close {
  background: none;
}
.btn-close:hover {
  background-color: none;
}

.btn-delete,
.btn-close {
  position: relative;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 100px;
  margin-bottom: 10px;
}
.btn-delete::before, .btn-delete::after,
.btn-close::before,
.btn-close::after {
  content: "";
  display: block;
  position: absolute;
  color: black;
  border-top: 1px solid black;
  top: 50%;
  left: 50%;
  width: 50%;
  margin-left: -25%;
}
.btn-delete::before,
.btn-close::before {
  transform: rotate(-45deg);
}
.btn-delete::after,
.btn-close::after {
  transform: rotate(45deg);
}
.btn-delete:hover::before, .btn-delete:hover::after,
.btn-close:hover::before,
.btn-close:hover::after {
  transition: 0.4s ease-out all;
}
.btn-delete:hover::before,
.btn-close:hover::before {
  transform: rotate(45deg);
}
.btn-delete:hover::after,
.btn-close:hover::after {
  transform: rotate(-45deg);
}

.btn.btn-save {
  position: relative;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 100px;
  margin-bottom: 10px;
  background-color: #a8dadc;
  background-image: url("../assets/bookmark.png");
  background-size: 20px;
  background-repeat: no-repeat;
  background-position: center;
}
.btn.btn-save:hover {
  background-color: #4cb5b9;
}

.desktop-table {
  margin-top: 16px;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid #e6e6e6;
  table-layout: fixed;
}
.compact-table th,
.compact-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: center;
  word-wrap: break-word;
  /* allow long words to wrap */
  word-break: break-word;
  /* helps with very long strings/URLs */
  white-space: normal;
  /* ensure wrapping is allowed */
}
.compact-table thead th {
  background: #f6f7fb;
  font-weight: 700;
}

.eo-col-header {
  text-align: left;
  min-width: 230px;
}

.eo-mini-field {
  margin: 6px 0;
}
.eo-mini-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  justify-content: space-between;
}

.allergen-input {
  width: 92px;
  text-align: center;
}

.mobile-cards {
  display: none;
  margin-top: 16px;
}

.eo-card {
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
.eo-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.eo-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.eo-fields .field {
  flex: 1;
  min-width: 180px;
}

details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.allergen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.allergen-grid input {
  text-align: center;
  padding: 5px;
  width: 100%;
}
.allergen-grid label {
  font-size: 0.9rem;
  color: #444;
}

.results-wrap {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.results-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.allergen-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}
.allergen-card.must {
  background: #ffe0e0;
  border-color: #f5b5b5;
}
.allergen-card.optional {
  background: #fff9db;
  border-color: #ffe38a;
}
.allergen-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.allergen-card p {
  margin: 0;
  font-size: 0.92rem;
}

.results,
.blend-overview {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

.overview-list {
  margin: 0;
  padding-left: 18px;
}

.saved-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}

.saved-block {
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  position: fixed;
  top: 0;
  right: -100%;
  height: 100vh;
  z-index: 100;
  transition: 0.4s ease-out all;
  overflow-y: scroll;
}

.eos-open .saved-eos {
  right: 0;
}

.blends-open .saved-blends {
  right: 0;
}

.saved-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.saved-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 12px;
  position: relative;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}
.saved-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.saved-card p {
  margin: 2px 0;
  color: #444;
}
.saved-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.saved-card .saved-load {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.saved-btns {
  text-align: center;
  margin-bottom: 20px;
}
.saved-btns .btn {
  margin-bottom: 5px;
}

.eo-btns .btn {
  margin-bottom: 5px;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Popup box */
.popup {
  background: white;
  border-radius: 12px;
  max-width: 900px;
  width: 90%;
  padding: 20px;
  position: relative;
  text-align: left;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  max-height: 95vh;
  overflow-y: scroll;
}
.popup ol,
.popup ul {
  padding-left: 10px;
}
.popup h2 {
  margin-top: 0;
}

.copyright {
  text-align: center;
  margin-top: 50px;
}

/* Images */
.popup img {
  max-width: 100%;
  border-radius: 8px;
  margin: 10px 0;
}

a {
  color: #4cb5b9;
  transition: 0.4s ease-out all;
}
a:hover {
  color: rgb(13, 75, 77);
}

#backToTop {
  display: none;
  /* Hidden by default */
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 100;
  background-color: #007bff;
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.3s;
}

#backToTop:hover {
  background-color: #0056b3;
}

@media (max-width: 800px) {
  .desktop-table {
    display: none;
  }
  .mobile-cards {
    display: block;
  }
  .saved-sections {
    grid-template-columns: 1fr;
  }
}
