/* Chesky chat widget - a floating help assistant, present on every page. */

.chesky-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--navy);
  box-shadow: var(--shadow), 0 10px 24px -8px rgba(31, 59, 87, 0.45);
  cursor: pointer;
  z-index: 1000;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.chesky-fab:hover { transform: translateY(-2px); }
.chesky-fab img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.chesky-fab .chesky-close-ico { display: none; color: #fff; font-size: 26px; line-height: 1; }
.chesky-fab.open img { display: none; }
.chesky-fab.open .chesky-close-ico { display: block; }
.chesky-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chesky-nudge {
  position: fixed;
  right: 90px;
  bottom: 30px;
  max-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--ink);
  z-index: 999;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.chesky-nudge.show { opacity: 1; transform: none; pointer-events: auto; }
.chesky-nudge button { position: absolute; top: 2px; right: 6px; border: none; background: none; cursor: pointer; color: var(--ink-soft); font-size: 14px; }

.chesky-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: min(70vh, 560px);
  background: var(--paper);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), 0 20px 50px -16px rgba(31, 59, 87, 0.35);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s;
}
.chesky-panel.open { opacity: 1; transform: none; visibility: visible; }

.chesky-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
}
.chesky-head img { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.chesky-head strong { display: block; font-size: 0.92rem; }
.chesky-head span { display: block; font-size: 0.72rem; color: var(--gold-light); }

.chesky-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chesky-msg { display: flex; flex-direction: column; max-width: 86%; }
.chesky-msg.from-visitor { align-self: flex-end; align-items: flex-end; }
.chesky-msg.from-bot, .chesky-msg.from-admin { align-self: flex-start; align-items: flex-start; }
.chesky-bubble {
  padding: 8px 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: #fff;
  white-space: pre-wrap;
}
.chesky-msg.from-visitor .chesky-bubble { background: var(--navy); color: #fff; border-color: var(--navy); }
.chesky-msg.from-admin .chesky-bubble { background: var(--gold-light); border-color: var(--gold); }
.chesky-msg-who { font-size: 0.68rem; color: var(--ink-soft); margin-bottom: 2px; }

.chesky-fb { display: flex; gap: 6px; margin-top: 4px; }
.chesky-fb button { border: none; background: none; cursor: pointer; font-size: 13px; opacity: 0.55; padding: 2px; }
.chesky-fb button:hover, .chesky-fb button.picked { opacity: 1; }

.chesky-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chesky-chip {
  border: 1px solid var(--gold);
  background: #fff;
  color: var(--navy);
  font-size: 0.78rem;
  padding: 5px 10px;
  cursor: pointer;
}
.chesky-chip:hover { background: var(--gold-light); }

.chesky-typing { display: inline-flex; gap: 3px; padding: 8px 12px; border: 1px solid var(--border); background: #fff; }
.chesky-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-soft); animation: chesky-bounce 1.2s infinite; }
.chesky-typing span:nth-child(2) { animation-delay: 0.15s; }
.chesky-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chesky-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

.chesky-form {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
  background: #fff;
}
.chesky-form .chesky-row { display: flex; gap: 6px; align-items: flex-end; }
.chesky-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.86rem;
  max-height: 80px;
  font-family: var(--font-body);
}
.chesky-form button[type="submit"] {
  background: var(--cta);
  color: #fff;
  border: none;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  flex-shrink: 0;
}
.chesky-form button[type="submit"]:disabled { opacity: 0.6; cursor: default; }
.chesky-mic-btn {
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  padding: 8px 9px;
  flex-shrink: 0;
  font-size: 15px;
}
.chesky-mic-btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); }

.chesky-handoff {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
  background: #fff;
}
.chesky-handoff .form-row { margin-bottom: 8px; }
.chesky-handoff label { display: block; font-size: 0.76rem; color: var(--ink-soft); margin-bottom: 2px; }
.chesky-handoff input, .chesky-handoff textarea {
  width: 100%;
  border: 1px solid var(--border);
  padding: 7px 9px;
  font: inherit;
  font-size: 0.86rem;
  font-family: var(--font-body);
}
.chesky-handoff button[type="submit"] {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 9px;
  cursor: pointer;
  font-size: 0.86rem;
}

.chesky-talk-human {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--cta);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

@media (max-width: 520px) {
  .chesky-panel { right: 10px; left: 10px; bottom: 86px; width: auto; height: min(74vh, 600px); }
  .chesky-nudge { right: 70px; }
  .chesky-fab { right: 14px; bottom: 14px; width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .chesky-fab, .chesky-panel, .chesky-nudge, .chesky-typing span { transition: none; animation: none; }
}
