/* ==========================================================================
   HC Agency — Custom AI Assistant Styles
   Integrates natively with HC Agency design system tokens
   ========================================================================== */

/* 1. FLOATING LAUNCHER BUTTON */
.hc-ai-launcher {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  background: var(--gradient-primary);
  color: var(--color-white);
  border: none;
  border-radius: 9999px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4), var(--shadow-glow);
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.hc-ai-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.5), 0 0 50px rgba(56, 189, 248, 0.3);
}

.hc-ai-launcher:active {
  transform: translateY(0) scale(0.98);
}

.hc-ai-launcher__icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hc-ai-launcher__badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #34D399;
  box-shadow: 0 0 8px #34D399;
}

/* Hide launcher when chat is open (on small mobile screens if configured) */
.hc-ai-launcher--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* 2. CHAT WINDOW CONTAINER */
.hc-ai-window {
  position: fixed;
  bottom: 5.5rem;
  right: 1.75rem;
  width: 390px;
  height: 590px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 7rem);
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(37, 99, 235, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out),
              visibility var(--duration-normal) var(--ease-out);
}

.hc-ai-window--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 3. HEADER */
.hc-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background-color: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

.hc-ai-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hc-ai-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  font-weight: 800;
  font-size: var(--text-xs);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.hc-ai-header__info {
  display: flex;
  flex-direction: column;
}

.hc-ai-header__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.hc-ai-header__status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.hc-ai-header__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #34D399;
  box-shadow: 0 0 6px #34D399;
}

.hc-ai-header__close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.hc-ai-header__close:hover {
  color: var(--color-text);
  background-color: var(--color-surface);
}

/* 4. CHAT BODY & MESSAGES */
.hc-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Scrollbar customization */
.hc-ai-body::-webkit-scrollbar {
  width: 5px;
}
.hc-ai-body::-webkit-scrollbar-track {
  background: transparent;
}
.hc-ai-body::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.hc-ai-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: hcAiMessageFadeIn var(--duration-normal) var(--ease-out);
}

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

.hc-ai-message--assistant {
  align-self: flex-start;
}

.hc-ai-message--user {
  align-self: flex-end;
}

.hc-ai-message__bubble {
  padding: 0.875rem 1.125rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
}

.hc-ai-message--assistant .hc-ai-message__bubble {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: var(--radius-sm);
}

.hc-ai-message--user .hc-ai-message__bubble {
  background: var(--gradient-primary);
  color: var(--color-white);
  border-bottom-right-radius: var(--radius-sm);
}

/* Formatting inside AI bubble */
.hc-ai-message__bubble p {
  margin-bottom: 0.5rem;
}
.hc-ai-message__bubble p:last-child {
  margin-bottom: 0;
}
.hc-ai-message__bubble ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.hc-ai-message__bubble li {
  margin-bottom: 0.25rem;
}
.hc-ai-message__bubble a,
.hc-ai-message__link {
  color: var(--color-secondary);
  text-decoration: underline;
  font-weight: 600;
  transition: color var(--duration-fast);
}
.hc-ai-message__bubble a:hover,
.hc-ai-message__link:hover {
  color: #60A5FA;
}
.hc-ai-message--user .hc-ai-message__bubble a {
  color: var(--color-white);
}

/* Image preview inside AI chat bubble */
.hc-ai-message__img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin: 0.625rem 0;
  border: 1px solid var(--color-border);
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 5. QUICK ACTION CHIPS */
.hc-ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hc-ai-chip {
  background-color: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--color-secondary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.hc-ai-chip:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.hc-ai-chip--cta {
  background: var(--gradient-primary);
  border: none;
  color: var(--color-white);
}

.hc-ai-chip--cta:hover {
  background: var(--color-primary-hover);
}

/* 6. TYPING INDICATOR */
.hc-ai-typing {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.875rem 1.125rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  width: fit-content;
  align-self: flex-start;
}

.hc-ai-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-text-secondary);
  animation: hcAiBounce 1.4s infinite ease-in-out both;
}

.hc-ai-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.hc-ai-typing__dot:nth-child(2) { animation-delay: -0.16s; }

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

/* 7. FOOTER INPUT FORM */
.hc-ai-footer {
  padding: 0.875rem 1rem;
  background-color: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
}

.hc-ai-input-form {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.375rem 0.5rem 0.375rem 0.875rem;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.hc-ai-input-form:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.hc-ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  padding: 0.25rem 0;
}

.hc-ai-input::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.hc-ai-send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: var(--color-white);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.hc-ai-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.hc-ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 8. ERROR & RETRY BUTTON */
.hc-ai-error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #EF4444;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-self: flex-start;
}

.hc-ai-retry-btn {
  align-self: flex-start;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #F8FAFC;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.hc-ai-retry-btn:hover {
  background: rgba(239, 68, 68, 0.4);
}

/* 9. MOBILE RESPONSIVE STYLES */
@media (max-width: 640px) {
  .hc-ai-launcher {
    bottom: 1rem;
    right: 1rem;
    padding: 0.625rem 1rem;
  }

  .hc-ai-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .hc-ai-window--open + .hc-ai-launcher {
    display: none;
  }
}
