@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');

html, body {
  max-width: 430px;
  margin: 0 auto;
  background-color: #f5f7fa; /* Couleur de fond de base */
  font-family: 'Montserrat', Arial, sans-serif;
  color: #1A2238;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-x: hidden;
}

body {
  padding-bottom: 80px;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* Colonnes: Gauche, Centre (taille auto), Droite */
  align-items: center; /* Centre verticalement tous les éléments du header */
  padding: 0.5rem 1.2rem; /* Padding de base pour mobile */
  box-shadow: 0 4px 16px -4px #0002;
  background: #fff;
  color: #333; /* Assure que le texte dans le header est toujours lisible */
}

.header-logo-container {
  grid-column: 1;
  justify-self: start; /* Aligne le logo à gauche de sa colonne */
}

.header-nav {
  grid-column: 2;
  justify-self: center; /* Centre la navigation dans la colonne du milieu */
  display: flex;
  gap: 25px; /* Espace entre les liens de navigation */
  position: relative;
  top: 1.5px; /* Ajustement manuel pour un alignement optique parfait avec le bouton Google */
}

.header-nav-link {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  font-size: 0.9rem;
}

.app-logo {
  height: auto;
  width: auto;
  max-width: 90px;
  max-height: 1.8rem;
  display: block;
  position: relative;
  bottom: 1.5px; /* Ajustement pour remonter légèrement le logo */
  /* La marge n'est plus nécessaire grâce à l'alignement central */
  filter: drop-shadow(0 2px 8px rgba(230, 192, 107, 0.2));
}

#auth-section {
  grid-column: 3;
  justify-self: end; /* Aligne la section d'authentification à droite */
}

.info-counters {
    margin: 1.5rem 0;
  text-align: center;
  font-size: 0.9em;
}

#accessible-aliments-counter {
  margin-top: 5px;
}

.bilan-card {
  background: transparent;
  border-radius: 0;
  padding: 1.2rem 0.5rem 0.5rem 0.5rem;
  box-shadow: none;
  margin-bottom: 1.2rem;
  display: block;
  border: none;
}
.bilan-card h2 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: #1A2238;
  font-weight: 600;
  letter-spacing: normal;
}
.bilan-score {
  font-size: 2.4rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #E6C06B;
  text-shadow: 0 2px 8px #E6C06B22;
  text-align: center;
}
.bilan-value {
  border-radius: 1rem;
  padding: 0.5rem 1.2rem;
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 700;
  background: #F5F7FA;
  color: #1A2238;
  border: 1.5px solid #E6C06B33;
  margin: 0 auto;
}
.bilan-anti { background: #e8fbe8; color: #6FCF97; border-color: #6FCF9733; }
.bilan-moderate { background: #fffbe0; color: #E6C06B; border-color: #E6C06B33; }
.bilan-pro { background: #ffe0e0; color: #c0392b; border-color: #c0392b33; }
.bilan-label {
  display: block;
  font-size: 1.1rem;
  margin-top: 0.2rem;
  font-weight: 500;
  color: #6FCF97;
}
.bilan-bar {
  background: #eee;
  border-radius: 1rem;
  height: 12px;
  margin: 1rem 0;
  width: 100%;
  max-width: 350px;
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
  border: 1.5px solid #E6C06B33;
}
.bilan-bar-inner {
  background: linear-gradient(90deg, #6FCF97 0%, #E6C06B 50%, #1A2238 100%);
  height: 100%;
  border-radius: 1rem;
  transition: width 0.5s;
}

.search-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}
.search-label {
  font-size: 1.1rem;
  font-weight: 500;
  color: #1A2238;
  margin-bottom: 0.5rem;
}
.input__container {
  position: relative;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border-radius: 22px;
  max-width: 300px;
  margin: 0 auto 1.2rem auto;
  box-shadow: none;
  width: 90%;
  transition: transform 400ms;
  transform-style: preserve-3d;
  /* Optionnel : effet 3D léger */
  /* transform: rotateX(8deg) rotateY(-10deg); */
  perspective: 500px;
  min-height: 48px;
}
.shadow__input {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  bottom: 0;
  z-index: -1;
  border-radius: 20px;
  background: linear-gradient(270deg, #6FCF97, #E6C06B, #1A2238, #6FCF97);
  background-size: 400% 400%;
  animation: shadowAnim 6s linear infinite;
  opacity: 0.7;
}
@keyframes shadowAnim {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.input__button__shadow {
  cursor: pointer;
  border: none;
  background: none;
  transition: transform 400ms, background 400ms;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  padding: 5px;
}
.input__button__shadow:hover {
  background: rgba(255, 255, 255, 0.25);
}
.searchbox-group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 340px;
  margin: 0 auto 1rem auto;
  background: #fff;
  border-radius: 2rem;
  box-shadow: 0 2px 8px #0001;
  padding: 0.2rem 0.5rem;
  border: 2px solid #6FCF97;
}
.search-input {
  flex: 2 1 0;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: #1A2238;
  font-family: 'Montserrat', Arial, sans-serif;
  padding: 0.7rem 0.7rem 0.7rem 1rem;
  border-radius: 2rem;
  box-shadow: none;
}
.poids-input {
  flex: 0 0 48px;
  max-width: 48px;
  min-width: 0;
  border: none;
  outline: none;
  background: #f5f7fa;
  font-size: 1rem;
  color: #1A2238;
  font-family: 'Montserrat', Arial, sans-serif;
  padding: 0.7rem 0.3rem 0.7rem 0.3rem;
  text-align: center;
  border-radius: 1.2rem;
  box-shadow: none;
  margin-left: 0.2rem;
}
.poids-unit {
  font-size: 1rem;
  color: #888;
  margin-left: 0.2rem;
  margin-right: 0.5rem;
}
.search-input:focus, .poids-input:focus {
  background: #f8f9fa;
}
.animated-border {
  position: relative;
  z-index: 1;
  background: #fff;
}
.animated-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: 2rem;
  padding: 0;
  background: linear-gradient(90deg, #6FCF97, #E6C06B, #1A2238, #6FCF97);
  background-size: 300% 100%;
  animation: borderMove 4s linear infinite;
}
@keyframes borderMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.search-results {
  width: 100%;
  max-width: 350px;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 2px 8px #1A223810;
  margin-top: 0.2rem;
  overflow: hidden;
  z-index: 10;
  position: relative;
  border: 1.5px solid #E6C06B33;
}
.result-item {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background 0.15s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: #e8fbe8; }

.repas-section {
  overflow: visible;
}

.repas-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.clear-meal-btn {
  background: #ff6b6b;
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.85em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
  height: fit-content;
  line-height: 1.2;
}

.clear-meal-btn:hover {
  background: #ff5252;
  box-shadow: 0 3px 6px rgba(255, 107, 107, 0.4);
}
.repas-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 2rem;
  color: #1A2238;
}
.repas-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  overflow: visible;
}
.aliment-card {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(26,34,56,0.10), 0 1.5px 4px rgba(26,34,56,0.06);
  padding: 1rem;
  gap: 1rem;
  position: relative;
  border: 1.5px solid #E6C06B33;
}
.aliment-info { flex: 1; }
.aliment-name {
  font-weight: 600;
  font-size: 1.1rem;
  display: block;
  margin-bottom: 0.2rem;
  color: #1A2238;
}
.aliment-score {
  font-size: 1.1rem;
  font-weight: bold;
  margin-right: 0.5rem;
  display: inline-block;
}
.score-anti { color: #6FCF97; }
.score-moderate { color: #E6C06B; }
.score-pro { color: #c0392b; }
.aliment-caractere {
  font-size: 0.98rem;
  color: #555;
  margin-left: 0.2rem;
}
.aliment-poids {
  font-size: 0.95rem;
  color: #888;
  margin-left: 0.2rem;
}



.section-separator {
  border: none;
  border-top: 1.5px solid #e0e3e8;
  margin: 0.5rem auto 1rem auto;
  width: 40%;
}

.section-separator-full {
  border: none;
  border-top: 1.5px solid #e0e3e8;
  margin: 0;
  width: 100%;
}

.repas-section,
.bilan-card {
  margin: 0 !important;
  padding: 0 !important;
}
.repas-section h2,
.bilan-card h2 {
  display: block;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  color: #1A2238 !important;
  margin: 0 0 1rem 0 !important;
  padding-left: 1.2rem !important;
  text-align: left !important;
  letter-spacing: normal !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.empty-meal-message {
  font-size: 0.75rem !important;
  color: #888 !important;
  text-align: center !important;
  margin: 1.2rem 0 !important;
}

.aliment-card.fiche-pro {
  position: relative;
  display: flex;
  background: #f9f9fb;
  border-radius: 10px;
  margin: 1.5rem 0.7em 0.4rem 0.7em;
  padding: 0 1rem 0.7rem 1rem !important;
  box-shadow: 0 2px 8px rgba(26,34,56,0.10), 0 1.5px 4px rgba(26,34,56,0.06);
  min-height: 70px;
  border: 2px solid rgba(26, 34, 56, 0.1);
}
.fiche-aliment-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 0 !important;
}
.fiche-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.fiche-row-top {
  font-size: 0.98em;
  font-weight: 500;
  margin-top: 0.8em !important;
  margin-bottom: 2px;
  padding-top: 0 !important;
}
.fiche-row-top .aliment-name {
  font-size: 0.97em !important;
  font-weight: 600;
  color: #222 !important;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fiche-row-top .aliment-name > * {
  margin-right: 1em;
}
.fiche-row-top .aliment-name > *:last-child {
  margin-right: 0;
}
.fiche-row-top .aliment-nom,
.fiche-row-top .aliment-poids,
.fiche-row-top .score-sante-badge,
.fiche-row-top .aliment-caractere {
  margin-right: 1em;
}
.fiche-row-top .aliment-caractere {
  margin-right: 0;
}
.fiche-row-top .aliment-poids {
  margin-left: 1em;
}
.aliment-name .aliment-poids {
  font-size: 0.88em;
  color: #888;
  font-weight: 400;
  margin-left: 0.2em;
}
.score-sante-badge {
  background: none !important;
  font-weight: bold;
  border-radius: 0;
  padding: 0;
  font-size: 0.95em;
  margin-left: 0.3em;
  min-width: 0;
  text-align: left;
  box-shadow: none;
}
.fiche-row-mid {
  font-size: 0.93em;
  color: #666;
  margin-bottom: 2px;
}
.fiche-row-mid .aliment-caractere {
  font-size: 0.85em !important;
  font-weight: normal !important;
  color: #3a5fa0;
  font-style: italic;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fiche-row-mid .aliment-poids {
  font-size: 0.91em;
  color: #888;
  margin-left: 1em;
}
.fiche-row-nutri {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4em 0.7em;
  font-size: 0.91em;
  color: #555;
  margin-top: 0.5em;
}
.nutri-badge {
  background: #ececec;
  border-radius: 6px;
  padding: 0 6px;
  margin-right: 0;
  font-size: 0.91em;
  text-align: center;
}
.nutri-badge.kcal { color: #b85c00; background: #fff3e0; }
.nutri-badge.prot { color: #1a7f4f; background: #e0f7e9; }
.nutri-badge.gluc { color: #1a5fb8; background: #e0e7f7; }
.nutri-badge.lip { color: #b81a1a; background: #f7e0e0; }
.nutri-badge.fibres { color: #4e1ab8; background: #ede0f7; }
.nutri-badge.ags {
  text-transform: lowercase;
}
.btn-delete {
  position: absolute;
  top: 7px;
  right: 10px;
  background: none;
  border: none;
  color: #c33;
  font-size: 0.9em;
  cursor: pointer;
  padding: 0 4px;
  z-index: 2;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.btn-delete:hover {
  opacity: 1;
  color: #a00;
}
.inflam-label {
  font-size: 0.91em;
  color: #888;
  font-weight: 500;
  margin-right: 0.3em;
}
.fiche-separator {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, #bbb 0%, #eee 100%);
  margin: 0.8em 0;
  opacity: 0.6;
  border: none;
  margin: 0.05em 0 0.4em 0;
}
.aliment-card.fiche-pro .btn-delete {
  top: 0.2em !important;
  right: 0.2em !important;
}

/* Masquer les flèches de l'input number pour tous les navigateurs */
input[type=number].poids-input::-webkit-inner-spin-button, 
input[type=number].poids-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number].poids-input {
  -moz-appearance: textfield; /* Firefox */
}



@media (max-width: 600px) {
  html, body { max-width: 100%; }
  .bilan-card, .repas-section, .search-section { margin: 1rem 0.2rem; }
  .aliment-card.fiche-pro { padding: 0.7rem; }
  .aliment-info-compact .aliment-name {
    font-size: 0.89em;
  }
  .fiche-row-top .aliment-name { font-size: 0.93em}
  .score-sante-badge { font-size: 0.91em; min-width: 26px; }
} 

.aliment-card.collapsed {
  background: #fff;
  border-radius: 0.8rem;
  box-shadow: 0 1px 3px #1A22380A;
  opacity: 0.98;
  padding: 0 0.7rem;
  margin: 1.5rem 0.7em 0.1rem 0.7em;
  min-height: 1.5rem;
  max-height: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  overflow: visible;
  transition: box-shadow 0.2s, background 0.2s, opacity 0.2s;
  position: relative;
  border: 2px solid rgba(26, 34, 56, 0.1);
}


.aliment-card.collapsed .fiche-row.fiche-row-top {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  height: 100%;
  justify-content: flex-start;
  transform: translateY(0.25rem);
}


.aliment-card.collapsed .aliment-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  font-size: 0.97em;
  color: #1A2238;
  text-align: left;
  width: 100%;
  height: 100%;
  background: none;
} 

.aliment-card.collapsed .btn-delete {
  top: 0em !important;
  right: 0.2em !important;
}



.caractere-inflammatoire-zone {
  position: absolute;
  top: -1rem;
  left: 10%;
  right: 10%;
  height: 1rem;
  border: 2px solid rgba(26, 34, 56, 0.15);
  border-bottom: none;
  border-radius: 0.8rem 0.8rem 0.6rem 0.6rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.7em;
  color: #3a5fa0;
  font-style: italic;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 25;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
  background: #ffffff;
}

/* Styles pour le nouveau bilan */
.bilan-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(26,34,56,0.10), 0 1.5px 4px rgba(26,34,56,0.06);
  padding: 1.5rem;
  margin: 0.7rem;
  border: 2px solid #E6C06B33;
}

.bilan-main-score {
  text-align: center;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 0.8rem;
  border: 1px solid #e9ecef;
}

.bilan-main-score.single-score {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80px; /* Give it some height to make centering visible */
}

.bilan-nutrition {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bilan-nutri-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.bilan-nutri-item {
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.9em;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 2.5rem;
}

.bilan-nutri-item.kcal { background: #fff3e0; color: #b85c00; }
.bilan-nutri-item.prot { background: #e0f7e9; color: #1a7f4f; }
.bilan-nutri-item.gluc { background: #e0e7f7; color: #1a5fb8; }
.bilan-nutri-item.lip { background: #f7e0e0; color: #b81a1a; }
.bilan-nutri-item.sucres { background: #fff0e0; color: #b85c00; }
.bilan-nutri-item.fibres { background: #ede0f7; color: #4e1ab8; }
.bilan-nutri-item.ags { background: #ffe0e0; color: #c0392b; }
.bilan-nutri-item.sel { background: #e0f0f7; color: #1a5fb8; }





/* Centering for analyze button and spacing for bilan */
.analyze-btn-container {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}

#analyze-meal-btn {
  display: none; /* Hidden by default, shown by JS */
  padding: 12px 28px;
  font-size: 1.15rem;
  font-weight: 600;
  border-radius: 25px;
  cursor: pointer;
  background: #6FCF97;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(111, 207, 151, 0.4);
  transition: all 0.3s ease;
}

#analyze-meal-btn:hover {
  background: #5ebc88;
  box-shadow: 0 6px 16px rgba(111, 207, 151, 0.5);
  transform: translateY(-2px);
}

section#bilan-card {
    margin-top: 35px !important;
}

/* Styles spécifiques pour les écrans plus larges (vue "ordinateur") */
@media (min-width: 601px) {
  .app-header {
    padding: 1rem 1.2rem; /* On redonne de la hauteur au header sur les grands écrans */
  }
}

/* --- Authentication Buttons & Profile --- */

/* Google Login Button (Circular) */
.google-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s, background-color 0.2s;
}

.google-login-btn:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  background-color: #f8f9fa;
}

.google-login-btn svg {
  width: 22px;
  height: 22px;
}

/* User Profile (when logged in) */
.user-profile {
  display: flex;
  align-items: center;
  min-width: 0;
  position: relative; /* Ancre pour le menu déroulant */
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #4285f4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer; /* Indique que l'élément est cliquable */
  transition: box-shadow 0.2s;
}

.user-avatar:hover {
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}

/* Le menu déroulant */
.user-dropdown {
  display: none; /* Caché par défaut */
  position: absolute;
  top: 120%; /* Positionné sous l'avatar */
  right: 0;
  background-color: white;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 100;
  border-radius: 8px;
  border: 1px solid #eee;
  padding: 0.5rem 0;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown.show {
  display: block; /* Affiche le menu */
}

.dropdown-user-info {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 0.5rem;
}

.dropdown-user-info .user-name {
  font-weight: 600;
  color: #333;
  display: block;
}

.dropdown-user-info .user-email {
  font-size: 0.85rem;
  color: #777;
  display: block;
}

.logout-btn {
  background: none;
  border: none;
  color: #d32f2f; /* Rouge pour une action de déconnexion */
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
  display: block; /* Prend toute la largeur */
  width: 100%;
  text-align: left;
  font-weight: 500;
}

.logout-btn:hover {
  background-color: #fbebeb;
}