/* 🌈 General page layout and background */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: #f5e9e2;
  font-family: "Lexend", Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* 📦 Main container styling */
.container {
  max-width: 500px;
  width: 100%;
  margin: 40px auto;
  padding: 32px 24px 24px 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 6px 32px rgba(80, 60, 40, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  position: relative;
}

/* 🏷️ Heading styles */
.heading {
  font-size: 2.1em;
  color: #5e4b8b;
  margin-bottom: 18px;
  font-weight: 700;
  text-align: center;
}

/* 📝 Form wrapper and layout */
.form-wrapper {
  width: 100%;
  margin-bottom: 18px;
  box-sizing: border-box;
}

/* 🥕 Suggested ingredients area */
.suggested-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  justify-content: center;
}

/* 🥕 Ingredient button styles */
.ingredient-btn {
  padding: 8px 16px;
  border: 1.5px solid #bdbdbd;
  border-radius: 20px;
  background: #f7f7fa;
  color: #5e4b8b;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
  position: relative;
}

.ingredient-btn:hover {
  background: #e8e8f0;
  border-color: #5e4b8b;
  transform: translateY(-1px);
}

.ingredient-btn:focus {
  outline: 2px solid #5e4b8b;
  outline-offset: 2px;
}

.ingredient-btn.selected {
  background: #bdecb6;
  border-color: #388e3c;
  color: #21404e;
  transform: translateY(-1px);
}

.ingredient-btn.selected:hover {
  background: #a8e6a1;
}

/* 🍽️ Dietary restrictions section */
.dietary-section {
  margin-bottom: 24px;
  padding: 16px;
  background: #f9f9fc;
  border-radius: 12px;
  border: 1px solid #e8e8f0;
}

.dietary-heading {
  font-size: 1.1em;
  color: #5e4b8b;
  margin: 0 0 12px 0;
  font-weight: 600;
  text-align: center;
}

.dietary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* 🍽️ Dietary restriction buttons */
.dietary-btn {
  padding: 6px 12px;
  border: 1.5px solid #d4d4d8;
  border-radius: 16px;
  background: #ffffff;
  color: #6b7280;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dietary-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.dietary-btn:focus {
  outline: 2px solid #5e4b8b;
  outline-offset: 2px;
}

.dietary-btn.selected {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
  transform: translateY(-1px);
}

.dietary-btn.selected:hover {
  background: #bfdbfe;
}

/* 🍽️ Dietary badges in recipe results */
.dietary-badge {
  margin-bottom: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  background: #dbeafe;
  color: #1e40af;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 500;
  border: 1px solid #93c5fd;
}

/* 📝 Ingredient form styles */
#ingredient-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* 🧾 Ingredient input styles */
#ingredient-input {
  padding: 10px 12px;
  border: 1.5px solid #bdbdbd;
  border-radius: 8px;
  font-size: 1em;
  outline: none;
  transition: all 0.3s ease;
}

#ingredient-input:focus,
#ingredient-input.focused {
  border-color: #5e4b8b;
  box-shadow: 0 0 0 3px rgba(94, 75, 139, 0.1);
}

#ingredient-input.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

/* 🔘 Submit button styles */
#submit-button {
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  background: #5e4b8b;
  color: #fff;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#submit-button:hover:not(:disabled) {
  background: #4a3a6b;
  transform: translateY(-1px);
}

#submit-button:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
  transform: none;
}

#submit-button:focus {
  outline: 2px solid #5e4b8b;
  outline-offset: 2px;
}

/* ℹ️ Explanation text */
.explanation {
  font-size: 12px;
  color: #7a7a7a;
  margin: 0;
  text-align: center;
}

/* 📜 Recipe results page */
#recipe-results {
  margin-top: 22px;
  background: #fffdf3;
  border-radius: 10px;
  padding: 20px;
  color: #333;
  line-height: 1.6;
  text-align: left;
  box-shadow: 0 2px 12px rgba(80, 60, 40, 0.07);
  min-width: 0;
  width: 100%;
  max-width: 100%;
  word-break: break-word;
  box-sizing: border-box;
  overflow-wrap: break-word;
  overflow-x: auto;
}

/* 📜 Recipe results: title and sections */
#recipe-results .recipe-title {
  color: #5e4b8b;
  font-size: 1.4em;
  margin-bottom: 10px;
  font-weight: 700;
}

#recipe-results .recipe-section {
  color: #5e4b8b;
  font-size: 1.08em;
  font-weight: bold;
}

#recipe-results ul {
  margin: 10px 0 10px 20px;
  padding: 0;
}

#recipe-results li {
  margin-bottom: 4px;
}

/* ⏳ Loading state styles */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #5e4b8b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-container p {
  color: #5e4b8b;
  font-weight: 500;
  margin: 0;
}

/* ⚠️ Error state styles */
.error-container {
  text-align: center;
  padding: 20px;
}

.error-message {
  color: #e53e3e;
  font-weight: 500;
  margin: 0 0 15px 0;
  padding: 10px;
  background: #fed7d7;
  border-radius: 8px;
  border: 1px solid #feb2b2;
}

.retry-button {
  background: #5e4b8b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.3s ease;
}

.retry-button:hover {
  background: #4a3a6b;
}

/* 👣 Footer styles */
footer {
  margin-top: 30px;
  text-align: center;
  font-size: 0.95em;
  color: #a7a7a7;
}

footer a {
  color: #5e4b8b;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

footer a:hover {
  color: #388e3c;
}

/* 🙈 Utility: Hide elements */
.hidden {
  display: none;
}

/* 🎯 Focus management for better accessibility */
*:focus {
  outline: 2px solid #5e4b8b;
  outline-offset: 2px;
}

button:focus,
input:focus {
  outline: 2px solid #5e4b8b;
  outline-offset: 2px;
}

/* 📱 Responsive styles for mobile */
@media (max-width: 600px) {
  .container {
    max-width: 98vw;
    padding: 16px 4vw 16px 4vw;
    border-radius: 0;
    margin: 0;
    min-height: 100vh;
  }
}

.form-wrapper {
  padding: 0;
  margin-bottom: 12px;
}

.dietary-section {
  padding: 12px;
  margin-bottom: 16px;
}

.dietary-heading {
  font-size: 1em;
}

.dietary-filters {
  gap: 6px;
}

.dietary-btn {
  font-size: 0.85em;
  padding: 5px 10px;
}

#recipe-results {
  padding: 12px 4vw;
  font-size: 1em;
}
