/* AFC Companion — floating voice guide.
   Everything is scoped under .afc-companion so nothing leaks into the site.
   Brand tokens come from /ds/tokens/colors.css with literal fallbacks. */

.afc-companion {
  --afc-midnight: var(--af-midnight, #041e42);
  --afc-light-blue: var(--af-light-blue, #00aeef);
  --afc-dark-blue: var(--af-dark-blue, #005baa);
  --afc-white: #fff;
  --afc-ink: #0d1b2a;
  --afc-muted: #5a6b7d;
  --afc-line: rgba(4, 30, 66, 0.12);
  --afc-radius: 16px;
  --afc-gap: 20px;

  position: fixed;
  inset-inline-end: var(--afc-gap);
  inset-block-end: var(--afc-gap);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-size: 15px;
  line-height: 1.5;
}

.afc-companion--rtl { align-items: flex-start; }

/* ── Launcher ───────────────────────────────────────────────────────────────── */
.afc-companion__fab {
  order: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--afc-white);
  background: linear-gradient(140deg, var(--afc-dark-blue), var(--afc-midnight));
  box-shadow: 0 10px 26px rgba(4, 30, 66, 0.34);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.afc-companion__fab:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(4, 30, 66, 0.4); }
.afc-companion__fab:focus-visible { outline: 3px solid var(--afc-light-blue); outline-offset: 3px; }
.afc-companion__fab-icon { display: inline-flex; }
.afc-companion.is-open .afc-companion__fab { background: var(--afc-light-blue); color: var(--afc-midnight); }

/* ── Panel ──────────────────────────────────────────────────────────────────── */
.afc-companion__panel {
  order: 1;
  width: min(380px, calc(100vw - 2 * var(--afc-gap)));
  max-height: min(620px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--afc-radius);
  background: var(--afc-white);
  color: var(--afc-ink);
  border: 1px solid var(--afc-line);
  box-shadow: 0 24px 60px rgba(4, 30, 66, 0.28);
  animation: afc-rise 0.22s ease both;
}

.afc-companion__panel[hidden] { display: none; }

@keyframes afc-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.afc-companion__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: var(--afc-white);
  background: var(--afc-midnight);
}

.afc-companion__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.afc-companion__id > span:last-child { display: block; min-width: 0; }

.afc-companion__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--afc-light-blue);
  box-shadow: 0 0 0 4px rgba(0, 174, 239, 0.22);
}

.afc-companion__title { display: block; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.afc-companion__sub { display: block; font-size: 12px; opacity: 0.72; }
.afc-companion__head-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.afc-companion__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease, color 0.18s ease;
}

.afc-companion__icon-btn:hover { background: rgba(255, 255, 255, 0.24); }
.afc-companion__icon-btn:focus-visible { outline: 3px solid var(--afc-light-blue); outline-offset: 2px; }
.afc-companion__icon-btn[hidden] { display: none; }

/* ── Conversation ───────────────────────────────────────────────────────────── */
.afc-companion__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f6f8fb;
}

.afc-companion__log:focus-visible { outline: 2px solid var(--afc-light-blue); outline-offset: -2px; }

.afc-companion__msg { display: flex; flex-direction: column; gap: 4px; max-width: 92%; }
.afc-companion__msg--you { align-self: flex-end; align-items: flex-end; }
.afc-companion--rtl .afc-companion__msg--you { align-self: flex-start; align-items: flex-start; }

.afc-companion__who {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--afc-muted);
}

.afc-companion__bubble {
  margin: 0;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--afc-white);
  border: 1px solid var(--afc-line);
  box-shadow: 0 2px 8px rgba(4, 30, 66, 0.05);
}

.afc-companion__msg--you .afc-companion__bubble {
  color: var(--afc-white);
  background: var(--afc-dark-blue);
  border-color: transparent;
}

.afc-companion__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.afc-companion__action {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--afc-white);
  background: var(--afc-dark-blue);
  transition: background 0.18s ease;
}

.afc-companion__action:hover { background: var(--afc-midnight); }
.afc-companion__action:focus-visible { outline: 3px solid var(--afc-light-blue); outline-offset: 2px; }

.afc-companion__action--ghost {
  color: var(--afc-dark-blue);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--afc-line);
}

.afc-companion__action--ghost:hover { color: var(--afc-white); background: var(--afc-midnight); }

/* ── Chips ──────────────────────────────────────────────────────────────────── */
.afc-companion__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--afc-line);
  background: var(--afc-white);
}

.afc-companion__chip {
  padding: 7px 13px;
  border: 1px solid var(--afc-line);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--afc-midnight);
  background: #f2f6fb;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.afc-companion__chip:hover { background: rgba(0, 174, 239, 0.14); border-color: var(--afc-light-blue); }
.afc-companion__chip:focus-visible { outline: 3px solid var(--afc-light-blue); outline-offset: 2px; }

/* ── Composer ───────────────────────────────────────────────────────────────── */
.afc-companion__form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--afc-line);
  background: var(--afc-white);
}

.afc-companion__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--afc-line);
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  color: var(--afc-ink);
  background: #f6f8fb;
}

.afc-companion__input:focus { outline: none; border-color: var(--afc-light-blue); box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.2); }

.afc-companion__form .afc-companion__icon-btn { flex: none; color: var(--afc-white); background: var(--afc-dark-blue); }
.afc-companion__form .afc-companion__icon-btn:hover { background: var(--afc-midnight); }
.afc-companion__mic { background: var(--afc-midnight) !important; }
.afc-companion__mic.is-live { background: var(--afc-light-blue) !important; color: var(--afc-midnight) !important; animation: afc-pulse 1.3s ease-in-out infinite; }

@keyframes afc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 174, 239, 0.55); }
  50% { box-shadow: 0 0 0 8px rgba(0, 174, 239, 0); }
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .afc-companion { --afc-gap: 14px; }
  .afc-companion__panel {
    position: fixed;
    inset: 12px 12px 84px;
    width: auto;
    max-height: none;
    border-radius: 14px;
  }
  .afc-companion__log { max-height: none; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .afc-companion *,
  .afc-companion__panel { animation: none !important; transition: none !important; }
  .afc-companion__fab:hover { transform: none; }
}

.afc-companion--still *,
.afc-companion--still .afc-companion__panel { animation: none !important; transition: none !important; }

/* Mobile: companion fully disabled (JS bails too — this covers cached JS). */
@media (max-width: 899px) {
  .afc-companion { display: none !important; }
}
