/* Стили standalone-страницы HerbaBot. Значения перенесены 1:1 из утверждённого макета
   (HerbaBot Page.dc.html): цвета, радиусы, отступы и анимации не менять без нового макета. */

:root {
  --hf-accent: #2ed3b7;
  --hf-accent-dark: #217569;
  --hf-user-bubble: #15b79e;
  --hf-bot-bubble: #134e48;
  --hf-text: #0d121c;
  --hf-bg: #f8fafc;
  --hf-border: #e3e8ef;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

/* Атрибут hidden обязан побеждать display:flex из классов экранов и оверлеев */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--hf-bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--hf-text);
}

a { color: #107569; text-decoration: none; }
a:hover { color: #0a5850; }
textarea::placeholder, input::placeholder { color: #98a2b3; }

.hf-scroll::-webkit-scrollbar { width: 6px; }
.hf-scroll::-webkit-scrollbar-track { background: transparent; }
.hf-scroll::-webkit-scrollbar-thumb { background: var(--hf-border); border-radius: 24px; }

@keyframes hf-wave { 0%, 100% { transform: scaleY(.28); } 50% { transform: scaleY(1); } }
@keyframes hf-dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@keyframes hf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes hf-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes hf-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes hf-spin { to { transform: rotate(360deg); } }

/* Каркас: скроллится только лента сообщений. --hf-vh обновляет JS по visualViewport,
   чтобы композер не уезжал под клавиатуру iOS. */
.hf-app {
  height: 100dvh;
  height: var(--hf-vh, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--hf-bg);
  overflow: hidden;
}

.hf-topbar { height: 4px; background: var(--hf-accent); flex: 0 0 auto; }

/* ===== Экран регистрации ===== */

.hf-register {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px clamp(20px, 6vw, 28px) calc(32px + env(safe-area-inset-bottom));
}

.hf-register-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.hf-register-form { display: flex; flex-direction: column; }
#hf-register-form { display: flex; flex-direction: column; }

.hf-register-logo { width: 84px; height: 84px; display: block; margin-bottom: 22px; }

.hf-register-title {
  font-size: clamp(22px, 6vw, 28px);
  line-height: 1.25;
  font-weight: 600;
  color: #202939;
  margin: 0 0 10px;
  text-wrap: pretty;
}

.hf-register-subtitle {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
  color: #697586;
  margin: 0 0 26px;
  text-wrap: pretty;
}

.hf-field-label { font-size: 13px; font-weight: 600; color: #475467; margin-bottom: 6px; }

.hf-input {
  height: 52px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--hf-border);
  background: #fff;
  width: 100%;
  font-size: 16px;
  color: var(--hf-text);
  outline: none;
  margin-bottom: 4px;
}
.hf-input:focus { border-color: var(--hf-accent); }

.hf-field-error { min-height: 18px; font-size: 12px; color: #d92d20; margin-bottom: 6px; }
.hf-field-error--last { margin-bottom: 14px; }

.hf-primary-btn {
  background: var(--hf-accent);
  color: #0a2926;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hf-primary-btn:hover { background: var(--hf-accent-dark); color: #ffffff; }
.hf-primary-btn:disabled { opacity: .6; cursor: default; }

.hf-register-note { font-size: 12px; line-height: 1.5; color: #98a2b3; margin: 18px 0 0; text-wrap: pretty; }

/* ===== Экран чата ===== */

.hf-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.hf-header {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid var(--hf-border);
  padding: 10px clamp(12px, 4vw, 28px);
}

.hf-header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hf-header-profile { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hf-header-avatar { width: 42px; height: 42px; display: block; flex: 0 0 auto; }
.hf-header-titles { display: flex; flex-direction: column; min-width: 0; }

.hf-header-name {
  color: var(--hf-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hf-header-online {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #15b79e;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.hf-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #15b79e;
  display: block;
  animation: hf-pulse 2s ease-in-out infinite;
}

.hf-header-clear {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #107569;
}
.hf-header-clear:hover { background: #f1f5f9; }
.hf-header-clear img { width: 20px; height: 20px; display: block; }

/* Лента сообщений */

.hf-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.hf-messages-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(14px, 4vw, 26px) clamp(12px, 4vw, 28px) 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hf-message {
  display: flex;
  flex-direction: column;
  max-width: min(680px, 88%);
  animation: hf-rise .22s ease-out;
}
.hf-message--user { align-self: flex-end; }
.hf-message--bot { align-self: flex-start; }
.hf-message--cards { max-width: min(680px, 96%); }

.hf-bubble {
  padding: 11px 13px;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  word-break: break-word;
  text-wrap: pretty;
  color: #fff;
}
.hf-message--user .hf-bubble { background: var(--hf-user-bubble); border-radius: 14px 14px 2px 14px; }
.hf-message--bot .hf-bubble { background: var(--hf-bot-bubble); border-radius: 14px 14px 14px 2px; }

/* pre-wrap только для «сырого» текста пользователя: в HTML от marked он превратил бы
   переводы строк между тегами в лишние пустые строки */
.hf-bubble-text--plain { white-space: pre-wrap; }
.hf-bubble-text > p { margin: 0 0 8px; }
.hf-bubble-text > p:last-child { margin-bottom: 0; }
.hf-bubble-text a { color: #a7f3e5; text-decoration: underline; }

.hf-bubble-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}
.hf-bubble-images + .hf-bubble-text { margin-top: 8px; }
.hf-bubble-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #f1f5f9;
}

/* Карточки товаров в пузыре бота */

.hf-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.hf-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--hf-border);
  border-radius: 12px;
  text-decoration: none;
}
.hf-card:hover { box-shadow: 0 6px 16px -6px rgba(19, 37, 70, .28); transform: translateY(-1px); }

.hf-card-image {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--hf-bg);
  display: block;
}
.hf-card-image--empty { background: #f1f5f9; }

.hf-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hf-card-title { color: var(--hf-text); font-size: 14px; font-weight: 600; line-height: 1.3; }
.hf-card-meta { color: #697586; font-size: 12px; font-weight: 400; line-height: 1.35; }
.hf-card-action { margin-top: 4px; color: #107569; font-size: 13px; font-weight: 600; line-height: 1.3; }

/* Индикатор набора */

.hf-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--hf-bot-bubble);
  padding: 14px 15px;
  border-radius: 14px 14px 14px 2px;
}
.hf-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  display: block;
  animation: hf-dot 1.2s infinite;
}
.hf-typing span:nth-child(2) { animation-delay: .2s; }
.hf-typing span:nth-child(3) { animation-delay: .4s; }

/* Композер */

.hf-composer-area {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--hf-border);
  padding: 10px clamp(12px, 4vw, 28px) calc(10px + env(safe-area-inset-bottom));
}

.hf-composer-inner { max-width: 900px; margin: 0 auto; }

.hf-attachments { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; }

.hf-attachment { position: relative; flex: 0 0 auto; }
.hf-attachment img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  border: 1px solid var(--hf-border);
  background: #f1f5f9;
}
.hf-attachment--uploading img { opacity: .45; }

.hf-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--hf-text);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.hf-attachment-remove svg { width: 10px; height: 10px; display: block; }

.hf-composer {
  border: 1px solid var(--hf-border);
  background: var(--hf-bg);
  border-radius: 20px;
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hf-composer--recording { border-color: #fecdca; background: #fffbfa; }

.hf-textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  color: var(--hf-text);
  padding: 8px 6px 4px;
  max-height: 148px;
  overflow-y: auto;
}

.hf-recording { display: flex; align-items: center; gap: 12px; padding: 10px 6px 6px; min-height: 44px; }

.hf-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d92d20;
  display: block;
  flex: 0 0 auto;
  animation: hf-pulse 1.1s ease-in-out infinite;
}

.hf-rec-time {
  font-size: 15px;
  font-weight: 600;
  color: var(--hf-text);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.hf-rec-bars { flex: 1; display: flex; align-items: center; gap: 3px; height: 26px; overflow: hidden; }
.hf-rec-bars span {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  height: 100%;
  border-radius: 2px;
  display: block;
  transform-origin: center;
  background: var(--hf-accent);
}
.hf-composer--transcribing .hf-rec-bars span { animation: none !important; transform: scaleY(.28); }
.hf-composer--transcribing .hf-rec-dot { animation: none; opacity: .4; }

.hf-rec-hint { font-size: 13px; color: #697586; flex: 0 0 auto; }

.hf-composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hf-composer-left { display: flex; align-items: center; gap: 4px; }
.hf-composer-right { display: flex; align-items: center; gap: 8px; }

.hf-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #475467;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.hf-icon-btn:hover { background: #eef2f6; color: #107569; }
.hf-icon-btn svg { width: 17px; height: 17px; display: block; }

.hf-mic-btn--recording { background: #fee4e2; color: #d92d20; }
.hf-mic-btn--recording:hover { background: #fee4e2; color: #d92d20; }

.hf-mic-btn--busy svg { visibility: hidden; }
.hf-mic-spinner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(16, 117, 105, .25);
  border-top-color: #107569;
  animation: hf-spin .8s linear infinite;
}

.hf-rec-cancel {
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #697586;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.hf-rec-cancel:hover { background: #eef2f6; color: var(--hf-text); }

.hf-send-btn {
  height: 44px;
  min-width: 56px;
  padding: 0 16px;
  border-radius: 14px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hf-accent);
  cursor: pointer;
}
.hf-send-btn:disabled { background: #dbe3ea; cursor: not-allowed; opacity: .8; }
.hf-send-btn img { width: 20px; height: 20px; display: block; }

/* ===== Оверлеи ===== */

.hf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 18, 28, .45);
  display: flex;
  justify-content: center;
}
.hf-overlay--sheet { z-index: 50; align-items: flex-end; }
.hf-overlay--center { z-index: 60; align-items: center; padding: 24px; }

.hf-sheet {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  animation: hf-sheet .22s ease-out;
}

.hf-sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--hf-border); margin: 2px auto 12px; }

.hf-sheet-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #98a2b3;
  padding: 0 10px 8px;
}

.hf-sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 10px;
  background: transparent;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--hf-text);
  text-align: left;
}
.hf-sheet-item:hover { background: var(--hf-bg); }

.hf-sheet-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #e9fbf7;
  color: #107569;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.hf-sheet-icon svg { width: 17px; height: 17px; display: block; }

.hf-sheet-cancel {
  width: 100%;
  margin-top: 8px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid var(--hf-border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #475467;
}
.hf-sheet-cancel:hover { background: var(--hf-bg); }

.hf-dialog {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  animation: hf-rise .18s ease-out;
}

.hf-dialog-title { font-size: 18px; font-weight: 600; color: #202939; margin-bottom: 8px; }
.hf-dialog-text { font-size: 14px; line-height: 1.5; color: #697586; margin-bottom: 20px; text-wrap: pretty; }
.hf-dialog-buttons { display: flex; gap: 10px; }

.hf-dialog-cancel {
  flex: 1;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--hf-border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #475467;
}
.hf-dialog-cancel:hover { background: var(--hf-bg); }

.hf-dialog-confirm {
  flex: 1;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--hf-accent);
  color: #0a2926;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
}
.hf-dialog-confirm:hover { background: var(--hf-accent-dark); color: #ffffff; }

.hf-toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  background: var(--hf-text);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: 12px;
  max-width: min(420px, 88vw);
  text-align: center;
  animation: hf-rise .18s ease-out;
}
