/* ── Chat Widget ── prefixed .cw-* ── Impulse Lab-inspired design ── */

/* ── (Bubble removed — booking toggle occupies bottom-right) ── */

/* ── Gradient glow (follows widget shape, animates between teaser ↔ modal) ── */
.cw-glow {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 88;
  /* Default size set by JS to match teaser pill */
  width: 0;
  height: 0;
  bottom: 32px;
  opacity: 0;
  transition: width .25s cubic-bezier(.4,0,.2,1),
              height .25s cubic-bezier(.4,0,.2,1),
              bottom .25s cubic-bezier(.4,0,.2,1),
              opacity .25s cubic-bezier(.4,0,.2,1);
}

.cw-glow.cw-visible {
  opacity: .6;
}

/* Expand to modal shape when chat is open */
.cw-glow.cw-expanded {
  width: 80vw;
  height: 60vh;
  bottom: 0;
  opacity: .9;
}

.cw-glow-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #0894FF, #C959DD, #FF2E54, #FF9004);
  filter: blur(12px);
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
  pointer-events: none;
}

/* ── Teaser bar (bottom-center, glassmorphism pill) ── */
.cw-teaser {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 89;
  width: auto;
  height: 56px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.cw-teaser.cw-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.cw-teaser.cw-hidden {
  display: none;
}

.cw-teaser-inner {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  border-radius: 16px;
  transition: box-shadow var(--transition-fast);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

.cw-teaser:hover .cw-teaser-inner {
  box-shadow: 0 14px 20px -3px rgba(0,0,0,.12), 0 6px 8px -2px rgba(0,0,0,.06);
}

.cw-teaser-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--brand-primary-500);
}

.cw-teaser-text {
  font-size: 1rem;
  color: #171717;
  white-space: nowrap;
}

.cw-teaser-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

/* ── Glass backdrop (full screen, behind modal) ── */
.cw-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.cw-backdrop.cw-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal (rises from bottom) ── */
.cw-modal {
  position: fixed;
  z-index: 200;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 80vw;
  height: 60vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.cw-modal.cw-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.cw-modal-glass {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -10px 40px rgba(0,0,0,.1);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

/* ── Close button (top-right, circular) ── */
.cw-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
  padding: 0;
}

.cw-modal-close:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,.05);
}

.cw-modal-close svg {
  width: 16px;
  height: 16px;
}

/* ── Messages area (scrollable) ── */
.cw-messages {
  flex: 1 1 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cw-messages::-webkit-scrollbar {
  display: none;
}

/* ── Conversation turn ── */
.cw-turn {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ── User question (bold heading) ── */
.cw-turn-question {
  font-size: 1.5rem;
  font-weight: 500;
  color: #171717;
  line-height: 1.3;
  margin: 0 0 12px;
  word-break: break-word;
}

/* ── Separator ── */
.cw-turn-sep {
  border: none;
  border-top: 1px solid #ebebeb;
  margin: 0 0 16px;
}

/* ── Bot answer ── */
.cw-turn-answer {
  font-size: 1rem;
  font-weight: 400;
  color: #5c5c5c;
  line-height: 1.75;
  word-break: break-word;
}

.cw-turn-answer p {
  margin: 0 0 8px;
}

.cw-turn-answer p:last-child {
  margin-bottom: 0;
}

/* ── Typing indicator ── */
.cw-typing {
  display: flex;
  gap: 5px;
  padding: 8px 0;
}

.cw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cw-bounce .6s infinite alternate;
}

.cw-typing span:nth-child(2) { animation-delay: .15s; }
.cw-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes cw-bounce {
  to { opacity: .3; transform: translateY(-4px); }
}

/* ── Inline tool cards ── */
.cw-tool-card {
  max-width: 440px;
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 0 0 1px rgba(51,51,51,.04);
}

.cw-tool-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #171717;
  margin: 0 0 4px;
}

.cw-tool-card-text {
  font-size: .875rem;
  color: #5c5c5c;
  margin: 0 0 12px;
  line-height: 1.5;
}

.cw-tool-card .cw-btn,
.cw-diag .cw-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 9999px;
  background: var(--brand-primary-500);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background var(--transition-fast);
}

.cw-tool-card .cw-btn:hover,
.cw-diag .cw-btn:hover {
  background: var(--brand-primary-600);
}

/* ── Inline contact form ── */
.cw-contact-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-contact-form input {
  padding: 10px 12px;
  border: 1px solid #ebebeb;
  border-radius: 10px;
  font-size: .875rem;
  color: #171717;
  outline: none;
  transition: border-color var(--transition-fast);
}

.cw-contact-form input:focus {
  border-color: var(--brand-primary-500);
}

.cw-contact-form .cw-form-row {
  display: flex;
  gap: 8px;
}

.cw-contact-form .cw-form-row input {
  flex: 1;
}

.cw-contact-sent {
  font-size: .875rem;
  color: var(--color-success);
  font-weight: 500;
  padding: 8px 0;
}

/* ── Welcome screen (initial state) ── */
.cw-welcome {
  max-width: 768px;
  margin: 0 auto;
  padding: 40px 24px 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.cw-welcome-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: #171717;
  line-height: 1.2;
  margin: 0 0 16px;
}

.cw-welcome-subtitle {
  font-size: 1.125rem;
  font-weight: 400;
  color: #9ca3af;
  line-height: 1.6;
  margin: 0;
  max-width: 520px;
}

.cw-welcome-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: auto;
  padding-bottom: 16px;
}

.cw-welcome-arrow {
  width: 44px;
  height: 64px;
  flex-shrink: 0;
}

.cw-welcome-hint-text {
  font-size: 1rem;
  font-style: italic;
  color: #9ca3af;
  padding-top: 2px;
}

/* ── Suggestion chips (above input) ── */
.cw-chips-area {
  flex-shrink: 0;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.cw-chips {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cw-chips::-webkit-scrollbar {
  display: none;
}

.cw-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  border: 1px solid #ebebeb;
  border-radius: 9999px;
  background: #fff;
  font-size: .875rem;
  color: #171717;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  font-family: inherit;
}

.cw-chip:hover {
  border-color: var(--brand-primary-500);
  background: rgba(41, 112, 255, .04);
}

/* ── Input area (bottom bar) ── */
.cw-input-area {
  position: relative;
  flex-shrink: 0;
  padding: 0 16px 16px;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.cw-input-group {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #ebebeb;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  overflow: visible;
}

.cw-textarea {
  flex: 1;
  resize: none;
  border: none;
  padding: 4px 8px;
  font-size: 1rem;
  font-family: inherit;
  color: #171717;
  outline: none;
  min-height: 40px;
  max-height: 240px;
  line-height: 1.5;
  background: transparent;
  overflow-y: auto;
}

.cw-textarea::placeholder {
  color: #9ca3af;
}

.cw-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #171717;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.cw-send-btn:hover {
  background: #333;
}

.cw-send-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.cw-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Diagnostic quiz (inline card, step-by-step) ── */
.cw-diag {
  max-width: 440px;
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 0 0 1px rgba(51,51,51,.04);
}

.cw-diag-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.cw-diag-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #e5e7eb;
  transition: background .2s;
}

.cw-diag-dot.cw-diag-dot-active {
  background: var(--brand-primary-500);
}

.cw-diag-dot.cw-diag-dot-done {
  background: #22c55e;
}

.cw-diag-step-label {
  font-size: .75rem;
  color: #9ca3af;
  margin-left: auto;
}

.cw-diag-question {
  font-size: 1rem;
  font-weight: 600;
  color: #171717;
  margin: 0 0 12px;
  line-height: 1.4;
}

.cw-diag-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-diag-opt {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  font-size: .875rem;
  color: #171717;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
  line-height: 1.4;
}

.cw-diag-opt:hover {
  border-color: var(--brand-primary-500);
  background: rgba(41, 112, 255, .04);
}

.cw-diag-opt.cw-diag-opt-selected {
  border-color: var(--brand-primary-500);
  background: rgba(41, 112, 255, .08);
  font-weight: 500;
}

.cw-diag-opt.cw-diag-opt-selected::after {
  content: '\2713';
  margin-left: auto;
  color: var(--brand-primary-500);
  font-weight: 600;
}

/* Summary after completion */
.cw-diag-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-diag-summary-row {
  display: flex;
  gap: 8px;
  font-size: .8125rem;
  line-height: 1.4;
}

.cw-diag-summary-label {
  color: #9ca3af;
  flex-shrink: 0;
  min-width: 80px;
}

.cw-diag-summary-value {
  color: #171717;
  font-weight: 500;
}

.cw-diag-done-title {
  font-size: 1rem;
  font-weight: 600;
  color: #171717;
  margin: 0 0 12px;
}

.cw-diag-done-text {
  font-size: .875rem;
  color: #5c5c5c;
  margin: 0 0 12px;
  line-height: 1.5;
}

/* ── Error message ── */
.cw-error {
  max-width: 768px;
  margin: 0 auto;
  padding: 8px 16px;
  font-size: .8125rem;
  color: var(--color-error);
  text-align: center;
  background: rgba(239, 68, 68, .06);
  border-radius: 10px;
}

/* ── Turnstile container (invisible) ── */
.cw-turnstile {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  /* Full-screen chat modal */
  .cw-modal {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  .cw-modal-glass {
    border-radius: 0;
  }

  /* Teaser: leave room for booking toggle on right */
  .cw-teaser {
    bottom: 16px;
    left: 16px;
    right: 80px; /* 64px toggle + 16px gap */
    transform: translateY(8px);
    width: auto;
  }

  .cw-teaser.cw-visible {
    transform: translateY(0);
  }

  .cw-teaser-text {
    white-space: normal;
    font-size: .875rem;
    line-height: 1.3;
  }

  .cw-teaser-inner {
    gap: 8px;
    padding: 0 14px;
  }

  /* Glow: match teaser position on mobile */
  .cw-glow {
    bottom: 16px;
    left: 16px;
    right: 80px;
    transform: none;
    width: auto !important;
  }

  .cw-glow.cw-expanded {
    left: 0;
    right: 0;
    width: 100vw !important;
    height: 100dvh;
    bottom: 0;
  }

  /* Smaller headings */
  .cw-turn-question {
    font-size: 1.25rem;
  }

  .cw-welcome {
    padding: 24px 16px 0;
  }

  .cw-welcome-title {
    font-size: 1.5rem;
  }

  .cw-welcome-subtitle {
    font-size: .9375rem;
  }

  .cw-turn {
    padding: 0 12px 32px;
  }

  /* Diagnostic form: full-width */
  .cw-diag {
    max-width: 100%;
  }

  .cw-tool-card {
    max-width: 100%;
  }

  /* Chips: smaller on mobile */
  .cw-chip {
    padding: 8px 12px;
    font-size: .8125rem;
  }

  .cw-chips {
    padding: 0 12px 10px;
  }

  /* Input area tighter */
  .cw-input-area {
    padding: 0 12px 12px;
  }
}
