/* reset & variables */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --secondary: #06b6d4;
  --text-dark: #333;
  --text-light: #f8f9fa;
  --background: #fff;
  --background-light: #f8f9fa;
  --card-bg: #fff;
  --radius: 20px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--background-light);
  color: var(--text-dark);
  line-height: 1.6;
}

/* container */
.container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

h1 i { margin-right: 10px; }

header p {
  color: var(--text-dark);
  opacity: 0.7;
}

/* search */
.search-container {
  display: flex;
  margin-bottom: 2rem;
  gap: 10px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

input[type="text"] {
  flex: 1;
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 0 var(--radius) 0 var(--radius);
  border: 1px solid #ddd;
  background: var(--background);
  color: var(--text-dark);
  outline: none;
}

input[type="text"]:focus { border-color: var(--primary); }

button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0 var(--radius) 0 var(--radius);
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

button:hover { background: var(--primary-dark); }

#result-heading {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  color: var(--text-dark);
}

/* meals grid */
.meals-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.meal {
  background: var(--card-bg);
  border-radius: 0 var(--radius) 0 var(--radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.meal:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.meal img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.meal-info { padding: 1rem; }

.meal-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.meal-category {
  display: inline-block;
  background: var(--primary-light);
  color: var(--text-dark);
  padding: 3px 8px;
  font-size: 0.8rem;
  border-radius: 20px;
  margin-bottom: 10px;
}

/* meal details */
#meal-details {
  background: var(--background);
  border-radius: 0 var(--radius) 0 var(--radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin: 2rem 0;
}

#back-btn {
  margin-bottom: 1.5rem;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 8px 16px;
}

#back-btn:hover {
  background: var(--primary);
  color: white;
}

.meal-details-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.meal-details-img {
  width: 100%;
  max-width: 400px;
  border-radius: 0 var(--radius) 0 var(--radius);
  margin-bottom: 1.5rem;
}

.meal-details-title {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  text-align: center;
}

.meal-details-category {
  margin-bottom: 1rem;
  text-align: center;
}

.meal-details-category span {
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.meal-details-instructions {
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.meal-details-instructions h3 { margin-bottom: 0.5rem; }

/* ingredients */
.ingredients-list {
  list-style-type: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 1.5rem;
  width: 100%;
}

.ingredients-list li {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--background-light);
  border-radius: 0 var(--radius) 0 var(--radius);
  font-size: 0.9rem;
}

.ingredients-list li i {
  color: var(--secondary);
  margin-right: 8px;
}

.youtube-link {
  display: inline-block;
  background: #ff0000;
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.youtube-link i { margin-right: 8px; }

/* error */
#error-container {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  padding: 1rem;
  border-radius: 0 var(--radius) 0 var(--radius);
  text-align: center;
  margin-bottom: 1.5rem;
}

.api-link {
  text-align: center;
  padding-bottom: 1.5rem;
  color: var(--text-dark);
  opacity: 0.7;
  font-size: 0.9rem;
}

.api-link a {
  color: var(--primary);
  text-decoration: none;
}

.hidden { display: none; }

/* responsive */
@media (max-width: 600px) {
  .search-container { flex-direction: column; }

  button#search-btn {
    width: 100%;
    padding: 10px;
  }

  .meals-container { grid-template-columns: 1fr; }

  .meal-details-img { max-width: 100%; }

  .ingredients-list { grid-template-columns: 1fr; }
}