/**
 * Hosted AI Assistant Styles
 * Based on Figma design with modern, clean aesthetic
 */

/* CSS Variables from Figma design */
:root {
  --hosted-ai-neutral-100: #ffffff;
  --hosted-ai-neutral-0: #242424;
  --hosted-ai-neutral-2: #242424;
  --hosted-ai-neutral-7: #000000;
  --hosted-ai-neutral-8: #ff8b53;
  --hosted-ai-neutral-9: #242424;
  --hosted-ai-orange-8: #e15e2c;
  --hosted-ai-beige-3: #f4ede0;
  --hosted-ai-text-color: #505050;
  --hosted-ai-placeholder-color: #595959;

  /* Typography from Figma */
  --hosted-ai-font-dm-mono: "DM Mono", monospace;
  --hosted-ai-font-satoshi: "Satoshi", sans-serif;
  --hosted-ai-font-manrope: "Manrope", sans-serif;

  /* Font Sizes */
  --hosted-ai-font-size-h1: 72px;
  --hosted-ai-font-size-h8: 20px;
  --hosted-ai-font-size-s1: 16px;
  --hosted-ai-font-size-p0: 16px;
  --hosted-ai-font-size-p2: 14px;

  /* Design system values */
  --hosted-ai-border-radius: 48px;
  --hosted-ai-border-radius-small: 12px;
  --hosted-ai-border-radius-pill: 12px;
  --hosted-ai-shadow-main: 0 4px 24px rgba(0, 0, 0, 0.08);
  --hosted-ai-gradient-bg: linear-gradient(180deg, #ffffff 0%, #f5f5f5 44.712%);
  --hosted-ai-gradient-brand: linear-gradient(
    90deg,
    #305effcc 0%,
    #9747ffcc 10.983%
  );
}

/* Main Widget Container */
.hosted-ai-assistant-widget {
  font-family: var(--hosted-ai-font-manrope);
  max-width: 980px;
  max-height: 790px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Collapsed State */
.hosted-ai-collapsed {
  background: white;
  border-radius: var(--hosted-ai-border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.hosted-ai-collapsed:hover {
  transform: translateY(-2px);
}

.hosted-ai-header {
  display: flex;
  flex-direction: column;
  align-items: center;

  padding: 44px 36px 0px 36px;
  position: relative;
}

.hosted-ai-collapsed .hosted-ai-header {
  padding: 44px 36px 60px 36px;
}

.hosted-ai-header-content {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.hosted-ai-title-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hosted-ai-subtitle {
  font-family: var(--hosted-ai-font-dm-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.16px;
  text-transform: uppercase;
  color: var(--hosted-ai-neutral-0);
  text-align: center;
  line-height: 1.3;
}

.hosted-ai-input-preview {
  background: white;
  border: 1px solid var(--hosted-ai-orange-8);
  border-radius: var(--hosted-ai-border-radius-pill);
  padding: 12px 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--hosted-ai-shadow-main);
  font-family: var(--hosted-ai-font-manrope);
  font-size: var(--hosted-ai-font-size-p0);
  font-weight: 500;
  color: var(--hosted-ai-placeholder-color);
  letter-spacing: 0.16px;
  line-height: 1.45;
  position: relative;
}

.hosted-ai-input-field {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--hosted-ai-font-manrope);
  font-size: 16px;
  font-weight: 500;
  color: var(--hosted-ai-neutral-0);
  letter-spacing: 0.16px;
  line-height: 1.45;
  background: transparent;
  padding-right: 40px;
  height: 100%;
}

.hosted-ai-input-field::placeholder {
  color: #595959;
  font-family: var(--hosted-ai-font-manrope);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.16px;
  line-height: 1.45;
}

.hosted-ai-microphone {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.hosted-ai-microphone:hover {
  background: rgba(0, 0, 0, 0.05);
}

.hosted-ai-microphone svg {
  width: 100%;
  height: 100%;
  color: var(--hosted-ai-text-color);
  opacity: 0.6;
  transition: all 0.3s ease;
}

.hosted-ai-microphone.active {
  background: var(--hosted-ai-orange-8);
}

.hosted-ai-microphone.active svg {
  color: white;
  opacity: 1;
}

@keyframes pulse {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.1);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

.voice-mode-active .hosted-ai-microphone.active {
  animation: pulse 1.5s infinite;
}

.hosted-ai-send-button {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s ease;
}

.hosted-ai-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hosted-ai-send-button svg {
  width: 100%;
  height: 100%;
  color: #666;
  transition: all 0.2s ease;
}

.hosted-ai-send-button:not(:disabled):hover {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
}

.hosted-ai-send-button:not(:disabled):hover svg {
  color: var(--hosted-ai-orange-8);
}

/* Clear chat and See less button styles */
.hosted-ai-clear-btn,
.hosted-ai-see-less-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--hosted-ai-font-manrope);
  font-size: var(--hosted-ai-font-size-p2);
  font-weight: 500;
  color: var(--hosted-ai-neutral-0);
  line-height: 1.5;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.hosted-ai-clear-btn:hover,
.hosted-ai-see-less-btn:hover {
  transform: translateY(-1px);
}

.hosted-ai-clear-btn svg,
.hosted-ai-see-less-btn svg {
  width: 12px;
  height: 12px;
  color: var(--hosted-ai-neutral-0);
}

.hosted-ai-scroll-btn {
  width: 32px;
  height: 32px;
  background: white;
  border: 1px solid #c8c8c8;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  position: absolute;
  right: 20px;
  z-index: 1000;
}

.hosted-ai-scroll-btn.scroll-top-btn {
  bottom: 20px;
  transform: rotate(180deg);
}

.hosted-ai-scroll-btn.scroll-bottom-btn {
  top: 20px;
}

.hosted-ai-scroll-btn:hover {
  background-color: #f8f8f8;
}

.hosted-ai-scroll-btn svg {
  width: 16px;
  height: 16px;
  color: #666;
}

.hosted-ai-assistant-widget[data-collapsed="false"] .hosted-ai-scroll-btn svg {
  transform: rotate(0deg);
}

/* Expanded State */
.hosted-ai-expanded {
  background: white;
  border-radius: var(--hosted-ai-border-radius);
  overflow: hidden;
  max-height: 790px;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid #24242433;
}

.hosted-ai-input-container {
  position: relative;
  background: white;
  border: 1px solid #e15e2c;
  border-radius: var(--hosted-ai-border-radius-pill);
  padding: 12px 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--hosted-ai-shadow-main);
}

.hosted-ai-textarea {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--hosted-ai-font-manrope);
  font-size: 16px;
  font-weight: 500;
  color: #595959;
  letter-spacing: 0.16px;
  line-height: 1.45;
  background: transparent;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  padding: 0 40px;
}

.hosted-ai-textarea::placeholder {
  color: #595959;
}

.hosted-ai-expanded-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  border-bottom: 1px solid #c8c8c8;
  flex-shrink: 0;
}

/* Chat Area */
.hosted-ai-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 32px;
  position: relative;
}

.hosted-ai-error-bar {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 12px 16px;
  border-radius: var(--hosted-ai-border-radius-small);
  text-align: center;
  margin-bottom: 16px;
  font-size: 14px;
}

.hosted-ai-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  max-height: calc(
    790px - 200px
  ); /* Account for header, controls, and padding */
  scrollbar-width: thin;
  scrollbar-color: #f4ede0 transparent;
}

/* Custom scrollbar for Webkit browsers */
.hosted-ai-messages::-webkit-scrollbar {
  width: 11px;
}

.hosted-ai-messages::-webkit-scrollbar-track {
  background: linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.08) 0%,
      rgba(0, 0, 0, 0.08) 100%
    ),
    linear-gradient(90deg, #f4ede0 0%, #f4ede0 100%);
  border-radius: 6px;
}

.hosted-ai-messages::-webkit-scrollbar-thumb {
  background: white;
  border-radius: 20px;
  border: 2px solid #f4ede0;
}

/* Message Styles */
.hosted-ai-message {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 170px;
}

.hosted-ai-message.user {
  align-items: flex-end;
  padding-left: 170px;
  padding-right: 20px;
}

.hosted-ai-message.assistant {
  align-items: flex-start;
  padding-right: 170px;
  padding-left: 20px;
}

.hosted-ai-message-content {
  width: fit-content;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--hosted-ai-border-radius-small);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}

.hosted-ai-message.user .hosted-ai-message-content {
  background: var(--hosted-ai-orange-8);
  border: 1px solid white;
}

.hosted-ai-message-text {
  flex: 1;
  font-family: var(--hosted-ai-font-manrope);
  font-weight: 500;
  color: var(--hosted-ai-neutral-0);
  letter-spacing: 0.16px;
  line-height: 1.45;
}

.hosted-ai-message.user .hosted-ai-message-text {
  font-family: var(--hosted-ai-font-satoshi);
  font-size: var(--hosted-ai-font-size-h8);
  font-weight: 500;
  color: white;
  letter-spacing: -0.4px;
  line-height: 1.3;
}

.hosted-ai-message.assistant .hosted-ai-message-text {
  font-size: var(--hosted-ai-font-size-p0);
  color: var(--hosted-ai-neutral-0);
}

/* Clipboard Button Styles */
.hosted-ai-clipboard-btn {
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  margin-left: 16px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  align-self: flex-start;
  position: static;
  opacity: 1;
  width: 32px;
  height: 32px;
}

.hosted-ai-clipboard-btn:hover {
  background: #f0f0f0;
  border-color: #d0d0d0;
  color: #333;
}

.hosted-ai-clipboard-btn:active {
  transform: scale(0.98);
  background: #e8e8e8;
}

.hosted-ai-clipboard-btn svg {
  width: 16px;
  height: 16px;
  color: inherit;
  transition: all 0.2s ease;
}

/* Rich text formatting in messages */
.hosted-ai-message-text h4 {
  font-weight: 700;
  margin: 16px 0 8px;
}

.hosted-ai-message-text p {
  margin-bottom: 12px;
}

.hosted-ai-message-text ul,
.hosted-ai-message-text ol {
  margin: 12px 0;
  padding-left: 24px;
}

.hosted-ai-message-text li {
  margin-bottom: 4px;
}

.hosted-ai-message-text strong {
  font-weight: 700;
}

/* Loading Animation */
.hosted-ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
}

.hosted-ai-loading-text {
  font-family: var(--hosted-ai-font-manrope);
  font-size: 16px;
  color: #666;
}

.hosted-ai-loading-dots {
  display: flex;
  gap: 4px;
}

.hosted-ai-loading-dots span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: hosted-ai-bounce 1.4s infinite;
}

.hosted-ai-loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.hosted-ai-loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes hosted-ai-bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Suggestion Pills */
.hosted-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 40px;
  border-bottom: 1px solid #e5e5e5;
}

.hosted-ai-pill {
  background: #333;
  color: white;
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  font-family: var(--hosted-ai-font-manrope);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.hosted-ai-pill:hover {
  background: #555;
}

.hosted-ai-scrollbar-track {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) rotate(270deg);
  width: 505px;
  height: 4px;
  background: white;
  transform-origin: center;
}

.hosted-ai-scrollbar-thumb {
  position: absolute;
  top: 370px;
  left: 50%;
  transform: translateX(-50%) rotate(270deg);
  width: 131px;
  height: 8px;
  background: white;
  border-radius: 20px;
  transform-origin: center;
}

.hosted-ai-action-btn {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  opacity: 0.7;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hosted-ai-action-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.hosted-ai-action-btn svg {
  width: 18px;
  height: 18px;
}

.hosted-ai-scroll-top-btn {
  margin-left: auto;
}

/* Mobile Bottom Sheet Styles */
.hosted-ai-mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hosted-ai-mobile-overlay.active {
  opacity: 1;
}

.hosted-ai-mobile-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.hosted-ai-mobile-bottom-sheet.active {
  transform: translateY(0);
}

.hosted-ai-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}

.hosted-ai-mobile-title {
  font-family: var(--hosted-ai-font-dm-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.16px;
  text-transform: uppercase;
  color: var(--hosted-ai-neutral-0);
}

.hosted-ai-mobile-close {
  width: 32px;
  height: 32px;
  background: #f5f5f5;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.hosted-ai-mobile-close:hover {
  background: #e5e5e5;
}

.hosted-ai-mobile-close svg {
  width: 18px;
  height: 18px;
  color: #666;
}

.hosted-ai-mobile-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Mobile floating button */
.hosted-ai-mobile-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--hosted-ai-orange-8);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(225, 94, 44, 0.3);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: all 0.3s ease;
}

.hosted-ai-mobile-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(225, 94, 44, 0.4);
}

.hosted-ai-mobile-fab svg {
  width: 24px;
  height: 24px;
  color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .hosted-ai-assistant-widget {
    max-width: 90%;
    margin: 0 auto;
  }

  .hosted-ai-messages {
    max-height: calc(790px - 180px);
  }
}

@media (max-width: 768px) {
  /* Hide desktop widget on mobile */
  .hosted-ai-assistant-widget:not(.hosted-ai-mobile-mode) {
    display: none;
  }

  /* Show mobile FAB */
  .hosted-ai-mobile-fab {
    display: flex;
  }

  /* Mobile bottom sheet adjustments */
  .hosted-ai-assistant-widget.hosted-ai-mobile-mode {
    position: static;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
    height: 100%;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-expanded {
    border-radius: 0;
    border: none;
    height: 100%;
    max-height: none;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-header {
    padding: 16px 20px 0 20px;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode
    .hosted-ai-collapsed
    .hosted-ai-header {
    padding: 16px 20px;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-controls,
  .hosted-ai-assistant-widget.hosted-ai-mobile-mode
    .hosted-ai-expanded-controls {
    padding: 16px 20px;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-message {
    padding: 16px 20px;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-suggestions {
    padding: 16px 20px;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-messages {
    max-height: calc(85vh - 200px);
    padding: 16px 0;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-scroll-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .hosted-ai-header {
    padding: 16px 12px 0 12px;
  }

  .hosted-ai-collapsed .hosted-ai-header {
    padding: 16px 12px;
  }

  .hosted-ai-controls,
  .hosted-ai-expanded-controls {
    padding: 12px 16px;
  }

  .hosted-ai-message {
    padding: 12px 16px;
  }

  .hosted-ai-suggestions {
    padding: 12px 16px;
  }

  .hosted-ai-input-preview,
  .hosted-ai-input-container {
    height: 48px;
    padding: 10px 12px;
  }

  .hosted-ai-subtitle {
    font-size: 14px;
    letter-spacing: 3.6px;
  }

  .hosted-ai-input-field,
  .hosted-ai-textarea {
    font-size: 14px;
  }

  /* Better touch targets for mobile */
  .hosted-ai-mobile-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .hosted-ai-mobile-fab {
    width: 64px;
    height: 64px;
    bottom: 16px;
    right: 16px;
  }

  .hosted-ai-mobile-fab svg {
    width: 28px;
    height: 28px;
  }

  .hosted-ai-send-button,
  .hosted-ai-pill {
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Adjust bottom sheet height for very small screens */
  .hosted-ai-mobile-bottom-sheet {
    max-height: 90vh;
  }

  .hosted-ai-assistant-widget.hosted-ai-mobile-mode .hosted-ai-messages {
    max-height: calc(90vh - 220px);
  }
}

/* Animation for state transitions */
.hosted-ai-assistant-widget[data-collapsed="false"] .hosted-ai-collapsed {
  display: none;
}

.hosted-ai-assistant-widget[data-collapsed="false"] .hosted-ai-expanded {
  display: flex;
}

/* Hide suggestions after first interaction */
.hosted-ai-assistant-widget.has-messages .hosted-ai-suggestions {
  display: none;
}
