/* Thème repris de landing/index.html : fond indigo profond, texte blanc,
   texte secondaire lavande, accent lavande clair (couleur des traits du
   logo animé). */
:root {
  --bg: #3E3894;
  --text: #ffffff;
  --text-muted: #c6c2f0;
  --accent: #8f89d6;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.16);
  --price: #8be7ab;
  --danger: #ff9a9a;
}

* { box-sizing: border-box; }

/* L'attribut natif "hidden" doit toujours l'emporter, même sur un élément
   dont une classe fixe déjà display: flex (ex. .authStep, .inlineForm,
   .totalBox) — sans ce !important, la règle de la classe gagne et
   l'élément reste visible malgré "hidden". */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.view { min-height: 100vh; }
.view[hidden] { display: none; }

/* ---------- Écran de connexion ---------- */

.authView {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.authCard {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.authLogo { width: 96px; height: 96px; }
.authWordmark { width: 180px; height: auto; margin-bottom: 8px; }

.authStep {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.authStep h1 {
  font-size: 20px;
  margin: 0;
}

.authHint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 4px;
}

.authInput {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 14px 16px;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.02em;
}
.authInput::placeholder { color: rgba(255, 255, 255, 0.4); }
.authInput:focus { outline: none; border-color: var(--accent); }

.authError {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

/* ---------- Boutons ---------- */

.btnPrimary {
  background: #ffffff;
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
}
.btnPrimary:active { opacity: 0.85; }
.btnPrimary:disabled { opacity: 0.5; cursor: default; }

.btnSmall { padding: 9px 14px; border-radius: 999px; font-size: 14px; }

.btnLink {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}
.btnLink:hover { color: var(--text); }

/* ---------- App ---------- */

.appViewRoot {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.appHeader {
  display: flex;
  align-items: center;
  gap: 12px;
}

.headerLogo { width: 34px; height: 34px; flex-shrink: 0; }

.headerGreeting {
  flex: 1;
  font-size: 14px;
  color: var(--text-muted);
}
.headerGreeting strong { color: var(--text); }

/* ---------- Listes (chips) ---------- */

.chipsRow {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.chipsRow::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: #ffffff;
  color: var(--bg);
  border-color: #ffffff;
}
.chip.addChip {
  border-style: dashed;
  color: var(--text-muted);
  background: transparent;
}

.listPrivacy {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.listPrivacy .dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--text-muted);
  flex-shrink: 0;
}

.inlineForm {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inlineInput {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--text);
}
.inlineInput::placeholder { color: rgba(255, 255, 255, 0.4); }
.inlineInput:focus { outline: none; border-color: var(--accent); }

/* ---------- Total estimé ----------
   Volontairement discret : un simple libellé, sans carte ni contour, pour
   ne pas rivaliser visuellement avec la liste d'articles. */

.totalBox {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px;
}
.totalLabel { font-size: 12px; color: var(--text-muted); }
.totalValue { font-size: 13px; font-weight: 600; color: var(--text-muted); }

/* ---------- Liste d'articles ---------- */

.itemsList {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.itemRow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}

.itemCheckbox {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.itemCheckbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.itemCheckbox svg { display: none; width: 14px; height: 14px; }
.itemCheckbox.checked svg { display: block; }

.itemThumb {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.itemThumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.itemThumb .initial {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.itemRow.checked .itemThumb { opacity: 0.5; }

.itemBody {
  flex: 1;
  min-width: 0;
  cursor: default;
}
.itemBody.linkable { cursor: pointer; }

.itemName {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.itemRow.checked .itemName {
  text-decoration: line-through;
  color: var(--text-muted);
}

.itemMeta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.itemMeta .price { color: var(--price); font-weight: 600; }

.itemDelete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px;
  border-radius: 999px;
}
.itemDelete:hover { color: var(--danger); }

/* Édition inline (renommage) — identique visuellement à l'ajout */
.itemEditInput {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 16px;
}
.itemEditInput:focus { outline: none; }

.emptyState {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
}

/* ---------- Ajout d'article + suggestions ---------- */

.addRow {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding-top: 12px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.addInputWrap { flex: 1; position: relative; }

.addInput,
.rowEditWrap .itemEditInput {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 14px 16px;
  color: var(--text);
}
.addInput::placeholder { color: rgba(255, 255, 255, 0.4); }
.addInput:focus { outline: none; border-color: var(--accent); }

.suggestions,
.editSuggestions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  background: #4d46ac;
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 5;
}
.editSuggestions { position: static; margin-top: 6px; box-shadow: none; }

.suggestionItem {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}
.suggestionItem:last-child { border-bottom: none; }
.suggestionItem:hover { background: rgba(255, 255, 255, 0.08); }
.suggestionItem .price { color: var(--price); font-weight: 600; margin-left: 6px; }

@media (min-width: 480px) {
  .authLogo { width: 110px; height: 110px; }
  .authWordmark { width: 210px; }
}
