/* PPSDM LH floating chatbot — scoped with ppsdm-chat-* */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

.ppsdm-chat-root {
  --ppsdm-chat-primary: #1c5871;
  --ppsdm-chat-primary-dark: #16465a;
  --ppsdm-chat-primary-mid: #1f647f;
  --ppsdm-chat-accent: #c0940f;
  --ppsdm-chat-accent-dark: #a67c0a;
  --ppsdm-chat-bg: #ffffff;
  --ppsdm-chat-muted: #6d6d6d;
  --ppsdm-chat-border: #e7e7e7;
  --ppsdm-chat-shadow: 0 16px 48px rgba(28, 88, 113, 0.22);
  --ppsdm-chat-font: 'Poppins', system-ui, sans-serif;

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1080;
  font-family: var(--ppsdm-chat-font);
  line-height: 1.45;
  color: var(--ppsdm-chat-primary-dark);
  box-sizing: border-box;
}

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

/* ---------- Floating launcher ---------- */

.ppsdm-chat-launcher {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.ppsdm-chat-launcher:hover {
  transform: translateY(-3px);
}

.ppsdm-chat-launcher:focus-visible {
  outline: 2px solid var(--ppsdm-chat-accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.ppsdm-chat-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 88px;
  height: 88px;
  transform: translate(-50%, -58%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(28, 88, 113, 0.35) 0%,
    rgba(192, 148, 15, 0.22) 45%,
    transparent 70%
  );
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.ppsdm-chat-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

.ppsdm-chat-pulse--teal {
  border: 2px solid rgba(28, 88, 113, 0.55);
  animation: ppsdm-chat-pulse 2.4s ease-out infinite;
}

.ppsdm-chat-pulse--gold {
  border: 2px solid rgba(192, 148, 15, 0.55);
  animation: ppsdm-chat-pulse 2.4s ease-out infinite 1.1s;
}

@keyframes ppsdm-chat-pulse {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

.ppsdm-chat-orb {
  position: relative;
  z-index: 1;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid var(--ppsdm-chat-primary);
  background: linear-gradient(180deg, #ffffff 0%, #f4f9fb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(28, 88, 113, 0.18);
  overflow: visible;
  transition: background 0.28s ease, border-color 0.28s ease;
}

.ppsdm-chat-orb-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

.ppsdm-chat-orb-close {
  display: none;
  width: 28px;
  height: 28px;
  color: #fff;
}

.ppsdm-chat-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(135deg, #c0940f 0%, #a67c0a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(166, 124, 10, 0.35);
  animation: ppsdm-chat-badge-bounce 1.8s ease-in-out infinite;
}

.ppsdm-chat-badge svg {
  width: 12px;
  height: 12px;
  fill: #fff;
}

@keyframes ppsdm-chat-badge-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.ppsdm-chat-caption {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--ppsdm-chat-primary) 0%,
    var(--ppsdm-chat-primary-dark) 100%
  );
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  box-shadow: 0 4px 12px rgba(28, 88, 113, 0.25);
}

/* Open state launcher */
.ppsdm-chat-root.is-open .ppsdm-chat-orb {
  border-color: transparent;
  background: linear-gradient(
    145deg,
    #1f647f 0%,
    #1c5871 50%,
    #16465a 100%
  );
}

.ppsdm-chat-root.is-open .ppsdm-chat-orb-logo,
.ppsdm-chat-root.is-open .ppsdm-chat-badge,
.ppsdm-chat-root.is-open .ppsdm-chat-caption,
.ppsdm-chat-root.is-open .ppsdm-chat-pulse,
.ppsdm-chat-root.is-open .ppsdm-chat-glow {
  display: none;
}

.ppsdm-chat-root.is-open .ppsdm-chat-orb-close {
  display: block;
}

/* ---------- Panel ---------- */

.ppsdm-chat-panel {
  position: absolute;
  right: 0;
  bottom: 100px;
  width: min(400px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  background: var(--ppsdm-chat-bg);
  border: 1px solid var(--ppsdm-chat-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--ppsdm-chat-shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.ppsdm-chat-root.is-open .ppsdm-chat-panel {
  display: flex;
  animation: ppsdm-chat-panel-in 0.28s ease forwards;
  pointer-events: auto;
}

@keyframes ppsdm-chat-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.ppsdm-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: #fff;
  color: var(--ppsdm-chat-primary-dark);
  flex-shrink: 0;
}

.ppsdm-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ppsdm-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ppsdm-chat-border);
  background: #f4f9fb;
  object-fit: contain;
  padding: 3px;
  flex-shrink: 0;
}

.ppsdm-chat-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ppsdm-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ppsdm-chat-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ppsdm-chat-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ppsdm-chat-subtitle-lead {
  font-weight: 700;
  color: var(--ppsdm-chat-primary-dark);
}

.ppsdm-chat-subtitle-rest {
  font-weight: 400;
  color: var(--ppsdm-chat-muted);
}

.ppsdm-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ppsdm-chat-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ppsdm-chat-border);
  border-radius: 10px;
  background: #f5f7f8;
  color: var(--ppsdm-chat-primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ppsdm-chat-icon-btn:hover {
  background: #eef3f6;
  border-color: #d9e2e6;
  color: var(--ppsdm-chat-primary);
}

.ppsdm-chat-icon-btn svg {
  width: 16px;
  height: 16px;
}

.ppsdm-chat-accent-bar {
  height: 3px;
  background: var(--ppsdm-chat-accent);
  flex-shrink: 0;
}

.ppsdm-chat-context {
  display: none;
}

.ppsdm-chat-icon-btn.is-active {
  background: #e7f1f5;
  border-color: #c9dde6;
  color: var(--ppsdm-chat-primary);
}

.ppsdm-chat-history {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background: #f7fafb;
}

.ppsdm-chat-root.is-history-open .ppsdm-chat-history {
  display: flex;
}

.ppsdm-chat-root.is-history-open .ppsdm-chat-body,
.ppsdm-chat-root.is-history-open .ppsdm-chat-footer {
  display: none !important;
}

.ppsdm-chat-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 4px;
}

.ppsdm-chat-history-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ppsdm-chat-history-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--ppsdm-chat-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.ppsdm-chat-history-back svg {
  width: 16px;
  height: 16px;
}

.ppsdm-chat-history-back:hover {
  color: var(--ppsdm-chat-primary-dark);
}

.ppsdm-chat-history-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ppsdm-chat-primary-dark);
}

.ppsdm-chat-history-hint {
  margin: 0;
  padding: 0 14px 8px;
  font-size: 11px;
  color: var(--ppsdm-chat-muted);
}

.ppsdm-chat-history-clear {
  border: 0;
  background: transparent;
  color: var(--ppsdm-chat-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  flex-shrink: 0;
}

.ppsdm-chat-history-clear:hover {
  color: #a33;
}

.ppsdm-chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ppsdm-chat-history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--ppsdm-chat-border);
  border-radius: 0;
  background: transparent;
  padding: 12px 8px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease;
}

.ppsdm-chat-history-item:last-child {
  border-bottom: 0;
}

.ppsdm-chat-history-item:hover {
  background: #eef5f8;
}

.ppsdm-chat-history-item.is-current {
  background: #e7f1f5;
}

.ppsdm-chat-history-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e7f1f5;
  color: var(--ppsdm-chat-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ppsdm-chat-history-item.is-current .ppsdm-chat-history-item-icon {
  background: var(--ppsdm-chat-primary);
  color: #fff;
}

.ppsdm-chat-history-item-icon svg {
  width: 16px;
  height: 16px;
}

.ppsdm-chat-history-item-body {
  min-width: 0;
  flex: 1;
}

.ppsdm-chat-history-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ppsdm-chat-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ppsdm-chat-history-item-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ppsdm-chat-muted);
}

.ppsdm-chat-history-empty {
  margin: 0;
  padding: 16px 14px 20px;
  font-size: 12px;
  color: var(--ppsdm-chat-muted);
  line-height: 1.5;
  text-align: center;
}

/* Messages */
.ppsdm-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fafcfd;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ppsdm-chat-msg {
  display: flex;
  max-width: 88%;
}

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

.ppsdm-chat-msg--assistant {
  align-self: flex-start;
}

.ppsdm-chat-bubble {
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ppsdm-chat-msg--user .ppsdm-chat-bubble {
  background: var(--ppsdm-chat-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ppsdm-chat-msg--assistant .ppsdm-chat-bubble {
  background: #eef5f8;
  color: var(--ppsdm-chat-primary-dark);
  border: 1px solid #d9e8ef;
  border-bottom-left-radius: 4px;
}

.ppsdm-chat-bubble p {
  margin: 0 0 0.55em;
}

.ppsdm-chat-bubble p:last-child {
  margin-bottom: 0;
}

.ppsdm-chat-bubble strong {
  font-weight: 600;
}

.ppsdm-chat-bubble ul,
.ppsdm-chat-bubble ol {
  margin: 0.35em 0 0.55em;
  padding-left: 1.2em;
}

.ppsdm-chat-bubble li {
  margin: 0.2em 0;
}

.ppsdm-chat-bubble h1,
.ppsdm-chat-bubble h2,
.ppsdm-chat-bubble h3,
.ppsdm-chat-bubble h4 {
  margin: 0 0 0.4em;
  font-size: 13px;
  font-weight: 600;
}

.ppsdm-chat-link-ref {
  font-weight: 600;
  color: var(--ppsdm-chat-primary);
}

.ppsdm-chat-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d9e8ef;
}

.ppsdm-chat-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    var(--ppsdm-chat-primary) 0%,
    var(--ppsdm-chat-primary-dark) 100%
  );
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  box-shadow: 0 6px 16px rgba(28, 88, 113, 0.18);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ppsdm-chat-link-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(
    90deg,
    var(--ppsdm-chat-accent) 0%,
    var(--ppsdm-chat-accent-dark) 100%
  );
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(192, 148, 15, 0.28);
}

.ppsdm-chat-link-btn-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.ppsdm-chat-link-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.ppsdm-chat-bubble p .ppsdm-chat-link-btn {
  display: none;
}

.ppsdm-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}

.ppsdm-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ppsdm-chat-primary);
  opacity: 0.35;
  animation: ppsdm-chat-typing 1.2s ease-in-out infinite;
}

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

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

@keyframes ppsdm-chat-typing {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Footer */
.ppsdm-chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--ppsdm-chat-border);
  background: #fff;
  flex-shrink: 0;
}

.ppsdm-chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  border: 1px solid var(--ppsdm-chat-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ppsdm-chat-primary-dark);
  background: #fff;
  outline: none;
  line-height: 1.4;
}

.ppsdm-chat-input::placeholder {
  color: #9aa0a6;
}

.ppsdm-chat-input:focus {
  border-color: rgba(28, 88, 113, 0.45);
  box-shadow: 0 0 0 3px rgba(28, 88, 113, 0.1);
}

.ppsdm-chat-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: var(--ppsdm-chat-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.ppsdm-chat-send:hover:not(:disabled) {
  background: var(--ppsdm-chat-primary-dark);
}

.ppsdm-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ppsdm-chat-send svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .ppsdm-chat-root {
    right: 16px;
    bottom: 16px;
  }

  .ppsdm-chat-panel {
    bottom: 96px;
  }
}
