/* INRAPE Chatbot — fenêtre à gauche du bouton, bas alignés */
.inrape-chat-root {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  right: 12px !important;
  bottom: 12px !important;
  z-index: 10050;
  width: auto;
  max-width: calc(100vw - 24px);
  height: auto;
  max-height: calc(100dvh - 24px);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  box-sizing: border-box;
  overflow: visible;
  pointer-events: none;
}

.inrape-chat-toggle {
  position: relative;
  z-index: 2;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: none;
  border-radius: 50%;
  background: #1b6b3a;
  color: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  padding: 0;
  overflow: visible;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.inrape-chat-toggle:hover {
  background: #14532d;
  transform: scale(1.06);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.34);
}

.inrape-chat-toggle-icon {
  display: block;
  flex-shrink: 0;
}

.inrape-chat-toggle-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.inrape-chat-panel {
  position: relative;
  z-index: 1;
  width: min(380px, calc(100vw - 24px - 56px - 10px));
  height: min(520px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  pointer-events: auto;
  transform-origin: bottom right;
  box-sizing: border-box;
}

.inrape-chat-panel[hidden] {
  display: none !important;
}

.inrape-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(135deg, #1b6b3a 0%, #14532d 100%);
  color: #fff;
  flex-shrink: 0;
}

.inrape-chat-identity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.inrape-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.inrape-chat-identity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.inrape-chat-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.inrape-chat-identity-text strong {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inrape-chat-call-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.inrape-chat-call-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.7);
}

.inrape-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  opacity: 0.92;
}

.inrape-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.25);
}

.inrape-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.inrape-chat-lang select {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  line-height: 1.2;
}

.inrape-chat-lang select option {
  color: #111827;
  background: #fff;
}

.inrape-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inrape-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.inrape-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.inrape-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: 100%;
}

.inrape-chat-row--bot {
  align-self: stretch;
}

.inrape-chat-row--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.inrape-chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid #d1d5db;
  flex-shrink: 0;
}

.inrape-chat-bubble {
  max-width: calc(100% - 34px);
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.inrape-chat-bubble--bot {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 4px;
}

.inrape-chat-bubble--rich {
  white-space: normal;
}

.inrape-chat-bubble--rich p {
  margin: 0 0 0.5rem;
}

.inrape-chat-bubble--rich p:last-child,
.inrape-chat-bubble--rich ul:last-child,
.inrape-chat-bubble--rich ol:last-child {
  margin-bottom: 0;
}

.inrape-chat-bubble--rich ul,
.inrape-chat-bubble--rich ol {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
}

.inrape-chat-bubble--rich li {
  margin-bottom: 0.2rem;
}

.inrape-chat-bubble--rich a {
  color: #1b6b3a;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-word;
}

.inrape-chat-bubble--user {
  background: #1b6b3a;
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 88%;
}

.inrape-chat-bubble--thinking {
  padding: 0.75rem 1rem;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.inrape-chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #166534;
}

.inrape-chat-brain {
  flex-shrink: 0;
  color: #1b6b3a;
  animation: inrape-brain-pulse 1.4s ease-in-out infinite;
}

.inrape-chat-brain-left {
  transform-origin: 12px 12px;
  animation: inrape-brain-wiggle 1.8s ease-in-out infinite;
}

.inrape-chat-brain-right {
  opacity: 0.85;
}

.inrape-chat-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  height: 1rem;
}

.inrape-chat-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #1b6b3a;
  opacity: 0.35;
  animation: inrape-dot-bounce 1.2s ease-in-out infinite;
}

.inrape-chat-thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.inrape-chat-thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes inrape-brain-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes inrape-brain-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}

@keyframes inrape-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.inrape-chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.inrape-chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  background: #f9fafb;
}

.inrape-chat-form input:focus {
  outline: none;
  border-color: #86efac;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(27, 107, 58, 0.12);
}

.inrape-chat-form button {
  border: none;
  border-radius: 10px;
  background: #1b6b3a;
  color: #fff;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.inrape-chat-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Scroll-to-top centré en bas de page */
.scroll-top {
  left: 50% !important;
  right: auto !important;
  bottom: 24px !important;
  z-index: 10040 !important;
  transform: translateX(-50%) translateY(16px) !important;
}

.scroll-top.visible {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(-50%) translateY(0) !important;
}

.scroll-top:hover {
  background: var(--green-800, #14532d) !important;
  transform: translateX(-50%) translateY(-3px) !important;
}

html[dir="rtl"] .inrape-chat-root {
  right: auto !important;
  left: 12px !important;
  flex-direction: row-reverse;
}

html[dir="rtl"] .inrape-chat-panel {
  transform-origin: bottom left;
}

html[dir="rtl"] .inrape-chat-bubble--bot {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 4px;
}

html[dir="rtl"] .inrape-chat-bubble--user {
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 4px;
}

@media (max-width: 480px) {
  .inrape-chat-root {
    right: 8px !important;
    bottom: 8px !important;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .inrape-chat-panel {
    width: min(380px, calc(100vw - 16px - 56px - 8px));
    height: min(70dvh, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
  }

  html[dir="rtl"] .inrape-chat-root {
    left: 8px !important;
  }
}

/* ── Appel audio WebRTC ─────────────────────────── */
.inrape-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.inrape-call-overlay[hidden] {
  display: none !important;
}
.inrape-call-card {
  width: min(320px, 100%);
  background: #0f3d24;
  color: #fff;
  border-radius: 20px;
  padding: 1.75rem 1.4rem 1.4rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}
.inrape-call-pulse {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(134, 239, 172, 0.2);
  border: 2px solid rgba(134, 239, 172, 0.7);
  animation: inrape-call-pulse 1.4s ease-out infinite;
}
@keyframes inrape-call-pulse {
  0% { transform: scale(0.92); opacity: 1; }
  70% { transform: scale(1.12); opacity: 0.45; }
  100% { transform: scale(0.92); opacity: 1; }
}
.inrape-call-label {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}
.inrape-call-status {
  margin: 0.45rem 0 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.inrape-call-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}
.inrape-call-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.inrape-call-btn--muted {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.inrape-call-btn--hang {
  background: #dc2626;
  color: #fff;
}
.inrape-chat-call-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
