/* =========================================================
   Plansource AI Chatbot - chatbot.css
   Popup, messages, typing, cards, pills, feedback, etc.
   ========================================================= */

/* ── TOGGLE BUTTON ───────────────────────────────────── */
#chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  background: linear-gradient(135deg, #E8623A, #C94E28);
  color: white;
  border-radius: 99px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(232,98,58,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
}
#chatbot-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 32px rgba(232,98,58,0.6);
}
.chatbot-toggle-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ── CHATBOT CONTAINER ───────────────────────────────── */
#chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 999;
  width: 450px;
  height: 650px;
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(107,26,42,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
#chatbot-container.chatbot-hidden {
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
}
#chatbot-container.chatbot-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── CHATBOT HEADER ──────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, #6B1A2A, #5C1A26);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(232,98,58,0.6);
}
.chatbot-name {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
}
.chatbot-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chatbot-status-dot {
  width: 7px; height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  box-shadow: 0 0 6px #4ADE80;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; }
}
.chatbot-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chatbot-scenario-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(232,98,58,0.25);
  color: #FFCBB4;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(232,98,58,0.4);
  font-family: 'Inter', sans-serif;
}
.chatbot-reset {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  cursor: pointer;
  display: none; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chatbot-reset.visible { display: flex; }
.chatbot-reset:hover { background: rgba(255,255,255,0.2); }
.chatbot-reset svg { flex-shrink: 0; }
.chatbot-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chatbot-close:hover { background: rgba(255,255,255,0.2); }

/* ── MESSAGES AREA ───────────────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #F9F5F3;
  scroll-behavior: smooth;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(107,26,42,0.2); border-radius: 4px; }

/* ── MESSAGE BUBBLES ─────────────────────────────────── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-in 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-row.user { flex-direction: row-reverse; }
.msg-row.bot  { flex-direction: row; }

.msg-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.msg-avatar-sm.bot { background: linear-gradient(135deg, #6B1A2A, #E8623A); color: white; }
.msg-avatar-sm.user { background: linear-gradient(135deg, #E8623A, #C94E28); color: white; }

.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.55;
  font-family: 'Inter', sans-serif;
}
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, #E8623A, #C94E28);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-row.bot .msg-bubble {
  background: white;
  color: #2C2C2C;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* ── TYPING INDICATOR ────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  width: fit-content;
}
.typing-indicator.user-typing {
  background: linear-gradient(135deg, #E8623A, #C94E28);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(232,98,58,0.3);
}
.typing-indicator.user-typing .typing-dot {
  background: rgba(255,255,255,0.85);
}
.typing-dot {
  width: 8px; height: 8px;
  background: #E8623A;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── TOOL CALL CHIP ──────────────────────────────────── */
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFF8F5;
  border: 1px solid rgba(232,98,58,0.25);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #8B3A2A;
  font-family: 'Inter', sans-serif;
  animation: chip-in 0.3s ease forwards;
  margin: 2px 0;
}
.tool-chip .spin {
  width: 12px; height: 12px;
  border: 2px solid rgba(232,98,58,0.3);
  border-top-color: #E8623A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.tool-chip .done { color: #22C55E; font-size: 0.85rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes chip-in { from { opacity:0; transform: scale(0.9); } to { opacity:1; transform: scale(1); } }

/* ── CITATIONS ───────────────────────────────────────── */
.citation-block {
  margin-top: 12px;
  border-top: 1px solid rgba(107,26,42,0.08);
  padding-top: 10px;
}
.citation-toggle {
  font-size: 0.75rem;
  font-weight: 600;
  color: #E8623A;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  font-family: 'Inter', sans-serif;
}
.citation-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.citation-item {
  background: #FFF8F5;
  border: 1px solid rgba(232,98,58,0.2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.75rem;
}
.citation-doc { font-weight: 600; color: #5C1A26; }
.citation-page { font-size: 0.68rem; color: #9CA3AF; margin-top: 2px; }

/* ── FOLLOW-UP PILLS ─────────────────────────────────── */
.followup-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pill-btn {
  background: white;
  border: 1.5px solid rgba(232,98,58,0.4);
  color: #E8623A;
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  animation: pill-in 0.3s ease forwards;
}
.pill-btn:hover { background: #E8623A; color: white; transform: translateY(-1px); }
@keyframes pill-in { from { opacity:0; transform: scale(0.85); } to { opacity:1; transform: scale(1); } }

/* ── EMOJI FEEDBACK ──────────────────────────────────── */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(107,26,42,0.08);
}
.feedback-label {
  font-size: 0.72rem;
  color: #9CA3AF;
  font-weight: 500;
  margin-right: 4px;
}
.emoji-btn {
  font-size: 1.3rem;
  background: none;
  border: 2px solid transparent;
  border-radius: 99px;
  padding: 4px 6px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  line-height: 1;
}
.emoji-btn:hover { transform: scale(1.3); border-color: rgba(232,98,58,0.3); }
.emoji-btn.selected { border-color: #E8623A; background: #FFF0EB; transform: scale(1.2); }
.feedback-thanks {
  font-size: 0.72rem;
  font-weight: 600;
  color: #22C55E;
  animation: pop-in 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
  margin-left: 6px;
}
@keyframes pop-in { from { opacity:0; transform: scale(0.7); } to { opacity:1; transform: scale(1); } }

/* ── DEPENDENT CARD ──────────────────────────────────── */
.dep-card {
  background: white;
  border: 1px solid rgba(107,26,42,0.1);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  animation: msg-in 0.35s ease forwards;
}
.dep-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.dep-avatar.spouse { background: linear-gradient(135deg, #6B1A2A, #E8623A); }
.dep-avatar.child  { background: linear-gradient(135deg, #3B5BDB, #7C9EF8); }
.dep-info { flex: 1; }
.dep-name { font-size: 0.9rem; font-weight: 700; color: #2C2C2C; }
.dep-sub  { font-size: 0.75rem; color: #6B7280; margin-top: 2px; }
.dep-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}
.dep-badge.spouse { background: #FFF0EB; color: #E8623A; }
.dep-badge.child  { background: #EEF2FF; color: #3B5BDB; }
.dep-status {
  font-size: 0.7rem;
  color: #22C55E;
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

/* ── AI FORM CARD ────────────────────────────────────── */
.form-card {
  background: white;
  border: 1px solid rgba(107,26,42,0.1);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.form-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #5C1A26;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 5px;
}
.form-field {
  margin-bottom: 6px;
}
.form-field label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: #6B7280;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-field-value {
  background: #F9F5F3;
  border: 1.5px solid rgba(232,98,58,0.2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #2C2C2C;
  min-height: 28px;
  transition: border-color 0.3s;
}
.form-field-value.filling {
  border-color: #E8623A;
  animation: form-fill-pulse 0.5s ease;
}
@keyframes form-fill-pulse {
  0% { background: #FFF0EB; } 100% { background: #F9F5F3; }
}
.form-submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #E8623A, #C94E28);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  font-family: 'Inter', sans-serif;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.2s;
}
.form-submit-btn.visible { opacity: 1; }
.form-submit-btn:hover { transform: translateY(-1px); }

/* ── AGENT HANDOFF CARD ──────────────────────────────── */
.handoff-progress {
  margin: 10px 0;
  background: #F9F5F3;
  border-radius: 10px;
  padding: 14px;
}
.handoff-steps { display: flex; flex-direction: column; gap: 8px; }
.handoff-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #9CA3AF;
  font-weight: 500;
}
.handoff-step.active { color: #E8623A; }
.handoff-step.done   { color: #22C55E; }
.step-icon { font-size: 1rem; width: 20px; text-align: center; }

.agent-card {
  background: linear-gradient(135deg, #6B1A2A, #5C1A26);
  border-radius: 14px;
  padding: 16px;
  margin-top: 8px;
  color: white;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: msg-in 0.4s ease forwards;
}
.agent-avatar-lg {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8623A, #C94E28);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 3px solid rgba(255,255,255,0.3);
}
.agent-info .agent-name { font-size: 0.95rem; font-weight: 700; }
.agent-info .agent-role { font-size: 0.75rem; opacity: 0.75; margin-top: 2px; }
.agent-wait {
  margin-top: 6px;
  font-size: 0.72rem;
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-block;
  color: #FFCBB4;
}

/* ── RESET OVERLAY MODAL ─────────────────────────────── */
.reset-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(74,16,32,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  transition: opacity 0.2s ease;
}
.reset-overlay-hidden {
  opacity: 0;
  pointer-events: none;
}
.reset-overlay-visible {
  opacity: 1;
  pointer-events: all;
}
.reset-modal {
  background: white;
  border-radius: 16px;
  padding: 28px 24px 22px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
  animation: modal-pop 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.reset-modal-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}
.reset-modal-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #5C1A26;
  margin-bottom: 8px;
}
.reset-modal-body {
  font-size: 0.82rem;
  color: #6B7280;
  line-height: 1.55;
  margin-bottom: 20px;
  font-family: 'Inter', sans-serif;
}
.reset-modal-actions {
  display: flex;
  gap: 10px;
}
.reset-btn-confirm {
  flex: 1;
  background: linear-gradient(135deg, #6B1A2A, #5C1A26);
  color: white;
  border: none;
  border-radius: 99px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(107,26,42,0.3);
}
.reset-btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(107,26,42,0.4); }
.reset-btn-cancel {
  flex: 1;
  background: white;
  color: #6B1A2A;
  border: 1.5px solid rgba(107,26,42,0.2);
  border-radius: 99px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
}
.reset-btn-cancel:hover { background: #F9F5F3; }

/* ── INPUT AREA ──────────────────────────────────────── */
.chatbot-input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid rgba(107,26,42,0.08);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1.5px solid rgba(107,26,42,0.15);
  border-radius: 99px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: #2C2C2C;
  outline: none;
  transition: border-color 0.2s;
  background: #F9F5F3;
}
.chatbot-input:focus { border-color: #E8623A; background: white; }
.chatbot-input::placeholder { color: #9CA3AF; }
.chatbot-send {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #E8623A, #C94E28);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(232,98,58,0.4);
}
.chatbot-send:hover { transform: scale(1.08); box-shadow: 0 5px 16px rgba(232,98,58,0.5); }