/* ==========================================================================
   AHU Tech Chatbot Widget — Premium Styles
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --ahu-primary: #1a56db;
  --ahu-primary-gradient: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
  --ahu-dark-bg: #1e1e2e;
  --ahu-card-bg: #ffffff;
  --ahu-text-primary: #1f2937;
  --ahu-text-secondary: #6b7280;
  --ahu-user-bubble: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
  --ahu-bot-bubble: #f3f4f6;
  --ahu-border: #e5e7eb;
  --ahu-messages-bg: #fafbfc;
  --ahu-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ahu-radius-window: 16px;
  --ahu-radius-bubble: 18px;
  --ahu-shadow-window: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --ahu-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Keyframe Animations ---------- */
@keyframes ahuFadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ahuPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(26, 86, 219, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(26, 86, 219, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(26, 86, 219, 0);
  }
}

@keyframes ahuBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes ahuOnlinePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes ahuShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ==========================================================================
   1. Toggle Button
   ========================================================================== */
.ahu-chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ahu-primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 8px 24px rgba(26, 86, 219, 0.4);
  transition: all 0.3s var(--ahu-ease);
  z-index: 99999;
  animation: ahuPulse 2s infinite;
}

.ahu-chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(26, 86, 219, 0.55);
}

.ahu-chatbot-toggle.active {
  animation: none;
}

.ahu-chatbot-toggle svg {
  transition: transform 0.3s var(--ahu-ease);
}

.ahu-chatbot-toggle.active svg {
  transform: rotate(90deg);
}

/* ==========================================================================
   2. Chat Window
   ========================================================================== */
.ahu-chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--ahu-card-bg);
  border-radius: var(--ahu-radius-window);
  box-shadow: var(--ahu-shadow-window);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;

  /* Hidden by default */
  opacity: 0;
  transform: scale(0.8);
  transform-origin: bottom right;
  pointer-events: none;

  transition: opacity 0.3s var(--ahu-ease),
              transform 0.3s var(--ahu-ease);
}

.ahu-chatbot-window.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* ==========================================================================
   3. Header
   ========================================================================== */
.ahu-chatbot-header {
  background: var(--ahu-primary-gradient);
  padding: 18px 20px;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--ahu-radius-window) var(--ahu-radius-window) 0 0;
  flex-shrink: 0;
}

.ahu-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Online status dot */
.ahu-chatbot-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: ahuOnlinePulse 2s infinite;
}

.ahu-chatbot-header-title {
  font-family: var(--ahu-font);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.ahu-chatbot-header-subtitle {
  font-family: var(--ahu-font);
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}

.ahu-chatbot-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ahu-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   4. Messages Container
   ========================================================================== */
.ahu-chatbot-chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* allow flex child to shrink */
}

.ahu-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ahu-messages-bg);
  font-family: var(--ahu-font);
}

/* Custom scrollbar */
.ahu-chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.ahu-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ahu-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.ahu-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ==========================================================================
   5. Individual Messages
   ========================================================================== */
.ahu-chatbot-message {
  display: flex;
  margin-bottom: 12px;
  animation: ahuFadeInUp 0.3s var(--ahu-ease) both;
}

.ahu-chatbot-message.user {
  flex-direction: row-reverse;
}

.ahu-chatbot-message.bot {
  flex-direction: row;
}

/* ==========================================================================
   6. Message Bubbles
   ========================================================================== */
.ahu-chatbot-bubble {
  padding: 12px 16px;
  max-width: 80%;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--ahu-font);
}

.ahu-chatbot-message.user .ahu-chatbot-bubble {
  background: var(--ahu-user-bubble);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
}

.ahu-chatbot-message.bot .ahu-chatbot-bubble {
  background: var(--ahu-bot-bubble);
  color: var(--ahu-text-primary);
  border-radius: 18px 18px 18px 4px;
}

/* ==========================================================================
   7. Typing Indicator
   ========================================================================== */
.ahu-chatbot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.ahu-chatbot-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: ahuBounce 1.4s infinite ease-in-out both;
}

.ahu-chatbot-typing span:nth-child(1) {
  animation-delay: 0s;
}

.ahu-chatbot-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ahu-chatbot-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

/* ==========================================================================
   8. Input Area
   ========================================================================== */
.ahu-chatbot-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--ahu-border);
  display: flex;
  gap: 8px;
  background: #ffffff;
  border-radius: 0 0 var(--ahu-radius-window) var(--ahu-radius-window);
  flex-shrink: 0;
}

/* ==========================================================================
   9. Text Input
   ========================================================================== */
.ahu-chatbot-input {
  flex: 1;
  border: 1.5px solid var(--ahu-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--ahu-font);
  color: var(--ahu-text-primary);
  outline: none;
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ahu-chatbot-input::placeholder {
  color: var(--ahu-text-secondary);
}

.ahu-chatbot-input:focus {
  border-color: var(--ahu-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

/* Shake animation class for invalid input */
.ahu-chatbot-input.shake {
  animation: ahuShake 0.4s;
}

/* ==========================================================================
   10. Send Button
   ========================================================================== */
.ahu-chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ahu-primary-gradient);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.ahu-chatbot-send:hover {
  transform: scale(1.05);
}

.ahu-chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   11. Email Form
   ========================================================================== */
.ahu-chatbot-email-form {
  padding: 32px 24px;
  text-align: center;
  background: #ffffff;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: var(--ahu-font);
}

.ahu-chatbot-email-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.ahu-chatbot-email-form h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ahu-text-primary);
  margin: 0 0 8px;
}

.ahu-chatbot-email-form p {
  font-size: 14px;
  color: var(--ahu-text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

.ahu-chatbot-email-form .ahu-chatbot-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 12px;
  border-radius: 12px;
}

.ahu-chatbot-email-submit {
  width: 100%;
  padding: 12px;
  background: var(--ahu-primary-gradient);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--ahu-font);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ahu-chatbot-email-submit:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.35);
}

.ahu-chatbot-email-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.ahu-chatbot-privacy {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ahu-text-secondary);
}

/* ==========================================================================
   12. Services Form
   ========================================================================== */
.ahu-chatbot-services-form {
  padding: 28px 24px;
  background: #ffffff;
  flex: 1;
  display: flex;
  flex-direction: column;
  font-family: var(--ahu-font);
}

.ahu-chatbot-services-eyebrow {
  display: inline-flex;
  align-self: flex-start;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(26, 86, 219, 0.12);
  color: var(--ahu-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ahu-chatbot-services-form h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--ahu-text-primary);
  margin: 0 0 8px;
}

.ahu-chatbot-services-form p {
  font-size: 14px;
  color: var(--ahu-text-secondary);
  margin: 0 0 16px;
  line-height: 1.5;
}

.ahu-chatbot-services-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--ahu-border);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  max-height: 220px;
  overflow-y: auto;
  box-sizing: border-box;
}

.ahu-chatbot-services-list::-webkit-scrollbar {
  width: 5px;
}

.ahu-chatbot-services-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.ahu-chatbot-service-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #edf0f3;
  color: var(--ahu-text-primary);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.ahu-chatbot-service-item:hover {
  border-color: rgba(26, 86, 219, 0.35);
  box-shadow: 0 6px 18px rgba(26, 86, 219, 0.08);
  transform: translateY(-1px);
}

.ahu-chatbot-service-item input {
  margin-top: 2px;
  accent-color: var(--ahu-primary);
  flex-shrink: 0;
}

.ahu-chatbot-service-item span {
  font-size: 14px;
  line-height: 1.45;
}

.ahu-chatbot-service-empty {
  padding: 12px;
  font-size: 14px;
  color: var(--ahu-text-secondary);
}

.ahu-chatbot-services-submit {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--ahu-primary-gradient);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--ahu-font);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.ahu-chatbot-services-submit:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.35);
}

.ahu-chatbot-services-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   13. Responsive — Mobile
   ========================================================================== */
@media (max-width: 480px) {
  .ahu-chatbot-window {
    width: 100%;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: var(--ahu-radius-window) var(--ahu-radius-window) 0 0;
  }

  .ahu-chatbot-header {
    border-radius: var(--ahu-radius-window) var(--ahu-radius-window) 0 0;
  }

  .ahu-chatbot-input-area {
    border-radius: 0;
  }

  .ahu-chatbot-services-form {
    padding: 24px 18px;
  }

  .ahu-chatbot-services-list {
    max-height: 200px;
  }
}
