/* ============================================
   CORONADO CHAT WIDGET
   Smart mini-chat for lead capture
   ============================================ */

/* ---------- FLOATING TRIGGER BUTTON ---------- */
.chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--gold);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(10, 31, 58, 0.25);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: chatTriggerPulse 0s 5s 1 forwards;
}

.chat-trigger:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(10, 31, 58, 0.35);
  background: var(--gold-hover);
}

.chat-trigger:active {
  transform: translateY(-1px);
}

.chat-trigger svg {
  color: var(--midnight);
  width: 26px;
  height: 26px;
}

.chat-trigger.is-hidden {
  transform: scale(0);
  pointer-events: none;
}

/* Notification badge */
.chat-trigger__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--wine);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
}

.chat-trigger__badge.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* Subtle pulse animation after 5s on page */
@keyframes chatTriggerPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(10, 31, 58, 0.25); }
  50% { box-shadow: 0 8px 24px rgba(201, 169, 97, 0.5); }
}

/* ---------- CHAT PANEL ---------- */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  height: 540px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(10, 31, 58, 0.25);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Mobile fullscreen */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 12px;
    right: 12px;
    left: 12px;
  }
}

/* ---------- CHAT HEADER ---------- */
.chat-header {
  background: var(--midnight);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.chat-header__avatar {
  width: 40px;
  height: 40px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header__avatar svg {
  color: var(--midnight);
  width: 22px;
  height: 22px;
}

.chat-header__info {
  flex: 1;
  min-width: 0;
}

.chat-header__name {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.chat-header__status {
  color: var(--gold-muted);
  font-size: 11px;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 400;
}

.chat-header__status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: chatStatusPulse 2s ease-in-out infinite;
}

@keyframes chatStatusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-header__close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background 0.2s ease;
}

.chat-header__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-header__close svg {
  width: 16px;
  height: 16px;
}

/* ---------- CHAT MESSAGES AREA ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  background: linear-gradient(180deg, var(--cream-light) 0%, #fff 100%);
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--gold-muted);
  border-radius: 2px;
}

/* ---------- MESSAGE BUBBLES ---------- */
.chat-message {
  display: flex;
  margin-bottom: 12px;
  animation: chatMessageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatMessageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message--bot {
  justify-content: flex-start;
}

.chat-message--user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-message--bot .chat-bubble {
  background: #fff;
  color: var(--midnight);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}

.chat-message--user .chat-bubble {
  background: var(--midnight);
  color: var(--cream-light);
  border-bottom-right-radius: 4px;
}

.chat-bubble strong {
  font-weight: 500;
  color: var(--gold);
}

.chat-message--user .chat-bubble strong {
  color: var(--gold);
}

.chat-bubble a {
  color: var(--gold);
  text-decoration: underline;
}

/* ---------- TYPING INDICATOR ---------- */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-typing__dot {
  width: 7px;
  height: 7px;
  background: var(--gold-muted);
  border-radius: 50%;
  animation: chatTyping 1.4s infinite ease-in-out;
}

.chat-typing__dot:nth-child(1) { animation-delay: 0s; }
.chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------- QUICK REPLIES ---------- */
.chat-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px;
  animation: chatMessageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-quick-reply {
  background: #fff;
  border: 1.5px solid var(--gold);
  color: var(--midnight);
  padding: 10px 14px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-quick-reply:hover {
  background: var(--gold);
  color: var(--midnight);
  transform: translateX(2px);
}

.chat-quick-reply__icon {
  font-size: 16px;
}

/* ---------- LEAD CAPTURE FORM ---------- */
.chat-form {
  background: var(--cream-light);
  border: 1px solid var(--gold-muted);
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0 16px;
  animation: chatMessageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-form__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--midnight);
  margin: 0 0 12px;
}

.chat-form__field {
  margin-bottom: 10px;
}

.chat-form__field:last-of-type {
  margin-bottom: 14px;
}

.chat-form__label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-on-light-muted);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-form__input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--midnight);
  transition: border-color 0.2s ease;
}

.chat-form__input:focus {
  outline: none;
  border-color: var(--gold);
}

.chat-form__input::placeholder {
  color: var(--text-on-light-muted);
  opacity: 0.6;
}

.chat-form__submit {
  width: 100%;
  background: var(--midnight);
  color: var(--gold);
  border: none;
  padding: 11px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  letter-spacing: 0.02em;
}

.chat-form__submit:hover {
  background: var(--navy-soft, #1A3A5C);
}

.chat-form__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- FOOTER (powered by) ---------- */
.chat-footer {
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-footer__channels {
  display: flex;
  gap: 8px;
}

.chat-footer__channel {
  width: 32px;
  height: 32px;
  background: var(--cream-light);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--midnight);
  text-decoration: none;
  transition: all 0.2s ease;
}

.chat-footer__channel:hover {
  background: var(--gold);
  border-color: var(--gold);
  transform: translateY(-2px);
}

.chat-footer__channel svg {
  width: 14px;
  height: 14px;
}

.chat-footer__powered {
  font-size: 10px;
  color: var(--text-on-light-muted);
  font-style: italic;
}

.chat-footer__powered strong {
  color: var(--gold);
  font-weight: 500;
}

/* ---------- TIME STAMP ---------- */
.chat-timestamp {
  text-align: center;
  font-size: 10px;
  color: var(--text-on-light-muted);
  margin: 8px 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---------- LINK BUBBLES (when bot recommends a page) ---------- */
.chat-link-bubble {
  display: block;
  background: #fff;
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 12px 14px;
  text-decoration: none;
  margin: 4px 0;
  transition: all 0.2s ease;
  max-width: 78%;
}

.chat-link-bubble:hover {
  background: var(--cream-light);
  transform: translateX(2px);
}

.chat-link-bubble__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--midnight);
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-link-bubble__title::after {
  content: '→';
  color: var(--gold);
  margin-left: auto;
}

.chat-link-bubble__desc {
  font-size: 11px;
  color: var(--text-on-light-muted);
  margin: 0;
  line-height: 1.4;
}

/* ---------- SUCCESS STATE ---------- */
.chat-success {
  background: var(--cream-light);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin: 8px 0;
  animation: chatMessageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-success__icon {
  width: 40px;
  height: 40px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  color: var(--midnight);
}

.chat-success__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--midnight);
  margin: 0 0 6px;
}

.chat-success__text {
  font-size: 12px;
  color: var(--text-on-light-muted);
  line-height: 1.5;
  margin: 0;
}

/* ============================================
   TEASER BUBBLE — "Hi! 👋 Need help?"
   Appears via smart trigger (time + scroll + idle)
   ============================================ */

.chat-teaser {
  position: fixed;
  bottom: 28px;
  right: 96px;
  background: #fff;
  border: 0.5px solid var(--border-light);
  border-radius: 16px 16px 4px 16px;
  padding: 12px 14px 12px 16px;
  box-shadow: 0 8px 24px rgba(10, 31, 58, 0.15);
  z-index: 9997;
  max-width: 240px;
  cursor: pointer;
  transform: translateX(20px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-teaser.is-visible {
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* On mobile, place teaser ABOVE the button to save horizontal space */
@media (max-width: 480px) {
  .chat-teaser {
    bottom: 96px;
    right: 24px;
    max-width: calc(100vw - 48px);
  }
}

.chat-teaser:hover {
  transform: translateX(0) scale(1.02);
  box-shadow: 0 12px 28px rgba(10, 31, 58, 0.22);
  border-color: var(--gold);
}

.chat-teaser__content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none; /* clicks pass through to parent */
}

.chat-teaser__text {
  flex: 1;
  min-width: 0;
}

.chat-teaser__greeting {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--midnight);
  line-height: 1.3;
}

.chat-teaser__message {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-on-light-muted);
  line-height: 1.4;
}

.chat-teaser__close {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-on-light-muted);
  flex-shrink: 0;
  padding: 0;
  margin-top: -2px;
  pointer-events: auto; /* Override parent's pointer-events:none */
  transition: all 0.2s ease;
}

.chat-teaser__close:hover {
  background: var(--cream-warm);
  color: var(--midnight);
}

.chat-teaser__close svg {
  width: 12px;
  height: 12px;
}

/* Subtle entry pulse to draw attention without being aggressive */
@keyframes teaserAttention {
  0%, 100% { box-shadow: 0 8px 24px rgba(10, 31, 58, 0.15); }
  50% { box-shadow: 0 8px 28px rgba(201, 169, 97, 0.35); }
}

.chat-teaser.is-visible {
  animation: teaserAttention 2s ease-in-out 0.5s 2;
}
