/*
 * PsyNurse Website FAQ Chatbot — styles (v2, corrected against repo)
 * ---------------------------------------------------------------
 * Uses the site's real design tokens (PsyNurseSite/css/styles.css
 * :root — var(--color-primary), var(--font-heading), etc.) instead of
 * v1's guessed hex values. This means the widget automatically stays
 * on-brand if the palette ever changes — no separate color file to
 * keep in sync. Load this AFTER styles.css in Site.Master so these
 * variables are already defined.
 *
 * z-index 500 is deliberately above the site's highest existing
 * z-index (the mobile drawer + overlay, at 200/210 in styles.css) so
 * the widget always sits on top, including while the mobile drawer is
 * open.
 */

#psynurse-chatbot-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  font-family: var(--font-body);
}

/* Toggle button */
#psynurse-chatbot-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}
#psynurse-chatbot-toggle:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
#psynurse-chatbot-toggle:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
#psynurse-chatbot-toggle:active {
  transform: scale(0.98);
}
.psynurse-chatbot-toggle-icon {
  font-size: 18px;
}

/* Panel */
#psynurse-chatbot-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: min(520px, 70vh);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

/* Bug fix (2026-08-30): the rule above sets `display: flex` unconditionally.
   An ID selector (#psynurse-chatbot-panel, specificity 1-0-0) is MORE
   specific than the browser's own default UA rule for the hidden attribute
   ([hidden] { display: none }, specificity 0-1-0), so it was silently
   winning and keeping the panel visible at all times regardless of the
   `hidden` DOM property the widget's JS toggles open/closed with. That's
   why the panel appeared without clicking the toggle, and why the × button
   (which just sets panel.hidden = true) appeared to do nothing. This rule
   is more specific still (1-1-0) and correctly wins when [hidden] is set,
   restoring real show/hide control -- no JS changes needed, the open/close
   logic itself was already correct. */
#psynurse-chatbot-panel[hidden] {
  display: none;
}

.psynurse-chatbot-header {
  background-color: var(--color-primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.psynurse-chatbot-title {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 600;
}
.psynurse-chatbot-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.psynurse-chatbot-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.psynurse-chatbot-disclaimer {
  background-color: var(--color-emergency-bg);
  color: var(--color-emergency-text);
  font-size: 0.75rem;
  line-height: 1.4;
  padding: 8px 18px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.psynurse-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--color-bg);
}

.psynurse-chatbot-bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}
.psynurse-chatbot-bubble p {
  margin: 0 0 6px 0;
}
.psynurse-chatbot-bubble a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
}
.psynurse-chatbot-bot {
  align-self: flex-start;
  background-color: var(--color-primary-subtle);
  color: var(--color-text-main);
}
.psynurse-chatbot-user {
  align-self: flex-end;
  background-color: var(--color-primary);
  color: #fff;
}

.psynurse-chatbot-form {
  display: flex;
  border-top: 1px solid var(--color-border-subtle);
  padding: 10px;
  gap: 8px;
}
.psynurse-chatbot-form input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-main);
}
.psynurse-chatbot-form input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.psynurse-chatbot-form button {
  background-color: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.psynurse-chatbot-form button:hover {
  background-color: var(--color-accent-hover);
}
.psynurse-chatbot-form button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.psynurse-chatbot-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;
}

/* Interactive Topic Menu & Cards */
.psynurse-chatbot-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px;
  width: 100%;
}
.psynurse-chatbot-menu-header {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  margin: 4px 2px 2px;
}
.psynurse-chatbot-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--color-text-main);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.84375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(20, 43, 58, 0.03);
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
.psynurse-chatbot-menu-item:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(20, 43, 58, 0.07);
}
.psynurse-chatbot-menu-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.psynurse-chatbot-menu-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
}
.psynurse-chatbot-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  font-size: 0.8125rem;
  flex-shrink: 0;
}
.psynurse-chatbot-menu-arrow {
  color: var(--color-text-light);
  font-size: 0.875rem;
  transition: transform 0.2s ease, color 0.2s ease;
}
.psynurse-chatbot-menu-item:hover .psynurse-chatbot-menu-arrow {
  color: var(--color-accent);
  transform: translateX(3px);
}
.psynurse-chatbot-menu-item-featured {
  background: linear-gradient(135deg, #ffffff 0%, var(--color-primary-subtle) 100%);
  border-color: var(--color-accent);
}
.psynurse-chatbot-menu-item-featured .psynurse-chatbot-menu-icon {
  background: var(--color-accent);
  color: #ffffff;
}
.psynurse-chatbot-menu-item-featured:hover {
  border-color: var(--color-accent-hover);
}

/* Typing Indicator Animation */
.psynurse-chatbot-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
}
.psynurse-chatbot-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-primary);
  border-radius: 50%;
  animation: psynurse-typing-bounce 1.3s infinite ease-in-out;
}
.psynurse-chatbot-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.psynurse-chatbot-dot:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes psynurse-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Elegant Boutique Lead Capture Card */
.psynurse-chatbot-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 4px 0 10px;
  box-shadow: 0 4px 14px rgba(20, 43, 58, 0.06);
  width: 100%;
  box-sizing: border-box;
}
.psynurse-chatbot-card-header {
  margin-bottom: 12px;
}
.psynurse-chatbot-card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.psynurse-chatbot-card-subtitle {
  font-size: 0.78125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin: 0;
}
.psynurse-chatbot-card-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.psynurse-chatbot-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.psynurse-chatbot-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-main);
  letter-spacing: 0.2px;
}
.psynurse-chatbot-field-label span.req {
  color: #DC2626;
}
.psynurse-chatbot-card-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #FAFAFA;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: var(--font-body);
  color: var(--color-text-main);
  transition: all 0.2s ease;
}
.psynurse-chatbot-card-input:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}
.psynurse-chatbot-card-textarea {
  min-height: 60px;
  resize: vertical;
}
.psynurse-chatbot-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.psynurse-chatbot-card-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--color-accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  padding: 10px 18px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.84375rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.psynurse-chatbot-card-submit:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.psynurse-chatbot-card-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}
.psynurse-chatbot-card-back {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  text-align: center;
  padding: 4px 0;
  transition: color 0.15s ease;
}
.psynurse-chatbot-card-back:hover {
  color: var(--color-primary);
}
.psynurse-chatbot-card-success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--color-success-text);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.psynurse-chatbot-card-success-title {
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Inline Booking Card */
.psynurse-chatbot-booking-card {
  background: #FFFFFF;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}
.psynurse-chatbot-booking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  width: fit-content;
}
.psynurse-chatbot-booking-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #16A34A;
}
.psynurse-chatbot-booking-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 0;
  line-height: 1.35;
}
.psynurse-chatbot-booking-desc {
  font-size: 0.8125rem;
  color: var(--color-text-main);
  line-height: 1.5;
  margin: 0;
}
.psynurse-chatbot-booking-highlights {
  background: var(--color-bg);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}
.psynurse-chatbot-booking-highlights strong {
  color: var(--color-text-main);
}
.psynurse-chatbot-booking-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--color-primary);
  color: #FFFFFF !important;
  text-decoration: none !important;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.84375rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
  text-align: center;
}
.psynurse-chatbot-booking-btn-primary:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.psynurse-chatbot-booking-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: transparent;
  color: var(--color-primary) !important;
  border: 1px solid var(--color-primary);
  text-decoration: none !important;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.78125rem;
  transition: all var(--transition-fast);
  text-align: center;
  cursor: pointer;
}
.psynurse-chatbot-booking-btn-secondary:hover {
  background-color: var(--color-primary-subtle);
}


/* Mobile: shrink and use a circular icon-only toggle. The mobile drawer
   nav (hamburger, top-right) and its footer CTA don't overlap the
   bottom-right corner, so no repositioning was needed here — but
   re-verify on a real phone since layouts shift. */
@media (max-width: 480px) {
  #psynurse-chatbot-root {
    right: 12px;
    bottom: 12px;
  }
  #psynurse-chatbot-panel {
    right: 12px;
    bottom: 76px;
    width: calc(100vw - 24px);
  }
  .psynurse-chatbot-toggle-label {
    display: none;
  }
  #psynurse-chatbot-toggle {
    padding: 14px;
    border-radius: 50%;
  }
}
