/* ===== Elite AI Chat Widget — Premium Onboarding Assistant ===== */

/* Floating CTA button */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 25px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(236, 28, 140, .45), 0 0 0 1px rgba(255,255,255,.1) inset;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  white-space: nowrap;
  height: 56px;
}
.chat-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(236, 28, 140, .55);
}
.chat-fab::after {
  content: "→";
  transition: transform .2s ease;
}
.chat-fab:hover::after {
  transform: translateX(4px);
}
.chat-fab.hidden {
  transform: scale(0) !important;
  opacity: 0;
  pointer-events: none;
}

/* Chat window */
.chat-window {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1001;
  width: 520px;
  max-width: calc(100vw - 32px);
  height: 650px;
  max-height: calc(100vh - 64px);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(36, 0, 41, .2), 0 0 0 1px rgba(236,28,140,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.3) translateY(40px);
  transform-origin: bottom right;
  opacity: 0;
  transition: transform .35s cubic-bezier(.25,.8,.25,1), opacity .3s ease;
  pointer-events: none;
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.chat-header {
  background: #ffffff;
  color: #333;
  padding: 18px 22px 14px;
  position: relative;
  flex-shrink: 0;
  border-bottom: 2px solid rgba(236,28,140,.15);
}
.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.chat-header-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
.chat-header-subtitle {
  font-size: 12px;
  color: #666;
  margin: 2px 0 8px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.chat-header-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(236,28,140,.1);
  border: none;
  color: #333;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.chat-header-close:hover {
  background: rgba(236,28,140,.2);
}
.chat-header h3 {
  font-family: 'Bricolage Grotesque', serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
  padding-right: 40px;
}
.chat-header p {
  font-size: 13px;
  color: #666;
  margin: 0;
  line-height: 1.4;
}

/* Progress bar */
.chat-progress {
  background: rgba(236,28,140,.15);
  height: 4px;
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
.chat-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s ease;
  width: 0%;
}
.chat-progress-text {
  font-size: 11px;
  color: #999;
  margin-top: 6px;
  text-align: right;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #faf7f5;
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(236,28,140,.2);
  border-radius: 2px;
}

/* Message bubbles */
.chat-msg {
  max-width: 85%;
  animation: msgIn .3s ease;
}
.chat-msg-center {
  align-self: center !important;
  max-width: 100%;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-bot {
  align-self: flex-start;
}
.chat-msg-user {
  align-self: flex-end;
}
.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}
.chat-msg-bot .chat-msg-bubble {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(236,28,140,.08);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(36,0,41,.06);
}
.chat-msg-user .chat-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-time {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-msg-user .chat-msg-time {
  text-align: right;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid rgba(236,28,140,.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 3px rgba(36,0,41,.06);
}
.chat-typing span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingDot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot {
  0%, 100% { opacity: .3; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* Quick reply options */
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
  overflow: visible;
}
.chat-option-btn {
  padding: 8px 14px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
  box-sizing: border-box;
}
.chat-option-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Input area */
.chat-input-area {
  padding: 14px 18px;
  background: #fff;
  border-top: 1px solid rgba(236,28,140,.08);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 12px 50px 12px 18px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 44px;
  line-height: 1.4;
  transition: border-color .2s;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: #b0a0a5;
}
.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
  flex-shrink: 0;
}
.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(236,28,140,.4);
}
.chat-send-btn:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* Skip button */
.chat-skip-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  margin-top: 4px;
  font-family: 'Inter', sans-serif;
  transition: color .2s;
}
.chat-skip-btn:hover {
  color: var(--accent);
}

/* Summary screen */
.chat-summary {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  background: #faf7f5;
}
.chat-summary-section {
  margin-bottom: 16px;
}
.chat-summary-section h4 {
  font-family: 'Bricolage Grotesque', serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 8px;
}
.chat-summary-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(236,28,140,.06);
}
.chat-summary-label {
  color: var(--muted);
  font-weight: 500;
  min-width: 100px;
  flex-shrink: 0;
}
.chat-summary-value {
  color: var(--ink);
}
.chat-summary-offer {
  background: var(--dark);
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 13px;
  line-height: 1.5;
}
.chat-summary-offer strong {
  color: var(--accent);
}
.chat-summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 16px;
  background: #faf7f5;
}
.chat-summary-actions .btn {
  justify-content: center;
  text-align: center;
}

/* Success card */
.chat-success-card {
  animation: successIn .5s cubic-bezier(.25,.8,.25,1);
}
@keyframes successIn {
  0% { opacity: 0; transform: scale(0.9) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Back button (hidden in header) */
.chat-header-back {
  display: none;
}

/* Bottom back bar */
.chat-back-bar {
  padding: 4px 18px;
  background: transparent;
  border-top: 1px solid rgba(236,28,140,.05);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.chat-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  font-family: 'Inter', sans-serif;
  transition: opacity .2s;
}
.chat-back-btn:hover {
  opacity: .7;
}

/* Other input field */
.other-input-wrap {
  width: 100%;
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}
.other-input-wrap input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid #e9d9d4;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .2s;
}
.other-input-wrap input:focus {
  border-color: var(--accent);
}
.other-input-wrap button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform .18s;
}
.other-input-wrap button:hover {
  transform: scale(1.1);
}

/* Mobile responsive */
@media (max-width: 768px) {
  /* Hide navbar and sticky bar when widget is open */
  body.widget-open .nav,
  body.widget-open .founding-sticky-bar {
    display: none !important;
  }
  .chat-window {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateY(100%) scale(1);
    transform-origin: bottom center;
    border-radius: 0 !important;
    z-index: 9999 !important;
  }
  .chat-window.open {
    transform: translateY(0) scale(1) !important;
  }
  .chat-messages {
    padding: 16px 12px 80px;
  }
  .chat-header {
    padding: 16px 18px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .chat-header-brand {
    gap: 8px;
  }
  .chat-header-logo {
    width: 24px;
    height: 24px;
  }
  .chat-header h3 {
    font-size: 15px;
    padding-left: 0;
    padding-right: 30px;
  }
  .chat-header-subtitle {
    font-size: 11px;
    margin: 2px 0 6px;
  }
  .chat-progress {
    height: 3px;
    margin-top: 8px;
  }
  .chat-progress-text {
    font-size: 10px;
    margin-top: 4px;
  }
  .chat-messages {
    padding: 16px;
  }
  .chat-msg-bubble {
    max-width: 85%;
    font-size: 14px;
  }
  .chat-input-area {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid rgba(236,28,140,.08);
  }
  .chat-input {
    font-size: 15px;
    padding: 12px 16px;
  }
  .chat-send-btn {
    width: 44px;
    height: 44px;
  }
  .chat-back-bar {
    padding: 8px 14px;
  }
  .chat-messages {
    padding-top: 60px;
  }
  .chat-fab {
    bottom: 24px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    padding: 12px 20px;
    font-size: 13px;
    box-shadow: none;
  }
  .chat-fab:hover {
    box-shadow: none;
  }
  .chat-header {
    padding: 16px 18px 12px;
  }
  .chat-header h3 {
    font-size: 15px;
  }
  .chat-messages {
    padding: 14px 12px;
  }
  .chat-msg-bubble {
    font-size: 13px;
    padding: 10px 14px;
  }
  .chat-msg-center {
    align-self: center !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  .chat-msg-center .chat-msg-bubble {
    max-width: 100% !important;
  }
  .chat-summary {
    padding: 12px;
  }
  .chat-summary-section h4 {
    font-size: 12px;
  }
  .chat-summary-row {
    font-size: 12px;
  }
  .chat-success-card {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
  }
  .chat-option-btn {
    font-size: 12px;
    padding: 7px 12px;
  }
  .chat-input-area {
    padding: 10px 12px;
  }
  .chat-input {
    padding: 10px 14px;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-send-btn {
    width: 38px;
    height: 38px;
  }
  .chat-back-bar {
    padding: 6px 12px;
  }
  .chat-back-btn {
    font-size: 12px;
  }
  /* Prevent background scroll when widget is open */
  body.widget-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
  }
  .chat-window {
    overscroll-behavior: contain;
  }
  .chat-messages {
    overscroll-behavior: contain;
  }
  body.widget-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(36, 0, 41, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
  }
}
