/* Același aspect ca aplicația de telefon (android/.../ui/Design.kt): verdele și crem-ul ei, banda verde de sus
   cu colțurile de jos rotunjite, carduri albe rotunjite, pozele 3D ale categoriilor, insignele colorate cu text. */
:root {
  --primary: #4a6b35;
  --on-primary: #ffffff;
  --primary-container: #d7e7c2;
  --on-primary-container: #142106;
  --secondary-container: #f3ddb8;
  --on-secondary-container: #2b1a00;
  --bg: #f4f0e4;
  --fg: #1c1c16;
  --muted: #4a473c;
  --outline: #9e9884;
  --line: #d6d0be;
  --card: #ffffff;
  --card-low: #fbf8ef;
  --container: #f1ecdf;
  --container-high: #eae4d5;
  --header: var(--primary);
  --on-header: var(--on-primary);
  --error: #b3261e;
  /* §6.1 [M15] cod de culori, comun cu mobilul */
  --red: #c62828;
  --orange: #e67e22;
  --yellow: #d4a017;
  --green: #2e7d32;
  --grey: #8a8a85;
  --shadow: 0 1px 2px rgba(40, 36, 20, 0.08), 0 1px 3px rgba(40, 36, 20, 0.06);
  --radius: 20px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #b4d49a; --on-primary: #213610; --primary-container: #344f22; --on-primary-container: #d0f0b4;
    --secondary-container: #5b4319; --on-secondary-container: #f3ddb8;
    --bg: #14160f; --fg: #e5e2d8; --muted: #c6c8b8; --outline: #8f9283; --line: #45483c;
    --card: #1c1f17; --card-low: #1a1c15; --container: #20231b; --container-high: #2a2d25;
    --header: var(--primary-container); --on-header: var(--on-primary-container);
    --error: #ffb4ab; --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 Roboto, "Google Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* Banda verde de sus, ca HeaderBand pe telefon. */
header {
  background: var(--header);
  color: var(--on-header);
  border-radius: 0 0 28px 28px;
  padding: 14px 24px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: 0.01em; }
header h1 a { color: inherit; text-decoration: none; }
#account { display: flex; gap: 10px; align-items: center; margin-left: auto; font-size: 0.95rem; }
#account button { border-color: color-mix(in srgb, var(--on-header) 45%, transparent); color: var(--on-header); }
#account button:hover { background: color-mix(in srgb, var(--on-header) 14%, transparent); }

/* Navigarea: pastile, cea aleasă albă (ca butoanele de jos ale telefonului, cea aleasă evidențiată). */
#nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; flex: 1 1 auto; }
#nav a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--on-header);
  text-decoration: none;
  font-weight: 500;
}
#nav a:hover { background: color-mix(in srgb, var(--on-header) 14%, transparent); }
#nav a.active { background: var(--card); color: var(--primary); }
@media (prefers-color-scheme: dark) { #nav a.active { background: var(--primary); color: var(--on-primary); } }

/* Comutatorul de casă: pastilă cu fond deschis pe banda verde, casa aleasă albă (ca pe telefon). */
.site-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  margin-left: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--on-header) 16%, transparent);
}
.site-toggle button {
  border: 0;
  border-radius: 999px;
  padding: 5px 16px;
  color: var(--on-header);
  font-weight: 500;
}
.site-toggle button.active { background: var(--card); color: var(--primary); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 64px; }
h2 { font-size: 1.75rem; font-weight: 700; margin: 12px 0 16px; }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin: 24px 0 10px; }
a { color: var(--primary); }

/* Butoane: pastile, ca pe telefon. */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: transparent;
  font-weight: 500;
}
button:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover { background: color-mix(in srgb, var(--primary) 88%, black); }
button.danger { background: var(--error); border-color: var(--error); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Câmpuri: chenar rotunjit, ca OutlinedTextField. */
input, select, textarea {
  padding: 10px 14px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--card-low);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input[type=checkbox] { accent-color: var(--primary); width: 18px; height: 18px; }
input[type=search] { border-radius: 999px; background: var(--card); padding-left: 18px; }
form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input { min-width: 0; flex: 1 1 220px; }
ul { padding-left: 20px; }
li { margin: 4px 0; }
.muted { color: var(--muted); }
.error { color: var(--error); }

.title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.title h2 { margin: 12px 0; }

/* §6.1 [M15]: insignă colorată, mereu cu text (Badge pe telefon). */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.badge.red { color: var(--red); }
.badge.orange { color: var(--orange); }
.badge.yellow { color: var(--yellow); }
.badge.green { color: var(--green); }
.badge.grey { color: var(--grey); }
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.filters select, .filters input { flex: 0 1 240px; }
.filters label.check { display: inline-flex; align-items: center; gap: 6px; }

/* Carduri albe rotunjite. */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin: 12px 0;
}
.card.warn { box-shadow: inset 0 0 0 1px var(--orange), var(--shadow); }

/* Tabele (produse, categorii, locații, loturi): un card alb, rânduri despărțite fin. */
.scroll { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--container-high); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-weight: 500; font-size: 0.85rem; color: var(--muted); white-space: nowrap; background: var(--card-low); }
td.num { white-space: nowrap; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: var(--card-low); }
tr.editing td { background: var(--container); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; white-space: nowrap; }
.row-actions button { padding: 4px 12px; }

/* Formulare */
form.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; align-items: start; }
form.fields .field label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
form.fields .field label > * { color: var(--fg); font-size: 1rem; }
form.fields .field label.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 26px; color: var(--fg); }
form.fields .field input:not([type=checkbox]), form.fields .field select { width: 100%; flex: none; }
form.fields .error, form.fields .actions { grid-column: 1 / -1; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
label.check input { flex: none; min-width: 0; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Lista de cumpărături: carduri, ca pe telefon. */
ul.shopping { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
ul.shopping li { margin: 0; padding: 12px 16px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); }
ul.shopping li.done { background: var(--card-low); box-shadow: none; }
ul.shopping li.done label { text-decoration: line-through; color: var(--muted); }

/* Eticheta BIO */
.bio {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  background: #3e8e41;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}

/* ——— Ca pe ecranul Acasă / Inventar al telefonului ——— */

/* Plăcile de stare (Expiră curând, Sub minim…): colorate când au ceva, albe când sunt pe zero. */
.status-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.status-tile {
  display: block;
  text-align: left;
  border-radius: 18px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid transparent;
  box-shadow: var(--shadow);
  color: var(--muted);
}
.status-tile b { display: block; font-size: 1.6rem; line-height: 1.2; font-weight: 600; }
.status-tile.on { box-shadow: none; }
.status-tile.on.red { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.status-tile.on.orange { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); border-color: color-mix(in srgb, var(--orange) 50%, transparent); }
.status-tile.on.yellow { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 14%, transparent); border-color: color-mix(in srgb, var(--yellow) 50%, transparent); }
.status-tile.on.grey { color: var(--fg); background: var(--container); border-color: var(--line); }

/* Banda de categorii cu poze (Inventar pe telefon). */
.category-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 0 6px; }
.category-strip button {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 104px;
  padding: 8px 4px;
  border: 0;
  border-radius: 18px;
  font-size: 0.85rem;
  font-weight: 500;
}
.category-strip button span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-strip button.active .tile { box-shadow: 0 0 0 3px var(--primary); }

/* Pătratul rotunjit cu poza categoriei și insigna locului în colț (CategoryTile). */
.tile {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--container);
  display: grid;
  place-items: center;
}
.tile img.pic { width: 86%; height: 86%; object-fit: contain; }
.tile img.place {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 26px;
  height: 26px;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e2dccb;
}
.tile.all { background: var(--primary-container); color: var(--on-primary-container); font-size: 1.6rem; }

/* Produsele ca pe telefon: card cu poza categoriei, numele, detaliile și insigna (ProductCard). */
.product-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.product-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  border: 0;
  width: 100%;
  font-weight: normal;
}
.product-card:hover { background: var(--card-low); }
.product-card .body { min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.product-card .name { font-weight: 600; font-size: 1.02rem; }
.product-card .detail { font-size: 0.86rem; color: var(--muted); }
.product-card .badges { display: flex; gap: 6px; flex-wrap: wrap; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; font-size: 1.15rem; font-weight: 600; }
.section-title .count {
  font-size: 0.85rem;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

/* Ecranul de conectare: verdele logo-ului, ca pe telefon. */
.login { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px 16px; }
.login img { width: min(320px, 70vw); }

@media (max-width: 600px) {
  header { padding: 10px 16px 14px; border-radius: 0 0 22px 22px; }
  main { padding: 14px 14px 48px; }
  .product-list { grid-template-columns: 1fr; }
}
.login { background: #255339; border-radius: 28px; margin: 12px auto; max-width: 560px; color: #f6efd9; }
.login button.primary { background: #4a6b35; border-color: #4a6b35; padding: 12px 28px; font-size: 1.05rem; }
/* Poza categoriei în tabele, lângă nume. */
.with-tile { display: inline-flex; align-items: center; gap: 10px; }
.tile.small { width: 36px; height: 36px; border-radius: 11px; }
.tile.small img.place { width: 18px; height: 18px; top: -3px; right: -3px; padding: 1px; }
td.row-actions { flex-wrap: nowrap; }
ul.shopping li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
ul.shopping li .muted { font-size: 0.88rem; }

/* Legătură discretă pe ecranul de conectare („Am un cod de invitație”). */
.link-button { border: 0; background: none; color: #f6efd9; text-decoration: underline; padding: 4px 8px; font-weight: 400; }
.link-button:hover { background: none; opacity: 0.85; }
.login p { text-align: center; max-width: 440px; margin: 0; }
.login .login-legal { color: #f6efd9; font-size: 0.85rem; opacity: 0.85; margin: 0; }
.login .login-legal a { color: inherit; }

/* Comutatorul de limbă RO | EN din antet. */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--on-header) 16%, transparent); }
.lang-switch button { border: 0; border-radius: 999px; padding: 3px 10px; color: var(--on-header); font-size: 0.85rem; font-weight: 600; }
.lang-switch button.active { background: var(--card); color: var(--primary); }
#account { margin-left: 0; }
.lang-switch { margin-left: auto; }

/* „Întreabă AI-ul tău” și „Trimite lista” (pages/askai.js) */
.send-block, .send-list, .ask-ai-row, .ask-ai-apps { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.send-block { margin: 0 0 12px; }
dialog.ask-ai { max-width: min(560px, 92vw); border: 1px solid var(--outline, #ccc); border-radius: 16px; padding: 16px 20px; }
dialog.ask-ai::backdrop { background: rgb(0 0 0 / 35%); }
dialog.ask-ai pre { white-space: pre-wrap; max-height: 220px; overflow: auto; font: inherit; font-size: 0.85rem;
  background: color-mix(in srgb, var(--primary) 6%, transparent); padding: 8px 10px; border-radius: 8px; }
