/* NutriGuru hosted layout fixes v1.
   Presentation-only: stabilises narrow form columns and gives NG Coach
   responses the full readable width available beside the avatar. */

/* Add-meal form: keep the photo/AI card header from squeezing its copy into
   a one-word column when badges are present on the right. */
#screenContent:has(#mealName) > .fade-in-up {
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: 0 auto;
  padding-left: clamp(14px, 4vw, 24px) !important;
  padding-right: clamp(14px, 4vw, 24px) !important;
  box-sizing: border-box;
}

#screenContent:has(#mealName) .ng-card {
  min-width: 0;
  box-sizing: border-box;
}

#screenContent:has(#mealName) .ng-card > .flex.items-start.justify-between {
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 12px;
}

#screenContent:has(#mealName) .ng-card > .flex.items-start.justify-between > div:first-child {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
}

#screenContent:has(#mealName) .ng-card > .flex.items-start.justify-between > div:last-child {
  display: flex;
  flex: 1 1 100%;
  width: 100%;
  max-width: none;
  min-width: 0;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

#screenContent:has(#mealName) .ng-card > .flex.items-start.justify-between > div:last-child > span {
  max-width: 100%;
  min-width: 0;
}

#screenContent:has(#mealName) .ng-card:has(#foodPhotoCameraInput) .border-dashed,
#screenContent:has(#mealName) .ng-card:has(#foodPhotoCameraInput) .grid {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#screenContent:has(#mealName) .ng-card:has(#foodPhotoCameraInput) button {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* NG Coach: an assistant answer uses all available width beside its icon.
   The user bubble keeps its original compact, right-aligned appearance. */
#screenContent:has(#coachPage) .coach-message-ai,
#screenContent:has(#chatMessages) #chatMessages > .flex:not(.justify-end) {
  width: 100%;
  min-width: 0;
  align-items: flex-start;
}

#screenContent:has(#coachPage) .coach-message-ai > .coach-bubble-ai,
#screenContent:has(#chatMessages) #chatMessages > .flex:not(.justify-end) > .chat-bubble-ai {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}

#screenContent:has(#coachPage) #chatMessages .ai-response,
#screenContent:has(#chatMessages) #chatMessages .ai-response {
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}

#screenContent:has(#coachPage) #chatMessages .ai-response-section,
#screenContent:has(#chatMessages) #chatMessages .ai-response-section {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Food photo actions: the shared alignment layer keeps most controls on one
   line, but these two labels must remain fully readable on narrow phones. */
#screenContent .ng-food-photo-button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 78px !important;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 11px 7px !important;
  border: 1px solid rgba(255, 216, 157, .62) !important;
  border-radius: 18px !important;
  background: linear-gradient(135deg, #ffd080, #ff8a00) !important;
  color: #241506 !important;
  box-shadow: 0 9px 22px rgba(255, 158, 47, .22), inset 0 1px 0 rgba(255,255,255,.48) !important;
  line-height: 1.18 !important;
  text-align: center !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: normal !important;
}

#screenContent .ng-food-photo-button:hover,
#screenContent .ng-food-photo-button:focus-visible {
  background: linear-gradient(135deg, #ffda92, #ff980f) !important;
  color: #241506 !important;
  border-color: rgba(255, 231, 190, .84) !important;
  box-shadow: 0 11px 26px rgba(255, 158, 47, .30), inset 0 1px 0 rgba(255,255,255,.56) !important;
  outline: none;
}

#screenContent .ng-food-photo-button > i {
  flex: 0 0 auto;
  margin: 0 !important;
  font-size: 22px !important;
  line-height: 1 !important;
}

#screenContent .ng-food-photo-button > span {
  display: block;
  width: 100%;
  min-width: 0;
  color: inherit;
  font-size: clamp(12px, 3.65vw, 15px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: anywhere !important;
}

@media (min-width: 640px) {
  #screenContent .ng-food-photo-button {
    min-height: 82px !important;
  }

  #screenContent .ng-food-photo-button > span {
    font-size: 15px;
  }
}

@media (max-width: 430px) {
  #screenContent:has(#mealName) > .fade-in-up {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #screenContent:has(#mealName) .ng-card > .flex.items-start.justify-between > div:last-child > span {
    flex: 1 1 100%;
  }

  #screenContent:has(#coachPage) .coach-bubble-ai,
  #screenContent:has(#chatMessages) #chatMessages .chat-bubble-ai {
    font-size: 15px;
    line-height: 1.58;
  }
}

@media (prefers-reduced-motion: reduce) {
  #screenContent:has(#coachPage) .coach-bubble-ai,
  #screenContent:has(#chatMessages) #chatMessages .chat-bubble-ai {
    scroll-behavior: auto;
  }
}
