/* HitReset Embedded Chat Widget - Centered → Chat Transition */
/* Designed for full-page iframe embedding */

:root {
  /* Colors - Clean light theme */
  --embed-background: transparent;
  --embed-surface: #ffffff;
  --embed-border: #d1d5db;
  --embed-border-hover: #2FE4C6;
  --embed-text-primary: #1a1a1a;
  --embed-text-secondary: #6b7280;
  --embed-text-muted: #9ca3af;
  --embed-accent: #2FE4C6;
  --embed-accent-dark: #0E0F12;
  --embed-user-bubble: #0E0F12;
  --embed-user-text: #ffffff;
  --embed-assistant-bubble: #f3f4f6;
  --embed-shadow: rgba(0, 0, 0, 0.08);
  --embed-shadow-hover: rgba(47, 228, 198, 0.25);
  --embed-shadow-focus: rgba(47, 228, 198, 0.3);

  /* Typography */
  --embed-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --embed-font-size-base: 16px;
  --embed-font-size-small: 13px;
  --embed-font-size-tiny: 11px;
  --embed-line-height: 1.5;

  /* Sizing */
  --embed-max-width: 720px;
  --embed-border-radius: 24px;
  --embed-border-radius-message: 12px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--embed-font-family);
  font-size: var(--embed-font-size-base);
  line-height: var(--embed-line-height);
  color: var(--embed-text-primary);
  background: var(--embed-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */

/* Initial state: centered layout using flexbox */
.embed-container {
  height: 100%;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ============================================
   CENTERED STATE (Initial)
   ============================================ */

/* Headlines - centered above input */
.headlines {
  text-align: center;
  margin-bottom: 24px;
  max-width: var(--embed-max-width);
  width: 100%;
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}

.headline {
  font-size: 26px;
  font-weight: 600;
  color: var(--embed-text-primary);
  margin: 0 0 12px 0;
  line-height: 1.3;
}

.subheadline {
  font-size: 26px;
  font-weight: 600;
  color: var(--embed-text-primary);
  margin: 0;
  line-height: 1.3;
}

/* Input area - centered initially */
.input-area {
  width: 100%;
  max-width: var(--embed-max-width);
  flex-shrink: 0;
}

/* ============================================
   CHAT INPUT
   ============================================ */

.chat-input-wrapper {
  position: relative;
  background: var(--embed-surface);
  border: 1px solid var(--embed-border);
  border-radius: var(--embed-border-radius);
  padding: 12px 60px 12px 20px;
  box-shadow: 0 2px 8px var(--embed-shadow);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-wrapper:hover {
  border-color: var(--embed-border-hover);
  box-shadow: 0 4px 12px var(--embed-shadow-hover);
}

.chat-input-wrapper:focus-within {
  border-color: var(--embed-border-hover);
  box-shadow: 0 4px 16px var(--embed-shadow-focus);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--embed-font-size-base);
  color: var(--embed-text-primary);
  resize: none;
  min-height: 24px;
  max-height: 200px;
  font-family: inherit;
  line-height: 1.5;
  background: transparent;
  overflow: hidden;
}

.chat-input::placeholder {
  color: var(--embed-text-muted);
}

.chat-submit-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--embed-accent-dark);
  color: var(--embed-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-submit-btn:hover:not(:disabled) {
  background: #1a1b1f;
  transform: translateY(-50%) scale(1.05);
}

.chat-submit-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.95);
}

.chat-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   CHAT MESSAGES (hidden initially)
   ============================================ */

.chat-messages {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: var(--embed-max-width);
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   CHAT ACTIVE STATE
   ============================================ */

.embed-container.chat-active {
  justify-content: flex-start;
  padding: 20px 20px 12px;
}

/* Hide headlines in chat mode */
.embed-container.chat-active .headlines {
  display: none;
}

/* Show messages in chat mode */
.embed-container.chat-active .chat-messages {
  display: flex;
}

/* Input area stays at bottom via flex order */
.embed-container.chat-active .input-area {
  margin-top: auto;
  padding-top: 12px;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--embed-border-radius-message);
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: message-appear 0.2s ease-out;
}

@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User messages */
.message.user {
  align-self: flex-end;
  background: var(--embed-user-bubble);
  color: var(--embed-user-text);
  text-align: left;
}

/* Assistant messages */
.message.assistant {
  align-self: flex-start;
  background: var(--embed-assistant-bubble);
  color: var(--embed-text-primary);
  text-align: left;
}

/* Message content - basic markdown support */
.message-content {
  white-space: pre-wrap;
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

.message-content ul, 
.message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-content li {
  margin: 4px 0;
}

.message-content a {
  color: var(--embed-accent-dark);
  text-decoration: underline;
}

/* User message code styling */
.message.user .message-content code {
  background: rgba(255, 255, 255, 0.15);
}

.message.user .message-content pre {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--embed-assistant-bubble);
  border-radius: var(--embed-border-radius-message);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--embed-text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   STREAMING CURSOR
   ============================================ */

.message.streaming .message-content::after {
  content: '▋';
  animation: cursor-blink 1s infinite;
  margin-left: 2px;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ============================================
   POWERED BY FOOTER
   ============================================ */

.powered-by {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 12px 0;
  font-size: var(--embed-font-size-tiny);
  color: var(--embed-text-muted);
}

/* In chat mode, footer is part of flow */
.embed-container.chat-active .powered-by {
  position: static;
  flex-shrink: 0;
}

.powered-by a {
  color: var(--embed-text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.powered-by a:hover {
  color: var(--embed-accent-dark);
  text-decoration: underline;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Phones */
@media (max-width: 768px) {
  .headline {
    font-size: 20px;
  }
  
  .subheadline {
    font-size: 20px;
  }
  
  .chat-input-wrapper {
    padding: 12px 52px 12px 16px;
  }
  
  .embed-container {
    padding: 16px;
  }
  
  .embed-container.chat-active {
    padding: 16px 16px 8px;
  }
  
  .message {
    max-width: 90%;
  }
}

/* Small phones */
@media (max-width: 374px) {
  :root {
    --embed-font-size-base: 14px;
  }
  
  .headline {
    font-size: 18px;
  }
  
  .subheadline {
    font-size: 18px;
  }
  
  .headlines {
    margin-bottom: 16px;
  }
}

/* Large screens */
@media (min-width: 1024px) {
  .message {
    max-width: 70%;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .chat-messages {
    scroll-behavior: auto;
  }
}

/* Custom scrollbar for messages */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--embed-border);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--embed-text-muted);
}

