/* ====================================================================
 * 7.1a  AI CHATBOX  –  extracted styles
 * ===================================================================*/

/* 7.1a-01  Floating toggle button & icon */
#chat-toggle {
  position: fixed;
  bottom: 90px;
  right: 20px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 9999;
}
#chat-toggle img {
  width: 60px;
  height: 60px;
  display: block;
  transition: transform .2s ease;
}
#chat-toggle:hover img {
  transform: scale(1.1);
}

/* 7.1a-02  “shake” attention-grab */
@keyframes chatToggleShake {
  0%,100% { transform: none; }
  10%     { transform: translate(-3px,-2px) rotate(-2deg); }
  20%     { transform: translate(4px, 2px) rotate(2deg); }
  30%     { transform: translate(-4px, 2px) rotate(-2deg); }
  40%     { transform: translate(4px,-2px) rotate(2deg); }
  50%     { transform: translate(-3px, 1px) rotate(-1deg); }
  60%     { transform: translate(3px,-1px) rotate(1deg); }
  70%     { transform: translate(-2px, 2px) rotate(-1deg); }
  80%     { transform: translate(2px,-2px) rotate(1deg); }
  90%     { transform: translate(-1px, 1px) rotate(0deg); }
}
.shake {
  animation: chatToggleShake 1.2s ease-in-out;
}

/* 7.1a-03  Main floating chat window */
#chat-window,
#chat-window * {
  color: var(--mygpt-font-col) !important;
}
#chat-window {
  position: fixed;
  bottom: 160px;
  right: 20px;
  width: 300px;
  max-height: 400px;
  background: var(--mygpt-input-bg);
  border: 1px solid #ccc;
  border-radius: 10px;
  display: none;
  flex-direction: column;
  z-index: 9998;
  box-shadow: 0 0 10px rgba(0,0,0,.2);
  overflow: hidden;
}

/* 7.1a-04  Header bar */
#chat-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding-right: 8px;
  background: var(--mygpt-header-bg);
  border-bottom: 1px solid #ddd;
}
#chat-header span {
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
}
#minimize-btn {
  font-size: 22px;
  transform: scaleX(1.4);
}

/* 7.1a-05  Chat log */
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-size: 14px;
}
.chat-container {
  max-width: 75%;
  margin-bottom: 10px;
  clear: both;
}
.user-msg {
  background: var(--mygpt-user-bg);
  padding: 12px 16px;
  border-radius: 16px;
  border-top-right-radius: 4px;
}
.ai-msg {
  background: var(--mygpt-ai-bg);
  padding: 12px 16px;
  border-radius: 16px;
  border-top-left-radius: 4px;
}
.chat-label {
  font-size: 11px;
  font-weight: bold;
  color: #555;
  margin-bottom: 2px;
}
.chat-label.user { text-align: right; }
.chat-label.ai   { text-align: left; }

/* 7.1a-05a  Prevent overflow in message bubbles */
.user-msg,
.ai-msg {
  /* wrap long words and URLs inside the bubble */
  overflow-wrap: break-word;
  word-break: break-word;
  /* preserve manual line breaks, but wrap normally */
  white-space: pre-wrap;
}

/* 7.1a-06  Input row */
#chat-input {
  display: flex;
  border-top: 1px solid #ddd;
}
#chat-input input {
  flex: 1;
  border: none;
  padding: 10px;
  background: var(--mygpt-input-bg);
  color: var(--mygpt-font-col);
}
#chat-input button {
  background: var(--mygpt-send-btn-bg, turquoise);
  color: #fff;
  border: 2px solid #333;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 20px;      /* ← pill shape */
  appearance: none;         /* strip any browser default */
  outline: none;
}

/* 7.1a-07  Pre-chat form */
#prechat {
  padding: 14px;
  font-size: 14px;
}
#prechat input {
  width: 100%;
  margin-bottom: 6px;
  padding: 6px;
  background: var(--mygpt-input-bg);
  color: var(--mygpt-font-col);
}
#prechat small {
  font-size: 11px;
  color: #666;
}
#prechat button {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  font-size: 14px;
}

/* 7.1a-08  Scroll-to-bottom arrow – header color, solid, black outline + grow on hover */
#chat-window #scroll-down-btn {
  position: absolute;
  bottom: 48px;             /* just above input */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 2px solid #000;
  border-radius: 50%;
  background: var(--mygpt-header-bg, #90D9F7);
  opacity: 1;
  cursor: pointer;
  transition: transform .2s ease;
  z-index: 10001;
}
#chat-window #scroll-down-btn::after {
  content: '↓';
  font-size: 18px;
  line-height: 1;
  color: var(--mygpt-font-col, #222);
}
#chat-window #scroll-down-btn:hover {
  transform: translateX(-50%) scale(1.15);
}

/* 7.1a-09  Typing-dots indicator */
.typing-dots {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding-left: 16px; /* match bubble padding */
}
.typing-dots .dot {
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--mygpt-ai-bg);
  opacity: 0.4;
  animation: blink 1s infinite ease-in-out;
}
.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

/* 7.1a-10  Sent marker */
.sent-marker {
  font-size: 11px;
  color: #666;
  margin: 4px 0;
}

/* 7.1a-11  blink keyframes */
@keyframes blink {
  0%, 80%, 100% { opacity: 0.4; }
  40%           { opacity: 1;   }
}

/* ====================================================================
 * 7.1b  Footer branding (unchanged)
 * ===================================================================*/
#chat-footer {
  height: 50px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #ddd;
}
#chat-footer a {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 300;
  color: #666;
  text-decoration: none;
}
#chat-footer img {
  height: 44px;
  margin-left: 6px;
  display: block;
}
