/* ─────────────────────────────────────────────────────────────────────────────
   Big Dodo Widget — Mauritius Resort Finder AI Concierge
   Luxury dark aesthetic matching the site design system.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Variables (locally scoped so they don't conflict) ── */
.bd-widget {
  --bd-gold:        #c9a84c;
  --bd-gold-bright: #e2bc60;
  --bd-gold-dim:    #9b7d35;
  --bd-gold-glow:   rgba(201, 168, 76, 0.12);
  --bd-gold-border: rgba(201, 168, 76, 0.30);
  --bd-navy:        #08111f;
  --bd-navy-card:   #0e1623;
  --bd-navy-raised: #111a28;
  --bd-midnight:    #0d1117;
  --bd-text:        #e8dfc8;
  --bd-champagne:   #f5e6c8;
  --bd-muted:       #8b949e;
  --bd-border:      rgba(255, 255, 255, 0.07);
  --bd-border-light:rgba(255, 255, 255, 0.12);
  --bd-shadow:      0 24px 64px rgba(0, 0, 0, 0.7), 0 8px 24px rgba(0, 0, 0, 0.4);
  --bd-radius:      16px;
  --bd-radius-sm:   10px;
  --bd-radius-pill: 100px;
  --bd-ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --bd-ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --bd-duration:    0.2s;

  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Trigger button ── */
.bd-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;

  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  outline: none;
  padding: 0;

  background: linear-gradient(135deg, var(--bd-gold) 0%, var(--bd-gold-bright) 50%, var(--bd-gold-dim) 100%);
  background-size: 200% auto;
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.45), 0 8px 32px rgba(0, 0, 0, 0.4);

  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;

  transition:
    background-position 0.4s var(--bd-ease),
    box-shadow 0.25s var(--bd-ease),
    transform 0.2s var(--bd-ease-out);
}

.bd-trigger:hover {
  background-position: right center;
  box-shadow: 0 6px 28px rgba(201, 168, 76, 0.6), 0 12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px) scale(1.04);
}

.bd-trigger:active {
  transform: scale(0.96);
}

.bd-trigger:focus-visible {
  box-shadow: 0 0 0 3px var(--bd-navy), 0 0 0 5px var(--bd-gold);
}

.bd-trigger__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.bd-trigger__label {
  font-size: 0.38rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #08111f;
  line-height: 1;
}

/* Pulse ring on first visit */
.bd-trigger--pulse::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(201, 168, 76, 0.6);
  animation: bd-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes bd-pulse {
  0%   { transform: scale(1); opacity: 0.8; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ── Chat panel ── */
.bd-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9001;

  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);

  background: var(--bd-navy-card);
  border: 1px solid var(--bd-gold-border);
  border-radius: var(--bd-radius);
  box-shadow: var(--bd-shadow);

  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.22s var(--bd-ease-out),
    transform 0.22s var(--bd-ease-out);
}

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

/* ── Panel header ── */
.bd-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--bd-border);
  background: linear-gradient(135deg, var(--bd-midnight) 0%, rgba(201, 168, 76, 0.04) 100%);
  flex-shrink: 0;
}

.bd-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bd-gold) 0%, var(--bd-gold-dim) 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(201, 168, 76, 0.4);
}

.bd-header__avatar svg {
  width: 20px;
  height: 20px;
}

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

.bd-header__name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bd-champagne);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.bd-header__status {
  font-size: 0.68rem;
  color: var(--bd-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.bd-header__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.bd-header__close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--bd-border);
  border-radius: 8px;
  background: transparent;
  color: var(--bd-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--bd-duration), color var(--bd-duration), background var(--bd-duration);
  flex-shrink: 0;
}

.bd-header__close:hover {
  border-color: var(--bd-gold-border);
  color: var(--bd-champagne);
  background: var(--bd-gold-glow);
}

.bd-header__close:focus-visible {
  outline: 2px solid var(--bd-gold);
  outline-offset: 2px;
}

/* ── Messages area ── */
.bd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

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

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

.bd-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* ── Individual messages ── */
.bd-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
}

.bd-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.bd-msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.bd-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.865rem;
  line-height: 1.65;
}

.bd-msg--user .bd-bubble {
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.18) 0%, rgba(201, 168, 76, 0.1) 100%);
  border: 1px solid var(--bd-gold-border);
  color: var(--bd-champagne);
  border-bottom-right-radius: 4px;
}

.bd-msg--assistant .bd-bubble {
  background: var(--bd-navy-raised);
  border: 1px solid var(--bd-border-light);
  color: var(--bd-text);
  border-bottom-left-radius: 4px;
}

/* ── Hotel recommendation cards within messages ── */
.bd-hotel-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: 340px;
}

.bd-hotel-card {
  background: var(--bd-midnight);
  border: 1px solid var(--bd-gold-border);
  border-radius: var(--bd-radius-sm);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}

.bd-hotel-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--bd-gold) 0%, var(--bd-gold-dim) 100%);
}

.bd-hotel-card__name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--bd-champagne);
  margin-bottom: 3px;
}

.bd-hotel-card__meta {
  font-size: 0.68rem;
  color: var(--bd-gold);
  margin-bottom: 6px;
  font-weight: 600;
}

.bd-hotel-card__reason {
  font-size: 0.78rem;
  color: var(--bd-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.bd-hotel-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bd-navy);
  background: linear-gradient(135deg, var(--bd-gold) 0%, var(--bd-gold-bright) 50%, var(--bd-gold-dim) 100%);
  background-size: 200% auto;
  padding: 6px 14px;
  border-radius: var(--bd-radius-pill);
  text-decoration: none;
  white-space: nowrap;
  transition: background-position 0.4s, transform 0.15s;
}

.bd-hotel-card__cta:hover {
  background-position: right center;
  transform: translateY(-1px);
}

/* ── Affiliate disclosure ── */
.bd-disclosure {
  font-size: 0.67rem;
  color: var(--bd-muted);
  margin-top: 8px;
  opacity: 0.75;
  line-height: 1.5;
}

/* ── Typing indicator ── */
.bd-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--bd-navy-raised);
  border: 1px solid var(--bd-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  gap: 5px;
  align-items: center;
}

.bd-typing--visible {
  display: flex;
}

.bd-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bd-gold);
  opacity: 0.4;
  animation: bd-bounce 1.2s ease-in-out infinite;
}

.bd-typing__dot:nth-child(2) { animation-delay: 0.18s; }
.bd-typing__dot:nth-child(3) { animation-delay: 0.36s; }

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

/* ── Suggested prompts ── */
.bd-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.bd-suggestion {
  font-size: 0.7rem;
  color: var(--bd-muted);
  border: 1px solid var(--bd-border);
  border-radius: var(--bd-radius-pill);
  padding: 5px 12px;
  background: transparent;
  cursor: pointer;
  transition: border-color var(--bd-duration), color var(--bd-duration), background var(--bd-duration);
  white-space: nowrap;
  font-family: inherit;
}

.bd-suggestion:hover {
  border-color: var(--bd-gold-border);
  color: var(--bd-gold);
  background: var(--bd-gold-glow);
}

.bd-suggestion:focus-visible {
  outline: 2px solid var(--bd-gold);
  outline-offset: 2px;
}

/* ── Input area ── */
.bd-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--bd-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bd-midnight);
  flex-shrink: 0;
}

.bd-input {
  flex: 1;
  background: var(--bd-navy-raised);
  border: 1px solid var(--bd-border);
  border-radius: var(--bd-radius-sm);
  color: var(--bd-text);
  font-size: 0.855rem;
  font-family: inherit;
  line-height: 1.5;
  padding: 9px 12px;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  transition: border-color var(--bd-duration), box-shadow var(--bd-duration);
  field-sizing: content;
}

.bd-input::placeholder { color: var(--bd-muted); }

.bd-input:focus {
  outline: none;
  border-color: var(--bd-gold-border);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.08);
}

.bd-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--bd-gold) 0%, var(--bd-gold-dim) 100%);
  color: var(--bd-navy);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.bd-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.45);
}

.bd-send:active { transform: scale(0.95); }

.bd-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.bd-send:focus-visible {
  outline: 2px solid var(--bd-gold);
  outline-offset: 2px;
}

/* ── Error message ── */
.bd-error {
  color: #f87171;
  font-size: 0.8rem;
  padding: 8px 12px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--bd-radius-sm);
}

/* ── Mobile: bottom-sheet layout ── */
@media (max-width: 768px) {
  .bd-trigger {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .bd-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    opacity: 1;
    transform: translateY(100%);
  }

  .bd-panel--open {
    transform: translateY(0);
  }

  .bd-messages {
    overscroll-behavior: contain;
  }
}

/* ── Reduce motion ── */
@media (prefers-reduced-motion: reduce) {
  .bd-panel,
  .bd-trigger,
  .bd-hotel-card__cta { transition: none; }

  .bd-typing__dot { animation: none; opacity: 0.6; }
  .bd-trigger--pulse::after { animation: none; }
}
