/* ═══════════════════════════════════════════════════════════════════════════
   weMOVEtogether Chat Widget — Alex Customer Support
   Design System: Teal #2D9B87, Navy #1A365D, Beige #EBE1D5, Inter
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Demo Page (remove when embedding) ─────────────────────────────────── */
.demo-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  background: #FAFAF8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.demo-header {
  text-align: center;
  max-width: 560px;
}

.demo-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1A365D;
  margin-bottom: 12px;
}

.demo-header p {
  font-size: 16px;
  color: #64748B;
  line-height: 1.6;
}

/* ─── Widget Container ──────────────────────────────────────────────────── */
.wmt-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Toggle Button ─────────────────────────────────────────────────────── */
.wmt-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2D9B87;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px rgba(45, 155, 135, 0.35), 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
}

.wmt-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(45, 155, 135, 0.45), 0 2px 4px rgba(0,0,0,0.1);
  background: #258F7A;
}

.wmt-chat-toggle:active {
  transform: scale(0.96);
}

.wmt-chat-icon-close {
  display: none;
}

.wmt-chat-widget.open .wmt-chat-icon-open {
  display: none;
}

.wmt-chat-widget.open .wmt-chat-icon-close {
  display: block;
}

.wmt-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #E53E3E;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ─── Chat Window ───────────────────────────────────────────────────────── */
.wmt-chat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: wmtSlideUp 0.25s ease-out;
}

.wmt-chat-widget.open .wmt-chat-window {
  display: flex;
}

@keyframes wmtSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.wmt-chat-header {
  background: linear-gradient(135deg, #1A365D 0%, #2D5A8E 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.wmt-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wmt-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.wmt-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.wmt-chat-header-name {
  font-size: 16px;
  font-weight: 600;
}

.wmt-chat-header-status {
  font-size: 13px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wmt-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48BB78;
  display: inline-block;
}

/* Close button in header — visible X icon */
.wmt-chat-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.wmt-chat-close:hover {
  background: rgba(255,255,255,0.25);
}

/* Legacy minimize class — keep for backward compat */
.wmt-chat-minimize {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.wmt-chat-minimize:hover {
  background: rgba(255,255,255,0.25);
}

/* ─── Messages ──────────────────────────────────────────────────────────── */
.wmt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

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

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

.wmt-chat-messages::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 3px;
}

/* ─── Message Bubbles ───────────────────────────────────────────────────── */
.wmt-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: wmtFadeIn 0.2s ease-out;
}

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

.wmt-msg-bot {
  align-self: flex-start;
}

.wmt-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.wmt-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2D9B87;
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.wmt-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.wmt-msg-user .wmt-msg-avatar {
  background: #1A365D;
}

.wmt-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wmt-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.wmt-msg-bot .wmt-msg-bubble {
  background: #F3F4F6;
  color: #1F2937;
  border-bottom-left-radius: 4px;
}

.wmt-msg-user .wmt-msg-bubble {
  background: #2D9B87;
  color: white;
  border-bottom-right-radius: 4px;
}

.wmt-msg-bubble a {
  color: #2D9B87;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.wmt-msg-user .wmt-msg-bubble a {
  color: #C6F6D5;
}

.wmt-msg-bubble ul,
.wmt-msg-bubble ol {
  margin: 8px 0 4px 20px;
  padding: 0;
}

.wmt-msg-bubble li {
  margin-bottom: 4px;
}

.wmt-msg-bubble strong {
  font-weight: 600;
}

.wmt-msg-time {
  font-size: 11px;
  color: #9CA3AF;
  padding: 0 4px;
}

.wmt-msg-user .wmt-msg-time {
  text-align: right;
}

/* ─── Typing Indicator ──────────────────────────────────────────────────── */
.wmt-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #F3F4F6;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.wmt-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9CA3AF;
  animation: wmtTyping 1.2s ease-in-out infinite;
}

.wmt-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.wmt-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes wmtTyping {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ─── Quick Actions ─────────────────────────────────────────────────────── */
.wmt-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.wmt-quick-btn {
  padding: 8px 14px;
  border: 1.5px solid #E5E7EB;
  border-radius: 20px;
  background: white;
  color: #1A365D;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.wmt-quick-btn:hover {
  border-color: #2D9B87;
  color: #2D9B87;
  background: #F0FDF9;
}

.wmt-quick-btn:active {
  transform: scale(0.97);
}

/* ─── Escalation Banner ─────────────────────────────────────────────────── */
.wmt-escalation-banner {
  background: #FEF3CD;
  border-top: 1px solid #F6E05E;
  padding: 12px 16px;
  flex-shrink: 0;
}

.wmt-escalation-banner p {
  font-size: 13px;
  font-weight: 500;
  color: #744210;
  margin-bottom: 8px;
}

.wmt-escalation-actions {
  display: flex;
  gap: 8px;
}

.wmt-escalation-yes {
  padding: 6px 14px;
  background: #2D9B87;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.wmt-escalation-yes:hover {
  background: #258F7A;
}

.wmt-escalation-no {
  padding: 6px 14px;
  background: transparent;
  color: #744210;
  border: 1px solid #D69E2E;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.wmt-escalation-no:hover {
  background: rgba(214, 158, 46, 0.1);
}

/* ─── Escalation Form ───────────────────────────────────────────────────── */
.wmt-escalation-form {
  background: #F0FDF9;
  border-top: 1px solid #C6F6D5;
  padding: 14px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wmt-escalation-form p {
  font-size: 13px;
  font-weight: 500;
  color: #1A365D;
  margin: 0;
}

.wmt-input,
.wmt-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #E5E7EB;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1F2937;
  background: white;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.wmt-input:focus,
.wmt-textarea:focus {
  outline: none;
  border-color: #2D9B87;
  box-shadow: 0 0 0 3px rgba(45, 155, 135, 0.1);
}

.wmt-textarea {
  resize: none;
}

.wmt-submit-btn {
  padding: 8px 16px;
  background: #2D9B87;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.wmt-submit-btn:hover {
  background: #258F7A;
}

/* ─── Input Area ────────────────────────────────────────────────────────── */
.wmt-chat-input-area {
  border-top: 1px solid #F3F4F6;
  padding: 12px 16px;
  flex-shrink: 0;
  background: white;
}

.wmt-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #F9FAFB;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.wmt-chat-input-wrapper:focus-within {
  border-color: #2D9B87;
  box-shadow: 0 0 0 3px rgba(45, 155, 135, 0.1);
}

.wmt-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: #1F2937;
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 80px;
  line-height: 1.4;
}

.wmt-chat-input::placeholder {
  color: #9CA3AF;
}

.wmt-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2D9B87;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
}

.wmt-chat-send:hover:not(:disabled) {
  background: #258F7A;
  transform: scale(1.05);
}

.wmt-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wmt-chat-footer {
  text-align: center;
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 8px;
}

.wmt-chat-footer a {
  color: #2D9B87;
  text-decoration: none;
}

.wmt-chat-footer a:hover {
  text-decoration: underline;
}

/* ─── Sources Card ──────────────────────────────────────────────────────── */
.wmt-sources {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #E5E7EB;
}

.wmt-sources-label {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wmt-source-link {
  font-size: 12px;
  color: #2D9B87;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wmt-source-link:hover {
  text-decoration: underline;
}

.wmt-source-link::before {
  content: "\2192";
  font-size: 10px;
}

/* ─── Mobile Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .wmt-chat-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .wmt-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    bottom: 72px;
    right: -8px;
    border-radius: 12px;
  }
  
  .wmt-chat-toggle {
    width: 54px;
    height: 54px;
  }
  
  .wmt-msg {
    max-width: 90%;
  }
}

/* ─── Print (hide widget) ───────────────────────────────────────────────── */
@media print {
  .wmt-chat-widget {
    display: none !important;
  }
}

/* ─── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .wmt-chat-window {
    animation: none;
  }
  
  .wmt-msg {
    animation: none;
  }
  
  .wmt-typing-dot {
    animation: none;
    opacity: 0.5;
  }
  
  .wmt-chat-toggle,
  .wmt-chat-send,
  .wmt-quick-btn {
    transition: none;
  }
}
