/* Hubert — floating widget + shared chat bubbles */

.hubert-widget {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1200;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.hubert-launcher {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px 10px 10px;
  background: linear-gradient(135deg, #c8b4f0 0%, #7ec8f0 100%);
  color: #2d2340;
  box-shadow: 0 12px 32px rgba(91, 47, 153, 0.3);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.hubert-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(91, 47, 153, 0.34);
}

.hubert-widget--open .hubert-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.hubert-launcher-icon {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #0d0d12;
  object-fit: cover;
}

.hubert-launcher-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hubert-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-soft, #e8dff0);
  border-radius: calc(var(--radius, 12px) + 6px);
  background: var(--surface-card, #fff);
  box-shadow: 0 18px 48px rgba(45, 35, 64, 0.22);
  overflow: hidden;
}

.hubert-panel[hidden] {
  display: none !important;
}

.hubert-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border-soft, #e8dff0);
  background: linear-gradient(180deg, var(--lavender-light, #f4eef9) 0%, var(--surface-card, #fff) 100%);
}

.hubert-panel-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hubert-panel-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0d0d12;
  object-fit: cover;
}

.hubert-panel-title {
  margin: 0;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--charcoal, #2d2340);
}

.hubert-panel-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted, #6b6478);
}

.hubert-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hubert-panel-reset,
.hubert-panel-close {
  border: 1px solid var(--border-soft, #e8dff0);
  background: #fff;
  color: var(--text-muted, #6b6478);
  border-radius: var(--radius-pill, 999px);
  cursor: pointer;
}

.hubert-panel-reset {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
}

.hubert-panel-close {
  width: 34px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
}

.hubert-panel-reset:hover,
.hubert-panel-close:hover {
  color: var(--charcoal, #2d2340);
  border-color: rgba(91, 47, 153, 0.2);
}

.hubert-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
}

.hubert-bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 0.93rem;
  line-height: 1.55;
}

.hubert-bubble--assistant {
  align-self: flex-start;
  background: var(--lavender-light, #f4eef9);
  color: var(--charcoal, #2d2340);
  border: 1px solid rgba(212, 184, 232, 0.5);
}

.hubert-bubble--user {
  align-self: flex-end;
  background: var(--lavender-deep, #5b2f99);
  color: #fff;
}

.hubert-bubble--typing {
  opacity: 0.75;
  font-style: italic;
}

.hubert-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.hubert-chip {
  border: 1px solid rgba(212, 184, 232, 0.8);
  background: #fff;
  color: var(--charcoal, #2d2340);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill, 999px);
  padding: 7px 12px;
  cursor: pointer;
}

.hubert-chip:hover {
  border-color: rgba(91, 47, 153, 0.35);
  background: var(--lavender-light, #f4eef9);
}

.hubert-form {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border-soft, #e8dff0);
  background: var(--surface-card, #fff);
}

.hubert-form-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.hubert-form textarea {
  width: 100%;
  min-width: 0;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border: 1px solid var(--border-soft, #e8dff0);
  border-radius: var(--radius, 12px);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.45;
  color: var(--charcoal, #2d2340);
}

.hubert-form textarea:focus {
  outline: 2px solid rgba(91, 47, 153, 0.25);
  outline-offset: 1px;
  border-color: rgba(91, 47, 153, 0.35);
}

.hubert-form .btn {
  min-height: 44px;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Contact page inline chat — Hubert avatar in header */
.contact-chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.contact-chat-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0d0d12;
  object-fit: cover;
}

/* Organiser dashboard — slightly smaller launcher & panel */
.hubert-widget--organiser .hubert-launcher-icon {
  width: 56px;
  height: 56px;
}

.hubert-widget--organiser .hubert-panel {
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 80px));
}

/* Hide launcher while mobile nav is open so it cannot cover the drawer */
body.nav-menu-open .hubert-widget,
body.events-filter-sheet-open .hubert-widget,
body.org-more-sheet-open .hubert-widget,
body.org-notifications-open .hubert-widget,
body.hub-cookie-modal-open .hubert-widget,
body:has(#hub-cookie-banner:not([hidden])) .hubert-widget {
  visibility: hidden;
  pointer-events: none;
}

/* Lift above sticky detail-page CTAs (tickets / enquire); park left so the bar stays full-width */
body.ev-ticket-jump-active .hubert-widget:not(.hubert-widget--open),
body.opp-enquire-jump-active .hubert-widget:not(.hubert-widget--open) {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: auto;
  left: max(12px, env(safe-area-inset-left));
}

body.ev-ticket-jump-active .hubert-launcher-icon,
body.opp-enquire-jump-active .hubert-launcher-icon {
  width: 44px;
  height: 44px;
}

@media (max-width: 900px) {
  body.events-page .hubert-widget:not(.hubert-widget--open) {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  body.events-page .hubert-launcher-icon {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 768px) {
  /* Clear fixed hub bottom nav (organiser + My account) */
  body.organiser-dashboard-page .hubert-widget:not(.hubert-widget--open),
  body.attendee-dashboard-page .hubert-widget:not(.hubert-widget--open) {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  body.organiser-dashboard-page .hubert-launcher-icon,
  body.attendee-dashboard-page .hubert-launcher-icon {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 640px) {
  .hubert-launcher-label {
    display: none;
  }

  .hubert-launcher {
    padding: 8px;
    border-radius: 50%;
  }

  .hubert-launcher-icon {
    width: 56px;
    height: 56px;
  }

  /* Sit above mobile sticky CTAs — park left so City Sponsor / enquiry stay tappable */
  body.advertising-page .hubert-widget:not(.hubert-widget--open),
  body.ad-sticky-cta-active .hubert-widget:not(.hubert-widget--open) {
    bottom: max(76px, calc(16px + env(safe-area-inset-bottom)));
    right: auto;
    left: max(12px, env(safe-area-inset-left));
  }

  body.organiser-dashboard-page .hubert-launcher-icon,
  body.attendee-dashboard-page .hubert-launcher-icon {
    width: 48px;
    height: 48px;
  }

  /* Fade off the footer so Legal / Cookie links stay tappable */
  .hubert-widget--near-footer:not(.hubert-widget--open) .hubert-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
  }

  .hubert-panel {
    width: calc(100vw - 24px);
    height: min(72vh, 620px);
    right: -4px;
  }

  .hubert-form-compose {
    grid-template-columns: 1fr;
  }

  .hubert-form .btn {
    width: 100%;
  }
}
