/* ============================================================
   SOCOVER Chatbot Widget - Styles v1.2.0
   ============================================================ */

:root {
  --sc-primary:       #1a3d6e;
  --sc-primary-hover: #2a5499;
  --sc-white:         #ffffff;
  --sc-bg-messages:   #f2f5f9;
  --sc-text:          #1e1e1e;
  --sc-text-light:    #6b7280;
  --sc-border:        #dde3ed;
  --sc-shadow:        rgba(26, 61, 110, 0.22);
  --sc-radius-window: 16px;
  --sc-radius-bubble: 18px;
}

/* ------------------------------------------------------------ */
/* Bouton flottant                                               */
/* ------------------------------------------------------------ */

.socover-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  background: var(--sc-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 22px var(--sc-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.socover-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 30px var(--sc-shadow);
}

.socover-chat-launcher:focus-visible {
  outline: 3px solid #6fa3e8;
  outline-offset: 3px;
}

.socover-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: var(--sc-white);
  transition: transform 0.25s ease, opacity 0.2s;
}

.socover-chat-launcher .icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.socover-chat-launcher.is-open .icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.socover-chat-launcher.is-open .icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Pastille de notification */
.socover-chat-launcher .sc-notif {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 13px;
  height: 13px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid white;
  transition: opacity 0.3s;
}

.socover-chat-launcher.is-open .sc-notif,
.socover-chat-launcher.notif-hidden .sc-notif {
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------ */
/* Bulle d'accroche                                             */
/* ------------------------------------------------------------ */

.sc-hook-bubble {
  position: fixed;
  bottom: 100px;
  right: 96px;
  background: var(--sc-white);
  color: var(--sc-text);
  border-radius: 14px 14px 4px 14px;
  padding: 11px 34px 11px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.16);
  max-width: 230px;
  z-index: 99997;
  animation: scFadeIn 0.35s ease;
  transition: opacity 0.25s ease, transform 0.25s ease;
  cursor: pointer;
  font-family: inherit;
}

.sc-hook-bubble.sc-hook-hide {
  opacity: 0;
  transform: scale(0.92) translateY(6px);
  pointer-events: none;
}

.sc-hook-text {
  display: block;
}

.sc-hook-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: none;
  background: #eef0f3;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  padding: 0;
  line-height: 1;
  transition: background 0.15s;
}

.sc-hook-close:hover {
  background: #dde1e7;
}

/* ------------------------------------------------------------ */
/* Fenêtre de chat                                               */
/* ------------------------------------------------------------ */

.socover-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 370px;
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--sc-white);
  border-radius: var(--sc-radius-window);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.20);
  display: flex;
  flex-direction: column;
  z-index: 99998;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.socover-chat-window.sc-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94) translateY(10px);
}

/* Header */
.sc-header {
  background: var(--sc-primary);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

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

.sc-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: white;
}

/* Avatar image configurée */
.sc-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.sc-header-info {
  flex: 1;
  min-width: 0;
}

.sc-header-name {
  color: white;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.sc-header-status {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.sc-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
  animation: scPulse 2.5s infinite;
}

@keyframes scPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Compteur de tours dans le header */
.sc-turns-counter {
  display: none;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 3px 9px;
  flex-shrink: 0;
  font-weight: 600;
  white-space: nowrap;
}

.sc-turns-counter.sc-turns-warn {
  background: rgba(231, 76, 60, 0.5);
  color: #fff;
}

/* Zone de messages */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sc-bg-messages);
  overscroll-behavior: contain;
}

.sc-messages::-webkit-scrollbar         { width: 4px; }
.sc-messages::-webkit-scrollbar-track   { background: transparent; }
.sc-messages::-webkit-scrollbar-thumb   { background: var(--sc-border); border-radius: 4px; }

/* Bulles */
.sc-msg {
  display: flex;
  flex-direction: column;
  max-width: 83%;
  animation: scFadeIn 0.2s ease;
}

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

.sc-msg.assistant { align-self: flex-start; }
.sc-msg.user      { align-self: flex-end; }

.sc-msg-text {
  padding: 10px 14px;
  border-radius: var(--sc-radius-bubble);
  font-size: 13.5px;
  line-height: 1.58;
  word-break: break-word;
}

.sc-msg.assistant .sc-msg-text {
  background: var(--sc-white);
  color: var(--sc-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.07);
}

.sc-msg.user .sc-msg-text {
  background: var(--sc-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.sc-typing-row {
  align-self: flex-start;
  animation: scFadeIn 0.2s ease;
}

.sc-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--sc-white);
  border-radius: var(--sc-radius-bubble);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.07);
}

.sc-typing span {
  width: 7px;
  height: 7px;
  background: var(--sc-primary);
  border-radius: 50%;
  opacity: 0.35;
  animation: scBounce 1.3s infinite ease;
}

.sc-typing span:nth-child(2) { animation-delay: 0.18s; }
.sc-typing span:nth-child(3) { animation-delay: 0.36s; }

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

/* Bandeau confirmation */
.sc-lead-confirmed {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
  color: #065f46;
  text-align: center;
  margin-top: 4px;
  animation: scFadeIn 0.3s ease;
}

/* Zone de saisie */
.sc-input-area {
  padding: 11px 12px;
  border-top: 1px solid var(--sc-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--sc-white);
  flex-shrink: 0;
}

.sc-input {
  flex: 1;
  border: 1.5px solid var(--sc-border);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  color: var(--sc-text);
  background: var(--sc-white);
}

.sc-input:focus          { border-color: var(--sc-primary); }
.sc-input::placeholder   { color: var(--sc-text-light); }
.sc-input:disabled       { background: #f8f9fa; cursor: not-allowed; }

.sc-send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--sc-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  outline: none;
}

.sc-send-btn:hover:not(:disabled) { background: var(--sc-primary-hover); }
.sc-send-btn:active:not(:disabled) { transform: scale(0.93); }
.sc-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.sc-send-btn svg {
  width: 19px;
  height: 19px;
  fill: white;
}

/* ------------------------------------------------------------ */
/* Responsive mobile                                             */
/* ------------------------------------------------------------ */

@media (max-width: 480px) {
  .socover-chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 82px;
    height: 60vh;
    max-height: 480px;
    min-height: 320px;
    border-radius: 14px;
  }

  .socover-chat-launcher {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }

  .sc-hook-bubble {
    right: 12px;
    bottom: 82px;
    max-width: calc(100vw - 30px);
    border-radius: 14px 14px 4px 14px;
  }
}
