/* Grip-Engineering Chat Widget */
#grip-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a7ca5 0%, #2a5c85 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#grip-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
#grip-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}
#grip-chat-bubble .grip-chat-close {
  display: none;
}
#grip-chat-bubble.open .grip-chat-icon { display: none; }
#grip-chat-bubble.open .grip-chat-close { display: block; }

/* Chat Window */
#grip-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  z-index: 99998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}
#grip-chat-window.open {
  display: flex;
  animation: gripChatSlideUp 0.25s ease-out;
}

@keyframes gripChatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.grip-chat-header {
  background: linear-gradient(135deg, #3a7ca5 0%, #2a5c85 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.grip-chat-header-icon {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.grip-chat-header-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
.grip-chat-header-text {
  flex: 1;
}
.grip-chat-header-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.grip-chat-header-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin: 0;
}
.grip-chat-header-reset {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: color 0.15s;
}
.grip-chat-header-reset:hover {
  color: #fff;
}

/* Messages area */
.grip-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.grip-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.5;
}
.grip-chat-msg a {
  color: #3a7ca5;
  text-decoration: underline;
}
.grip-chat-msg-user {
  align-self: flex-end;
  background: #3a7ca5;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.grip-chat-msg-user a {
  color: #d0e8f5;
}
.grip-chat-msg-bot {
  align-self: flex-start;
  background: #f0f2f5;
  color: #333;
  border-bottom-left-radius: 4px;
}
.grip-chat-msg-typing {
  align-self: flex-start;
  background: #f0f2f5;
  padding: 12px 18px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.grip-chat-typing-dots {
  display: flex;
  gap: 4px;
}
.grip-chat-typing-dots span {
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  animation: gripChatBounce 1.4s infinite ease-in-out both;
}
.grip-chat-typing-dots span:nth-child(1) { animation-delay: 0s; }
.grip-chat-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.grip-chat-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes gripChatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.grip-chat-input-area {
  padding: 10px 14px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fafafa;
}
.grip-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: Arial, Helvetica, sans-serif;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  background: #fff;
}
.grip-chat-input:focus {
  border-color: #3a7ca5;
}
.grip-chat-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #3a7ca5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.grip-chat-send:hover {
  background: #2a5c85;
}
.grip-chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.grip-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* Powered by */
.grip-chat-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #aaa;
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
  #grip-chat-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 80px;
    height: calc(100vh - 100px);
  }
  #grip-chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}
