/* ═══════════════════════════════════════════════════
   CHAT WIDGET — "Ask Sensei" floating button
   Self-contained: add/remove from any page without
   touching the main stylesheet. (Lesson 7)

   Z-index hierarchy (above nav drawer at 200):
     Floating button  → 99998
     Chat overlay     → 99999
═══════════════════════════════════════════════════ */

/* ── Floating button (Lessons 8 & 11) ──────────── */
#floatingChatBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;

  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  background: var(--green, #365341);
  color: var(--rice-paper, #FAF8F2);
  border: none;
  border-radius: 50px;      /* pill shape */
  cursor: pointer;

  font-family: Inter, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;

  box-shadow: 0 4px 20px rgba(54, 83, 65, 0.38);

  /* Lesson 11: opacity+scale transition instead of display:none */
  transition: opacity 0.3s ease, transform 0.3s ease,
              background 0.2s ease, box-shadow 0.2s ease;
  transform-origin: bottom right;
}

#floatingChatBtn:hover {
  background: var(--green-hover, #4A6E57);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(54, 83, 65, 0.44);
}

#floatingChatBtn .fcb-icon {
  font-size: 16px;
  line-height: 1;
}

/* Lesson 11: smooth hide — opacity+scale, NOT display:none */
#floatingChatBtn.chat-open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

/* Mobile adjustments (Lesson 13) */
@media (max-width: 600px) {
  #floatingChatBtn {
    bottom: 16px;
    right: 16px;
    padding: 12px 18px;
    font-size: 13px;
  }
}

/* ── Chat overlay (Lesson 10) ───────────────────── */
/*
 * pointer-events: none on the overlay so it doesn't
 * block the page — only #chatPanel restores clicks.
 */
#chatOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 99999;
  pointer-events: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 24px 24px 0;
}

#chatOverlay.active {
  display: flex;
}

/* Mobile: bottom sheet (Lesson 13) */
@media (max-width: 600px) {
  #chatOverlay {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }
}

/* ── Chat panel (Lessons 10 & 12) ───────────────── */
#chatPanel {
  width: 380px;
  height: 540px;
  background: var(--rice-paper, #FAF8F2);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 16px 56px rgba(0, 0, 0, 0.22),
    0 4px 16px rgba(0, 0, 0, 0.10);

  /* Lesson 10: restore pointer events only on the panel */
  pointer-events: all;

  /* Lesson 12: grow from the button corner */
  transform-origin: bottom right;
  animation: sw-expand 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Mobile: full-width bottom sheet (Lesson 13) */
@media (max-width: 600px) {
  #chatPanel {
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 80px);
    border-radius: 20px 20px 0 0;
    transform-origin: bottom center;
  }
}

/* Lesson 12: spring expand animation */
@keyframes sw-expand {
  0%   { opacity: 0.6; transform: scale(0.09); border-radius: 30px; }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: scale(1);    border-radius: 20px; }
}

/* ── Panel header ───────────────────────────────── */
#chatPanelHeader {
  background: var(--green, #365341);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#chatPanelAvatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  color: var(--rice-paper, #FAF8F2);
  flex-shrink: 0;
}

#chatPanelTitle {
  flex: 1;
  min-width: 0;
}

#chatPanelTitle strong {
  display: block;
  font-family: Inter, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--rice-paper, #FAF8F2);
  line-height: 1.3;
}

#chatPanelTitle span {
  font-family: Inter, sans-serif;
  font-size: 10.5px;
  font-weight: 400;
  color: rgba(250, 248, 242, 0.55);
  letter-spacing: 0.03em;
}

#chatCloseBtn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(250, 248, 242, 0.65);
  padding: 4px 6px;
  line-height: 1;
  font-size: 22px;
  flex-shrink: 0;
  transition: color 0.15s ease;
  border-radius: 4px;
}

#chatCloseBtn:hover {
  color: var(--rice-paper, #FAF8F2);
}

/* ── Iframe fills the rest of the panel ─────────── */
#chatFrame {
  flex: 1;
  border: none;
  width: 100%;
  display: block;
  background: var(--rice-paper, #FAF8F2);
}
