/* ==========================================================================
   HumanTechno AI Consultant - Embeddable Chat Widget Styles
   Prefixed with .ht-ai- to prevent collisions with host stylesheets (Odoo, etc.)
   ========================================================================== */

:root {
  --ht-ai-primary: #0f4c81;
  --ht-ai-primary-hover: #0c3c66;
  --ht-ai-primary-light: #e8f1f8;
  --ht-ai-accent: #00a88f;
  --ht-ai-bg: #ffffff;
  --ht-ai-surface: #f8fafc;
  --ht-ai-text: #1e293b;
  --ht-ai-text-muted: #64748b;
  --ht-ai-border: #e2e8f0;
  --ht-ai-radius: 16px;
  --ht-ai-shadow: 0 10px 25px -5px rgba(15, 76, 129, 0.15), 0 8px 10px -6px rgba(15, 76, 129, 0.1);
  --ht-ai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base Widget Container */
.ht-ai-container {
  font-family: var(--ht-ai-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ht-ai-text);
  box-sizing: border-box;
  z-index: 999999;
  position: fixed;
  bottom: 24px;
  right: 24px;
}

.ht-ai-container * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Floating Launch Button (Collapsed State) */
.ht-ai-launch-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--ht-ai-primary) 0%, #1e5f99 100%);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 76, 129, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.ht-ai-launch-btn:hover {
  background: linear-gradient(135deg, var(--ht-ai-primary-hover) 0%, #154e80 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 76, 129, 0.45);
}

.ht-ai-launch-btn:active {
  transform: translateY(0);
}

.ht-ai-launch-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Chat Card Window (Expanded State) */
.ht-ai-card {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 48px);
  background: var(--ht-ai-bg);
  border-radius: var(--ht-ai-radius);
  box-shadow: var(--ht-ai-shadow);
  border: 1px solid var(--ht-ai-border);
  overflow: hidden;
  z-index: 1000000;
  animation: ht-ai-fade-in 0.25s ease-out;
}

.ht-ai-card.ht-ai-open {
  display: flex;
}

@keyframes ht-ai-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Card Header */
.ht-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--ht-ai-primary) 0%, #174b78 100%);
  color: #ffffff;
}

.ht-ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ht-ai-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.ht-ai-title-wrap {
  display: flex;
  flex-direction: column;
}

.ht-ai-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.ht-ai-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ht-ai-badge-online {
  width: 7px;
  height: 7px;
  background-color: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.ht-ai-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.ht-ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Chat Body / Message Feed */
.ht-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background-color: var(--ht-ai-surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Message Bubbles */
.ht-ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: ht-ai-msg-pop 0.2s ease-out;
}

@keyframes ht-ai-msg-pop {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ht-ai-msg-user {
  align-self: flex-end;
}

.ht-ai-msg-bot {
  align-self: flex-start;
}

.ht-ai-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ht-ai-msg-user .ht-ai-bubble {
  background: var(--ht-ai-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ht-ai-msg-bot .ht-ai-bubble {
  background: #ffffff;
  color: var(--ht-ai-text);
  border: 1px solid var(--ht-ai-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Staff Member Message Bubble */
.ht-ai-msg-staff {
  align-self: flex-start;
}

.ht-ai-msg-staff .ht-ai-bubble {
  background: #f0fdf4;
  color: #14532d;
  border: 1px solid #bbf7d0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ht-ai-staff-badge {
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* System Notice Bubble */
.ht-ai-system-notice {
  align-self: center;
  background: #f1f5f9;
  color: #475569;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 12px;
  margin: 6px 0;
  text-align: center;
  max-width: 90%;
  border: 1px solid #e2e8f0;
}

/* Source Citation Tag */
.ht-ai-sources {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ht-ai-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
}

.ht-ai-source-tag {
  background-color: #e2e8f0;
  color: #475569;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ht-ai-source-tag:hover {
  filter: brightness(0.95);
}

.ht-ai-source-web {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.ht-ai-source-web:hover {
  background-color: #bae6fd;
  color: #0284c7;
  text-decoration: underline;
}

.ht-ai-source-internal {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Quick Suggestion Chips */
.ht-ai-chips-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.ht-ai-chips-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ht-ai-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ht-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ht-ai-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--ht-ai-primary);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.ht-ai-chip:hover {
  background: var(--ht-ai-primary-light);
  border-color: var(--ht-ai-primary);
  color: var(--ht-ai-primary-hover);
}

/* Typing / Loading Indicator */
.ht-ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--ht-ai-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.ht-ai-dot {
  width: 6px;
  height: 6px;
  background: var(--ht-ai-text-muted);
  border-radius: 50%;
  animation: ht-ai-bounce 1.4s infinite ease-in-out both;
}

.ht-ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ht-ai-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ht-ai-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.ht-ai-footer {
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid var(--ht-ai-border);
}

.ht-ai-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ht-ai-surface);
  border: 1px solid var(--ht-ai-border);
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ht-ai-form:focus-within {
  border-color: var(--ht-ai-primary);
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.15);
  background: #ffffff;
}

.ht-ai-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ht-ai-text);
  outline: none;
}

.ht-ai-input::placeholder {
  color: #94a3b8;
}

.ht-ai-send-btn {
  background: var(--ht-ai-primary);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.ht-ai-send-btn:hover:not(:disabled) {
  background: var(--ht-ai-primary-hover);
  transform: scale(1.04);
}

.ht-ai-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.ht-ai-send-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* Header Action Buttons */
.ht-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ht-ai-handoff-header-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.ht-ai-handoff-header-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Quick Action / Conversion Bar */
.ht-ai-action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--ht-ai-border);
  overflow-x: auto;
}

.ht-ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.ht-ai-btn-lead {
  background: #0f4c81;
  color: #ffffff;
}

.ht-ai-btn-lead:hover {
  background: #0c3c66;
}

.ht-ai-btn-human {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}

.ht-ai-btn-human:hover {
  background: #e2e8f0;
}

/* Lead Modal Popup */
.ht-ai-lead-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000005;
  animation: ht-ai-fade-in 0.2s ease-out;
}

.ht-ai-lead-box {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 340px;
  padding: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.ht-ai-lead-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.ht-ai-lead-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #0f172a;
}

.ht-ai-lead-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 2px;
}

.ht-ai-lead-close:hover {
  color: #0f172a;
}

.ht-ai-lead-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 9px;
}

.ht-ai-lead-field label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.ht-ai-lead-field input,
.ht-ai-lead-field textarea {
  width: 100%;
  padding: 6px 9px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
}

.ht-ai-lead-field input:focus,
.ht-ai-lead-field textarea:focus {
  border-color: #0f4c81;
}

.ht-ai-lead-consent {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 12px;
}

.ht-ai-lead-consent label {
  font-size: 10.5px;
  color: #64748b;
  line-height: 1.35;
}

.ht-ai-lead-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ht-ai-lead-cancel {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.ht-ai-lead-submit {
  background: #0f4c81;
  border: none;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ht-ai-lead-submit:hover {
  background: #0c3c66;
}

/* Footer Attribution Note */
.ht-ai-footnote {
  text-align: center;
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .ht-ai-card {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .ht-ai-container {
    bottom: 16px;
    right: 16px;
  }
}
