/* Shared floating widgets: WhatsApp + AI assistant.
   Each concept sets these variables on :root to theme the assistant. */
:root {
  --w-primary: #111;
  --w-on-primary: #fff;
  --w-surface: #fff;
  --w-text: #1b1b1b;
  --w-muted: #6b6b6b;
  --w-border: #e5e5e5;
  --w-bot-bg: #f2f2f2;
  --w-radius: 18px;
  --w-font: inherit;
  --w-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  --wa: #25d366;
  --wa-dark: #128c4a;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- WhatsApp ---------- */
.wa-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: inline-flex; align-items: center; gap: 8px;
  height: 58px; padding: 0 14px; border-radius: 999px;
  background: var(--wa); color: #fff; text-decoration: none;
  font: 600 15px/1 var(--w-font);
  box-shadow: 0 10px 30px rgba(18, 140, 74, .4);
  transition: transform .2s ease, background .2s ease;
}
.wa-fab:hover { background: var(--wa-dark); transform: translateY(-2px); }
.wa-fab:focus-visible { outline: 3px solid var(--w-primary); outline-offset: 3px; }
.wa-fab__label { padding-right: 4px; }
@media (max-width: 640px) { .wa-fab { width: 56px; height: 56px; padding: 0; justify-content: center; } .wa-fab__label { display: none; } }

/* ---------- AI assistant ---------- */
.ai { font-family: var(--w-font); }
.ai-fab {
  position: fixed; right: 20px; bottom: 90px; z-index: 61;
  display: inline-flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 20px 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--w-primary); color: var(--w-on-primary);
  font: 600 15px/1 var(--w-font);
  box-shadow: var(--w-shadow);
  transition: transform .2s ease;
}
.ai-fab:hover { transform: translateY(-2px); }
.ai-fab:focus-visible { outline: 3px solid var(--w-text); outline-offset: 3px; }
.ai-fab__icon { display: inline-flex; }
.ai-fab__icon--close, .ai.is-open .ai-fab__icon--open { display: none; }
.ai.is-open .ai-fab__icon--close { display: inline-flex; }
.ai.is-open .ai-fab__label { display: none; }
.ai.is-open .ai-fab { padding: 0; width: 58px; justify-content: center; }
@media (max-width: 640px) { .ai-fab { bottom: 86px; width: 56px; height: 56px; padding: 0; justify-content: center; } .ai-fab__label { display: none; } }

.ai-panel {
  position: fixed; right: 20px; bottom: 160px; z-index: 62;
  width: min(380px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 190px));
  display: flex; flex-direction: column;
  background: var(--w-surface); color: var(--w-text);
  border: 1px solid var(--w-border); border-radius: var(--w-radius);
  box-shadow: var(--w-shadow); overflow: hidden;
}
.ai-panel[hidden] { display: none; }
@media (max-width: 640px) { .ai-panel { right: 16px; bottom: 156px; } }

.ai-panel__head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--w-primary); color: var(--w-on-primary); }
.ai-panel__head strong { display: block; font-size: 15px; }
.ai-panel__head small { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .85; }
.ai-panel__avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.18); }
.ai-panel__close { margin-left: auto; background: transparent; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.ai-panel__close:hover { background: rgba(255,255,255,.15); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; display: inline-block; }

.ai-panel__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.ai-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-line; word-wrap: break-word; }
.ai-msg a { color: inherit; text-decoration: underline; word-break: break-all; }
.ai-msg--bot { align-self: flex-start; background: var(--w-bot-bg); border-bottom-left-radius: 4px; }
.ai-msg--user { align-self: flex-end; background: var(--w-primary); color: var(--w-on-primary); border-bottom-right-radius: 4px; }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; display: block; }

.ai-panel__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.ai-chip { border: 1px solid var(--w-border); background: transparent; color: var(--w-text); border-radius: 999px; padding: 6px 11px; font: 500 12.5px/1.2 var(--w-font); cursor: pointer; }
.ai-chip:hover { border-color: var(--w-primary); }

.ai-panel__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--w-border); }
.ai-panel__form input { flex: 1; min-width: 0; border: 1px solid var(--w-border); border-radius: 10px; padding: 10px 12px; font: 14px var(--w-font); color: var(--w-text); background: var(--w-surface); }
.ai-panel__form input:focus { outline: 2px solid var(--w-primary); outline-offset: 0; border-color: transparent; }
.ai-panel__form button { display: grid; place-items: center; width: 42px; border: 0; border-radius: 10px; background: var(--w-primary); color: var(--w-on-primary); cursor: pointer; }
.ai-panel__form button:disabled { opacity: .5; }
.ai-panel__note { margin: 0; padding: 0 14px 10px; font-size: 11px; color: var(--w-muted); text-align: center; }

@media (prefers-reduced-motion: reduce) { .wa-fab, .ai-fab { transition: none; } }

/* ---------- Motion bootstrapping (shared by all concepts) ----------
   `html.motion` is added in <head> only when motion is allowed; elements marked
   [data-intro] start hidden so the intro timeline can reveal them without a flash. */
.motion [data-intro], .motion .wa-fab, .motion .ai-fab { opacity: 0; }
.motion .ai-panel__log { scroll-behavior: smooth; }
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }
