/* =========================================
   Chat Widget – Atlantic Rénovation 29
   Design compact & moderne
   ========================================= */

/* --- Bouton flottant --- */
.chat-widget-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 54px;
  height: 54px;
  background: #1a4fa0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(26,79,160,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  z-index: 1000;
  transition: transform .25s, box-shadow .25s;
}
.chat-widget-button:hover { transform: scale(1.08); box-shadow: 0 8px 24px rgba(26,79,160,.65); }
.chat-widget-button.open  { transform: rotate(45deg); }

.chat-widget-button::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(26,79,160,.3);
  animation: cw-ring 2.2s ease-out infinite;
}
.chat-widget-button.open::before { display: none; }

@keyframes cw-ring {
  0%   { transform: scale(1); opacity: .9; }
  70%  { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* --- Fenêtre --- */
.chat-widget-container {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 340px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px) scale(.95);
  pointer-events: none;
  transition: opacity .28s, transform .28s cubic-bezier(.34,1.3,.64,1);
  z-index: 999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
}
.chat-widget-container.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header --- */
.chat-header {
  background: #1a4fa0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status {
  color: rgba(255,255,255,.8);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}
.chat-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  animation: cw-blink 1.8s ease-in-out infinite;
}
@keyframes cw-blink { 0%,100%{opacity:1} 50%{opacity:.35} }

.chat-close {
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.chat-close:hover { background: rgba(255,255,255,.25); }

/* --- Barre de progression --- */
.chat-progress-bar { height: 2px; background: #e5e7eb; flex-shrink: 0; }
.chat-progress-fill { height: 100%; background: #1a4fa0; transition: width .35s ease; }

/* --- Zone messages --- */
.chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: #ddd #f8f9fb;
}

/* --- Bulles --- */
.chat-message {
  max-width: 80%;
  padding: 8px 11px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  animation: cw-pop .22s ease;
  word-break: break-word;
}
@keyframes cw-pop {
  from { opacity:0; transform: scale(.9) translateY(6px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}
.chat-message.bot {
  background: #fff;
  color: #1e293b;
  border-radius: 3px 14px 14px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.09);
  align-self: flex-start;
  white-space: pre-line;
}
.chat-message.user {
  background: #1a4fa0;
  color: #fff;
  border-radius: 14px 14px 3px 14px;
  align-self: flex-end;
  box-shadow: 0 2px 8px rgba(26,79,160,.3);
}

/* --- Typing indicator --- */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: #fff;
  border-radius: 3px 14px 14px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.09);
  align-self: flex-start;
  width: fit-content;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: cw-dot 1.1s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cw-dot {
  0%,80%,100% { transform:scale(1); opacity:.45; }
  40%          { transform:scale(1.25); opacity:1; }
}

/* --- Zone de saisie --- */
.chat-form {
  padding: 10px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  gap: 7px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: 8px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 12.5px;
  font-family: inherit;
  resize: none;
  min-height: 36px;
  max-height: 90px;
  background: #f8f9fb;
  color: #1e293b;
  line-height: 1.45;
  transition: border-color .2s;
  outline: none;
}
.chat-input:focus { border-color: #1a4fa0; background: #fff; }
.chat-input-file { display: none; }

.chat-send-btn {
  width: 36px;
  height: 36px;
  background: #1a4fa0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s, background .2s;
}
.chat-send-btn:hover { background: #123880; transform: scale(1.08); }
.chat-send-btn:disabled { opacity: .35; cursor: default; transform: none; }

/* --- Boutons choix --- */
.chat-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-btn {
  padding: 5px 11px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: #334155;
  transition: border-color .18s, background .18s, transform .18s;
  white-space: nowrap;
}
.chat-btn:hover {
  border-color: #1a4fa0;
  background: #eff5ff;
  color: #1a4fa0;
  transform: translateY(-1px);
}
.chat-btn.upload { border-color: #1a4fa0; color: #1a4fa0; }
.chat-btn.upload:hover { background: #fff5ec; }
.chat-btn.skip  { border-color: #cbd5e1; color: #64748b; }
.chat-btn.confirm-photos { background: #1a4fa0 !important; color: #fff !important; border-color: #1a4fa0 !important; }
.chat-btn.hint-chip.active { background: #eff5ff; border-color: #1a4fa0; color: #1a4fa0; }

/* --- Fichiers --- */
.chat-file-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-file-item {
  background: #fff8f3;
  border: 1px solid #fcd9b6;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #92400e;
}
.chat-file-remove {
  background: none;
  border: none;
  color: #1a4fa0;
  cursor: pointer;
  font-size: .9rem;
  padding: 0;
  line-height: 1;
}

/* --- Mobile --- */
@media (max-width: 420px) {
  .chat-widget-container {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 84px;
    height: calc(100dvh - 100px);
    max-height: 520px;
    border-radius: 14px;
  }
  .chat-widget-button { bottom: 16px; right: 16px; width: 48px; height: 48px; font-size: 1.2rem; }
}
