/* Rachel Chat Widget — Wallace Corporation Design System */
/* Brand tokens: pink=#e02387, bright-blue=#65a2d2, mid-blue=#3857ad, light-blue=#319ec7 */

/* ------------------------------------------------------------------------- */
/* CTA Trigger
/* ------------------------------------------------------------------------- */
.rachel-cta {
  display: inline-block;
  color: var(--light-blue, #319ec7);
  text-decoration: none;
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.3s ease;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  line-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.rachel-cta:hover {
  color: #e02387;
}

/* Footer override — match footer list item styling */
.footer-col-links .rachel-cta {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: none;
  letter-spacing: normal;
  min-height: auto;
  line-height: inherit;
  display: block;
}
.footer-col-links .rachel-cta:hover {
  color: var(--light-blue);
}

/* Body-copy CTA — matches surrounding text */
.rachel-cta--body {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: inherit;
  text-transform: none;
  letter-spacing: normal;
  min-height: auto;
  line-height: inherit;
}

/* ------------------------------------------------------------------------- */
/* Floating Bubble (minimised state)
/* ------------------------------------------------------------------------- */
.rachel-bubble {
  position: fixed;
  bottom: clamp(1rem, 3vw, 1.5rem);
  left: clamp(0.5rem, 2vw, 1rem);
  z-index: 9998;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(101, 162, 210, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}
.rachel-bubble--visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}
.rachel-bubble:hover {
  border-color: #e02387;
  background: rgba(0, 0, 0, 0.97);
}
.rachel-bubble-icon {
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
}
.rachel-bubble:hover .rachel-bubble-icon {
  color: #e02387;
}

/* ------------------------------------------------------------------------- */
/* Chat Panel
/* ------------------------------------------------------------------------- */
.rachel-panel {
  position: fixed;
  bottom: clamp(1.5rem, 4vw, 2.5rem);
  left: clamp(1.5rem, 4vw, 2.5rem);
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 560px;
  max-height: calc(100vh - 6rem);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(101, 162, 210, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.rachel-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ------------------------------------------------------------------------- */
/* Screens (intake / handoff / chat — only one visible at a time)
/* ------------------------------------------------------------------------- */
.rachel-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  height: 100%;
}
.rachel-screen--active {
  display: flex;
}

/* ------------------------------------------------------------------------- */
/* Intake Screen
/* ------------------------------------------------------------------------- */
.rachel-intake-header {
  padding: 1.25rem 1.5rem 0;
}
.rachel-intake-brand {
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #319ec7;
  opacity: 0.6;
}
.rachel-intake-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
}
.rachel-intake-text {
  font-family: Roboto, sans-serif;
  font-weight: 300;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.6;
  margin: 0 0 1.75rem;
}
.rachel-intake-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ------------------------------------------------------------------------- */
/* Inputs (Wallace Corp form style — bottom-border, transparent bg)
/* ------------------------------------------------------------------------- */
.rachel-input-group {
  position: relative;
}
.rachel-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(101, 162, 210, 0.2);
  color: #ffffff;
  font-family: Roboto, sans-serif;
  font-weight: 300;
  font-size: 0.9rem;
  padding: 0.6rem 0;
  outline: none;
  transition: border-color 0.3s ease;
}
.rachel-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-weight: 300;
}
.rachel-input:focus {
  border-bottom-color: #e02387;
}
/* Override browser autofill styles */
.rachel-input:-webkit-autofill,
.rachel-input:-webkit-autofill:hover,
.rachel-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 30px rgba(0, 0, 0, 0.94) inset !important;
  -webkit-text-fill-color: #ffffff !important;
  caret-color: #ffffff;
  transition: background-color 5000s ease-in-out 0s;
}
.rachel-input-line {
  display: none;
}

.rachel-intake-btn,
.rachel-lead-submit {
  align-self: flex-start;
  background: transparent;
  border: 1px solid rgba(224, 35, 135, 0.4);
  color: #e02387;
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.5rem 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 2px;
}
.rachel-intake-btn:hover,
.rachel-lead-submit:hover {
  background: #e02387;
  color: #ffffff;
  border-color: #e02387;
}

/* ------------------------------------------------------------------------- */
/* Handoff Screen
/* ------------------------------------------------------------------------- */
.rachel-handoff-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.rachel-handoff-text {
  font-family: Roboto, sans-serif;
  font-weight: 300;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.5);
}
.rachel-handoff-dots {
  display: flex;
  gap: 4px;
}
.rachel-handoff-dots span {
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 1.2rem;
  color: #65a2d2;
  animation: rachel-dot-breathe 1.5s ease-in-out infinite;
}
.rachel-handoff-dots span:nth-child(2) { animation-delay: 0.2s; }
.rachel-handoff-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rachel-dot-breathe {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 0.8; }
}

/* ------------------------------------------------------------------------- */
/* Chat Header
/* ------------------------------------------------------------------------- */
.rachel-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(101, 162, 210, 0.1);
  flex-shrink: 0;
}
.rachel-chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.rachel-chat-header-names {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  gap: 0.25rem;
}
.rachel-chat-header-name {
  font-family: Roboto, sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  color: #ffffff;
}
.rachel-chat-header-status {
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #319ec7;
  opacity: 0.5;
}
.rachel-chat-header-right {
  display: flex;
  gap: 0.25rem;
}
.rachel-chat-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
  transition: color 0.3s ease;
}
.rachel-chat-btn:hover {
  color: #e02387;
}

/* ------------------------------------------------------------------------- */
/* Avatars
/* ------------------------------------------------------------------------- */
.rachel-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rachel-avatar--rachel {
  overflow: hidden;
}
.rachel-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rachel-avatar--user {
  background: linear-gradient(135deg, #65a2d2, #319ec7);
  color: #ffffff;
}
.rachel-avatar-initials {
  font-family: Monaco, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------------- */
/* Messages Area
/* ------------------------------------------------------------------------- */
.rachel-chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
/* Custom scrollbar */
.rachel-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.rachel-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.rachel-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(101, 162, 210, 0.2);
  border-radius: 2px;
}

/* Message bubble: Rachel */
.rachel-msg {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  max-width: 85%;
}
.rachel-msg-bubble {
  background: rgba(101, 162, 210, 0.08);
  border: 1px solid rgba(101, 162, 210, 0.1);
  border-radius: 0 10px 10px 10px;
  padding: 0.6rem 0.85rem;
  font-family: Roboto, sans-serif;
  font-weight: 400;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  white-space: pre-wrap;
}
.rachel-msg-bubble strong {
  font-weight: 500;
}
.rachel-msg-bubble em {
  font-style: italic;
}
.rachel-msg--user .rachel-msg-bubble {
  background: rgba(224, 35, 135, 0.08);
  border: 1px solid rgba(224, 35, 135, 0.12);
  border-radius: 10px 0 10px 10px;
}

/* Message bubble: User */
.rachel-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Typing indicator */
.rachel-typing {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  max-width: 85%;
}
.rachel-typing-bubble {
  background: rgba(101, 162, 210, 0.06);
  border-radius: 0 10px 10px 10px;
  padding: 0.6rem 1rem;
  display: flex;
  gap: 3px;
}
.rachel-typing-bubble span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: rachel-dot-breathe 1.5s ease-in-out infinite;
}
.rachel-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.rachel-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

/* ------------------------------------------------------------------------- */
/* Chat Input
/* ------------------------------------------------------------------------- */
.rachel-chat-input-wrap {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(101, 162, 210, 0.1);
  flex-shrink: 0;
}
.rachel-chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rachel-chat-input {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(101, 162, 210, 0.15);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: #ffffff;
  font-family: Roboto, sans-serif;
  font-weight: 300;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.3s ease;
}
.rachel-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}
.rachel-chat-input:focus {
  border-color: #e02387;
}
.rachel-chat-send {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  flex-shrink: 0;
}
.rachel-chat-send:hover {
  color: #e02387;
}

/* ------------------------------------------------------------------------- */
/* Lead Capture — Choice Buttons + Forms
/* ------------------------------------------------------------------------- */
.rachel-lead-choice {
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(101, 162, 210, 0.08);
}
.rachel-lead-choice-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.rachel-lead-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(101, 162, 210, 0.06);
  border: 1px solid rgba(101, 162, 210, 0.15);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-family: Roboto, sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}
.rachel-lead-option:hover {
  background: rgba(101, 162, 210, 0.12);
  border-color: #65a2d2;
  color: #ffffff;
}
.rachel-lead-option svg {
  opacity: 0.6;
  flex-shrink: 0;
}
.rachel-lead-option:hover svg {
  opacity: 0.9;
}
.rachel-lead-option--skip {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.75rem;
}
.rachel-lead-option--skip:hover {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.6);
}

/* ------------------------------------------------------------------------- */
/* Lead Capture Forms (inline in chat input area)
/* ------------------------------------------------------------------------- */
.rachel-lead-form {
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(101, 162, 210, 0.08);
}
.rachel-lead-text {
  font-family: Roboto, sans-serif;
  font-weight: 300;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}
.rachel-lead-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}
.rachel-lead-skip {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-family: Roboto, sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.3s ease;
  padding: 0;
}
.rachel-lead-skip:hover {
  color: rgba(255, 255, 255, 0.6);
}
.rachel-lead-submit {
  font-size: 0.65rem;
  padding: 0.4rem 0.9rem;
  align-self: auto;
}

/* ------------------------------------------------------------------------- */
/* Responsive — Mobile
/* ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  /* Fullscreen panel, safe-area aware */
  .rachel-panel {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    bottom: 0;
    left: 0;
    border-radius: 0;
    border: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Tighter header */
  .rachel-chat-header {
    padding: 0.6rem 0.75rem;
    padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
  }
  .rachel-chat-header-name {
    font-size: 0.8rem;
  }
  .rachel-chat-header-status {
    font-size: 0.55rem;
  }

  /* Avatars slightly smaller */
  .rachel-avatar {
    width: 28px;
    height: 28px;
  }

  /* Messages: tighter padding, wider bubbles */
  .rachel-chat-messages {
    padding: 0.75rem 0.5rem;
  }
  .rachel-msg {
    max-width: 90%;
  }
  .rachel-msg-bubble {
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
  }

  /* Intake panel */
  .rachel-intake-body {
    padding: 1rem 1.25rem;
  }
  .rachel-intake-text {
    font-size: 0.9rem;
  }
  .rachel-intake-brand {
    padding: 0.5rem 0 0;
  }

  /* Larger input for touch */
  .rachel-input {
    font-size: 1rem;          /* prevents iOS zoom on focus */
    padding: 0.75rem 0;
  }
  .rachel-intake-btn {
    width: 100%;
    text-align: center;
    padding: 0.7rem;
  }

  /* Chat input — anchored for keyboard */
  .rachel-chat-input-wrap {
    padding: 0.6rem 0.5rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  }
  .rachel-chat-input {
    font-size: 1rem;          /* prevents iOS zoom */
    padding: 0.65rem 0.75rem;
  }
  .rachel-chat-send {
    padding: 0.5rem;
  }

  /* Lead choice buttons stack */
  .rachel-lead-choice-buttons {
    flex-direction: column;
  }
  .rachel-lead-option {
    width: 100%;
    justify-content: center;
    padding: 0.7rem;
  }

  /* Lead forms */
  .rachel-lead-form {
    padding-bottom: 0.5rem;
  }
  .rachel-lead-actions {
    gap: 0.5rem;
  }
  .rachel-lead-submit {
    font-size: 0.7rem;
    padding: 0.55rem 1rem;
  }

  /* Smaller bubble on mobile */
  .rachel-bubble {
    bottom: 1rem;
    left: 1rem;
    width: 48px;
    height: 48px;
  }
}

/* Tablet — panel constrained but not fullscreen */
@media (min-width: 481px) and (max-width: 768px) {
  .rachel-panel {
    width: 360px;
    height: 520px;
  }
}
