/* Live handoff – Aminos-liknande panel (alternativ B) */

:root {
  --ped-chat-agent-bg: #eceff3;
  --ped-chat-agent-fg: #1a1f2e;
  --ped-chat-visitor-bg: #3a8fa8;
  --ped-chat-visitor-fg: #ffffff;
}

/* Dölj Aminos så bara Pedesign-live syns (väntar eller live). */
body.ped-handoff-suppress-aminos iframe[src*="aminos"],
body.ped-handoff-suppress-aminos iframe[src*="ai.pedesign"],
body.ped-handoff-suppress-aminos iframe[src*="pedesign.se/w/"],
body.ped-handoff-suppress-aminos [id*="simplebot"],
body.ped-handoff-suppress-aminos [id*="aminos"],
body.ped-handoff-suppress-aminos [class*="chat-widget"],
body.ped-handoff-suppress-aminos [class*="ChatWidget"],
body.ped-handoff-suppress-aminos [class*="aminos"],
body.ped-handoff-suppress-aminos [class*="simplebot"],
body.ped-handoff-suppress-aminos #widget-chat-host {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

body.ped-handoff-suppress-aminos [data-ped-aminos-host="1"] {
  display: none !important;
  pointer-events: none !important;
}

.ped-handoff {
  position: fixed;
  z-index: 2147483646;
  right: 20px;
  bottom: 20px;
  width: min(400px, calc(100vw - 32px));
  font-family: var(--font-text, system-ui, -apple-system, sans-serif);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.ped-handoff:not(.ped-handoff--collapsed) .ped-handoff__launcher,
.ped-handoff:not(.ped-handoff--collapsed) .ped-handoff__launcher[hidden],
.ped-handoff--peek .ped-handoff__launcher {
  display: none !important;
}

.ped-handoff--peek .ped-handoff__panel {
  display: none;
}

.ped-handoff--hidden {
  display: none;
}

.ped-handoff--collapsed .ped-handoff__panel {
  display: none;
}

.ped-handoff__launcher {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0b1020;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 32px -8px rgba(11, 16, 32, 0.35);
  border: 1px solid #e2e8f0;
}

.ped-handoff__launcher--ping {
  animation: ped-launcher-ping 0.6s ease-out 2;
}

@keyframes ped-launcher-ping {
  0% { box-shadow: 0 0 0 0 rgba(24, 119, 171, 0.45); }
  100% { box-shadow: 0 0 0 12px rgba(24, 119, 171, 0); }
}

.ped-handoff__launcher-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
}

.ped-handoff__peek {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: min(340px, calc(100vw - 32px));
}

.ped-handoff__peek-hit {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.ped-handoff__peek-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  background: #fff;
  border: 1px solid #e2ebf2;
  box-shadow: 0 12px 32px -10px rgba(11, 16, 32, 0.35);
}

.ped-handoff__peek-who {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #3d4659;
  margin-bottom: 4px;
}

.ped-handoff__peek-text {
  display: block;
  font-size: 0.9rem;
  line-height: 1.4;
  color: #141a24;
  word-break: break-word;
}

.ped-handoff__peek-text--typing {
  font-style: italic;
  color: #2d3d4a;
}

.ped-handoff__peek-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1877ab;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px -6px rgba(24, 119, 171, 0.55);
  border: 2px solid #fff;
}

.ped-handoff__peek--ping {
  animation: ped-launcher-ping 0.6s ease-out 2;
}

.ped-handoff__panel {
  display: flex;
  flex-direction: column;
  height: min(580px, calc(100vh - 40px));
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  color: #1a1f2e;
  box-shadow: 0 20px 50px -18px rgba(11, 16, 32, 0.4);
  border: 1px solid #e8edf5;
}

.ped-handoff__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f4f9fc 0%, #eef6fa 100%);
  border-bottom: 1px solid #e2ebf2;
  flex-shrink: 0;
}

.ped-handoff__head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ped-handoff__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1877ab;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.ped-handoff__peek-avatar {
  overflow: hidden;
}

.ped-handoff__avatar--logo {
  background: #fff;
}

.ped-handoff-available {
  position: fixed;
  z-index: 2147483645;
  right: 68px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  border: 0;
  pointer-events: none;
}

.ped-handoff-available[hidden] {
  display: none !important;
}

body.ped-handoff-suppress-aminos .ped-handoff-available {
  display: none !important;
}

.ped-handoff-available__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: none;
}

.ped-handoff__avatar img,
.ped-handoff__peek-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.ped-handoff__head-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ped-handoff__online-dot {
  display: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.ped-handoff--live .ped-handoff__online-dot {
  display: block;
}

.ped-handoff--waiting .ped-handoff__online-dot {
  display: block;
  background: #f59e0b;
}

.ped-handoff__head-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ped-handoff__title {
  font-weight: 700;
  color: #0f2940;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ped-handoff__subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7c8f;
}

.ped-handoff__tools {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ped-handoff__icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4a5568;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.ped-handoff__icon-btn:hover {
  background: rgba(24, 119, 171, 0.1);
  color: #1877ab;
}

.ped-handoff__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px 14px 14px;
  gap: 8px;
}

.ped-handoff__messages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
  scroll-behavior: smooth;
}

.ped-handoff__msg {
  margin: 0;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  animation: ped-handoff-in 0.22s ease-out;
}

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

.ped-handoff__msg-who {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #6b7c8f;
  margin-bottom: 3px;
}

.ped-handoff__msg-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}

.ped-handoff__msg--agent {
  background: var(--ped-chat-agent-bg);
  color: var(--ped-chat-agent-fg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ped-handoff__msg--visitor {
  background: var(--ped-chat-visitor-bg);
  color: var(--ped-chat-visitor-fg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ped-handoff__msg--visitor .ped-handoff__msg-who {
  display: none;
}

.ped-handoff__status {
  margin: 0;
  font-size: 0.8rem;
  color: #6b7c8f;
  flex-shrink: 0;
}

.ped-handoff__typing {
  margin: 0;
  font-size: 0.8rem;
  font-style: italic;
  color: #5c6b7e;
  flex-shrink: 0;
}

.ped-handoff__typing[hidden] {
  display: none !important;
}

.ped-handoff__form {
  flex-shrink: 0;
  margin: 0;
}

.ped-handoff__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid #dce4ee;
  background: #fafbfc;
}

.ped-handoff__composer textarea {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  resize: none;
  border: 0;
  padding: 4px 2px;
  background: transparent;
  font: inherit;
  line-height: 1.4;
}

.ped-handoff__composer textarea:focus {
  outline: none;
}

.ped-handoff__send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #c5d0dc;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ped-handoff__composer:focus-within .ped-handoff__send,
.ped-handoff__send:hover {
  background: #1877ab;
}

.ped-handoff--waiting .ped-handoff__panel {
  height: auto;
  border-color: #f5e6a8;
}

.ped-handoff--waiting .ped-handoff__status {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #1a1f2e;
  padding: 2px 2px 6px;
}

@media (max-width: 760px) {
  .ped-handoff {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .ped-handoff__panel {
    height: min(78vh, 640px);
  }
}