/* =====================================================================
   HTS AI Engine - App 100 floating HTS Assistant (CR-10)
   Colours come from the branding variables (--hts-primary, --hts-secondary, --hts-text from the customization tables)
   and the theme's surface colours; no colour literal here.
   ===================================================================== */
.hts-asst-root { position: fixed; inset-inline-end: 1.25rem; bottom: 1.25rem; z-index: 900; display: flex; flex-direction: column;
                 align-items: flex-end; gap: 0.75rem; pointer-events: none; }
.hts-asst-root > * { pointer-events: auto; }

.hts-asst-fab {
  width: 3.25rem; height: 3.25rem; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--hts-primary); color: var(--hts-text);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--hts-secondary) 35%, transparent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hts-asst-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 24px color-mix(in srgb, var(--hts-secondary) 40%, transparent); }
.hts-asst-fab:focus-visible { outline: 3px solid color-mix(in srgb, var(--hts-primary) 45%, transparent); outline-offset: 3px; }
.hts-asst-fab.is-open .fa::before { content: "\f00d"; }

.hts-asst-panel {
  width: min(24rem, calc(100vw - 2rem)); height: min(36rem, calc(100vh - 7rem));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ut-component-background-color, Canvas); color: var(--ut-component-text-default-color, CanvasText);
  border: 1px solid var(--hts-line); border-radius: var(--hts-radius, 12px);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--hts-secondary) 30%, transparent);
}
.hts-asst-panel[hidden] { display: none; }

.hts-asst-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.625rem 0.75rem;
                 background: var(--hts-secondary); color: var(--hts-text); }
.hts-asst-title { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.hts-asst-title .fa { color: var(--hts-primary); }
.hts-asst-actions { display: inline-flex; gap: 0.125rem; }
.hts-asst-icon-btn { width: 2rem; height: 2rem; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer;
                     display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s ease; }
.hts-asst-icon-btn:hover:not(:disabled) { background: color-mix(in srgb, currentColor 14%, transparent); }
.hts-asst-icon-btn:disabled { opacity: 0.45; cursor: default; }
.hts-asst-icon-btn[hidden] { display: none; }

.hts-asst-list { flex: 1 1 auto; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem;
                 overscroll-behavior: contain; }
.hts-asst-msg { display: flex; }
.hts-asst-msg--user { justify-content: flex-end; }
.hts-asst-bubble { max-width: 88%; padding: 0.5rem 0.75rem; border-radius: 12px; line-height: 1.45; overflow-wrap: anywhere;
                   font-size: 0.875rem; }
.hts-asst-msg--user .hts-asst-bubble { background: var(--hts-red-soft); white-space: pre-wrap; }
.hts-asst-msg--assistant .hts-asst-bubble { background: var(--hts-soft-2); }
.hts-asst-bubble p { margin: 0 0 0.4rem; }
.hts-asst-bubble p:last-child { margin-bottom: 0; }
.hts-asst-bubble ul, .hts-asst-bubble ol { margin: 0.25rem 0 0.4rem; padding-inline-start: 1.2rem; }
.hts-asst-bubble table { border-collapse: collapse; font-size: 0.8125rem; margin: 0.25rem 0; }
.hts-asst-bubble th, .hts-asst-bubble td { border: 1px solid var(--hts-line); padding: 0.2rem 0.4rem; }
.hts-asst-bubble pre { white-space: pre-wrap; font-size: 0.75rem; }
.hts-asst-bubble .hts-code-copy { display: none; }
.hts-asst-bubble--error { border: 1px solid color-mix(in srgb, var(--hts-primary) 45%, transparent); white-space: pre-wrap; }
.hts-asst-dots { display: inline-flex; gap: 0.25rem; padding: 0.25rem 0; }
.hts-asst-dots i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--hts-primary); animation: hts-asst-blink 1.2s infinite both; }
.hts-asst-dots i:nth-child(2) { animation-delay: 0.2s; }
.hts-asst-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes hts-asst-blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.hts-asst-welcome-title { margin: 0 0 0.6rem; font-size: 0.875rem; opacity: 0.85; }
.hts-asst-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.hts-asst-chip { border: 1px solid var(--hts-line); background: var(--hts-soft); color: inherit; border-radius: 999px;
                 padding: 0.3rem 0.65rem; font-size: 0.8125rem; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.hts-asst-chip:hover { background: var(--hts-red-soft); border-color: color-mix(in srgb, var(--hts-primary) 40%, transparent); }
.hts-asst-loading, .hts-asst-muted { opacity: 0.7; font-size: 0.8125rem; }

.hts-asst-hist { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem 0.75rem; }
.hts-asst-hist[hidden] { display: none; }
.hts-asst-hist:not([hidden]) ~ .hts-asst-status { display: none; }
.hts-asst-hist-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.hts-asst-hist-item { display: flex; align-items: center; gap: 0.25rem; border-radius: 8px; }
.hts-asst-hist-item.is-current { background: var(--hts-soft-2); }
.hts-asst-hist-open { flex: 1 1 auto; min-width: 0; text-align: start; border: 0; background: transparent; color: inherit; cursor: pointer;
                      padding: 0.45rem 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; }
.hts-asst-hist-open:hover { text-decoration: underline; }
.hts-asst-panel:has(.hts-asst-hist:not([hidden])) .hts-asst-list { display: none; }

.hts-asst-status { padding: 0.25rem 0.75rem; font-size: 0.75rem; opacity: 0.8; }
.hts-asst-status[hidden] { display: none; }
.hts-asst-composer { display: flex; align-items: flex-end; gap: 0.375rem; padding: 0.5rem 0.625rem; border-top: 1px solid var(--hts-line); }
.hts-asst-input { flex: 1 1 auto; resize: none; max-height: 8rem; min-height: 2.5rem; padding: 0.45rem 0.6rem; border-radius: 10px;
                  border: 1px solid var(--hts-line); background: transparent; color: inherit; font: inherit; font-size: 0.875rem; box-sizing: border-box; }
.hts-asst-input:focus { outline: 2px solid color-mix(in srgb, var(--hts-primary) 40%, transparent); outline-offset: 0; }
.hts-asst-send, .hts-asst-stop { width: 2.5rem; height: 2.5rem; background: var(--hts-primary); color: var(--hts-text); border-radius: 10px; }
.hts-asst-send:hover:not(:disabled), .hts-asst-stop:hover { background: color-mix(in srgb, var(--hts-primary) 85%, var(--hts-secondary)); }
.hts-asst-foot { padding: 0 0.75rem 0.5rem; font-size: 0.6875rem; opacity: 0.6; }

/* the chat page composer stays reachable: the bubble sits above it on small screens */
@media (max-width: 640px) {
  .hts-asst-root { inset-inline-end: 0.75rem; bottom: 0.75rem; }
  .hts-asst-panel { width: calc(100vw - 1.5rem); height: calc(100vh - 8rem); }
}
@media (prefers-reduced-motion: reduce) {
  .hts-asst-fab, .hts-asst-chip, .hts-asst-icon-btn { transition: none; }
  .hts-asst-dots i { animation: none; opacity: 0.6; }
}
@media print { .hts-asst-root { display: none; } }
