/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f9f9f9;
}

h1, h2, h3 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
}

img {
  max-width: 100%;
  height: auto;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
}

.app-title {
  font-size: 1.5rem;
  color: #2d5a27;
}

#search-form {
  width: 100%;
  max-width: 600px;
}

.search-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

#search-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

#search-input:focus {
  outline: none;
  border-color: #ff8c42;
}

#search-button {
  padding: 0.75rem 1.5rem;
  background-color: #ff8c42;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#search-button:hover {
  background-color: #e67e22;
}

#clear-button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

#clear-button:hover {
  background-color: #f0f0f0;
}

.search-toggle {
  display: flex;
  gap: 1rem;
  border: none;
  padding: 0;
}

.search-toggle legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-toggle label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.favorites-link {
  background: none;
  border: 2px solid #2d5a27;
  color: #2d5a27;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.favorites-link:hover {
  background-color: #2d5a27;
  color: white;
}

/* Recipes Grid */
.recipes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.recipe-card {
  background-color: #fff;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.recipe-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.recipe-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.recipe-content {
  padding: 1rem;
}

.recipe-title {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #2d5a27;
}

.recipe-summary {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.recipe-time {
  font-size: 0.8rem;
  color: #ff8c42;
  margin-bottom: 1rem;
}

.recipe-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-button {
  background-color: #ff8c42;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.view-button:hover {
  background-color: #e67e22;
}

.favorite-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.favorite-button:hover {
  transform: scale(1.2);
}

.favorite-button.favorited {
  color: #e74c3c;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: #fff;
  border-radius: 15px;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
  margin: 1rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
}

#modal-title {
  margin-bottom: 1rem;
  color: #2d5a27;
}

#modal-image {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
}

#modal-summary {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

#modal-ingredients ul,
#modal-nutrition ul,
#modal-steps ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

#modal-ingredients li,
#modal-nutrition li,
#modal-steps li {
  margin-bottom: 0.5rem;
}

#modal-source-link {
  display: inline-block;
  background-color: #2d5a27;
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 25px;
  transition: background-color 0.3s ease;
}

#modal-source-link:hover {
  background-color: #1e3f1d;
}

/* Hidden class */
.hidden {
  display: none !important;
}

/* Loading indicator */
.loading {
  text-align: center;
  font-size: 1.2rem;
  color: #ff8c42;
  margin-top: 2rem;
  padding: 1rem;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (min-width: 768px) {
  .header-container {
    flex-direction: row;
    justify-content: space-between;
    padding: 1.5rem 2rem;
  }

  .app-title {
    margin: 0;
  }

  .recipes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    max-width: 600px;
    margin: 2rem;
  }
}

@media (min-width: 1024px) {
  .recipes-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-content {
    max-width: 800px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
#search-input:focus,
#search-button:focus,
.favorites-link:focus,
.view-button:focus,
.favorite-button:focus,
.modal-close:focus,
#modal-source-link:focus {
  outline: 2px solid #ff8c42;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .header,
  .modal,
  .favorite-button,
  .view-button {
    display: none;
  }
}
