/* ============================================================
   WOMECH — AI CHAT WIDGET (chat.css)
   Sidebar mode + FAB/floating mode
   Powered by Gemini | Branded: Brandscapers Africa
   Storage: Per-session in-memory only — no persistence.
   ============================================================ */

/* ============================================================
   SIDEBAR CHAT SECTION
   Injected inside .navbar, between .nav-links and .sidenav-footer
   Hidden automatically when .navbar.topnav via CSS transition
   ============================================================ */

#wm-sidebar-chat {
  flex-shrink: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
  /* Entry animation (topnav → sidebar): expand then fade in */
  transition:
    max-height 0.44s cubic-bezier(0.77, 0, 0.175, 1),
    opacity    0.3s  0.2s ease,
    transform  0.38s 0.08s cubic-bezier(0.77, 0, 0.175, 1);
  max-height: 320px;
  opacity: 1;
  transform: translateY(0);
}

/* The site now uses a permanent top navigation; chat stays in FAB mode. */
.navbar #wm-sidebar-chat { display: none !important; }

/* Exit animation (sidebar → topnav): fade then collapse */
.navbar.topnav #wm-sidebar-chat {
  max-height: 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  flex: 0 0 0 !important;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  border-top-color: transparent;
  transition:
    opacity    0.22s ease,
    max-height 0.42s 0.08s cubic-bezier(0.77, 0, 0.175, 1),
    transform  0.28s ease,
    border-top-color 0s 0.5s;
}

/* ---- Sidebar chat header (click to collapse/expand) ---- */
.wm-s-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: var(--white);
  flex-shrink: 0;
}

.wm-s-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.4px;
}

.wm-s-title i {
  font-size: 0.9rem;
  color: var(--pink);
}

.wm-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: wmPulse 2s ease-in-out infinite;
}

@keyframes wmPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

#wmSArrow {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.65);
  transition: transform 0.3s cubic-bezier(0.77,0,0.175,1);
}

#wmSArrow.collapsed {
  transform: rotate(180deg);
}

/* ---- Sidebar chat body (collapsible) ---- */
.wm-s-body {
  overflow: hidden;
  transition:
    max-height 0.38s cubic-bezier(0.77, 0, 0.175, 1),
    opacity    0.28s ease;
  max-height: 280px;
  opacity: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.wm-s-body.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Messages in sidebar */
#wmSMsgs {
  height: 130px;
  overflow-y: auto;
  padding: 8px 10px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ============================================================
   FAB WRAPPER
   Fixed, bottom-right; appears in topnav mode
   ============================================================ */

#wm-fab-wrap {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  /* Start hidden */
  opacity: 0;
  transform: translateY(22px) scale(0.82);
  transition:
    opacity   0.38s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#wm-fab-wrap.wm-fab-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: none;
}

#wm-fab-wrap.wm-fab-visible > * {
  pointer-events: auto;
}

/* ---- FAB button ---- */
#wm-fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 20px rgba(0, 21, 81, 0.38);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              background 0.22s,
              box-shadow 0.22s;
  position: relative;
  flex-shrink: 0;
}

#wm-fab-btn:hover {
  transform: scale(1.1);
  background: var(--blue-dark);
  box-shadow: 0 6px 28px rgba(0, 21, 81, 0.5), 0 0 0 6px rgba(214,22,107,0.13);
}

/* Badge */
#wm-fab-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--pink);
  color: var(--white);
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  border: 2px solid var(--white);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.22s, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#wm-fab-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* ---- FAB chat panel ---- */
#wm-fab-panel {
  width: 330px;
  max-height: 500px;
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 8px 48px rgba(0,0,0,0.18), 0 2px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transform-origin: bottom right;
  transition:
    opacity   0.28s ease,
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#wm-fab-panel.wm-panel-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* FAB panel header */
.wm-fab-hdr {
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: var(--white);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wm-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--pink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.wm-hdr-info {
  flex: 1;
}

.wm-hdr-info strong {
  display: block;
  font-family: var(--font-head);
  font-size: 0.88rem;
  font-weight: 700;
}

.wm-hdr-info span {
  font-size: 0.7rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wm-chat-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.wm-chat-close-btn:hover {
  color: var(--white);
  background: rgba(255,255,255,0.12);
}

/* FAB messages container */
#wmFMsgs {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
}

/* ============================================================
   SHARED CHAT COMPONENTS (messages, input, chips, footer)
   ============================================================ */

/* Message rows */
.wm-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  animation: wmMsgIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
}

.wm-msg-row.user {
  flex-direction: row-reverse;
}

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

.wm-msg-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  flex-shrink: 0;
}

.wm-msg-row.assistant .wm-msg-icon {
  background: var(--blue);
  color: var(--white);
}

.wm-msg-row.user .wm-msg-icon {
  background: var(--pink);
  color: var(--white);
}

.wm-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.55;
}

.wm-bubble ul {
  margin: 4px 0 0 14px;
}

.wm-bubble li {
  margin-bottom: 2px;
}

.wm-msg-row.assistant .wm-bubble {
  background: var(--grey-light);
  color: var(--dark);
  border-bottom-left-radius: 3px;
}

.wm-msg-row.user .wm-bubble {
  background: var(--blue);
  color: var(--white);
  border-bottom-right-radius: 3px;
}

/* Typing indicator */
.wm-typing-bubble {
  padding: 10px 14px;
  background: var(--grey-light);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wm-typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--grey);
  animation: wmTypingBounce 1.1s ease-in-out infinite;
}

.wm-typing-bubble span:nth-child(2) { animation-delay: 0.16s; }
.wm-typing-bubble span:nth-child(3) { animation-delay: 0.32s; }

@keyframes wmTypingBounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1;   }
}

/* Error message */
.wm-error-msg {
  font-size: 0.77rem;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 7px 11px;
  text-align: center;
  margin: 4px 0;
}

/* Suggestion chips */
.wm-suggs {
  padding: 5px 10px 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex-shrink: 0;
}

.wm-chip {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid rgba(26,62,191,0.25);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.wm-chip:hover {
  background: var(--blue);
  color: var(--white);
  transform: translateY(-1px);
}

/* Input row */
.wm-input-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.wm-input-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 13px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  color: var(--dark);
  background: var(--grey-light);
}

.wm-input-row input:focus {
  border-color: var(--blue);
  background: var(--white);
}

.wm-input-row input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wm-input-row button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pink);
  border: none;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.18s;
}

.wm-input-row button:hover:not(:disabled) {
  background: #b8125d;
  transform: scale(1.1);
}

.wm-input-row button:disabled {
  background: var(--grey);
  cursor: not-allowed;
  transform: none;
}

/* Powered-by footer */
.wm-chat-footer {
  font-size: 0.65rem;
  color: var(--grey);
  text-align: center;
  padding: 5px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.wm-chat-footer strong {
  color: var(--blue);
  font-weight: 700;
}

/* Scrollbar */
#wmSMsgs::-webkit-scrollbar,
#wmFMsgs::-webkit-scrollbar { width: 3px; }
#wmSMsgs::-webkit-scrollbar-track,
#wmFMsgs::-webkit-scrollbar-track { background: transparent; }
#wmSMsgs::-webkit-scrollbar-thumb,
#wmFMsgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   RESPONSIVE — hide FAB on very small nav screens
   ============================================================ */
@media (max-width: 480px) {
  #wm-fab-panel {
    width: calc(100vw - 28px);
    right: 0;
  }
  #wm-fab-wrap {
    right: 14px;
    bottom: 14px;
  }
}
