/* ─────────────────────────────────────────────────────────────
   THE FACULTY LOUNGE — Floating chat widget
   A docked, Facebook-style chat that can live on any page.
   Paired with chat-widget.js. Uses the same green design tokens
   as the rest of the site; falls back to its own values if the
   page doesn't define them.
   ───────────────────────────────────────────────────────────── */

.flc-root {
  --flc-forest: var(--forest, #1d6349);
  --flc-green:  var(--green, #2e7d5e);
  --flc-pale:   var(--pale-g, #e6f5ef);
  --flc-cream:  var(--cream, #f5fbf7);
  --flc-text:   var(--text, #1A2820);
  --flc-muted:  var(--muted, #4F6D5F);
  --flc-border: var(--border, #e4ede9);
  --flc-theirs: #eef6f2;
  --flc-font:   var(--font-sans, 'DM Sans', system-ui, sans-serif);
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9000;
  font-family: var(--flc-font);
}

/* ── Launcher bubble ── */
.flc-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--flc-forest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(29,99,73,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.flc-launcher:hover { transform: translateY(-2px); box-shadow: 0 9px 26px rgba(29,99,73,0.42); }
.flc-launcher svg { width: 25px; height: 25px; stroke: #fff; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.flc-launcher-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: #e74c3c; color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.flc-launcher-badge[hidden] { display: none; }

/* ── Panel ── */
.flc-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 340px;
  height: 470px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border: 1px solid var(--flc-border);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(29,99,73,0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: flc-pop 0.16s ease-out;
}
.flc-panel[hidden] { display: none; }
@keyframes flc-pop { from { opacity: 0; transform: scale(0.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (prefers-reduced-motion: reduce) { .flc-panel, .flc-launcher { animation: none; transition: none; } }

.flc-head {
  flex-shrink: 0;
  background: var(--flc-forest);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.flc-back {
  background: none; border: none; cursor: pointer; padding: 2px;
  display: none; align-items: center; color: #fff;
}
.flc-back svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; }
.flc-head.thread .flc-back, .flc-head.newmsg .flc-back { display: inline-flex; }
.flc-head-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: none; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; overflow: hidden;
  background: var(--flc-pale); color: var(--flc-green);
}
.flc-head.thread .flc-head-avatar { display: flex; }
.flc-head-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* Content-width so the "+" sits right next to the word (the minimize button is
   pushed right by .flc-head-actions margin-left:auto). In thread view it can
   still shrink and ellipsis a long name because of min-width:0. */
.flc-title { font-size: 15px; font-weight: 600; flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flc-head-actions { display: flex; gap: 4px; margin-left: auto; }
.flc-icon-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: 6px; display: inline-flex; color: rgba(255,255,255,0.85);
  transition: background 0.12s;
}
.flc-icon-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }
.flc-icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
/* "New message" compose button — only shown on the conversation list */
.flc-new {
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: 6px; display: inline-flex; color: rgba(255,255,255,0.85);
  transition: background 0.12s;
}
.flc-new:hover { background: rgba(255,255,255,0.18); color: #fff; }
.flc-new svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flc-head.thread .flc-new, .flc-head.newmsg .flc-new { display: none; }

/* ── Views ── */
.flc-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.flc-view { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.flc-view.active { display: flex; }

/* Conversation list */
.flc-list { flex: 1; overflow-y: auto; }
/* A11Y (August 2026): conversation rows (both the list and the new-message search
   results) are real <button>s now; they used to be click-only divs, so a keyboard
   user could open the panel but never open a conversation. Nothing interactive is
   nested inside a row, so the whole row is the button. The declarations below the
   blank line are the button resets that keep it pixel-identical to the old div. */
.flc-convo {
  display: flex; gap: 10px; align-items: center;
  padding: 11px 14px; cursor: pointer;
  border: none; border-bottom: 1px solid var(--flc-border);
  transition: background 0.1s;

  width: 100%; background: none; appearance: none; -webkit-appearance: none;
  font: inherit; color: inherit; text-align: left;
}
.flc-convo:hover { background: #f4fbf7; }
.flc-convo:focus { outline: none; }
.flc-convo:focus-visible { outline: 2px solid var(--flc-green); outline-offset: -2px; }
.flc-convo-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: var(--flc-pale); color: var(--flc-green);
}
.flc-convo-avatar img { width: 100%; height: 100%; object-fit: cover; }
.flc-convo-body { flex: 1; min-width: 0; }
.flc-convo-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.flc-convo-name { font-size: 13.5px; font-weight: 500; color: var(--flc-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flc-convo.unread .flc-convo-name { font-weight: 700; }
.flc-convo-time { font-size: 10.5px; color: var(--flc-muted); flex-shrink: 0; white-space: nowrap; }
.flc-convo-preview { font-size: 12px; color: var(--flc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.flc-convo.unread .flc-convo-preview { color: var(--flc-text); }
.flc-convo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--flc-green); flex-shrink: 0; margin-left: 4px; }
.flc-convo-dot[hidden] { display: none; }
.flc-empty { padding: 32px 20px; text-align: center; font-size: 13px; color: var(--flc-muted); }

/* Blocked-state bar (replaces the compose box in a blocked thread) */
.flc-blocked {
  flex-shrink: 0; border-top: 1px solid var(--flc-border);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; background: #fff;
}
.flc-blocked[hidden] { display: none; }
.flc-blocked-text { flex: 1; font-size: 12px; color: var(--flc-muted); line-height: 1.4; }
.flc-unblock {
  flex-shrink: 0; border: 1px solid var(--flc-border); background: var(--flc-cream);
  color: var(--flc-green); font-family: var(--flc-font); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: border-color 0.12s;
}
.flc-unblock:hover { border-color: var(--flc-green); }
.flc-blocked-tag { color: #b4453a; font-weight: 600; }

/* New-message search view */
.flc-newsearch { flex-shrink: 0; padding: 10px 12px; border-bottom: 1px solid var(--flc-border); }
.flc-newinput {
  width: 100%; border: 1px solid var(--flc-border); border-radius: 18px;
  padding: 8px 13px; font-family: var(--flc-font); font-size: 13px;
  background: var(--flc-cream); color: var(--flc-text);
}
.flc-newinput:focus { outline: none; border-color: var(--flc-green); }
.flc-newinput::placeholder { color: var(--flc-muted); }
.flc-results { flex: 1; overflow-y: auto; }

/* Thread view */
.flc-thread { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--flc-cream); }
.flc-row { display: flex; width: 100%; gap: 7px; align-items: flex-end; }
.flc-row.mine { justify-content: flex-end; }
.flc-mine-col { display: flex; flex-direction: column; align-items: flex-end; }
.flc-mine-col, .flc-their-col { min-width: 0; max-width: 76%; }
.flc-avt {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; background: var(--flc-theirs); color: var(--flc-green);
}
.flc-avt img { width: 100%; height: 100%; object-fit: cover; }
.flc-bubble {
  max-width: 100%; padding: 8px 12px; font-size: 13px; line-height: 1.5;
  border-radius: 14px; overflow-wrap: anywhere;
}
.flc-bubble.theirs { background: var(--flc-theirs); color: var(--flc-text); border-radius: 14px 14px 14px 4px; }
.flc-bubble.mine { background: var(--flc-forest); color: rgba(255,255,255,0.95); border-radius: 14px 14px 4px 14px; }
.flc-time { font-size: 10px; color: var(--flc-muted); margin-top: 2px; }
.flc-mine-col .flc-time { color: var(--flc-muted); }
.flc-sys { align-self: center; font-size: 11px; color: var(--flc-muted); background: #fff; border: 1px solid var(--flc-border); padding: 4px 10px; border-radius: 10px; text-align: center; max-width: 90%; }

/* Compose */
.flc-compose { flex-shrink: 0; border-top: 1px solid var(--flc-border); padding: 9px 10px; display: flex; gap: 7px; align-items: flex-end; background: #fff; }
.flc-input {
  flex: 1; border: 1px solid var(--flc-border); border-radius: 18px; padding: 8px 13px;
  font-family: var(--flc-font); font-size: 13px; resize: none; background: var(--flc-cream);
  color: var(--flc-text); min-height: 36px; max-height: 90px; line-height: 1.4;
}
.flc-input:focus { outline: none; border-color: var(--flc-green); }
.flc-send {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--flc-green); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.12s;
}
.flc-send:hover { opacity: 0.88; }
.flc-send svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; }

/* A11Y (August 2026): visually hidden polite live region used by
   chat-widget.js to announce incoming messages to screen readers while the
   panel is open. Standard screen-reader-only pattern; it renders nothing on
   screen and takes no layout space (.flc-root is position:fixed, this child
   is absolutely positioned and clipped to 1px). */
/* .flc-sr is the same visually-hidden treatment without the live-region role,
   used for the "Unread" text on conversation rows (August 2026). */
.flc-live, .flc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Mobile: full-width panel */
@media (max-width: 480px) {
  .flc-root { right: 12px; bottom: 12px; }
  .flc-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
  /* Slightly smaller bubble on phones so it intrudes less on content
     (July 2026 mobile review). */
  .flc-launcher { width: 48px; height: 48px; }
  .flc-launcher svg { width: 22px; height: 22px; }
}

/* Auto-hide the launcher bubble when the footer / bottom CTA is in view so
   it never sits on top of those controls. Only the closed launcher hides;
   an open chat panel is left alone. Toggled by chat-widget.js via an
   IntersectionObserver on the page footer. Scoped to phones (<=768px) — on
   larger screens there is room to spare, so desktop behavior is unchanged.
   (July 2026 mobile review.) */
@media (max-width: 768px) {
  .flc-root.flc-at-footer .flc-launcher {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }
}
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .flc-root.flc-at-footer .flc-launcher { transition: none; }
}
