/* SiteChat AI — Frontend Widget — by Ahamad-dev */

#sitechat-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

#sc-launcher,
#sc-window,
#sc-header,
#sc-messages,
#sc-input-area,
#sc-close-btn,
#sc-send,
.sc-avatar,
.sc-msg,
.sc-msg-avatar,
.sc-sources,
.sc-typing,
.sc-branding {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#sc-launcher {
  position: fixed;
  z-index: 999999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sc-primary, #2563EB);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
#sc-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.25); }
#sc-launcher.open  { transform: scale(1); }
#sc-launcher svg   { transition: all .2s; }
#sc-launcher.bottom-right { bottom: 24px; right: 24px; }
#sc-launcher.bottom-left  { bottom: 24px; left: 24px; }

#sc-window {
  position: fixed;
  z-index: 999998;
  width: 360px;
  height: 540px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 64px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all .25s cubic-bezier(.34,1.3,.64,1);
}
#sc-window.open         { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
#sc-window.bottom-right { bottom: 92px; right: 24px; }
#sc-window.bottom-left  { bottom: 92px; left: 24px; }

@media (max-width: 480px) {
  #sc-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 86px;
    right: 12px;
    left: 12px;
    border-radius: 16px;
  }
}

#sc-header {
  background: var(--sc-primary, #2563EB);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sc-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.sc-header-info { flex: 1; }
.sc-bot-name { font-weight: 700; font-size: 14px; color: #fff; line-height: 1.3; }
.sc-online   { font-size: 12px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.sc-online::before { content: ''; width: 6px; height: 6px; background: #4ADE80; border-radius: 50%; flex-shrink: 0; }

#sc-close-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
#sc-close-btn:hover { background: rgba(255,255,255,.25); }

#sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F9FAFB;
  scroll-behavior: smooth;
}
#sc-messages::-webkit-scrollbar       { width: 4px; }
#sc-messages::-webkit-scrollbar-track { background: transparent; }
#sc-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

.sc-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
}
.sc-msg.bot  { align-self: flex-start; }
.sc-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.sc-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sc-primary, #2563EB);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

/* Bubble — padding explicite pour ne pas être écrasé par les thèmes WP */
.sc-bubble {
  display: block;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
  border-radius: 18px;
  font-size: 13.5px !important;
  line-height: 1.6 !important;
  word-break: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}
.sc-msg.bot .sc-bubble {
  background: #ffffff;
  color: #1F2937 !important;
  border: 1px solid #E5E7EB;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.sc-msg.user .sc-bubble {
  background: var(--sc-primary, #2563EB);
  color: #ffffff !important;
  border-bottom-right-radius: 4px;
}

.sc-sources {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-left: 2px;
}
.sc-source-link {
  font-size: 11.5px;
  color: var(--sc-primary, #2563EB);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: .75;
  transition: opacity .15s;
}
.sc-source-link:hover { opacity: 1; text-decoration: underline; }
.sc-source-link::before { content: '↗'; font-size: 10px; }

.sc-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
}
.sc-typing span {
  width: 7px;
  height: 7px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: sc-bounce .9s ease-in-out infinite;
}
.sc-typing span:nth-child(2) { animation-delay: .15s; }
.sc-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes sc-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-7px); }
}

#sc-input-area {
  padding: 10px 12px;
  border-top: 1px solid #E5E7EB;
  background: #ffffff;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#sc-input {
  flex: 1;
  border: 1.5px solid #E5E7EB;
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 110px;
  min-height: 40px;
  line-height: 1.5;
  color: #111827;
  background: #F9FAFB;
  transition: border-color .15s, background .15s;
  overflow-y: auto;
  box-sizing: border-box;
}
#sc-input:focus        { border-color: var(--sc-primary, #2563EB); background: #fff; }
#sc-input::placeholder { color: #9CA3AF; }

#sc-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sc-primary, #2563EB);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform .15s, opacity .15s;
}
#sc-send:hover    { transform: scale(1.08); }
#sc-send:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.sc-branding {
  text-align: center;
  padding: 5px 8px;
  font-size: 10.5px;
  color: #9CA3AF;
  background: #fff;
  border-top: 1px solid #F3F4F6;
}
.sc-branding a { color: #9CA3AF; text-decoration: none; font-weight: 500; }
.sc-branding a:hover { color: #6B7280; }
