/* ==========================================================================
   DSM-5 Psychiatry & Clinical Psychology AI Assistant Widget Stylesheet
   ========================================================================== */

:root {
  --wa-primary: #6366f1;
  --wa-primary-hover: #4f46e5;
  --wa-bg-glass: rgba(15, 23, 42, 0.88);
  --wa-bg-card: #1e293b;
  --wa-text-main: #f8fafc;
  --wa-text-muted: #94a3b8;
  --wa-border: rgba(255, 255, 255, 0.1);
  --wa-user-msg-bg: #4f46e5;
  --wa-user-msg-text: #ffffff;
  --wa-bot-msg-bg: #334155;
  --wa-bot-msg-text: #f1f5f9;
  --wa-radius: 16px;
  --wa-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --wa-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --wa-bg-glass: rgba(255, 255, 255, 0.95);
  --wa-bg-card: #ffffff;
  --wa-text-main: #0f172a;
  --wa-text-muted: #64748b;
  --wa-border: rgba(0, 0, 0, 0.1);
  --wa-bot-msg-bg: #f1f5f9;
  --wa-bot-msg-text: #0f172a;
}

/* Container */
.wa-widget-container {
  position: fixed;
  z-index: 99999;
  font-family: var(--wa-font);
  box-sizing: border-box;
}
.wa-widget-container *, .wa-widget-container *::before, .wa-widget-container *::after {
  box-sizing: border-box;
}

.wa-position-bottom-right { bottom: 24px; right: 24px; }
.wa-position-bottom-left { bottom: 24px; left: 24px; }

/* Floating Toggle Button */
.wa-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-primary), #818cf8);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--wa-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
  position: relative;
}
.wa-toggle-btn:hover {
  transform: scale(1.08);
}

/* Pulsing Glowing Attention Effects */
.wa-toggle-btn.wa-pulsing {
  animation: waPulseGlow 2.5s infinite ease-in-out;
}

.wa-toggle-btn.wa-pulsing::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.8);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.6);
  z-index: -1;
  animation: waRingExpand 2.5s infinite cubic-bezier(0.1, 0.8, 0.3, 1);
}

@keyframes waPulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7), 0 10px 20px -5px rgba(0, 0, 0, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 25px 8px rgba(99, 102, 241, 0.8), 0 15px 25px -5px rgba(99, 102, 241, 0.4);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0), 0 10px 20px -5px rgba(0, 0, 0, 0.5);
    transform: scale(1);
  }
}

@keyframes waRingExpand {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* Teaser Speech Bubble */
.wa-teaser-bubble {
  position: absolute;
  bottom: 74px;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  color: #f8fafc;
  border: 1px solid rgba(99, 102, 241, 0.5);
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 16px rgba(99, 102, 241, 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 99998;
}

.wa-teaser-bubble.wa-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: waBounceTeaser 3s infinite ease-in-out;
}

@keyframes waBounceTeaser {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.wa-teaser-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}

.wa-teaser-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.wa-toggle-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Chat Window Panel */
.wa-chat-panel {
  display: none;
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  background: var(--wa-bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--wa-border);
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-shadow);
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  bottom: 74px;
  right: 0;
  animation: waSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes waSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wa-chat-panel.wa-open {
  display: flex;
}

/* Header */
.wa-header {
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.85);
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wa-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wa-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.wa-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--wa-text-main);
  margin: 0;
}
.wa-subtitle {
  font-size: 12px;
  color: #818cf8;
  margin: 0;
}
.wa-header-actions {
  display: flex;
  gap: 8px;
}
.wa-icon-btn {
  background: transparent;
  border: none;
  color: var(--wa-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.wa-icon-btn:hover {
  color: var(--wa-text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Body / Message List */
.wa-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wa-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: waFadeIn 0.2s ease-in;
}
@keyframes waFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.wa-msg-user {
  align-self: flex-end;
}
.wa-msg-user .wa-bubble {
  background: var(--wa-user-msg-bg);
  color: var(--wa-user-msg-text);
  border-radius: 16px 16px 4px 16px;
}

.wa-msg-assistant {
  align-self: flex-start;
}
.wa-msg-assistant .wa-bubble {
  background: var(--wa-bot-msg-bg);
  color: var(--wa-bot-msg-text);
  border-radius: 16px 16px 16px 4px;
}

.wa-bubble {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.wa-bubble p { margin: 0 0 8px 0; }
.wa-bubble p:last-child { margin-bottom: 0; }
.wa-bubble code {
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12.5px;
}

/* Quick Suggestion Chips */
.wa-suggestions {
  padding: 8px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.5);
}
.wa-sugg-chip {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.wa-sugg-chip:hover {
  background: rgba(99, 102, 241, 0.25);
  color: white;
  border-color: #818cf8;
}
.wa-sugg-crisis {
  background: rgba(225, 29, 72, 0.15);
  color: #fca5a5;
  border-color: rgba(225, 29, 72, 0.3);
}
.wa-sugg-crisis:hover {
  background: #e11d48;
  color: white;
}

/* Action Cards */
.wa-action-card {
  margin-top: 10px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--wa-primary);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.wa-card-title {
  font-weight: 600;
  color: #818cf8;
}
.wa-card-rec {
  color: #34d399;
}

/* Typing animation */
.wa-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}
.wa-dot {
  width: 7px;
  height: 7px;
  background: var(--wa-text-muted);
  border-radius: 50%;
  animation: waPulse 1.2s infinite ease-in-out;
}
.wa-dot:nth-child(2) { animation-delay: 0.2s; }
.wa-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes waPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Input Footer */
.wa-footer {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  width: 100%;
}

.wa-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-input-wrapper:focus-within {
  border-color: var(--wa-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.wa-chat-input,
textarea#wa-chat-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: #f8fafc !important;
  font-family: var(--wa-font);
  font-size: 13.5px;
  line-height: 1.4;
  resize: none !important;
  max-height: 90px;
  padding: 8px 0;
  margin: 0;
}

.wa-chat-input::placeholder,
textarea#wa-chat-input::placeholder {
  color: #94a3b8;
  opacity: 0.8;
}

.wa-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-primary), #4f46e5);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, box-shadow 0.2s;
}

.wa-send-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}
