/* ── TQM AI Chatbot Widget – Light Blue Theme ── */

/* ── Toggle button ── */
#tqm-chatbot-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A73E8 0%, #0D5BC4 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26, 115, 232, 0.45);
  animation: tqm-pulse 2.8s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

#tqm-chatbot-btn:hover {
  transform: scale(1.08);
  animation: none;
  box-shadow: 0 6px 28px rgba(26, 115, 232, 0.55);
}

@keyframes tqm-pulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(26, 115, 232, 0.4), 0 0 0 0 rgba(26, 115, 232, 0.4);
  }
  60% {
    box-shadow: 0 4px 20px rgba(26, 115, 232, 0.4), 0 0 0 14px rgba(26, 115, 232, 0);
  }
}

/* ── Panel ── */
#tqm-chatbot-panel {
  position: fixed;
  bottom: 110px;
  right: 28px;
  z-index: 9999;
  width: 432px;
  height: 600px;
  background: #ffffff;
  border-radius: 22px;
  box-shadow:
    0 16px 56px rgba(13, 71, 161, 0.18),
    0 4px 16px rgba(13, 71, 161, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(18px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

#tqm-chatbot-panel.tqm-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#tqm-chat-header {
  background: linear-gradient(135deg, #1A73E8 0%, #0D5BC4 100%);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

#tqm-chat-header-info {
  display: flex;
  align-items: center;
  gap: 11px;
}

#tqm-chat-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#tqm-chat-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

#tqm-chat-logo-fallback {
  display: none;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-family: Inter, sans-serif;
  letter-spacing: -0.3px;
}

#tqm-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

#tqm-chat-status-dot {
  width: 7px;
  height: 7px;
  background: #69F0AE;
  border-radius: 50%;
  animation: tqm-blink 2s ease-in-out infinite;
}

@keyframes tqm-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#tqm-chat-header-text h4 {
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 700;
  margin: 0 0 1px;
  font-family: Inter, sans-serif;
  line-height: 1.2;
}

#tqm-chat-header-text p {
  color: rgba(255,255,255,0.65);
  font-size: 11.5px;
  margin: 0;
  font-family: Inter, sans-serif;
  display: flex;
  align-items: center;
  gap: 5px;
}

#tqm-header-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

#tqm-close-btn,
#tqm-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.65);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  line-height: 0;
}

#tqm-close-btn:hover,
#tqm-clear-btn:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.12);
}

/* ── Messages ── */
#tqm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: #EAF4FD;
  scroll-behavior: smooth;
}

#tqm-messages::-webkit-scrollbar { width: 4px; }
#tqm-messages::-webkit-scrollbar-track { background: transparent; }
#tqm-messages::-webkit-scrollbar-thumb { background: #90CAF9; border-radius: 4px; }

/* ── Bubbles ── */
.tqm-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.6;
  font-family: Inter, -apple-system, sans-serif;
  word-break: break-word;
  animation: tqm-msg-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.tqm-msg.tqm-no-anim { animation: none; }

@keyframes tqm-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tqm-msg.tqm-bot {
  background: #ffffff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(13, 91, 196, 0.1);
}

.tqm-msg.tqm-user {
  background: linear-gradient(135deg, #1A73E8 0%, #0D5BC4 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* ── Action / nav buttons inside chat ── */
.tqm-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  align-self: flex-start;
  max-width: 88%;
}

.tqm-action-btn {
  padding: 7px 13px;
  background: #EAF4FD;
  border: 1.5px solid #64B5F6;
  border-radius: 20px;
  font-size: 12.5px;
  color: #0D5BC4;
  font-family: Inter, sans-serif;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tqm-action-btn:hover {
  background: #1A73E8;
  color: #ffffff;
  border-color: #1A73E8;
}

/* ── Quick chips ── */
#tqm-chips {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
  align-self: flex-start;
  width: 100%;
  max-width: 88%;
}

.tqm-chip {
  padding: 8px 14px;
  background: #DBEAFE;
  border: 1.5px solid #93C5FD;
  border-radius: 20px;
  font-size: 13px;
  color: #1E40AF;
  font-family: Inter, sans-serif;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  font-weight: 500;
}

.tqm-chip:hover {
  background: #1A73E8;
  color: #ffffff;
  border-color: #1A73E8;
}

/* ── Typing indicator ── */
.tqm-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 15px;
  background: #ffffff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(13, 91, 196, 0.1);
}

.tqm-typing span {
  width: 7px;
  height: 7px;
  background: #90CAF9;
  border-radius: 50%;
  display: inline-block;
  animation: tqm-bounce 1.2s ease-in-out infinite;
}
.tqm-typing span:nth-child(2) { animation-delay: 0.18s; }
.tqm-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes tqm-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input row ── */
#tqm-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #E3F2FD;
  flex-shrink: 0;
}

#tqm-input {
  flex: 1;
  border: 1.5px solid #BBDEFB;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: Inter, sans-serif;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  background: #F5FBFF;
  color: #1a1a2e;
  resize: none;
  line-height: 1.5;
}

#tqm-input:focus {
  border-color: #1A73E8;
  background: #ffffff;
}

#tqm-input::placeholder { color: #90CAF9; }

#tqm-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #42A5F5 0%, #1E88E5 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s, transform 0.12s;
  line-height: 0;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.35);
}

#tqm-send-btn:hover { opacity: 0.88; }
#tqm-send-btn:active { transform: scale(0.92); }
#tqm-send-btn:disabled {
  background: #CFD8DC;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #tqm-chatbot-btn { animation: none; }
  #tqm-chatbot-panel { transition: opacity 0.15s ease; transform: none; }
  #tqm-chatbot-panel.tqm-open { transform: none; }
  .tqm-msg { animation: none; }
  #tqm-chat-status-dot { animation: none; }
  #tqm-messages { scroll-behavior: auto; }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #tqm-chatbot-panel {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
    bottom: 96px;
    height: calc(100svh - 108px);
    max-height: 680px;
  }
  #tqm-chatbot-btn {
    right: 18px;
    bottom: 18px;
  }
}
