/* Shopping Assistant v1 — стили */

:root {
  --bg: #f5f1e8;
  --bg-gradient: radial-gradient(ellipse at top, #fbf6ea 0%, #f1ecde 100%);
  --surface: #ffffff;
  --surface-soft: #faf7f0;
  --border: #e7e0cf;
  --border-strong: #d8cfb6;

  --text: #243b2b;
  --text-muted: #6b7a6f;
  --text-faint: #98a39a;

  --primary: #2d6a4f;
  --primary-dark: #1f4d39;
  --primary-soft: #e3efe8;
  --accent: #d97706;
  --accent-soft: #fcefd9;
  --danger: #b73e3e;
  --danger-soft: #fbe5e1;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(36, 59, 43, 0.04), 0 1px 6px rgba(36, 59, 43, 0.05);
  --shadow-md: 0 4px 16px rgba(36, 59, 43, 0.06), 0 2px 6px rgba(36, 59, 43, 0.04);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text",
          "Helvetica Neue", "Inter", "PT Sans", "Arial", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-gradient);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { padding: 16px; }

button { font-family: inherit; cursor: pointer; }

/* ===== Каркас ===== */
.layout {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.topbar__brand {
  display: flex; align-items: center; gap: 10px;
}
.topbar__icon { font-size: 24px; }
.topbar__title {
  margin: 0; font-size: 18px; font-weight: 700; color: var(--primary-dark);
  letter-spacing: -0.01em;
}

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: transparent; border: none;
  padding: 8px 14px;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--surface-soft); }
.tab.is-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.tab__count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: 1px;
}
.tab.is-active .tab__count { background: var(--primary); color: #fff; }

/* ===== Main ===== */
.main { flex: 1; display: flex; flex-direction: column; }
.view { display: none; flex: 1; }
.view.is-active { display: flex; flex-direction: column; }

/* ===== Чат ===== */
.view--chat { gap: 12px; }

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  min-height: 200px;
  max-height: 60vh;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg--user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg--assistant {
  align-self: flex-start;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg--assistant strong { color: var(--primary-dark); }
.msg--assistant em { color: var(--text-muted); font-style: normal; }

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.composer__input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 10px;
  max-height: 120px;
  min-height: 24px;
  color: var(--text);
}
.composer__input::placeholder { color: var(--text-faint); }
.composer__send {
  flex: 0 0 auto;
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.composer__send:hover { background: var(--primary-dark); }
.composer__send:disabled { background: var(--text-faint); cursor: not-allowed; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.suggestions__label { color: var(--text-faint); font-size: 13px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 999px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary-soft);
}

/* ===== Список ===== */
.list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  max-height: 65vh;
}
.cat-group { display: flex; flex-direction: column; gap: 6px; }
.cat-group__title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.cat-item__check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.cat-item__check::after {
  content: "";
  width: 10px; height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform .15s;
}
.cat-item.is-purchased .cat-item__check {
  background: var(--primary); border-color: var(--primary);
}
.cat-item.is-purchased .cat-item__check::after { transform: rotate(-45deg) scale(1); }
.cat-item__body { flex: 1; font-size: 15px; }
.cat-item__name { font-weight: 500; }
.cat-item__meta { color: var(--text-faint); font-size: 13px; margin-left: 6px; }
.cat-item__qty {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}
.cat-item.is-purchased .cat-item__name {
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
  color: var(--text-faint);
}

.list-empty, .history-empty, .prefs-empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
}
.list-empty__icon { font-size: 40px; margin-bottom: 8px; }
.list-empty__title { margin: 0 0 4px; color: var(--text); font-weight: 600; }
.list-empty__text { margin: 0; font-size: 14px; }

.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 4px 0;
  margin-top: 12px;
}
.list-footer__summary { color: var(--text-muted); font-size: 13px; }
.list-footer__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }

/* ===== Сноска ===== */
.footnote {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  margin: 12px 0 0;
}

/* ===== Адаптив ===== */
@media (max-width: 720px) {
  body { padding: 10px; }
  .topbar { padding: 10px 12px; }
  .topbar__title { font-size: 16px; }
  .tab { padding: 6px 10px; font-size: 13px; }
  .msg { max-width: 90%; }
}

@media (max-width: 480px) {
  .tab__count { display: none; }
}
