/* Emma — site assistant */

.ede-emma-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ede-emma[hidden],
.ede-emma-teaser[hidden] { display: none; }

/* ---------- Launcher ---------- */

.ede-emma-launcher {
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  background: var(--accent);
  color: var(--white);
}
.ede-emma-launcher img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ede-emma-launcher-close {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--navy-900);
  opacity: 0;
  transform: rotate(-90deg);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ede-emma-launcher[aria-expanded="true"] img { opacity: 0; transform: scale(0.8); }
.ede-emma-launcher[aria-expanded="true"] .ede-emma-launcher-close { opacity: 1; transform: none; }
.ede-emma-launcher[aria-expanded="true"] .ede-emma-online,
.ede-emma-launcher[aria-expanded="true"] .ede-float-tip { display: none; }
.ede-emma-launcher:focus-visible { outline: 3px solid var(--accent-light); outline-offset: 3px; }

.ede-emma-online {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #2fbf71;
  border: 2.5px solid var(--white);
}

/* ---------- Teaser ---------- */

.ede-emma-teaser {
  position: absolute;
  right: 74px;
  bottom: 4px;
  width: 248px;
  display: flex;
  align-items: flex-start;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 16px 40px rgba(12, 16, 32, 0.18);
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ede-emma-teaser.is-visible { opacity: 1; transform: none; }
.ede-emma-teaser-body {
  flex: 1;
  text-align: left;
  border: 0;
  background: none;
  padding: 14px 4px 14px 16px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
.ede-emma-teaser-body strong {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  margin-bottom: 2px;
}
.ede-emma-teaser-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 6px 6px 0 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
}
.ede-emma-teaser-close:hover { background: var(--paper); color: var(--ink); }

/* ---------- Panel ---------- */

.ede-emma {
  position: fixed;
  right: 20px;
  bottom: 100px;
  z-index: 60;
  width: 392px;
  height: min(640px, calc(100vh - 128px));
  height: min(640px, calc(100dvh - 128px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(12, 16, 32, 0.28);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ede-emma.is-open { opacity: 1; transform: none; }

body.ede-assistant-open .ede-float-btn--phone,
body.ede-assistant-open .ede-float-btn--mail { display: none; }

.ede-emma-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: var(--white);
}
.ede-emma-head-avatar { position: relative; flex: none; }
.ede-emma-head-avatar img { width: 42px; height: 42px; border-radius: 50%; }
.ede-emma-head-avatar .ede-emma-online { right: -1px; bottom: -1px; width: 12px; height: 12px; border-color: var(--navy-900); }
.ede-emma-head-text { flex: 1; min-width: 0; }
.ede-emma-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--white);
}
.ede-emma-head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.72);
}
.ede-emma-icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  transition: background 0.15s ease, color 0.15s ease;
}
.ede-emma-icon-btn:hover,
.ede-emma-icon-btn:focus-visible { background: rgba(255, 255, 255, 0.12); color: var(--white); outline: none; }

/* ---------- Messages ---------- */

.ede-emma-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.ede-emma-msg { display: flex; gap: 8px; max-width: 100%; }
.ede-emma-msg.is-new { animation: ede-emma-in 0.22s ease both; }
.ede-emma-msg--user { justify-content: flex-end; }
.ede-emma-msg-avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; margin-top: 2px; }
.ede-emma-msg-body { min-width: 0; max-width: calc(100% - 36px); display: grid; gap: 8px; justify-items: start; }

.ede-emma-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.ede-emma-msg--bot .ede-emma-bubble {
  background: var(--white);
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
  color: var(--ink);
}
.ede-emma-msg--user .ede-emma-bubble {
  max-width: 82%;
  background: var(--accent);
  color: var(--white);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
}
.ede-emma-bubble--error { border-color: rgba(179, 45, 46, 0.25) !important; background: #fff8f8 !important; }
.ede-emma-bubble p { margin: 0; }
.ede-emma-bubble p + p,
.ede-emma-bubble p + ul,
.ede-emma-bubble p + ol,
.ede-emma-bubble ul + p,
.ede-emma-bubble ol + p { margin-top: 8px; }
.ede-emma-bubble ul,
.ede-emma-bubble ol { margin: 0; padding-left: 20px; }
.ede-emma-bubble li + li { margin-top: 4px; }
.ede-emma-bubble a { color: var(--accent); font-weight: 600; text-underline-offset: 2px; }
.ede-emma-bubble strong { font-weight: 600; }

.ede-emma-retry {
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.ede-emma-retry:hover { border-color: var(--accent); color: var(--accent); }

.ede-emma-typing { display: inline-flex; align-items: center; gap: 4px; padding: 14px 16px; }
.ede-emma-typing span:not(.ede-emma-sr) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-light);
  animation: ede-emma-dot 1.1s infinite ease-in-out;
}
.ede-emma-typing span:nth-child(2) { animation-delay: 0.15s; }
.ede-emma-typing span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- Suggestions ---------- */

.ede-emma-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 36px;
  animation: ede-emma-in 0.3s ease 0.1s both;
}
.ede-emma-chip {
  border: 1px solid rgba(75, 89, 156, 0.35);
  background: var(--white);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ede-emma-chip:hover,
.ede-emma-chip:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--white); outline: none; }
.ede-emma-chip--primary { background: var(--navy-900); border-color: var(--navy-900); color: var(--white); font-weight: 600; }

/* ---------- Inline cards ---------- */

.ede-emma-card {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(12, 16, 32, 0.06);
}
.ede-emma-card-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.ede-emma-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ede-emma-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.ede-emma-wide { grid-column: 1 / -1; }
.ede-emma-grid input,
.ede-emma-grid select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}
.ede-emma-grid input:focus,
.ede-emma-grid select:focus { outline: none; border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px var(--glow); }
.ede-emma-hp { position: absolute; left: -9999px; }
.ede-emma-form-error { margin: 10px 0 0; font-size: 13px; color: #b32d2e; }
.ede-emma-submit {
  width: 100%;
  margin-top: 12px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--navy-900);
  color: var(--white);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}
.ede-emma-submit:hover { background: var(--accent); }
.ede-emma-submit:disabled { opacity: 0.6; cursor: progress; }
.ede-emma-card-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

.ede-emma-card--sent { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: var(--ink); }
.ede-emma-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e3f6ec;
  color: #1e8a52;
}

/* ---------- Composer ---------- */

.ede-emma-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  background: var(--white);
  border-top: 1px solid var(--line);
}
.ede-emma-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 132px;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: var(--paper);
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}
.ede-emma-composer textarea:focus { outline: none; border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px var(--glow); }
.ede-emma-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}
.ede-emma-send:hover:not(:disabled) { background: var(--navy-900); transform: translateX(1px); }
.ede-emma-send:disabled { opacity: 0.35; cursor: default; }
.ede-emma-foot {
  flex: none;
  margin: 0;
  padding: 0 14px 10px;
  background: var(--white);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}
.ede-emma-foot a { color: var(--ink); font-weight: 600; }

/* ---------- Motion ---------- */

@keyframes ede-emma-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes ede-emma-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ede-emma,
  .ede-emma-teaser,
  .ede-emma-launcher img,
  .ede-emma-launcher-close { transition: none; }
  .ede-emma-msg.is-new,
  .ede-emma-chips { animation: none; }
  .ede-emma-typing span:not(.ede-emma-sr) { animation-duration: 2.4s; }
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .ede-emma { right: 12px; bottom: 160px; height: min(600px, calc(100dvh - 180px)); }
  .ede-emma-teaser { right: 70px; }
  body.ede-assistant-open .ede-mobile-cta { display: none; }
}

@media (max-width: 640px) {
  .ede-emma {
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    transform: translateY(24px);
    transform-origin: bottom center;
  }
  .ede-emma-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .ede-emma-foot { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .ede-emma-composer textarea { font-size: 16px; }
  .ede-emma-teaser { width: min(248px, calc(100vw - 100px)); }
  body.ede-assistant-open { overflow: hidden; }
  body.ede-assistant-open .ede-float { display: none; }
}
