/* =========================================================
   Chatbot PrestaShop — Widget flottant
   ========================================================= */

:root {
  --cb-primary:    #2563eb;
  --cb-primary-dk: #1d4ed8;
  --cb-bg:         #ffffff;
  --cb-surface:    #f1f5f9;
  --cb-border:     #e2e8f0;
  --cb-text:       #1e293b;
  --cb-muted:      #64748b;
  --cb-bot-bg:     #f1f5f9;
  --cb-user-bg:    #2563eb;
  --cb-user-text:  #ffffff;
  --cb-radius:     16px;
  --cb-shadow:     0 8px 30px rgba(0, 0, 0, 0.12);
  --cb-w:          360px;
  --cb-h:          520px;
}

/* ----- Bouton bulle ----- */
#cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cb-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--cb-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 9999;
}

#cb-toggle:hover {
  background: var(--cb-primary-dk);
  transform: scale(1.05);
}

#cb-toggle svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.15s;
}

#cb-toggle .cb-icon-close {
  display: none;
}

#cb-toggle.cb-open .cb-icon-chat {
  display: none;
}

#cb-toggle.cb-open .cb-icon-close {
  display: block;
}

/* Badge de notification */
#cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  display: none;
}

/* ----- Fenêtre de chat ----- */
#cb-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: var(--cb-w);
  height: var(--cb-h);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#cb-window.cb-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ----- En-tête ----- */
#cb-header {
  background: var(--cb-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#cb-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

#cb-header-info {
  flex: 1;
  min-width: 0;
}

#cb-header-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

#cb-header-status {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

#cb-header-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

/* ----- Zone de messages ----- */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

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

/* Message générique */
.cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: cb-in 0.2s ease;
}

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

.cb-msg.cb-bot {
  align-self: flex-start;
}

.cb-msg.cb-user {
  align-self: flex-end;
}

.cb-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.cb-msg.cb-bot .cb-bubble {
  background: var(--cb-bot-bg);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
}

.cb-msg.cb-user .cb-bubble {
  background: var(--cb-user-bg);
  color: var(--cb-user-text);
  border-bottom-right-radius: 4px;
}

.cb-time {
  font-size: 10px;
  color: var(--cb-muted);
  margin-top: 3px;
  padding: 0 2px;
}

.cb-msg.cb-user .cb-time {
  align-self: flex-end;
}

/* Indicateur de frappe */
#cb-typing {
  display: none;
  align-self: flex-start;
}

#cb-typing .cb-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}

#cb-typing .cb-dot {
  width: 7px;
  height: 7px;
  background: var(--cb-muted);
  border-radius: 50%;
  animation: cb-bounce 1.2s infinite;
}

#cb-typing .cb-dot:nth-child(2) { animation-delay: 0.2s; }
#cb-typing .cb-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ----- Suggestions rapides ----- */
#cb-suggestions {
  padding: 6px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.cb-suggestion {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--cb-primary);
  color: var(--cb-primary);
  background: transparent;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.cb-suggestion:hover {
  background: var(--cb-primary);
  color: #fff;
}

/* ----- Zone de saisie ----- */
#cb-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--cb-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cb-bg);
  flex-shrink: 0;
}

#cb-input {
  flex: 1;
  border: 1px solid var(--cb-border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  color: var(--cb-text);
  background: var(--cb-surface);
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 0.15s;
  font-family: inherit;
}

#cb-input:focus {
  border-color: var(--cb-primary);
  background: #fff;
}

#cb-input::placeholder {
  color: var(--cb-muted);
}

#cb-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--cb-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#cb-send:hover:not(:disabled) {
  background: var(--cb-primary-dk);
}

#cb-send:active:not(:disabled) {
  transform: scale(0.92);
}

#cb-send:disabled {
  background: var(--cb-border);
  cursor: not-allowed;
}

#cb-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* ----- Feedback 👍 / 👎 ----- */
.cb-feedback {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  padding: 0 2px;
}

.cb-fb-btn {
  background: transparent;
  border: 1px solid var(--cb-border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.5;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.cb-fb-btn:hover {
  background: var(--cb-surface);
  transform: scale(1.1);
}

.cb-fb-active-up {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
}

.cb-fb-active-down {
  background: #fee2e2 !important;
  border-color: #dc2626 !important;
}

.cb-fb-comment {
  display: none;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  animation: cb-in 0.2s ease;
}

.cb-fb-textarea {
  width: 100%;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  color: var(--cb-text);
  background: var(--cb-surface);
  transition: border-color 0.15s;
}

.cb-fb-textarea:focus { border-color: var(--cb-primary); }

.cb-fb-send {
  align-self: flex-end;
  background: var(--cb-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.cb-fb-send:hover { background: var(--cb-primary-dk); }

/* ----- Message d'erreur ----- */
.cb-error .cb-bubble {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ----- Responsive mobile ----- */
@media (max-width: 480px) {
  #cb-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  #cb-toggle {
    bottom: 16px;
    right: 16px;
  }
}
