/* ============================================================
   Demseuls Chat Widget – Frontend
   ============================================================ */

#dsc-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Toggle button ---- */
#dsc-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #005ca8;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .15s;
}

#dsc-toggle:hover {
  background: #0073d1;
  transform: scale(1.05);
}

/* Badge "message non lu" */
.dsc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e53935;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  pointer-events: none;
  animation: dsc-badge-pulse 1.6s ease-in-out infinite;
}

#dsc-toggle { position: relative; }

@keyframes dsc-badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ---- Chat window ---- */
#dsc-window {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  max-height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Header ---- */
#dsc-header {
  background: #005ca8;
  color: #fff;
  padding: 14px 16px;
}

.dsc-header-title {
  font-size: 15px;
  font-weight: 700;
}

.dsc-header-sub {
  font-size: 12px;
  opacity: .85;
  margin-top: 2px;
}

/* ---- Messages ---- */
#dsc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8fb;
}

.dsc-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.dsc-msg--user {
  background: #005ca8;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.dsc-msg--bot {
  background: #fff;
  color: #222;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Typing indicator */
.dsc-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}

.dsc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: dsc-bounce .9s infinite;
}

.dsc-typing span:nth-child(2) { animation-delay: .15s; }
.dsc-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes dsc-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* Lead notice */
.dsc-lead-notice {
  background: #e6f4ea;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  text-align: center;
}

/* ---- Input area ---- */
#dsc-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #e8eaf0;
  background: #fff;
  gap: 8px;
}

#dsc-input {
  flex: 1;
  border: 1px solid #dde0e8;
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

#dsc-input:focus { border-color: #005ca8; }

#dsc-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #005ca8;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}

#dsc-send:hover     { background: #0073d1; }
#dsc-send:disabled  { background: #aaa; cursor: not-allowed; }

/* ---- Responsive ---- */
/* Sous 992px, l'icône tarteaucitron BottomRight est masquée
   (cf. demecoV2/scss/templates/tac.scss) → on remet le widget en bas. */
@media (max-width: 992px) {
  #dsc-widget { bottom: 24px; }
}

@media (max-width: 480px) {
  #dsc-window {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 68px;
  }
  #dsc-widget { right: 16px; bottom: 16px; }
}
