/* Dira IBS — website chat widget.
   Self-contained: the public landing page does not load dira.css, so nothing
   here may depend on it. Where a theme token exists it is used, with the
   shipped value as the fallback, so the widget follows Platform → Appearance
   on pages that do load the stylesheet and still looks right on those that
   do not. */

.dira-chat-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--brand-600, #166534); color: var(--text-invert, #fff);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.dira-chat-launcher:hover  { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(15, 23, 42, .28); }
.dira-chat-launcher:focus-visible { outline: 3px solid var(--brand-100, #dcfce7); outline-offset: 2px; }
.dira-chat-launcher[hidden] { display: none; }
.dira-chat-launcher svg { flex: none; }

.dira-chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483001;
  width: 376px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 40px);
  display: none; flex-direction: column; overflow: hidden;
  background: var(--bg-surface, #fff); color: var(--text-body, #1e293b);
  border: 1px solid var(--border-color, #d4ded6); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .26);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.dira-chat-panel.is-open { display: flex; }

.dira-chat-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: var(--brand-600, #166534); color: var(--text-invert, #fff);
}
.dira-chat-head b   { font-size: 14.5px; font-weight: 700; }
.dira-chat-head p   { margin: 1px 0 0; font-size: 11.5px; opacity: .82; }
.dira-chat-head .sp { flex: 1; }
.dira-chat-close {
  border: 0; background: rgba(255,255,255,.16); color: inherit; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
}
.dira-chat-close:hover { background: rgba(255,255,255,.28); }

.dira-chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dira-chat-msg { max-width: 85%; padding: 10px 13px; border-radius: 13px; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; }
.dira-chat-msg.bot   { align-self: flex-start; background: var(--bg-page, #f3f6f3); border: 1px solid var(--border-color, #d4ded6); border-bottom-left-radius: 4px; }
.dira-chat-msg.me    { align-self: flex-end;  background: var(--brand-600, #166534); color: var(--text-invert, #fff); border-bottom-right-radius: 4px; }
.dira-chat-msg.agent { align-self: flex-start; background: #eef4ff; border: 1px solid #c7d8f7; border-bottom-left-radius: 4px; }
.dira-chat-msg .who  { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .7; margin-bottom: 3px; }

.dira-chat-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 12px; }
.dira-chat-chip {
  border: 1px solid var(--border-color, #d4ded6); background: var(--bg-surface, #fff);
  color: var(--brand-600, #166534); cursor: pointer;
  padding: 7px 11px; border-radius: 999px; font: 600 12px system-ui, sans-serif;
}
.dira-chat-chip:hover { background: var(--brand-50, #ecfdf3); }

.dira-chat-foot { border-top: 1px solid var(--border-color, #d4ded6); padding: 10px; background: var(--bg-surface, #fff); }
.dira-chat-row  { display: flex; gap: 8px; }
.dira-chat-input {
  flex: 1; min-width: 0; padding: 10px 12px; font: 13.5px system-ui, sans-serif;
  border: 1px solid var(--border-color, #d4ded6); border-radius: 10px;
  background: var(--bg-input, #fff); color: var(--text-body, #1e293b);
}
.dira-chat-input:focus { outline: 2px solid var(--brand-600, #166534); outline-offset: -1px; }
.dira-chat-send {
  border: 0; border-radius: 10px; padding: 0 15px; cursor: pointer;
  background: var(--brand-600, #166534); color: var(--text-invert, #fff); font: 600 13px system-ui, sans-serif;
}
.dira-chat-send:disabled { opacity: .55; cursor: not-allowed; }

.dira-chat-form { display: none; padding: 12px 16px 4px; gap: 8px; flex-direction: column; }
.dira-chat-form.is-open { display: flex; }
.dira-chat-form label { font-size: 11.5px; font-weight: 700; color: var(--text-muted, #64748b); }
.dira-chat-form input, .dira-chat-form textarea {
  width: 100%; padding: 9px 11px; font: 13px system-ui, sans-serif;
  border: 1px solid var(--border-color, #d4ded6); border-radius: 9px;
  background: var(--bg-input, #fff); color: var(--text-body, #1e293b);
}
.dira-chat-form textarea { resize: vertical; min-height: 64px; }
.dira-chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.dira-chat-note { font-size: 11.5px; color: var(--text-muted, #64748b); padding: 0 16px 10px; }
.dira-chat-err  { font-size: 12.5px; color: #b91c1c; padding: 0 16px 8px; }

/* A phone keyboard eats most of the viewport, so the panel goes full-bleed
   and the log — not the page — is what scrolls. */
@media (max-width: 480px) {
  .dira-chat-panel {
    right: 0; bottom: 0; width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0;
  }
  .dira-chat-launcher { right: 14px; bottom: 14px; padding: 12px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .dira-chat-launcher { transition: none; }
}

/* Typing indicator — three dots while the agent is composing. Without it a
   two-second wait reads as a broken widget. */
.dira-chat-typing { display: flex; gap: 4px; align-items: center; padding: 13px; }
.dira-chat-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted, #64748b);
  opacity: .45; animation: dira-chat-bounce 1.1s infinite ease-in-out;
}
.dira-chat-typing i:nth-child(2) { animation-delay: .15s; }
.dira-chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dira-chat-bounce {
  0%, 70%, 100% { transform: translateY(0);    opacity: .35; }
  35%           { transform: translateY(-4px); opacity: .9; }
}
@media (prefers-reduced-motion: reduce) {
  .dira-chat-typing i { animation: none; opacity: .5; }
}