/* Prayojan site assistant — floating chat widget (chat.js).
   Colors come from styles-v2.css's :root variables so the widget matches
   the dark theme on index.html and try.html. */

.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 110;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chat-fab:hover { transform: scale(1.07); box-shadow: 0 14px 34px rgba(99, 102, 241, 0.6); }

/* index.html's floating "Try now" balloon owns the bottom-right corner —
   lift the widget above it when both are on the page. */
.chat-lift .chat-fab { bottom: 168px; }
.chat-lift .chat-panel { bottom: 236px; }

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 110;
  width: 340px;
  height: 460px;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  font-family: var(--font);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.chat-head-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.chat-head-sub { font-size: 0.72rem; color: var(--text-faint); }
.chat-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.chat-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg-bot {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--indigo);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-note {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 0.78rem;
  text-align: center;
  padding: 2px 8px;
}

/* typing indicator — three pulsing dots in a bot bubble */
.chat-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  animation: chat-blink 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  outline: none;
}
.chat-input:focus { border-color: var(--indigo); }
.chat-send {
  border: none;
  border-radius: 12px;
  padding: 0 14px;
  background: var(--indigo);
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-send:not(:disabled):hover { filter: brightness(1.12); }

@media (max-width: 480px) {
  .chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 88px;
    height: 62vh;
  }
  .chat-fab { right: 16px; bottom: 16px; }
}

/* --- draggable / dismissible additions ------------------------------------- */

.chat-fab { touch-action: none; user-select: none; -webkit-user-select: none; }
.chat-fab.dragging { cursor: grabbing; transition: none; transform: none; }
.chat-fab.dragging:hover { transform: none; }
.chat-fab-open { filter: brightness(0.85); }

/* tiny dismiss badge on the bubble's corner */
.chat-fab-x {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  opacity: 0.85;
}
.chat-fab-x:hover { color: var(--text); background: var(--bg-raised); opacity: 1; }

/* slim tab docked to the screen edge while the widget is dismissed */
.chat-tab {
  position: fixed;
  z-index: 110;
  width: 28px;
  height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
}
.chat-tab:hover { background: var(--bg-raised); }
/* rounded on the side facing into the page */
.chat-tab[style*="left: 0"] { border-radius: 0 10px 10px 0; border-left: none; }
.chat-tab[style*="right: 0"] { border-radius: 10px 0 0 10px; border-right: none; }

/* author display:flex overrides the [hidden] UA rule — keep hidden working */
.chat-fab[hidden], .chat-tab[hidden], .chat-panel[hidden] { display: none; }
