/* =========================================================
   Arambh Assistant — Chatbot Widget
   ========================================================= */

.chat-fab {
  position: fixed;
  right: 24px; bottom: 78px;          /* sits above back-to-top */
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.40);
  z-index: 90;
  animation: chatBounce 3s ease-in-out infinite;
  transition: transform 0.3s, box-shadow 0.3s;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 16px 40px rgba(124, 58, 237, 0.55);
}
.chat-fab .chat-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  background: #22C55E;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes chatBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.chat-panel {
  position: fixed;
  right: 24px; bottom: 150px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 200px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.20);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 91;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid var(--border);
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  color: #fff;
  display: flex; align-items: center; gap: 0.75rem;
  position: relative;
  flex-shrink: 0;
}
.chat-header .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.chat-header h4 {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.chat-header p {
  font-size: 0.72rem;
  opacity: 0.85;
  margin: 0;
  display: flex; align-items: center; gap: 0.35rem;
}
.chat-header p::before {
  content: '';
  width: 7px; height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  display: inline-block;
}
.chat-close {
  position: absolute;
  right: 12px; top: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.chat-close:hover { background: rgba(255,255,255,0.28); transform: rotate(90deg); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  background: var(--bg);
  display: flex; flex-direction: column;
  gap: 0.8rem;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237,0.25);
  border-radius: 3px;
}

.chat-msg {
  max-width: 85%;
  padding: 0.65rem 0.95rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: msgIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 0.7rem 1rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.chat-typing span {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}

.chat-suggestions {
  display: flex; flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 1rem 0;
}
.chat-suggestion {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.chat-suggestion:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.85rem;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 0.65rem 0.95rem;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: #fff;
  outline: none;
  resize: none;
  max-height: 100px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 58, 237,0.12);
}
.chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.chat-send:hover { background: var(--accent-dark); transform: scale(1.06); }
.chat-send:disabled {
  background: #94A3B8;
  cursor: not-allowed;
  transform: none;
}

/* Dark mode for chatbot */
body.dark .chat-panel {
  background: #121A2B;
  border-color: var(--border);
}
body.dark .chat-body { background: #0B1120; }
body.dark .chat-msg.bot {
  background: #1B2436;
  color: var(--text);
  border-color: var(--border);
}
body.dark .chat-typing { background: #1B2436; border-color: var(--border); }
body.dark .chat-form {
  background: #121A2B;
  border-top-color: var(--border);
}
body.dark .chat-input {
  background: #0B1120;
  border-color: var(--border);
  color: var(--text);
}
body.dark .chat-suggestion {
  background: #1B2436;
  border-color: var(--border);
  color: var(--accent);
}

@media (max-width: 500px) {
  .chat-fab { right: 16px; bottom: 70px; width: 54px; height: 54px; font-size: 1.4rem; }
  .chat-panel {
    right: 12px; left: 12px; bottom: 132px;
    width: auto;
    height: calc(100vh - 170px);
  }
}


/* ---- Responsive: mobile chat + multiline messages ---- */
.chat-msg { white-space: pre-line; }
@media (max-width: 600px) {
  .chat-panel {
    right: 10px; left: 10px; width: auto;
    bottom: 84px; height: calc(100vh - 120px); max-height: none;
    border-radius: 16px;
  }
  .chat-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; font-size: 1.4rem; }
  .chat-suggestions { flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .chat-panel { bottom: 78px; height: calc(100vh - 110px); }
}
