/*
 * SARA widget — Europpharm / style Apple soft premium
 * Palette existante :
 * primaire #0057d9, marine #0b1f3a, gris #5d6675, fond clair #f4f8fd
 * Police : pile système (latin / arabe / cyrillique / arménien / géorgien)
 */

 .sara-root {
  --sara-primary: #0057d9;
  --sara-primary-dark: #0046ad;
  --sara-primary-glow: rgba(0, 87, 217, 0.22);

  --sara-navy: #0b1f3a;
  --sara-gray: #5d6675;

  --sara-bg: #eef3f9;
  --sara-bg-alt: #f7f9fc;

  --sara-white: rgba(255, 255, 255, 0.72);
  --sara-glass: rgba(255, 255, 255, 0.58);
  --sara-glass-strong: rgba(255, 255, 255, 0.78);
  --sara-border: rgba(255, 255, 255, 0.55);

  --sara-radius: 28px;
  --sara-radius-sm: 18px;

  --sara-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-medium: 0 18px 50px rgba(15, 23, 42, 0.16);
  --shadow-large: 0 30px 90px rgba(15, 23, 42, 0.20);

  --ring-soft: 0 0 0 4px rgba(0, 87, 217, 0.12);

  position: fixed;
  z-index: 999999;
  right: 20px;
  bottom: 20px;
  font-family: var(--sara-font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--sara-navy);
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  forced-color-adjust: none; /* empeche un mode "contraste eleve" du systeme/navigateur de recolorer les bordures */
}

.sara-root[dir="rtl"] {
  right: auto;
  left: 20px;
}

.sara-root *,
.sara-root *::before,
.sara-root *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- */
/* Launcher                                                         */
/* ---------------------------------------------------------------- */
.sara-launcher {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.42) !important;
  background:
    linear-gradient(180deg, #2f8cff 0%, #0057d9 100%) !important;
  color: var(--sara-white) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(0, 87, 217, 0.24),
    0 18px 40px rgba(15, 23, 42, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  overflow: visible;
}

.sara-launcher::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.30), transparent 42%);
  pointer-events: none;
}

.sara-launcher:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow:
    0 14px 30px rgba(0, 87, 217, 0.30),
    0 30px 70px rgba(15, 23, 42, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.30);
  filter: saturate(1.05);
}

.sara-launcher:active {
  transform: translateY(-1px) scale(1.01);
}

.sara-launcher:focus-visible {
  outline: none;
  box-shadow:
    0 14px 30px rgba(0, 87, 217, 0.30),
    0 30px 70px rgba(15, 23, 42, 0.22),
    var(--ring-soft);
}

.sara-launcher-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(0, 87, 217, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.10) inset;
  opacity: 0.55;
  animation: sara-pulse 2.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes sara-pulse {
  0% {
    transform: scale(0.88);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.42);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sara-launcher-ring {
    animation: none;
    display: none;
  }
  .sara-launcher,
  .sara-panel,
  .sara-chip,
  .sara-link-chip,
  .sara-send,
  .sara-close,
  .sara-input {
    transition: none !important;
  }
}

.sara-panel-visible .sara-launcher-icon {
  transform: rotate(0deg);
}

/* Bulle d'invitation ("Parler à une assistante") a cote du launcher.
   Meme habillage glass que le reste du widget ; masquee/retiree du flux
   tant qu'elle n'est pas activee par le JS (voir showLauncherLabel). */
.sara-launcher-label {
  position: absolute;
  right: 78px;
  bottom: 13px;
  max-width: 220px;
  display: flex;
  align-items: center;
  text-align: left;
  border: none !important;
  outline: none !important;
  border-radius: 999px;
  padding: 11px 16px;
  color: var(--sara-navy) !important;
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-medium);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sara-launcher-label-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sara-launcher-label:hover {
  background: rgba(255, 255, 255, 0.94);
}

.sara-launcher-label:focus-visible {
  outline: none !important;
  box-shadow: var(--shadow-medium), var(--ring-soft);
}

.sara-launcher-label-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-inline-start: 2px;
  background: currentColor;
  opacity: 0.4;
  vertical-align: text-bottom;
  animation: sara-caret-blink 0.9s step-end infinite;
}

@keyframes sara-caret-blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0; }
}

.sara-root[dir="rtl"] .sara-launcher-label {
  right: auto;
  left: 78px;
  text-align: right;
}

@media (max-width: 480px) {
  .sara-launcher-label {
    max-width: 62vw;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sara-launcher-label {
    transition: none;
  }
  .sara-launcher-label-text::after {
    animation: none;
  }
}

/* ---------------------------------------------------------------- */
/* Panel                                                            */
/* ---------------------------------------------------------------- */
.sara-panel {
  position: absolute;
  bottom: 82px;
  right: 0;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.64)) !important;
  color: var(--sara-navy) !important;
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: var(--sara-radius);
  border: 1px solid rgba(255, 255, 255, 0.58) !important;
  box-shadow:
    0 20px 80px rgba(15, 23, 42, 0.18),
    0 3px 12px rgba(255, 255, 255, 0.45) inset !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(35px) scale(0.92);
  filter: blur(6px);
  pointer-events: none;
  transition:
    opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.sara-root[dir="rtl"] .sara-panel {
  right: auto;
  left: 0;
}

.sara-panel.sara-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

.sara-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(0, 87, 217, 0.08), transparent 35%),
    radial-gradient(circle at bottom right, rgba(0, 87, 217, 0.05), transparent 30%);
}

@media (max-width: 480px) {
  .sara-panel {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 78vh;
    max-height: 78vh;
    border-radius: 28px 28px 0 0;
  }
}

/* ---------------------------------------------------------------- */
/* Header                                                           */
/* ---------------------------------------------------------------- */
.sara-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  color: var(--sara-white) !important;
  background:
    linear-gradient(180deg, rgba(11, 31, 58, 0.98), rgba(11, 31, 58, 0.92)) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14) !important;
}

.sara-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent);
}

.sara-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, #2f8cff 0%, #0057d9 100%) !important;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow:
    0 8px 18px rgba(0, 87, 217, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
  z-index: 1;
}

.sara-header-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  position: relative;
  z-index: 1;
}

.sara-header-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15px;
  color: inherit !important;
}

.sara-close {
  position: relative;
  z-index: 1;
  background: none;
  border: none !important;
  outline: none !important;
  color: var(--sara-white);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 8px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sara-close:hover {
  background: rgba(255, 255, 255, 0.10);
  transform: scale(1.03);
}

.sara-close:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

/* ---------------------------------------------------------------- */
/* Messages                                                         */
/* ---------------------------------------------------------------- */
.sara-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(circle at top, rgba(0, 87, 217, 0.05), transparent 40%),
    linear-gradient(180deg, var(--sara-bg-alt), #eef3f8) !important;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.sara-messages::-webkit-scrollbar {
  width: 8px;
}

.sara-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 20px;
}

.sara-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sara-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.48;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sara-bubble-bot {
  align-self: flex-start;
  color: var(--sara-navy) !important;
  background: rgba(255, 255, 255, 0.76) !important;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.65) inset;
  border-bottom-left-radius: 6px;
}

.sara-bubble-user {
  align-self: flex-end;
  color: #ffffff !important;
  background:
    linear-gradient(180deg, #2f8cff 0%, #0057d9 100%) !important;
  box-shadow:
    0 10px 24px rgba(0, 87, 217, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.16) inset;
  border-bottom-right-radius: 6px;
}

[dir="rtl"] .sara-bubble-bot {
  border-bottom-left-radius: 22px;
  border-bottom-right-radius: 6px;
}

[dir="rtl"] .sara-bubble-user {
  border-bottom-right-radius: 22px;
  border-bottom-left-radius: 6px;
}

/* ---------------------------------------------------------------- */
/* Quick replies                                                    */
/* ---------------------------------------------------------------- */
.sara-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}

.sara-chip {
  border: none !important;
  outline: none !important;
  color: var(--sara-navy) !important;
  background: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow:
    0 6px 14px rgba(15, 23, 42, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.7) inset;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.25s ease,
    color 0.25s ease;
}

.sara-chip:hover {
  transform: translateY(-2px);
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.sara-chip:focus-visible {
  outline: none !important;
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.72) inset,
    var(--ring-soft);
}

.sara-chip:hover {
  background: rgba(255, 255, 255, 0.92);
}

/* ---------------------------------------------------------------- */
/* Link chip                                                        */
/* ---------------------------------------------------------------- */
/* Pilule de lien cliquable : même logique que .sara-chip, mais pleine
   pour distinguer une action de navigation d'une simple suggestion. */
.sara-link-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 90%;
  text-decoration: none;
  border: none !important;
  outline: none !important;
  color: #ffffff !important;
  background:
    linear-gradient(180deg, #2f8cff 0%, #0057d9 100%) !important;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow:
    0 10px 22px rgba(0, 87, 217, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.2s ease,
    box-shadow 0.25s ease;
}

.sara-link-chip:hover {
  background:
    linear-gradient(180deg, #267df6 0%, #004fbf 100%);
  transform: translateY(-2px);
  box-shadow:
    0 14px 28px rgba(0, 87, 217, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.sara-link-chip:focus-visible {
  outline: none !important;
  box-shadow:
    0 14px 28px rgba(0, 87, 217, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    var(--ring-soft);
}

.sara-link-chip svg {
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- */
/* Typing                                                           */
/* ---------------------------------------------------------------- */
.sara-typing-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  background: transparent;
  color: var(--sara-gray);
  font-size: 12.5px;
  position: relative;
  z-index: 1;
}

.sara-typing-wrap.sara-hidden {
  display: none;
}

.sara-typing {
  display: flex;
  gap: 3px;
}

.sara-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sara-gray);
  animation: sara-bounce 1.2s infinite ease-in-out;
}

.sara-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.sara-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sara-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sara-typing span {
    animation: none;
    opacity: 0.8;
  }
}

/* ---------------------------------------------------------------- */
/* Input row                                                        */
/* ---------------------------------------------------------------- */
.sara-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(11, 31, 58, 0.08) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.74)) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  position: relative;
  z-index: 1;
}

.sara-input {
  flex: 1;
  resize: none;
  border: none !important;
  outline: none !important;
  border-radius: 18px;
  padding: 13px 14px;
  font-family: var(--sara-font);
  font-size: 14px;
  max-height: 96px;
  color: var(--sara-navy) !important;
  background:
    rgba(255, 255, 255, 0.74) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.78),
    0 5px 16px rgba(15, 23, 42, 0.06);
  transition:
    box-shadow 0.25s ease,
    background 0.25s ease,
    transform 0.25s ease;
}

.sara-input::placeholder {
  color: rgba(93, 102, 117, 0.72);
}

.sara-input:focus,
.sara-input:focus-visible {
  outline: none !important;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 4px rgba(0, 87, 217, 0.12),
    0 10px 25px rgba(0, 87, 217, 0.10),
    inset 0 1px 2px rgba(255, 255, 255, 0.78);
}

.sara-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none !important;
  outline: none !important;
  background:
    linear-gradient(180deg, #2f8cff 0%, #0057d9 100%) !important;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(0, 87, 217, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.20) inset;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.2s ease;
}

.sara-send:hover {
  transform: scale(1.08);
  box-shadow:
    0 12px 24px rgba(0, 87, 217, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.20) inset;
}

.sara-send:active {
  transform: scale(1.03);
}

.sara-send:focus-visible {
  outline: none;
  box-shadow:
    0 12px 24px rgba(0, 87, 217, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.20) inset,
    var(--ring-soft);
}

[dir="rtl"] .sara-send svg {
  transform: scaleX(-1);
}

/* ---------------------------------------------------------------- */
/* Utilities                                                        */
/* ---------------------------------------------------------------- */
.sara-hidden {
  display: none !important;
}

/* Better selection */
.sara-root ::selection {
  background: rgba(0, 87, 217, 0.18);
  color: var(--sara-navy);
}

/* Gentle fade-in helper if needed */
@keyframes sara-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.sara-fade-up {
  animation: sara-fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}