/* ==========================================================================
   WashoHub Care Assistant — Chat Widget Styles
   Uses the site's existing CSS variables (style.css :root) so it inherits
   the WashoHub theme automatically, including dark/light mode.
   ========================================================================== */

#wh-chat-root {
  --wh-radius: 20px;
  --wh-radius-sm: 12px;
  font-family: var(--font-body);
}

/* ---------- Floating Launcher Button ---------- */
#wh-chat-launcher {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.35), 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#wh-chat-launcher:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 36px rgba(var(--primary-rgb), 0.45), 0 2px 8px rgba(0,0,0,0.12);
}

#wh-chat-launcher:active { transform: translateY(-1px) scale(0.98); }

#wh-chat-launcher svg { width: 28px; height: 28px; color: #fff; transition: opacity 0.15s, transform 0.2s; }
#wh-chat-launcher .wh-icon-close { position: absolute; opacity: 0; transform: rotate(-45deg) scale(0.6); }
#wh-chat-launcher.wh-open .wh-icon-chat { opacity: 0; transform: rotate(45deg) scale(0.6); }
#wh-chat-launcher.wh-open .wh-icon-close { opacity: 1; transform: rotate(0) scale(1); position: static; }

#wh-chat-launcher.wh-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--primary);
  animation: wh-pulse-ring 2.2s ease-out infinite;
  z-index: -1;
}
@keyframes wh-pulse-ring {
  0% { opacity: 0.45; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.9); }
}

#wh-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}
#wh-unread-badge.wh-hidden { display: none; }

/* ---------- Chat Window ---------- */
#wh-chat-window {
  position: fixed;
  bottom: 96px;
  right: 22px;
  width: 392px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 130px));
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-color);
  border-radius: var(--wh-radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#wh-chat-window.wh-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 480px) {
  #wh-chat-window {
    right: 8px;
    left: 8px;
    bottom: 88px;
    width: auto;
    height: min(78vh, 640px);
  }
}

/* ---------- Header ---------- */
#wh-chat-header {
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#wh-chat-header .wh-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
#wh-chat-header .wh-header-text { flex: 1; min-width: 0; }
#wh-chat-header .wh-header-title { font-family: var(--font-headline); font-weight: 700; font-size: 15px; line-height: 1.2; }
#wh-chat-header .wh-header-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#wh-chat-header .wh-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,0.3); flex-shrink: 0; }
#wh-chat-header button {
  background: rgba(255,255,255,0.15);
  border: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
#wh-chat-header button:hover { background: rgba(255,255,255,0.28); }
#wh-chat-header svg { width: 16px; height: 16px; }

/* ---------- Messages Area ---------- */
#wh-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#wh-chat-body::-webkit-scrollbar { width: 6px; }
#wh-chat-body::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 10px; }

.wh-msg-row { display: flex; gap: 8px; max-width: 100%; }
.wh-msg-row.wh-user { justify-content: flex-end; }
.wh-bubble {
  padding: 10px 14px;
  border-radius: var(--wh-radius-sm);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 82%;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: wh-pop-in 0.18s ease;
}
@keyframes wh-pop-in { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: translateY(0);} }

.wh-msg-row.wh-bot .wh-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--card-shadow);
}
.wh-msg-row.wh-user .wh-bubble {
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.wh-bubble strong { font-weight: 700; }
.wh-bubble a { color: inherit; text-decoration: underline; }
.wh-msg-row.wh-bot .wh-bubble a { color: var(--primary); }

.wh-bot-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; margin-top: 2px;
}

/* Typing indicator */
.wh-typing-dots { display: flex; gap: 4px; padding: 4px 2px; }
.wh-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: wh-bounce 1.2s infinite ease-in-out;
}
.wh-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.wh-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wh-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Quick Replies ---------- */
.wh-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 4px 34px;
  max-width: 90%;
}
.wh-chip {
  background: var(--accent-light);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  color: var(--primary);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.wh-chip:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
.wh-chip:disabled { opacity: 0.5; cursor: default; transform: none; }

.wh-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 4px 34px;
  max-width: 94%;
}
.wh-menu-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 10px;
  border-radius: var(--wh-radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
  box-shadow: var(--card-shadow);
}
.wh-menu-btn:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--card-shadow-hover); }

/* Card blocks (order summary, tracking timeline, price list) */
.wh-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--wh-radius-sm);
  padding: 12px 14px;
  margin-left: 34px;
  max-width: 90%;
  font-size: 13px;
  box-shadow: var(--card-shadow);
}
.wh-card-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.wh-card-row span:first-child { color: var(--text-muted); }
.wh-card-row span:last-child { color: var(--text-primary); font-weight: 600; text-align: right; }
.wh-card-total { border-top: 1px dashed var(--border-color); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.wh-card-title { font-family: var(--font-headline); font-weight: 700; margin-bottom: 6px; color: var(--primary); font-size: 13.5px; }

.wh-track-step { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.wh-track-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-hover); flex-shrink: 0; }
.wh-track-step.wh-done .wh-track-dot { background: #10b981; }
.wh-track-step.wh-current .wh-track-dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.2); }
.wh-track-step.wh-done span.wh-label, .wh-track-step.wh-current span.wh-label { color: var(--text-primary); font-weight: 600; }
.wh-track-step span.wh-label { color: var(--text-muted); }

/* ---------- Footer / Input ---------- */
#wh-chat-footer {
  border-top: 1px solid var(--border-color);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-card);
}
#wh-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: var(--font-body);
  max-height: 80px;
  outline: none;
  transition: border-color 0.15s;
}
#wh-chat-input:focus { border-color: var(--primary); }

.wh-round-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.wh-round-btn svg { width: 17px; height: 17px; }
#wh-send-btn { background: linear-gradient(120deg, var(--primary), var(--secondary)); color: #fff; }
#wh-send-btn:hover { transform: scale(1.06); }
#wh-send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
#wh-mic-btn { background: var(--accent-light); color: var(--primary); }
#wh-mic-btn.wh-listening { background: #ef4444; color: #fff; animation: wh-mic-pulse 1s infinite; }
@keyframes wh-mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.wh-powered {
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 5px 0 2px;
  flex-shrink: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #wh-chat-launcher, #wh-chat-window, .wh-bubble, .wh-typing-dots span, #wh-chat-launcher.wh-pulse::before {
    animation: none !important;
    transition: none !important;
  }
}
