@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Work+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #EDEFE6;
  font-family: 'Work Sans', sans-serif;
  color: #223B2B;
}

button, input, select { font-family: inherit; }
button { cursor: pointer; }

header {
  background: #223B2B;
  padding: 28px 20px 32px;
}
.header-inner { max-width: 880px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { flex-shrink: 0; }
h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 30px;
  color: #F4F6EE;
  margin: 0;
  letter-spacing: -0.01em;
}
.tagline { color: #B9C9B4; margin-top: 6px; font-size: 14.5px; }

main { max-width: 880px; margin: -16px auto 0; padding: 0 20px 48px; }

.form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #FFFFFF;
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(34,59,43,0.10);
  margin-bottom: 28px;
}
.form input, .form select {
  border: 1.5px solid #DCE3D6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14.5px;
  background: #FBFCF9;
  color: #223B2B;
  outline: none;
}
.form input[name="name"] { flex: 1 1 160px; }
.form input[name="quantity"] { width: 64px; font-family: 'IBM Plex Mono', monospace; }
.form input[name="expiry"] { width: 140px; }
#add-btn {
  background: #E3A72E;
  color: #2A2110;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 20px;
}
.banner.error { background: #FBEAE6; color: #8A3B2E; }
.banner.info { background: #FCF3E3; color: #8A6412; }

.shelves { display: flex; flex-direction: column; gap: 26px; }
.empty { text-align: center; color: #7C8F79; font-size: 14.5px; padding: 40px 0; }

.shelf { position: relative; padding-bottom: 18px; }
.shelf-label {
  display: flex; align-items: center; gap: 7px;
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 15.5px;
  color: #3E5A44; margin-bottom: 12px;
}
.items-row { display: flex; flex-wrap: wrap; gap: 10px; }
.item-card {
  position: relative;
  background: #FFFFFF;
  border: 1px solid #E2E8DB;
  border-radius: 12px;
  padding: 12px 14px 10px;
  min-width: 140px;
  box-shadow: 0 2px 6px rgba(34,59,43,0.06);
}
.item-card.expiring { border-color: #E3A72E; }
.item-card.expired { border-color: #D65A45; background: #FBF1EF; }
.item-card.selected { border-color: #223B2B; box-shadow: 0 0 0 1px #223B2B; }

.delete-btn {
  position: absolute; top: 6px; right: 6px;
  background: transparent; border: none; color: #B7C2B1;
  padding: 3px; border-radius: 6px; display: flex;
}
.item-name { font-size: 14px; font-weight: 500; margin-bottom: 6px; padding-right: 14px; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.qty-btn {
  background: #F0F3EA; border: 1px solid #DCE3D6; border-radius: 6px;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  color: #3E5A44;
}
.qty-value { font-family: 'IBM Plex Mono', monospace; font-size: 13px; min-width: 44px; text-align: center; }
.qty-unit { color: #8A9985; font-size: 11px; }
.expiry-tag { font-size: 11.5px; }
.expiry-tag.expiring { color: #A87A15; }
.expiry-tag.expired { color: #B8402E; font-weight: 600; }
.expiry-tag.ok { color: #8A9985; }

.shelf-edge {
  position: absolute; bottom: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(180deg, #C9D4C0, transparent);
  border-radius: 4px;
}

.recipe-section { margin-top: 36px; text-align: center; }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
  text-align: left;
}
.recipe-card {
  background: #FFFFFF; border: 1px solid #E2E8DB; border-radius: 14px;
  padding: 18px; box-shadow: 0 4px 14px rgba(34,59,43,0.08);
}
.recipe-card h3 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; margin: 0 0 6px;
}
.match-badge {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  background: #EAF1E5; color: #3E5A44; border-radius: 999px;
  padding: 3px 9px; margin-bottom: 10px;
}
.recipe-card ol { font-size: 13.5px; padding-left: 18px; margin: 0 0 10px; color: #3A4B39; }
.missing { font-size: 12.5px; background: #FCF3E3; color: #8A6412; border-radius: 8px; padding: 6px 10px; }
.missing b { font-weight: 600; }

@media (max-width: 480px) {
  h1 { font-size: 26px; }
  .form { padding: 12px; }
}

/* Barre d'outils fusionnée : sélection + filtre + tri */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid #E2E8DB;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #5C6F58;
}
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar button,
.toolbar select {
  border: 1px solid #DCE3D6;
  background: #F0F3EA;
  color: #223B2B;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
}

.item-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  accent-color: #223B2B;
}
.item-card { padding-left: 30px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34,59,43,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-box {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  margin: 0;
  color: #223B2B;
}
#close-modal-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: #7C8F79;
  padding: 4px;
}
.modal-hint { font-size: 13px; color: #5C6F58; margin: 0; }
#prompt-text {
  flex: 1;
  min-height: 220px;
  resize: vertical;
  border: 1.5px solid #DCE3D6;
  border-radius: 10px;
  padding: 12px;
  font-size: 13.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: #223B2B;
  background: #FBFCF9;
}
#copy-textarea-btn {
  background: #E3A72E;
  color: #2A2110;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 14.5px;
}
.copy-feedback { font-size: 12.5px; color: #3E5A44; min-height: 16px; margin: 0; }

#scan-btn {
  background: #3E5A44;
  color: #F4F6EE;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14.5px;
}
.scan-box { max-width: 420px; }
#scan-video {
  width: 100%;
  border-radius: 12px;
  background: #111;
  max-height: 60vh;
}
.scan-status { font-size: 13px; color: #5C6F58; text-align: center; margin: 4px 0 0; }

.date-sorted { display: flex; flex-direction: column; gap: 8px; }
.date-item-row { position: relative; }
.date-item-row .item-card { min-width: 100%; }
.date-item-cat {
  position: absolute;
  top: 10px;
  right: 32px;
  font-size: 15px;
}

/* Groupe de 3 boutons harmonisés (Prompt IA / Idées recettes / Pinterest),
   répété en haut et en bas de la page. */
.action-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.action-group button {
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  background: #223B2B;
  color: #F4F6EE;
  box-shadow: 0 3px 10px rgba(34,59,43,0.18);
}
