/* ===========================
   Общая страница
=========================== */

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f5f5;
}
/* ===========================
   Цветовая схема ForgeBit
=========================== */

:root {
  --fb-primary: #f4b400;
  --fb-primary-hover: #ffca28;

  --fb-text: #1f2937;
  --fb-light: #f3f4f6;
  --fb-border: #ececec;

  --fb-dark: #1a1a1a;
}

/* ===========================
   Кнопка
=========================== */

#chat-button {
  position: fixed;

  right: 30px;
  bottom: 30px;

  width: 64px;
  height: 64px;

  border: none;
  border-radius: 50%;

  /* background: #2563eb;
  color: white; */
  background: var(--fb-primary);
  color: #111;

  font-size: 28px;

  cursor: pointer;

  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);

  transition: 0.25s;

  z-index: 1000;
}

#chat-button:hover {
  transform: scale(1.08);

  /* background: #1d4ed8; */
  background: var(--fb-primary);
  color: #111;
}

/* ===========================
   Окно чата
=========================== */

#chat-window {
  position: fixed;

  right: 30px;
  bottom: 110px;

  width: 380px;
  height: 620px;

  background: var(--fb-window, white);

  border-radius: 22px;

  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.18);

  overflow: hidden;

  display: flex;
  flex-direction: column;
}

/* ===========================
   Шапка
=========================== */

.chat-header {
  display: flex;

  justify-content: space-between;

  align-items: center;

  padding: 16px 20px;

  /* box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06); */
  border-bottom: 1px solid rgba(244, 180, 0, 0.25);
}

.chat-brand {
  display: flex;

  align-items: center;

  gap: 12px;
}

.chat-logo {
  width: 48px;

  height: 48px;

  object-fit: contain;
}

#chat-title {
  font-weight: 600;

  font-size: 18px;
}

/* ===========================
   Основная область
=========================== */

#chat-body-shell {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#chat-body {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;

  padding: 24px;

  color: #374151;
}

.welcome h3 {
  margin-top: 0;
}

.welcome ul {
  padding-left: 20px;
}

/* ===========================
   Нижняя панель
=========================== */

#chat-footer {
  display: flex;

  flex: 0 0 auto;

  gap: 12px;

  padding: 18px;

  /* border-top: 1px solid #ececec; */
  border-top: 1px solid rgba(244,180,0,.2);
}

#chat-footer input {
  flex: 1;

  padding: 12px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  outline: none;

  font-size: 15px;
}

#chat-footer button {
  width: 48px;

  border: none;

  border-radius: 12px;

  /* background: #2563eb;
  color: white; */
  background: #172235;
  color: #e5eefc;
  border: 1px solid rgba(148, 163, 184, 0.28);

  cursor: pointer;
}

#chat-footer button svg,
#voice-stage svg {
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#voice-button.active {
  background: #111827;
  color: #f4b400;
  box-shadow: inset 0 0 0 2px #f4b400;
}

#voice-stage[hidden] { display: none !important; }

#voice-stage {
  position: relative;
  flex: 0 0 155px;
  pointer-events: none;
  background: linear-gradient(180deg, #071321 0%, #0d2032 48%, rgba(243, 244, 246, 0.96) 100%);
}

#voice-stage .voice-stage-inner { position: relative; width: 100%; height: 100%; }

#voice-stage svg,
#voice-stage-icon svg {
  width: 64px;
  height: 64px;
}

/* Keep the informational stage inside the widget; it never captures input. */
#voice-stage .voice-orb-slot { position: absolute; top: 10px; left: 50%; width: 110px; height: 110px; transform: translateX(-50%); display: grid; place-items: center; }
#voice-stage .voice-status-slot { position: absolute; top: 121px; left: 12px; right: 12px; height: 34px; display: flex; align-items: center; justify-content: center; }

#voice-stage-state { font-size: 13px; font-weight: 600; line-height: 1.2; text-align: center; }

.voice-orb {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
}

.voice-stage-image { position: absolute; inset: 0; width: 110px; height: 110px; object-fit: contain; display: block; z-index: 1; }
.voice-stage-image[hidden] { display: none; }
#voice-stage-icon { position: absolute; inset: 0; display: grid; place-items: center; line-height: 0; z-index: 2; color: #f7fbff; filter: drop-shadow(0 0 8px rgba(103, 196, 255, .65)); }
#voice-stage [data-voice-icon] { display: none; }
#voice-stage[data-state="connecting"] [data-voice-icon="connecting"],
#voice-stage[data-state="listening"] [data-voice-icon="listening"],
#voice-stage[data-state="recognizing"] [data-voice-icon="listening"],
#voice-stage[data-state="waiting"] [data-voice-icon="thinking"],
#voice-stage[data-state="speaking"] [data-voice-icon="speaking"],
#voice-stage[data-state="muted"] [data-voice-icon="muted"] { display: block; }
.voice-icon-connecting { transform-origin: 60px 60px; animation: voice-icon-spin 1.2s linear infinite; }
.voice-listening-waves { filter: drop-shadow(0 0 4px rgba(128, 231, 255, .95)); }
.voice-listening-waves path { animation: voice-listen-wave 1.5s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.voice-listening-waves path:nth-child(2), .voice-listening-waves path:nth-child(5) { animation-delay: .25s; }
.voice-listening-waves path:nth-child(3), .voice-listening-waves path:nth-child(6) { animation-delay: .5s; }
.voice-thinking-dot:nth-child(1) { animation: voice-thinking-dot 1.35s ease-in-out infinite; }
.voice-thinking-dot:nth-child(2) { animation: voice-thinking-dot 1.35s ease-in-out .22s infinite; }
.voice-thinking-dot:nth-child(3) { animation: voice-thinking-dot 1.35s ease-in-out .44s infinite; }
.voice-speaking-waves { filter: drop-shadow(0 0 4px rgba(128, 214, 255, .95)); }
.voice-speaking-waves path { animation: voice-speak-wave 1.1s ease-out infinite; transform-box: fill-box; transform-origin: left center; }
.voice-speaking-waves path:nth-child(2) { animation-delay: .25s; }
.voice-speaking-waves path:nth-child(3) { animation-delay: .5s; }
#voice-stage-state { color: #e8f1ff; text-shadow: 0 1px 10px rgba(0, 0, 0, .45); }

#send-button { background: var(--fb-primary); color: #111827; border-color: rgba(244, 180, 0, .7); }
#voice-button:hover:not(:disabled), #send-button:hover:not(:disabled) { filter: brightness(1.08); }
#voice-button:active:not(:disabled), #send-button:active:not(:disabled) { transform: translateY(1px); }
#voice-button:focus-visible, #send-button:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
#voice-button.active { background: #111d31; color: #f4b400; border-color: #f4b400; box-shadow: inset 0 0 0 1px rgba(244,180,0,.45), 0 0 12px rgba(244,180,0,.18); }
[data-control="mute"] { background: #1f2937 !important; color: #e5eefc !important; border-color: rgba(148,163,184,.35) !important; }
#voice-button.active { background: #55202a; color: #f9d4d8; border-color: rgba(248,113,113,.62); box-shadow: inset 0 0 0 1px rgba(248,113,113,.28), 0 0 12px rgba(127,29,29,.25); }

@keyframes voice-icon-spin { to { transform: rotate(360deg); } }
@keyframes voice-listen-wave { 0% { opacity: .95; transform: scale(1); } 65%, 100% { opacity: 0; transform: scale(1.08); } }
@keyframes voice-thinking-dot { 0%, 65%, 100% { opacity: .35; filter: brightness(.85) drop-shadow(0 0 0 transparent); } 25% { opacity: 1; filter: brightness(1.35) drop-shadow(0 0 5px rgba(128, 231, 255, .95)); } }
@keyframes voice-speak-wave { 0% { opacity: .95; transform: scaleX(.96); } 70%, 100% { opacity: 0; transform: scaleX(1.06); } }
@media (prefers-reduced-motion: reduce) { .voice-icon-animated, .voice-icon-connecting, .voice-listening-waves path, .voice-thinking-dot, .voice-speaking-waves path { animation: none !important; } }

@media (max-width: 480px) {
  #voice-stage { flex-basis: 135px; }
  #voice-stage .voice-orb-slot { top: 8px; width: 95px; height: 95px; }
  #voice-stage .voice-status-slot { top: 105px; height: 30px; }
  .voice-stage-image { width: 95px; height: 95px; }
  #voice-stage svg, #voice-stage-icon svg { width: 58px; height: 58px; }
  #voice-stage-state { font-size: 12px; }
}

#chat-footer button:hover:not(:disabled) {
  background: var(--fb-primary-hover);
}

#voice-button.active { background: #55202a; color: #f9d4d8; border-color: rgba(248,113,113,.62); box-shadow: inset 0 0 0 1px rgba(248,113,113,.28), 0 0 12px rgba(127,29,29,.25); }

.voice-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* ===========================
   Скрытое состояние
=========================== */

#chat-window {
  opacity: 0;

  visibility: hidden;

  transform: translateY(30px) scale(0.95);

  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s;
}

/* ===========================
   Открытое состояние
=========================== */

#chat-window.open {
  opacity: 1;

  visibility: visible;

  transform: translateY(0) scale(1);
}
/* ===========================
   Сообщения
=========================== */

#messages {
  display: flex;

  flex-direction: column;

  gap: 16px;
}

.message {
  display: flex;
}

.message.assistant {
  justify-content: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 80%;

  padding: 14px 16px;

  border-radius: 18px;

  line-height: 1.5;

  font-size: 15px;
}

.message.assistant .bubble {
  background: #f3f4f6;

  color: var(--fb-text);
}

/* .message.user .bubble {
  background: #2563eb;

  color: white;
} */
 .message.user .bubble {
  background: var(--fb-primary);
  color: #111;
}

#chat-footer button:disabled {
  opacity: 0.5;

  cursor: not-allowed;
}

#chat-footer input:disabled {
  background: #f3f4f6;
}
.typing-indicator {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;

  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.5);
    opacity: 0.3;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================
   Markdown
========================= */

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
  margin: 0.8em 0 0.4em;
  line-height: 1.3;
  font-weight: 600;
}

.bubble h1 {
  font-size: 1.5rem;
}

.bubble h2 {
  font-size: 1.3rem;
}

.bubble h3 {
  font-size: 1.15rem;
}

.bubble p {
  margin: 0.6em 0;
  line-height: 1.6;
}

.bubble ul,
.bubble ol {
  margin: 0.6em 0;
  padding-left: 1.4em;
}

.bubble li {
  margin: 0.35em 0;
}

.bubble strong {
  font-weight: 600;
}

.bubble em {
  font-style: italic;
}

.bubble hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
}

/* Блоки кода */
.bubble pre {
  background: #1e1e1e;
  color: #f5f5f5;

  padding: 14px;

  border-radius: 10px;

  overflow-x: auto;

  margin: 1em 0;
}

.bubble code {
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9em;
}

.bubble :not(pre) > code {
  background: rgba(0, 0, 0, 0.08);

  padding: 2px 5px;

  border-radius: 4px;
}

/* Цитаты */
.bubble blockquote {
  margin: 1em 0;
  padding: 0.6em 1em;

  border-left: 4px solid #4caf50;

  background: rgba(76, 175, 80, 0.08);

  font-style: italic;
}

/* Таблицы */
.bubble table {
  width: 100%;

  border-collapse: collapse;

  margin: 1em 0;

  font-size: 0.95em;
}

.bubble th,
.bubble td {
  border: 1px solid rgba(0, 0, 0, 0.15);

  padding: 8px 10px;

  text-align: left;
}

.bubble th {
  background: rgba(0, 0, 0, 0.06);

  font-weight: 600;
}

/* Ссылки */
.bubble a {
  /* color: #1976d2; */
  color: #d99500;
  font-weight: 500;

  text-decoration: none;
}

.bubble a:hover {
  color: var(--fb-primary);
  text-decoration: underline;
}

/* Изображения */
.bubble img {
  max-width: 100%;

  border-radius: 10px;

  margin: 10px 0;
}
