/* Floating AI support chat — matches site green theme */

.ai-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1080;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: row;
  gap: 10px;
  width: auto;
  max-width: none;
  height: auto;
  min-height: 52px;
  padding: 8px 18px 8px 8px;
  margin: 0;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: var(--primary-gradient, linear-gradient(135deg, #2E8B57 0%, #3CB371 100%));
  color: #fff;
  box-shadow: 0 8px 24px rgba(46, 139, 87, 0.4);
  overflow: visible;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.ai-chat-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(46, 139, 87, 0.5);
  color: #fff;
}

.ai-chat-fab.is-open {
  background: var(--primary-dark, #1a5e3a);
}

.ai-chat-fab-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.ai-chat-fab-label {
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1;
}

.ai-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 1080;
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 140px));
  display: none;
  flex-direction: column;
  background: var(--card-bg, rgba(255, 255, 255, 0.97));
  border-radius: var(--border-radius-lg, 16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  border: 1px solid rgba(46, 139, 87, 0.12);
}

.ai-chat-panel.is-open {
  display: flex;
  animation: aiChatIn 0.22s ease;
}

@keyframes aiChatIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-chat-header {
  background: var(--primary-gradient, linear-gradient(135deg, #2E8B57 0%, #3CB371 100%));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-chat-header-title {
  font-weight: 600;
  font-size: 0.98rem;
  margin: 0;
  line-height: 1.3;
}

.ai-chat-header-sub {
  font-size: 0.75rem;
  opacity: 0.9;
  margin: 0;
}

.ai-chat-header-actions {
  display: flex;
  gap: 4px;
}

.ai-chat-header .btn-icon {
  background: transparent;
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.ai-chat-header .btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f4f7f5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-bubble.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--text-dark, #2C3E50);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-chat-bubble.user {
  align-self: flex-end;
  background: var(--primary-gradient, linear-gradient(135deg, #2E8B57 0%, #3CB371 100%));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-chat-bubble.error {
  align-self: flex-start;
  background: #fff5f5;
  color: #c0392b;
  border: 1px solid rgba(231, 76, 60, 0.2);
}

.ai-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.ai-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary, #2E8B57);
  opacity: 0.4;
  animation: aiDot 1.2s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiDot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.ai-chat-footer {
  padding: 12px;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 110px;
  border-radius: var(--border-radius, 12px);
  border: 1px solid rgba(46, 139, 87, 0.25);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
}

.ai-chat-form textarea:focus {
  outline: none;
  border-color: var(--primary, #2E8B57);
  box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.15);
}

.ai-chat-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--primary-gradient, linear-gradient(135deg, #2E8B57 0%, #3CB371 100%));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-chat-hint {
  font-size: 0.7rem;
  color: var(--text-light, #6C757D);
  margin-top: 6px;
  margin-bottom: 0;
}

@media (max-width: 575.98px) {
  .ai-chat-fab {
    right: 12px;
    bottom: 12px;
    padding: 7px 14px 7px 7px;
    gap: 8px;
    min-height: 48px;
  }

  .ai-chat-fab-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .ai-chat-fab-label {
    font-size: 0.88rem;
  }

  .ai-chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 76px;
    height: min(70vh, 560px);
  }
}
