/* ============================================================================
 * agent_widget.css — плавающий ИИ-ассистент на лендинге (Phase B).
 * Самодостаточная палитра (нейро-навигация), тема через :root[data-theme].
 * Лендинг с мягким CSP (inline разрешён), но стили держим в классах.
 * ========================================================================== */

.agw-root {
  --agw-g1: #3A86C8; --agw-g2: #6E7CE0; --agw-g3: #46C9C3;
  --agw-glow: rgba(58, 134, 200, 0.45);
  --agw-surface: #FFFFFF; --agw-surface2: #F2F5FA;
  --agw-fg: #06182E; --agw-mute: #46586F; --agw-line: rgba(6, 24, 46, 0.16);
  --agw-accent: #0F3F60; --agw-on-accent: #EEF2F7;
  position: fixed; right: 22px; bottom: 22px; z-index: 1200;
  font-family: "Geist", -apple-system, "Inter", Arial, sans-serif;
}
:root[data-theme="dark"] .agw-root {
  --agw-g1: #4F97D6; --agw-g2: #8A95EC; --agw-g3: #5FD6D0;
  --agw-glow: rgba(95, 168, 224, 0.40);
  --agw-surface: #112B4D; --agw-surface2: #0B1F3A;
  --agw-fg: #E6ECF3; --agw-mute: #9DB3CC; --agw-line: rgba(230, 236, 243, 0.18);
  --agw-accent: #3A86C8; --agw-on-accent: #06182E;
}

/* ── Орб ─────────────────────────────────────────────────────────────────── */
.agw-orb {
  position: relative; flex: 0 0 auto; border-radius: 50%;
  background: conic-gradient(from 140deg, var(--agw-g1), var(--agw-g2),
              var(--agw-g3), var(--agw-g2), var(--agw-g1));
  box-shadow: 0 0 18px var(--agw-glow), inset 0 0 10px rgba(255, 255, 255, 0.18);
  animation: agw-spin 7s linear infinite;
}
.agw-orb::before {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 70% 75%, var(--agw-g3), rgba(0, 0, 0, 0) 55%),
    #06182E;
}
.agw-orb__glyph { position: absolute; inset: 0; width: 100%; height: 100%;
  color: #BFE3FF; filter: drop-shadow(0 0 2px rgba(70, 201, 195, 0.7)); }
.agw-orb--sm { width: 26px; height: 26px; box-shadow: 0 0 8px var(--agw-glow); }
.agw-orb--sm::before { inset: 2px; }
@keyframes agw-spin { to { transform: rotate(360deg); } }

/* ── FAB (плавающая кнопка) ──────────────────────────────────────────────── */
.agw-fab {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  border: none; background: var(--agw-surface); color: var(--agw-fg);
  padding: 8px 16px 8px 8px; border-radius: 40px;
  box-shadow: 0 10px 30px rgba(6, 24, 46, 0.22); border: 1px solid var(--agw-line);
  transition: transform .12s, box-shadow .12s;
}
.agw-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(6, 24, 46, 0.30); }
.agw-fab .agw-orb { width: 40px; height: 40px; }
.agw-fab__label { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.agw-fab__pulse { position: absolute; right: -2px; top: -2px; width: 10px; height: 10px;
  border-radius: 50%; background: #1A5D43; box-shadow: 0 0 0 2px var(--agw-surface); }
@media (max-width: 480px) { .agw-fab__label { display: none; } .agw-fab { padding: 7px; } }

/* ── Панель ──────────────────────────────────────────────────────────────── */
.agw-panel {
  width: 370px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 120px);
  background: var(--agw-surface); color: var(--agw-fg);
  border: 1px solid var(--agw-line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(6, 24, 46, 0.34);
  display: flex; flex-direction: column;
  animation: agw-rise .18s ease-out;
}
@keyframes agw-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.agw-head {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px;
  background:
    radial-gradient(120% 160% at 90% -30%, rgba(110, 124, 224, 0.18), rgba(0, 0, 0, 0) 55%),
    var(--agw-surface);
  border-bottom: 1px solid var(--agw-line); position: relative;
}
.agw-head::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--agw-g1), var(--agw-g2), var(--agw-g3), transparent); }
.agw-head .agw-orb { width: 38px; height: 38px; }
.agw-head__t { flex: 1 1 auto; min-width: 0; }
.agw-head__title { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.2; }
.agw-head__sub { margin: 1px 0 0; font-size: 12px; color: var(--agw-mute); }
.agw-close { flex: 0 0 auto; width: 30px; height: 30px; border: none; cursor: pointer;
  background: transparent; color: var(--agw-mute); font-size: 20px; line-height: 1; border-radius: 8px; }
.agw-close:hover { background: var(--agw-surface2); color: var(--agw-fg); }

.agw-stream { flex: 1 1 auto; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 11px; }
.agw-msg { display: flex; gap: 8px; max-width: 88%; }
.agw-msg--bot { align-self: flex-start; }
.agw-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.agw-bubble { padding: 9px 12px; font-size: 14px; line-height: 1.45; border-radius: 12px;
  white-space: pre-wrap; word-break: break-word; }
.agw-msg--bot .agw-bubble { background: var(--agw-surface2); border: 1px solid var(--agw-line);
  border-top-left-radius: 3px; }
.agw-msg--user .agw-bubble { background: var(--agw-accent); color: var(--agw-on-accent);
  border-top-right-radius: 3px; }
.agw-av { margin-top: 2px; }

.agw-typing { display: inline-flex; gap: 4px; padding: 12px; }
.agw-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--agw-g2);
  animation: agw-bounce 1.2s ease-in-out infinite; }
.agw-typing span:nth-child(2) { animation-delay: .18s; }
.agw-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes agw-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* Карточка подтверждения */
.agw-confirm { align-self: stretch; border: 1px solid var(--agw-g2); border-radius: 12px;
  padding: 13px; background: var(--agw-surface);
  box-shadow: inset 3px 0 0 var(--agw-g2); }
.agw-confirm__label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--agw-g2); font-weight: 700; margin-bottom: 5px; }
.agw-confirm__text { font-size: 14px; margin: 0 0 12px; }
.agw-confirm__actions { display: flex; gap: 8px; }
.agw-btn { font: inherit; font-weight: 600; font-size: 13px; padding: 8px 16px; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--agw-line); background: var(--agw-surface); color: var(--agw-fg); }
.agw-btn:hover { border-color: var(--agw-accent); }
.agw-btn:disabled { opacity: .5; cursor: default; }
.agw-btn--primary { background: var(--agw-accent); color: var(--agw-on-accent); border-color: var(--agw-accent); }

/* Чипы */
.agw-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 10px; }
.agw-chip { font: inherit; font-size: 13px; color: var(--agw-accent); cursor: pointer;
  padding: 6px 11px; border-radius: 20px; background: var(--agw-surface2); border: 1px solid var(--agw-line); }
.agw-chip:hover { border-color: var(--agw-g2); }

/* Ввод */
.agw-inputbar { display: flex; gap: 8px; align-items: flex-end; padding: 11px 12px;
  border-top: 1px solid var(--agw-line); }
.agw-textarea { flex: 1 1 auto; font: inherit; font-size: 14px; color: var(--agw-fg);
  background: var(--agw-surface2); border: 1px solid var(--agw-line); border-radius: 10px;
  padding: 10px 12px; resize: none; max-height: 110px; line-height: 1.4; }
.agw-textarea:focus { outline: none; border-color: var(--agw-g2);
  box-shadow: 0 0 0 3px rgba(110, 124, 224, 0.16); }
.agw-send { flex: 0 0 auto; width: 42px; height: 42px; cursor: pointer; border: none; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, var(--agw-g1), var(--agw-g2)); box-shadow: 0 0 14px var(--agw-glow); }
.agw-send:disabled { opacity: .5; cursor: default; box-shadow: none; }
.agw-send svg { width: 18px; height: 18px; }

/* Гость (не залогинен) */
.agw-login { padding: 26px 20px; text-align: center; flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.agw-login .agw-orb { width: 56px; height: 56px; }
.agw-login__t { font-size: 15px; font-weight: 600; }
.agw-login__d { font-size: 13px; color: var(--agw-mute); line-height: 1.5; }
.agw-login__btn { display: inline-block; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 11px 22px; border-radius: 10px; color: var(--agw-on-accent);
  background: linear-gradient(135deg, var(--agw-g1), var(--agw-g2)); box-shadow: 0 0 16px var(--agw-glow); }

.agw-foot { font-size: 11px; color: var(--agw-mute); padding: 8px 14px; border-top: 1px solid var(--agw-line);
  text-align: center; }

@media (max-width: 480px) {
  .agw-root { right: 12px; bottom: 12px; }
  .agw-panel { height: 70vh; }
}
@media (prefers-reduced-motion: reduce) {
  .agw-orb, .agw-typing span { animation: none; }
}
