:root {
  --primary: #4361ee;
  --primary-dark: #3f37c9;
  --accent: #4cc9f0;
  --text: #e9ecef;
  --light: #f8f9fa;
  --dark: #121212;
  --dark-card: #1e1e1e;
  --dark-section: #252525;
  --border-radius: 15px;
  --box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

* {
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--dark);
  color: var(--text);
  min-height: 100vh;
  display: block;
  padding-top: 80px; /* Space for fixed header */
  width: 100%;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 0.8s ease-out forwards;
}

h1 {
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 32px;
  font-weight: 600;
}

.subtitle {
  color: #ffffff;
  font-size: 18px;
  opacity: 0.9;
}

.info-section {
  margin: 2rem 2rem;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.info-section p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #ffffff;
  margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .info-section {
    padding: 1.2rem;
    margin: 1.5rem 0;
  }
  
  .info-section p {
    font-size: 1rem;
  }
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

h2 {
  text-align: center;
  padding-bottom: 20px;
  color: var(--accent);
  font-size: 22px;
}

h3 {
  color: var(--accent);
}

.input-section {
  background-color: var(--dark-card);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--box-shadow);
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.8s ease-out forwards;
  animation-delay: 0.2s;
}

.text-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #333;
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 20px;
  background-color: var(--dark-section);
  color: #ffffff;
  transition: all 0.3s;
}

.text-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.btn {
  display: block;
  margin: 10px auto;
  text-align: center;
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(67, 97, 238, 0.35);
}

.results-section {
  background-color: var(--dark-card);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--box-shadow);
  display: none;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.results-section.active {
  display: block;
  animation: slideUpFade 0.8s forwards;
}

.nutrition-card {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
}

.nutrient {
  flex: 1;
  min-width: 120px;
  background-color: var(--dark-section);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  transition: all 0.5s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(20px);
  animation-name: fadeInStaggered;
  animation-duration: 0.5s;
  animation-fill-mode: forwards;
  animation-timing-function: ease-out;
}

.nutrient:nth-child(1) { animation-delay: 0.1s; }
.nutrient:nth-child(2) { animation-delay: 0.2s; }
.nutrient:nth-child(3) { animation-delay: 0.3s; }
.nutrient:nth-child(4) { animation-delay: 0.4s; }
.nutrient:nth-child(5) { animation-delay: 0.5s; }
.nutrient:nth-child(6) { animation-delay: 0.6s; }

.nutrient:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.nutrient-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
  margin: 5px 0;
}

.nutrient-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.food-preview {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #333;
  animation: fadeIn 0.8s forwards;
}

.food-details h3 {
  margin-top: 0;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 20px;
}

.food-details p {
  margin: 0;
  color: #ffffff;
  font-size: 15px;
}

@media (max-width: 768px) {
  .nutrient {
    min-width: 100px;
  }
}

.loading {
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  right: 10px;
  margin-top: -10px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  color: #d32f2f;
  background-color: rgba(211, 47, 47, 0.1);
  padding: 10px;
  border-radius: var(--border-radius);
  margin-top: 10px;
  display: none;
  border-left: 4px solid #d32f2f;
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.food-options {
  margin-top: 15px;
  display: none;
  animation: growDown 0.4s ease-out forwards;
}

.food-option {
  padding: 12px;
  background-color: var(--dark-section);
  border-radius: var(--border-radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
  color: #ffffff;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
  animation-delay: calc(var(--i, 0) * 0.05s);
}

.food-option:hover {
  background-color: #333;
  transform: translateX(5px);
}

.recent-searches {
  margin-top: 15px;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s forwards;
  animation-delay: 0.4s;
}

.recent-searches h3 {
  color: var(--accent);
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 600;
}

.recent-btn {
  background-color: var(--dark-section);
  border: none;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  margin: 5px;
  margin-bottom: 15px;
  font-size: 14px;
  transition: all 0.3s;
  color: #ffffff;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.recent-btn:hover {
  background-color: #333;
  transform: translateY(-2px);
}

/* Ripple effect for buttons */
.recent-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%);
  transform-origin: 50% 50%;
}

.recent-btn:hover::after {
  animation: ripple 0.6s ease-out;
}

/* Fix for Nutrition Facts header */
.results-section h3 {
  color: var(--accent);
  margin-bottom: 15px;
  font-size: 20px;
  font-weight: 600;
}

/* Additional styles for nutrition facts breakdown */
.nutrition-info p {
  color: #ffffff;
  font-size: 15px;
  margin-bottom: 8px;
  line-height: 1.5;
}

/* Improve visibility of section headers */
.section-title {
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  margin: 15px 0 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 5px;
}

/* Improve table readability if present */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}

th, td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #ffffff;
}

th {
  color: var(--accent);
  font-weight: 600;
}

/* Scroll animation observer */
.scroll-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease-out;
}

.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Animation keyframes */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes growDown {
  from {
    transform: scaleY(0);
    transform-origin: top;
  }
  to {
    transform: scaleY(1);
    transform-origin: top;
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@keyframes fadeInStaggered {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  20% {
    transform: scale(25, 25);
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: scale(40, 40);
  }
}

