/*
 * chat.css — Floating AI chat widget
 * Gravity Projex | Copyright 2026
 */

#rwc-chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  font-family: var(--font-sans);
}

/* ── FAB BUTTON ─────────────────────────────────────────────────────────── */
#rwc-chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--steel);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: .2s ease;
  position: relative;
  color: var(--white);
}
#rwc-chat-fab:hover { background: var(--charcoal); transform: scale(1.06); }
#rwc-chat-fab.open  { background: var(--charcoal); }

.fab-icon { position: absolute; transition: .2s; display: flex; }
.fab-icon--open  { opacity: 1; transform: scale(1); }
.fab-icon--close { opacity: 0; transform: scale(0.6); }
#rwc-chat-fab.open .fab-icon--open  { opacity: 0; transform: scale(0.6); }
#rwc-chat-fab.open .fab-icon--close { opacity: 1; transform: scale(1); }

.fab-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 20px; height: 20px;
  background: var(--yellow);
  color: var(--steel);
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 900;
  align-items: center;
  justify-content: center;
  display: none;
  border: 2px solid var(--white);
}

/* ── CHAT PANEL ─────────────────────────────────────────────────────────── */
#rwc-chat-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-height: 640px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--sand);
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.chat-header {
  background: var(--steel);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header__info { display: flex; align-items: center; gap: .875rem; }
.chat-header__avatar {
  width: 36px; height: 36px;
  background: var(--yellow);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--steel);
  flex-shrink: 0;
}
.chat-header__name { font-size: .875rem; font-weight: 700; color: var(--white); }
.chat-header__status { font-size: .7rem; color: var(--concrete); display: flex; align-items: center; gap: .3rem; margin-top: .1rem; }
.online-dot { width: 7px; height: 7px; background: #4ade80; border-radius: 50%; }
.chat-close-btn { background: none; border: none; color: var(--concrete); cursor: pointer; padding: .25rem; transition: .15s; display: flex; }
.chat-close-btn:hover { color: var(--white); }

/* ── MESSAGES ───────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 200px;
  max-height: 340px;
  scroll-behavior: smooth;
}

/* When gate is visible, shrink messages to make room */
#rwc-chat-panel:has(#chat-gate:not([style*="display: none"])) .chat-messages {
  max-height: 140px;
}
.chat-msg { display: flex; }
.chat-msg--user     { justify-content: flex-end; }
.chat-msg--assistant { justify-content: flex-start; }

.chat-bubble {
  max-width: 80%;
  padding: .65rem .9rem;
  border-radius: 12px;
  font-size: .875rem;
  line-height: 1.55;
}
.chat-msg--user .chat-bubble {
  background: var(--steel);
  color: var(--white);
  border-bottom-right-radius: 3px;
}
.chat-msg--assistant .chat-bubble {
  background: var(--sand);
  color: var(--steel);
  border-bottom-left-radius: 3px;
}

/* Typing indicator */
.chat-msg--typing .chat-bubble {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .75rem .9rem;
}
.chat-msg--typing .chat-bubble span {
  display: block;
  width: 7px; height: 7px;
  background: var(--concrete);
  border-radius: 50%;
  animation: chat-bounce .9s infinite ease-in-out;
}
.chat-msg--typing .chat-bubble span:nth-child(2) { animation-delay: .15s; }
.chat-msg--typing .chat-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── SUGGESTIONS ────────────────────────────────────────────────────────── */
.chat-suggestions {
  padding: .4rem .75rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border-top: 1px solid var(--sand);
  flex-shrink: 0;
}
.chat-suggestion {
  text-align: left;
  background: none;
  border: 1px solid var(--sand);
  border-radius: 6px;
  padding: .35rem .65rem;
  font-family: inherit;
  font-size: .73rem;
  color: var(--grit);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-suggestion:hover { border-color: var(--steel); color: var(--steel); background: var(--sand); }

/* ── INPUT ──────────────────────────────────────────────────────────────── */
.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--sand);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  border: 1px solid var(--sand);
  border-radius: 8px;
  padding: .55rem .875rem;
  font-family: inherit;
  font-size: .875rem;
  color: var(--steel);
  resize: none;
  max-height: 120px;
  transition: border .15s;
  line-height: 1.4;
}
#chat-input:focus { outline: none; border-color: var(--steel); }
#chat-send-btn {
  width: 36px; height: 36px;
  background: var(--yellow);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--steel);
  flex-shrink: 0;
  transition: .15s;
}
#chat-send-btn:hover   { background: var(--yellow-dk); }
#chat-send-btn:disabled { opacity: .5; cursor: default; }

/* ── FOOTER NOTE ────────────────────────────────────────────────────────── */
.chat-footer-note {
  text-align: center;
  font-size: .65rem;
  color: var(--clay);
  padding: .3rem .75rem .5rem;
  border-top: 1px solid var(--sand);
  flex-shrink: 0;
}
.chat-footer-note a { color: var(--concrete); text-decoration: underline; }

/* ── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #rwc-chat-panel {
    position: fixed;
    bottom: 0; right: 0; left: 0;
    width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
  }
  #rwc-chat-widget { bottom: 1rem; right: 1rem; }
}

/* ── GATE FORM ──────────────────────────────────────────────────────────── */
.chat-gate {
  padding: 1rem;
  background: var(--sand);
  border-top: 1px solid var(--clay);
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 360px;
}
.chat-gate__header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 700;
  color: var(--steel);
  margin-bottom: .3rem;
}
.chat-gate__sub {
  font-size: .78rem;
  color: var(--grit);
  margin-bottom: .875rem;
}
.chat-gate__fields {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-bottom: .875rem;
}
.chat-gate__fields input,
.chat-gate__fields select,
.chat-gate__fields textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--clay);
  border-radius: 5px;
  font-family: inherit;
  font-size: .82rem;
  color: var(--steel);
  background: var(--white);
  transition: border .15s;
}
.chat-gate__fields input:focus,
.chat-gate__fields select:focus,
.chat-gate__fields textarea:focus { outline: none; border-color: var(--steel); }
.chat-gate__fields textarea { resize: none; min-height: 50px; }
.btn-gate-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  width: 100%;
  padding: .65rem 1rem;
  background: var(--yellow);
  color: var(--steel);
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .04em;
  cursor: pointer;
  transition: .15s;
}
.btn-gate-submit:hover { background: var(--yellow-dk); }
.btn-gate-skip {
  display: block;
  width: 100%;
  margin-top: .4rem;
  padding: .4rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .75rem;
  color: var(--concrete);
  cursor: pointer;
  text-align: center;
  transition: .15s;
}
.btn-gate-skip:hover { color: var(--grit); }
