/* ============================================
   AI Opportunity Advisor — Chatbot (glass theme)
   ============================================ */

:root {
  --chat-w: 384px;
  --chat-h: 620px;
}

/* --- Floating Action Button --- */
.chatbot-fab {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-accent);
  z-index: 1099;
  transition: transform var(--t-spring), box-shadow var(--t-base), opacity var(--t-base);
}
.chatbot-fab:hover { transform: scale(1.06) translateY(-2px); box-shadow: 0 10px 34px rgba(99, 102, 241, 0.5); }
.chatbot-fab:active { transform: scale(0.95); }
.chatbot-fab__icon { width: 27px; height: 27px; position: relative; z-index: 2; }
.chatbot-fab__icon svg { width: 100%; height: 100%; }
.chatbot-fab.hidden { transform: scale(0) translateY(20px); opacity: 0; pointer-events: none; }

.chatbot-fab__pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--cyan); z-index: 1;
  animation: chat-pulse 2.6s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes chat-pulse {
  0% { transform: scale(0.95); opacity: 0.5; }
  70% { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  top: calc(var(--nav-gap) + var(--nav-h) + var(--sp-8));
  bottom: var(--sp-3);
  right: var(--sp-6);
  width: var(--chat-w);
  height: auto;
  max-height: none;
  background: var(--panel-pop);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1100;
  transform-origin: bottom right;
  transition: transform var(--t-spring), opacity var(--t-base);
}
.chatbot-window[aria-hidden="true"] {
  opacity: 0 !important;
  transform: translateY(20px) scale(0.95);
  pointer-events: none !important;
  visibility: hidden;
}
.chatbot-window--maximized {
  width: min(760px, 100vw) !important;
  height: 100vh !important;
  max-height: 100vh !important;
  inset: 0 0 0 auto !important;
  border-radius: 0 !important;
  transform: none !important;
}
@media (max-width: 480px) {
  .chatbot-window {
    width: 100%; height: 100%; max-height: 100vh;
    inset: 0 !important; border-radius: 0; transform: none !important;
  }
}

/* Header */
.chatbot-header {
  padding: var(--sp-4) var(--sp-5);
  background: var(--grad-cta);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 10;
  cursor: grab; user-select: none;
}
.chatbot-header:active { cursor: grabbing; }
.chatbot-header__info { display: flex; align-items: center; gap: var(--sp-3); }
.chatbot-header__avatar {
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.chatbot-header__avatar svg { width: 23px; height: 23px; color: #fff; }
.chatbot-header__title { font-family: var(--font-display); font-size: var(--fs-base); font-weight: 700; margin: 0; line-height: 1.2; }
.chatbot-header__status { font-size: var(--fs-xs); color: rgba(255, 255, 255, 0.85); display: flex; align-items: center; gap: 5px; }
.chatbot-header__status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 8px #4ade80;
}
.chatbot-header__controls { display: flex; align-items: center; gap: 2px; }
.chatbot-header__btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.75); background: transparent; border: none; cursor: pointer;
  transition: all var(--t-fast);
}
.chatbot-header__btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.chatbot-header__btn svg { width: 16px; height: 16px; pointer-events: none; }

/* Messages */
.chatbot-messages {
  flex: 1; overflow-y: auto;
  padding: var(--sp-5);
  background: transparent;
  display: flex; flex-direction: column; gap: var(--sp-4);
  scroll-behavior: smooth;
}
.chat-msg { display: flex; flex-direction: column; max-width: 86%; animation: chat-slide 0.3s ease-out forwards; }
@keyframes chat-slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg--bot { align-self: flex-start; }
.chat-msg--user { align-self: flex-end; }
.chat-msg__bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm); line-height: 1.55;
}
.chat-msg--bot .chat-msg__bubble {
  background: var(--glass-2);
  border: 1px solid var(--stroke);
  color: var(--text-1);
  border-bottom-left-radius: 5px;
}
.chat-msg--user .chat-msg__bubble {
  background: var(--grad-accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.chat-msg__bubble strong { font-weight: 700; }

/* Option chips */
.chat-options { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.chat-options--horizontal { flex-direction: row; flex-wrap: wrap; }
.chat-option-btn {
  background: var(--glass-2);
  border: 1px solid var(--stroke-2);
  color: var(--text-1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
  transition: all var(--t-fast); text-align: left;
}
.chat-option-btn:hover { background: var(--glass-3); border-color: var(--indigo); transform: translateY(-1px); }
.chat-option-btn--primary { background: var(--grad-accent); border-color: transparent; color: #fff; }
.chat-option-btn--primary:hover { box-shadow: var(--glow-accent); }

/* Typing */
.chat-typing {
  display: flex; align-items: center; gap: 4px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass-2); border: 1px solid var(--stroke);
  border-radius: var(--r-lg); border-bottom-left-radius: 5px;
  align-self: flex-start;
}
.chat-typing__dot { width: 6px; height: 6px; background: var(--text-3); border-radius: 50%; animation: chat-bounce 1.4s infinite ease-in-out both; }
.chat-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing__dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes chat-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Opportunity card in chat */
.chat-opp-card {
  background: var(--well);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-top: var(--sp-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.chat-opp-card__title { font-size: var(--fs-sm); font-weight: 700; color: var(--text-1); margin: 0; }
.chat-opp-card__org { font-size: var(--fs-xs); color: var(--text-3); }
.chat-opp-card__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-opp-card__match {
  font-size: var(--fs-xs); padding: 3px 9px;
  background: rgba(52, 211, 153, 0.14); color: var(--emerald);
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: var(--r-full); font-weight: 600;
}
.chat-opp-card__desc {
  font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5;
  padding: var(--sp-2) var(--sp-3);
  background: var(--glass);
  border-radius: var(--r-sm);
  border-left: 2px solid var(--cyan);
}
.chat-opp-card__actions { display: flex; gap: var(--sp-2); }
.chat-opp-card__btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: all var(--t-fast);
}
.chat-opp-card__btn--ghost { background: var(--glass-2); border-color: var(--stroke); color: var(--text-1); }
.chat-opp-card__btn--ghost:hover { background: var(--glass-3); }
.chat-opp-card__btn--primary { background: var(--grad-accent); color: #fff; }
.chat-opp-card__btn--primary:hover { box-shadow: var(--glow-accent); }
.chat-opp-card__btn--saved { background: rgba(52, 211, 153, 0.16); color: var(--emerald); border-color: rgba(52, 211, 153, 0.3); }

/* Input */
.chatbot-input {
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass);
  border-top: 1px solid var(--stroke);
  z-index: 10;
}
.chatbot-input__form {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--field-bg);
  border: 1px solid var(--stroke);
  border-radius: var(--r-full);
  padding: 4px 4px 4px var(--sp-4);
  transition: all var(--t-fast);
}
.chatbot-input__form:focus-within { border-color: rgba(129, 140, 248, 0.55); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16); }
.chatbot-input__field {
  flex: 1; border: none; background: transparent;
  font-size: var(--fs-sm); color: var(--text-1); outline: none; padding: var(--sp-2) 0;
}
.chatbot-input__field::placeholder { color: var(--text-3); }
.chatbot-input__send {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--t-fast); border: none; cursor: pointer;
}
.chatbot-input__send svg { width: 17px; height: 17px; }
.chatbot-input__send:not(:disabled):hover { transform: scale(1.06); box-shadow: var(--glow-accent); }
.chatbot-input__send:disabled { background: var(--glass-3); color: var(--text-3); cursor: not-allowed; }
.chatbot-input__footer { text-align: center; font-size: 10px; color: var(--text-3); margin-top: var(--sp-2); letter-spacing: 0.02em; }

/* Keep back-to-top clear of the FAB */
.backtop { bottom: calc(var(--sp-6) + 76px); }
@media (max-width: 480px) { .backtop { bottom: calc(var(--sp-6) + 70px); } }
