.dd-assistant {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  font-family: var(--dd-font);
}

.dd-assistant__toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 15px 8px 9px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--dd-primary), #164d86);
  color: #fff;
  box-shadow: 0 12px 30px rgb(16 42 67 / 18%);
  font: inherit;
  font-size: 14px;
  font-weight: 780;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.dd-assistant__toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgb(16 42 67 / 22%);
}

.dd-assistant__toggle-icon {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: rgb(255 255 255 / 16%);
}

.dd-assistant__toggle-icon svg {
  width: 19px;
  height: 19px;
}

.dd-assistant__panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  display: flex;
  width: min(372px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 96px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgb(16 42 67 / 10%);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 64px rgb(16 42 67 / 18%);
}

.dd-assistant__panel[hidden] {
  display: none;
}

.dd-assistant__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid rgb(16 42 67 / 7%);
  background:
    radial-gradient(circle at top left, rgb(29 95 167 / 8%), transparent 48%),
    #fff;
}

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

.dd-assistant__brand-icon {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: #eef5fc;
  color: var(--dd-primary);
}

.dd-assistant__brand-icon svg {
  width: 24px;
  height: 24px;
}

.dd-assistant__title,
.dd-assistant__subtitle,
.dd-assistant__status,
.dd-assistant__bubble p,
.dd-assistant__summary p,
.dd-assistant__section-label {
  margin: 0;
}

.dd-assistant__title {
  color: var(--dd-navy);
  font-size: 15px;
  font-weight: 820;
  line-height: 1.2;
}

.dd-assistant__subtitle {
  margin-top: 2px;
  color: var(--dd-muted);
  font-size: 10.5px;
  line-height: 1.2;
}

.dd-assistant__close {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--dd-muted);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.dd-assistant__close:hover {
  background: #f3f7fb;
  color: var(--dd-navy);
}

.dd-assistant__close svg {
  width: 17px;
  height: 17px;
}

.dd-assistant__transcript {
  display: flex;
  min-height: 112px;
  max-height: 220px;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 13px 14px;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #f8fafc 0%, #f5f8fb 100%);
}

.dd-assistant__message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.dd-assistant__message--user {
  justify-content: flex-end;
}

.dd-assistant__avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #e7f0fa;
  color: var(--dd-primary);
}

.dd-assistant__avatar svg {
  width: 17px;
  height: 17px;
}

.dd-assistant__bubble {
  width: fit-content;
  max-width: 82%;
  padding: 9px 11px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.dd-assistant__bubble--assistant {
  border: 1px solid rgb(16 42 67 / 7%);
  border-bottom-left-radius: 5px;
  background: #fff;
  color: var(--dd-text);
  box-shadow: 0 4px 12px rgb(16 42 67 / 3%);
}

.dd-assistant__bubble--user {
  border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, var(--dd-primary), #164d86);
  color: #fff;
}

.dd-assistant__bubble--error {
  border-color: color-mix(in srgb, var(--dd-danger) 22%, var(--dd-border));
  background: var(--dd-danger-soft);
  color: var(--dd-danger);
}

.dd-assistant__typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid rgb(16 42 67 / 7%);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  background: #fff;
  color: var(--dd-muted);
  font-size: 11.5px;
}

.dd-assistant__typing-dots {
  display: inline-flex;
  gap: 4px;
}

.dd-assistant__typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(29 95 167 / 46%);
  animation: ddAssistantBounce 900ms infinite ease-in-out;
}

.dd-assistant__typing-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.dd-assistant__typing-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes ddAssistantBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.42;
  }

  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.dd-assistant__actions {
  padding: 12px 13px 11px;
  border-top: 1px solid rgb(16 42 67 / 7%);
  background: #fff;
}

.dd-assistant__section-label {
  margin-bottom: 8px;
  color: var(--dd-muted);
  font-size: 10.5px;
  font-weight: 760;
  letter-spacing: .025em;
}

.dd-assistant__primary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.dd-assistant__action-card {
  display: flex;
  min-width: 0;
  min-height: 62px;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid rgb(16 42 67 / 9%);
  border-radius: 13px;
  background: #fff;
  color: var(--dd-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.dd-assistant__action-card:hover:not(:disabled) {
  border-color: rgb(29 95 167 / 24%);
  background: #f8fbff;
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgb(16 42 67 / 5%);
}

.dd-assistant__action-card > span:last-child {
  min-width: 0;
}

.dd-assistant__action-card strong,
.dd-assistant__action-card small {
  display: block;
}

.dd-assistant__action-card strong {
  color: var(--dd-navy);
  font-size: 11.5px;
  font-weight: 790;
  line-height: 1.25;
}

.dd-assistant__action-card small {
  margin-top: 2px;
  color: var(--dd-muted);
  font-size: 9.5px;
  line-height: 1.2;
}

.dd-assistant__action-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: #eef5fc;
  color: var(--dd-primary);
}

.dd-assistant__action-icon svg {
  width: 17px;
  height: 17px;
}

.dd-assistant__action-card:disabled,
.dd-assistant__secondary-actions button:disabled {
  cursor: wait;
  opacity: .5;
}

.dd-assistant__more {
  margin-top: 9px;
  border-top: 1px solid rgb(16 42 67 / 7%);
  padding-top: 8px;
}

.dd-assistant__more summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--dd-muted);
  font-size: 10.5px;
  font-weight: 740;
  cursor: pointer;
  list-style: none;
}

.dd-assistant__more summary::-webkit-details-marker {
  display: none;
}

.dd-assistant__more summary svg {
  width: 16px;
  height: 16px;
  transition: transform 140ms ease;
}

.dd-assistant__more[open] summary svg {
  transform: rotate(180deg);
}

.dd-assistant__secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
}

.dd-assistant__secondary-actions button {
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid rgb(16 42 67 / 9%);
  border-radius: 999px;
  background: #fff;
  color: var(--dd-text);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}

.dd-assistant__secondary-actions button:hover:not(:disabled) {
  border-color: rgb(29 95 167 / 24%);
  background: #f7fbff;
  color: var(--dd-primary);
}

.dd-assistant__status {
  min-height: 0;
  padding: 0 13px;
  background: #fff;
  color: var(--dd-primary);
  font-size: 10.5px;
  font-weight: 700;
}

.dd-assistant__status:not(:empty) {
  min-height: 28px;
  padding-top: 6px;
  padding-bottom: 8px;
}

.dd-assistant__summary {
  width: min(100%, 292px);
  align-self: flex-start;
  padding: 11px;
  border: 1px solid rgb(16 42 67 / 8%);
  border-radius: 14px;
  background: #fff;
  color: var(--dd-text);
  font-size: 11.5px;
}

.dd-assistant__summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.dd-assistant__summary-metric {
  padding: 8px;
  border-radius: 9px;
  background: #f1f6fb;
}

.dd-assistant__summary-metric span {
  display: block;
  color: var(--dd-muted);
  font-size: 9.5px;
}

.dd-assistant__summary-metric strong {
  display: block;
  margin-top: 3px;
  color: var(--dd-navy);
  font-size: 17px;
}

.dd-assistant__summary-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dd-assistant__summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.dd-assistant__summary-latest {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgb(16 42 67 / 8%);
}

.dd-assistant__complaint-summary {
  width: min(100%, 292px);
  align-self: flex-start;
  padding: 10px 11px;
  border: 1px solid rgb(16 42 67 / 8%);
  border-radius: 14px;
  background: #fff;
  color: var(--dd-text);
  font-size: 11.5px;
}

.dd-assistant__complaint-summary strong {
  display: block;
  color: var(--dd-navy);
  font-size: 15px;
}

.dd-assistant__complaint-summary span {
  display: block;
  margin-top: 2px;
  color: var(--dd-muted);
}

.dd-assistant__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
}

.dd-assistant__links a {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid rgb(16 42 67 / 9%);
  border-radius: 9px;
  background: #fff;
  color: var(--dd-primary);
  font-size: 10.5px;
  font-weight: 760;
  text-decoration: none;
}

.dd-assistant__links a:hover {
  border-color: rgb(29 95 167 / 24%);
  background: #f7fbff;
}

.dd-assistant__toggle:focus-visible,
.dd-assistant__close:focus-visible,
.dd-assistant__action-card:focus-visible,
.dd-assistant__secondary-actions button:focus-visible,
.dd-assistant__links a:focus-visible,
.dd-assistant__more summary:focus-visible {
  outline: 2px solid var(--dd-primary);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .dd-assistant {
    right: 10px;
    bottom: 10px;
  }

  .dd-assistant__panel {
    bottom: 58px;
    width: calc(100vw - 20px);
    max-height: min(74vh, 540px);
    border-radius: 19px;
  }

  .dd-assistant__transcript {
    max-height: 205px;
  }

  .dd-assistant__action-card {
    min-height: 58px;
  }
}

/* A5 production hardening */
.dd-assistant {
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
}

.dd-assistant__panel {
  overscroll-behavior: contain;
}

.dd-assistant__transcript {
  scrollbar-width: thin;
  scrollbar-color: rgb(29 95 167 / 28%) transparent;
}

.dd-assistant__transcript::-webkit-scrollbar {
  width: 7px;
}

.dd-assistant__transcript::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgb(29 95 167 / 25%);
}

@media (max-width: 640px) {
  .dd-assistant {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .dd-assistant__panel {
    width: min(
      calc(100vw - 20px),
      calc(
        100vw
        - env(safe-area-inset-left)
        - env(safe-area-inset-right)
        - 20px
      )
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  .dd-assistant *,
  .dd-assistant *::before,
  .dd-assistant *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
