/* Chat assistant bubble and panel (assistant.js). Uses the Lumora tokens, so it follows the
   academy's theme and dark mode. The student portal has the same styles in
   app/src/components/assistant/assistant.css — keep the two in step. */

/* ── Launcher ── */
.lu-asst-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  width: 58px; height: 58px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--brand, #0b6b61); color: var(--on-brand, #fff);
  box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,.2));
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
.lu-asst-fab:hover { background: var(--brand-hover, #08574f); transform: translateY(-2px); }
.lu-asst-fab:focus-visible { outline: 3px solid var(--focus, #7fb7ff); outline-offset: 2px; }
.lu-asst-fab svg { width: 26px; height: 26px; }
.lu-asst-fab.is-hidden { display: none; }
.lu-asst-fab-dot { position: absolute; top: 3px; right: 3px; width: 13px; height: 13px; border-radius: 99px; background: var(--danger, #e5484d); border: 2px solid var(--surface, #fff); }
.lu-asst-fab-dot[hidden] { display: none; }

.lu-asst-teaser {
  position: fixed; right: 20px; bottom: 90px; z-index: 900; max-width: 270px;
  display: flex; align-items: flex-start; gap: 6px; padding: 12px 10px 12px 14px;
  background: var(--surface, #fff); color: var(--ink, #1a1a1a); border: 1px solid var(--line, #e5e5e5);
  border-radius: 16px 16px 4px 16px; box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.12));
  animation: lu-asst-in .3s ease-out both;
}
.lu-asst-teaser-text { border: 0; background: none; padding: 0; font: inherit; font-size: 13.5px; line-height: 1.45; text-align: left; color: inherit; cursor: pointer; }
.lu-asst-teaser-close { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink-3, #888); width: 20px; height: 20px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.lu-asst-teaser-close:hover { background: var(--surface-2, #f1efe9); color: var(--ink, #1a1a1a); }
.lu-asst-teaser-close svg { width: 14px; height: 14px; }

/* ── Panel ── */
.lu-asst-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 901;
  width: 400px; height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg, #f7f6f2); color: var(--ink, #1a1a1a);
  border: 1px solid var(--line, #e5e5e5); border-radius: 20px;
  box-shadow: var(--shadow-lg, 0 20px 50px rgba(0,0,0,.25));
  font-size: 14px; line-height: 1.5;
  animation: lu-asst-pop .2s ease-out both;
}
.lu-asst-panel[hidden] { display: none; }
@keyframes lu-asst-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.lu-asst-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; flex: none;
  background: var(--brand, #0b6b61); color: var(--on-brand, #fff);
}
.lu-asst-avatar {
  width: 38px; height: 38px; border-radius: 999px; flex: none;
  background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center;
}
.lu-asst-avatar svg { width: 20px; height: 20px; }
.lu-asst-title { flex: 1; min-width: 0; line-height: 1.25; }
.lu-asst-title strong { display: block; font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lu-asst-title span { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; opacity: .9; }
.lu-asst-title span::before { content: ''; width: 7px; height: 7px; border-radius: 99px; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.lu-asst-iconbtn {
  width: 34px; height: 34px; border: 0; border-radius: 10px; cursor: pointer; flex: none;
  background: transparent; color: inherit; display: flex; align-items: center; justify-content: center;
}
.lu-asst-iconbtn:hover { background: rgba(255,255,255,.16); }
.lu-asst-iconbtn:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 1px; }
.lu-asst-iconbtn svg { width: 19px; height: 19px; }

/* ── Messages ── */
.lu-asst-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth;
  padding: 16px 14px 12px; display: flex; flex-direction: column; gap: 14px;
}
.lu-asst-row { display: flex; gap: 8px; align-items: flex-start; }
.lu-asst-row.is-user { justify-content: flex-end; }
.lu-asst-ava {
  width: 28px; height: 28px; border-radius: 999px; flex: none; margin-top: 2px;
  background: var(--brand-soft, #e0f0ec); color: var(--brand, #0b6b61);
  display: flex; align-items: center; justify-content: center;
}
.lu-asst-ava svg { width: 15px; height: 15px; }
.lu-asst-msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lu-asst-row.is-bot .lu-asst-msg { flex: 1; max-width: calc(100% - 36px); align-items: flex-start; }
.lu-asst-row.is-user .lu-asst-msg { max-width: 82%; align-items: flex-end; }
.lu-asst-msg > * { max-width: 100%; }
.lu-asst-msg > .lu-asst-menu, .lu-asst-msg > .lu-asst-cards, .lu-asst-msg > .lu-asst-box { width: 100%; }

.lu-asst-bubble { padding: 9px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.lu-asst-row.is-user .lu-asst-bubble { background: var(--brand, #0b6b61); color: var(--on-brand, #fff); border-bottom-right-radius: 6px; }
.lu-asst-row.is-bot .lu-asst-bubble { background: var(--surface, #fff); border: 1px solid var(--line, #e5e5e5); }
.lu-asst-row.is-bot .lu-asst-msg > .lu-asst-bubble:first-child { border-top-left-radius: 6px; }
.lu-asst-bubble ul { margin: 4px 0; padding-left: 18px; white-space: normal; }
.lu-asst-bubble li { margin: 2px 0; }
.lu-asst-bubble p { margin: 0; }
.lu-asst-bubble p + p, .lu-asst-bubble p + ul, .lu-asst-bubble ul + p { margin-top: 6px; }
.lu-asst-bubble strong { font-weight: 600; }
.lu-asst-bubble.is-error { background: var(--danger-soft, #fdecea); border-color: transparent; color: var(--danger, #b4321f); }

.lu-asst-typing { display: inline-flex; align-items: center; gap: 4px; padding: 13px 16px; }
.lu-asst-typing span { width: 7px; height: 7px; border-radius: 99px; background: var(--ink-3, #999); animation: lu-asst-dot 1.2s infinite ease-in-out; }
.lu-asst-typing span:nth-child(2) { animation-delay: .15s; }
.lu-asst-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes lu-asst-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.lu-asst-in { animation: lu-asst-in .22s ease-out both; }
@keyframes lu-asst-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Menus and answer options from earlier steps are folded away once the student moved on. */
.lu-asst-msg .is-stale { display: none; }

/* ── Menu (list of services) ── */
.lu-asst-menu { display: flex; flex-direction: column; gap: 6px; }
.lu-asst-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  text-align: left; font: inherit; font-size: 14px; font-weight: 500; line-height: 1.35; cursor: pointer;
  padding: 10px 12px 10px 14px; border-radius: 12px;
  border: 1px solid var(--line, #e5e5e5); background: var(--surface, #fff); color: var(--ink, #1a1a1a);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.lu-asst-menu-item::after { content: '›'; font-size: 20px; line-height: 1; color: var(--ink-3, #999); flex: none; transition: transform .15s ease, color .15s ease; }
.lu-asst-menu-item:hover { border-color: var(--brand, #0b6b61); background: var(--brand-soft, #e0f0ec); color: var(--brand-ink, #075048); }
.lu-asst-menu-item:hover::after { color: var(--brand, #0b6b61); transform: translateX(2px); }
.lu-asst-menu-item.is-secondary { font-weight: 500; color: var(--ink-2, #555); background: transparent; border-style: dashed; }
.lu-asst-menu-item.is-secondary::after { content: none; }

/* ── Answer options (pills) ── */
.lu-asst-options { display: flex; flex-wrap: wrap; gap: 6px; }
.lu-asst-option {
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; line-height: 1.3;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--brand, #0b6b61);
  background: var(--surface, #fff); color: var(--brand-ink, #075048);
  transition: background .15s ease;
}
.lu-asst-option:hover { background: var(--brand-soft, #e0f0ec); }
.lu-asst-option.is-secondary { border-color: var(--line-strong, #ccc); color: var(--ink-2, #555); }

/* ── Action buttons ── */
.lu-asst-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.lu-asst-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong, #ccc); background: var(--surface, #fff); color: var(--ink, #1a1a1a);
  border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.lu-asst-btn:hover { border-color: var(--brand, #0b6b61); color: var(--brand-ink, #075048); }
.lu-asst-btn.is-primary { background: var(--brand, #0b6b61); border-color: var(--brand, #0b6b61); color: var(--on-brand, #fff); }
.lu-asst-btn.is-primary:hover { background: var(--brand-hover, #08574f); color: var(--on-brand, #fff); }
.lu-asst-btn:disabled { opacity: .5; cursor: default; }

/* ── Cards ── */
.lu-asst-cards { display: flex; flex-direction: column; gap: 8px; }
.lu-asst-card { display: flex; gap: 12px; padding: 12px; background: var(--surface, #fff); border: 1px solid var(--line, #e5e5e5); border-radius: 14px; }
.lu-asst-card img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2, #eee); }
.lu-asst-card-main { flex: 1; min-width: 0; }
.lu-asst-card-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.lu-asst-card-sub { font-size: 12px; color: var(--ink-3, #777); margin-top: 2px; }
.lu-asst-card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-2, #555); margin-top: 6px; }
.lu-asst-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft, #e0f0ec); color: var(--brand-ink, #075048); margin-left: 6px; vertical-align: 1px; }
.lu-asst-progress { height: 5px; border-radius: 99px; background: var(--surface-3, #e8e5dc); margin-top: 8px; overflow: hidden; }
.lu-asst-progress > span { display: block; height: 100%; background: var(--brand, #0b6b61); border-radius: 99px; }
.lu-asst-card-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lu-asst-card-btns .lu-asst-btn { height: 30px; padding: 0 12px; font-size: 12.5px; }

/* ── Confirm card (summary before an action runs) ── */
.lu-asst-box { padding: 14px 16px; background: var(--surface, #fff); border: 1px solid var(--line, #e5e5e5); border-radius: 14px; box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,.04)); }
.lu-asst-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.lu-asst-box-title { font-weight: 600; font-size: 14px; }
.lu-asst-box-lines { display: grid; gap: 4px; }
.lu-asst-box-line { font-size: 13px; color: var(--ink-2, #555); white-space: pre-wrap; overflow-wrap: anywhere; }
.lu-asst-box-line strong { color: var(--ink, #1a1a1a); font-weight: 600; }
.lu-asst-box .lu-asst-btns { margin-top: 14px; }
.lu-asst-box .lu-asst-btns .lu-asst-btn { flex: 1; }
.lu-asst-edits { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line, #e5e5e5); }
.lu-asst-link { border: 0; background: none; padding: 0; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--brand-ink, #075048); cursor: pointer; }
.lu-asst-link:hover { text-decoration: underline; }
.lu-asst-status { flex: none; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2, #f1efe9); color: var(--ink-2, #555); }
.lu-asst-status.is-done { background: var(--success-soft, #e3f4ea); color: var(--success, #1e7a46); }
.lu-asst-status.is-failed { background: var(--danger-soft, #fdecea); color: var(--danger, #b4321f); }
.lu-asst-box.is-closed { box-shadow: none; }
.lu-asst-box.is-closed .lu-asst-btns, .lu-asst-box.is-closed .lu-asst-edits { display: none; }
.lu-asst-box.is-closed .lu-asst-box-head { margin-bottom: 6px; }

/* ── Footer: chips and message box ── */
.lu-asst-chips {
  display: flex; gap: 8px; overflow-x: auto; flex: none; scrollbar-width: none;
  padding: 10px 14px; background: var(--surface, #fff); border-top: 1px solid var(--line, #e5e5e5);
}
.lu-asst-chips::-webkit-scrollbar { display: none; }
.lu-asst-chips[hidden] { display: none; }
.lu-asst-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 1px solid var(--line-strong, #ccc); background: var(--surface, #fff); color: var(--ink, #1a1a1a);
  border-radius: 999px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.lu-asst-chip:hover { border-color: var(--brand, #0b6b61); color: var(--brand-ink, #075048); background: var(--brand-soft, #e0f0ec); }

.lu-asst-input { display: flex; align-items: flex-end; gap: 8px; flex: none; padding: 10px 12px 12px; background: var(--surface, #fff); border-top: 1px solid var(--line, #e5e5e5); }
.lu-asst-chips:not([hidden]) + .lu-asst-input { border-top: 0; padding-top: 0; }
.lu-asst-input[hidden] { display: none; }
.lu-asst-input textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 42px; font: inherit; font-size: 14px; line-height: 1.45;
  color: var(--ink, #1a1a1a); background: var(--surface-2, #f4f4f4); border: 1px solid transparent; border-radius: 14px; padding: 10px 14px; box-sizing: border-box;
}
.lu-asst-input textarea:focus { outline: none; border-color: var(--brand, #0b6b61); background: var(--surface, #fff); }
.lu-asst-send {
  width: 42px; height: 42px; flex: none; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--brand, #0b6b61); color: var(--on-brand, #fff); display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, opacity .15s ease;
}
.lu-asst-send:hover:not(:disabled) { background: var(--brand-hover, #08574f); }
.lu-asst-send:disabled { opacity: .4; cursor: default; }
.lu-asst-send svg { width: 18px; height: 18px; }
.lu-asst-foot { text-align: center; font-size: 11px; color: var(--ink-3, #888); padding: 0 12px 8px; background: var(--surface, #fff); flex: none; }

.lu-asst-panel.is-busy .lu-asst-menu-item, .lu-asst-panel.is-busy .lu-asst-option, .lu-asst-panel.is-busy .lu-asst-chip { pointer-events: none; opacity: .6; }
.lu-asst-menu-item:focus-visible, .lu-asst-option:focus-visible, .lu-asst-btn:focus-visible, .lu-asst-chip:focus-visible, .lu-asst-link:focus-visible { outline: 2px solid var(--focus, #7fb7ff); outline-offset: 2px; }

/* ── Small screens: full-screen chat ── */
@media (max-width: 560px) {
  .lu-asst-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .lu-asst-fab { right: 16px; bottom: 80px; }
  .lu-asst-teaser { right: 16px; bottom: 148px; }
  .lu-asst-input { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .lu-asst-in, .lu-asst-teaser, .lu-asst-panel, .lu-asst-typing span { animation: none; }
  .lu-asst-fab, .lu-asst-menu-item::after { transition: none; }
  .lu-asst-body { scroll-behavior: auto; }
}
