/* assistant.css
   Floating AI question and answer widget.
   Scoped to .asst-* classes so it is inert on pages without the widget.
   Colors come from theme.css tokens; never hardcode a brand color here. */

.asst-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1200;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-elevated);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.asst-launcher:hover { background: var(--color-primary-soft); }
.asst-launcher:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.asst-launcher:active { transform: scale(0.95); }
.asst-launcher svg { width: 1.6rem; height: 1.6rem; }
.asst-launcher[hidden] { display: none; }

/* ---------- Panel ---------- */
.asst-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1201;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 2.5rem);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  animation: asst-rise 0.22s ease;
}

.asst-panel[hidden] { display: none; }

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

.asst-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0.85rem var(--space-sm);
  background: var(--color-primary-deep);
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.asst-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text-inverse);
}

.asst-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-inverse);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.asst-close:hover { background: rgba(244, 247, 250, 0.18); }
.asst-close:focus-visible { outline: 2px solid var(--color-text-inverse); outline-offset: 1px; }

.asst-notice {
  margin: 0;
  padding: 0.5rem var(--space-sm);
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-line);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- Thread ---------- */
.asst-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.asst-msg {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  line-height: 1.5;
  font-size: 0.94rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: asst-pop 0.24s ease;
}

.asst-msg.bot {
  align-self: flex-start;
  background: var(--color-bg-alt);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.asst-msg.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: 4px;
}

.asst-msg.error {
  align-self: stretch;
  max-width: 100%;
  background: #FCEEEC;
  color: #7A271A;
  border: 1px solid #E7A99E;
}

.asst-retry {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0;
  border: none;
  background: none;
  color: #7A271A;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

@keyframes asst-pop {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.asst-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.asst-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-secondary);
  animation: asst-blink 1.2s infinite ease-in-out both;
}

.asst-typing i:nth-child(2) { animation-delay: 0.18s; }
.asst-typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes asst-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Input row ---------- */
.asst-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem var(--space-sm);
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
  flex-shrink: 0;
}

.asst-input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.4;
  resize: none;
  max-height: 6rem;
}

.asst-input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
  border-color: var(--color-primary);
}

.asst-input:disabled { background: var(--color-bg-alt); }

.asst-send {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: background 0.2s ease;
}

.asst-send:hover:not(:disabled) { background: var(--color-primary-soft); }
.asst-send:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.asst-send:disabled { background: var(--color-secondary); cursor: not-allowed; opacity: 0.6; }
.asst-send svg { width: 1.15rem; height: 1.15rem; }

/* ---------- Mobile: full width bottom sheet ---------- */
@media (max-width: 600px) {
  .asst-launcher { right: 1rem; bottom: 1rem; }

  .asst-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    height: 78vh;
    max-height: 78vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .asst-msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .asst-panel, .asst-msg { animation: none; }
  .asst-typing i { animation: none; opacity: 0.5; }
  .asst-launcher { transition: none; }
}
