/* =============================================================
   CEDRAVA — chat-widget.css
   Deliberately separate from styles.css: this component has its
   own typography (Work Sans, per the client's spec for the chat
   specifically) and a light-panel-on-dark-launcher pattern that
   doesn't otherwise appear on the site.
   ============================================================= */
:root {
  --chat-bone: #EDEFF1;
  --chat-navy: #1B2430;
  --chat-navy-rgb: 27, 36, 48;
  --chat-copper: #B8875F;
  --chat-copper-rgb: 184, 135, 95;
  --chat-stone: #6B7280;
  --chat-line: rgba(27, 36, 48, .12);
  --chat-font: "Work Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.cdv-chat-launcher {
  position: fixed; right: 1.4rem; bottom: 1.4rem; z-index: 900;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--chat-navy); color: var(--chat-bone);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; font-family: var(--chat-font);
  box-shadow: 0 8px 24px -6px rgba(0,0,0,.4);
  transition: transform .25s ease;
}
.cdv-chat-launcher:hover { transform: translateY(-2px); }
.cdv-chat-launcher svg { width: 26px; height: 26px; }
.cdv-chat-launcher .cdv-chat-dot {
  position: absolute; top: 4px; right: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--chat-copper); border: 2px solid var(--chat-navy);
}

.cdv-chat-panel {
  position: fixed; right: 1.4rem; bottom: 5.6rem; z-index: 900;
  width: min(380px, calc(100vw - 2.4rem)); height: min(600px, calc(100vh - 8rem));
  background: var(--chat-bone); color: var(--chat-navy);
  border-radius: 16px; overflow: hidden; display: none;
  flex-direction: column; font-family: var(--chat-font);
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.45);
}
.cdv-chat-panel.is-open { display: flex; }

.cdv-chat-header {
  background: var(--chat-navy); color: var(--chat-bone);
  padding: .9rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  flex: none;
}
.cdv-chat-header-title { font-weight: 600; font-size: .95rem; }
.cdv-chat-header-sub { font-size: .72rem; color: rgba(237,239,241,.6); margin-top: .1rem; }
.cdv-chat-header-actions { display: flex; align-items: center; gap: .5rem; }
.cdv-chat-book-link {
  font-size: .72rem; font-weight: 600; color: var(--chat-copper);
  border: 1px solid rgba(184,135,95,.5); border-radius: 999px; padding: .35rem .7rem;
  white-space: nowrap;
}
.cdv-chat-book-link:hover { background: rgba(184,135,95,.15); }
.cdv-chat-close {
  background: transparent; border: none; color: var(--chat-bone); cursor: pointer;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; opacity: .8;
}
.cdv-chat-close:hover { opacity: 1; }

.cdv-chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem;
}
.cdv-chat-msg { max-width: 84%; font-size: .87rem; line-height: 1.45; padding: .65rem .85rem; border-radius: 12px; }
.cdv-chat-msg.user { align-self: flex-end; background: var(--chat-navy); color: var(--chat-bone); border-bottom-right-radius: 3px; }
.cdv-chat-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--chat-line); border-bottom-left-radius: 3px; }
.cdv-chat-msg.typing { align-self: flex-start; background: #fff; border: 1px solid var(--chat-line); display: flex; gap: .3rem; padding: .8rem 1rem; }
.cdv-chat-msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--chat-stone); opacity: .5; animation: cdvTypingDot 1.1s ease-in-out infinite; }
.cdv-chat-msg.typing span:nth-child(2) { animation-delay: .15s; }
.cdv-chat-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cdvTypingDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.cdv-chat-escalate {
  align-self: stretch; background: rgba(184,135,95,.12); border: 1px solid rgba(184,135,95,.4);
  border-radius: 12px; padding: .8rem .9rem; font-size: .82rem; display: flex; flex-direction: column; gap: .6rem;
}
.cdv-chat-escalate a {
  align-self: flex-start; background: var(--chat-copper); color: #1A1410; font-weight: 600;
  font-size: .8rem; padding: .5rem .9rem; border-radius: 999px;
}

.cdv-chat-form { flex: none; display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--chat-line); background: #fff; }
.cdv-chat-input {
  flex: 1; border: 1px solid var(--chat-line); border-radius: 999px; padding: .6rem 1rem;
  font-family: var(--chat-font); font-size: .87rem; color: var(--chat-navy); background: var(--chat-bone);
}
.cdv-chat-input:focus { outline: none; border-color: var(--chat-copper); }
.cdv-chat-send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--chat-copper); color: #1A1410; display: flex; align-items: center; justify-content: center;
}
.cdv-chat-send:disabled { opacity: .5; cursor: default; }
.cdv-chat-send svg { width: 17px; height: 17px; }

@media (max-width: 480px) {
  .cdv-chat-panel { right: .6rem; bottom: 5rem; }
  .cdv-chat-launcher { right: 1rem; bottom: 1rem; }
}
