.whatsapp-widget {
  position: fixed;
  right: 24px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: auto;
  z-index: 90;
  width: 64px;
  height: 64px;
}

.whatsapp-trigger {
  position: relative;
  z-index: 3;
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid rgb(91 85 155 / 55%);
  border-radius: 50%;
  background: #168c9e;
  color: var(--color-brand-secondary);
  box-shadow:
    0 0 0 8px rgb(69 191 209 / 15%),
    0 12px 32px rgb(22 140 158 / 30%);
  cursor: pointer;
  scale: 1;
  translate: none;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.whatsapp-trigger > img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.whatsapp-trigger:hover {
  background: #117f90;
  scale: 1;
  translate: none;
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 0 0 9px rgb(69 191 209 / 18%),
    0 16px 36px rgb(22 140 158 / 34%);
}

.whatsapp-trigger:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.whatsapp-dialog {
  position: fixed;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.whatsapp-backdrop {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgb(245 250 251 / 72%);
  opacity: 0;
  pointer-events: auto;
  backdrop-filter: blur(2px);
  transition: opacity 220ms ease;
}

.whatsapp-panel {
  position: fixed;
  z-index: 2;
  right: 24px;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 82px);
  left: auto;
  width: min(376px, calc(100vw - 32px));
  max-height: calc(100dvh - 124px);
  overflow: auto;
  padding: 0;
  border: 1px solid #dedfe5;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(48 45 67 / 18%);
  opacity: 0;
  pointer-events: auto;
  translate: none;
  transform: translateY(14px) scale(0.985);
  transform-origin: bottom right;
  transition: opacity 220ms ease, transform 220ms ease;
}

.whatsapp-widget.is-open .whatsapp-backdrop {
  opacity: 1;
}

.whatsapp-widget.is-open .whatsapp-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.whatsapp-panel__header {
  display: flex;
  min-height: 112px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px 11px;
}

.whatsapp-panel__header > div {
  min-width: 0;
}

.whatsapp-panel__header p {
  margin: 0;
  color: var(--color-brand-secondary);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
}

.whatsapp-panel__header h2 {
  margin: 4px 0 0;
  color: #050505;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.whatsapp-panel__header > div > span {
  display: block;
  margin-top: 5px;
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.7;
}

.whatsapp-panel__close {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #d4d5da;
  border-radius: 15px;
  background: #fff;
  color: #080808;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.whatsapp-panel__close svg {
  width: 24px;
  height: 24px;
}

.whatsapp-panel__close:hover {
  border-color: rgb(91 85 155 / 35%);
  background: rgb(91 85 155 / 5%);
  color: var(--color-brand-secondary);
}

.whatsapp-panel__close:focus-visible {
  outline: 3px solid var(--color-brand-primary);
  outline-offset: 2px;
}

.whatsapp-panel__options {
  display: grid;
  gap: 9px;
  padding: 0 20px 17px;
}

.whatsapp-department {
  display: grid;
  min-height: 67px;
  grid-template-columns: 46px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid #dedede;
  border-radius: 17px;
  background: #f8f8f8;
  color: var(--color-text);
  transition: border-color 170ms ease, background-color 170ms ease, transform 170ms ease;
}

.whatsapp-department:hover {
  border-color: rgb(69 191 209 / 55%);
  background: #f3fcfd;
  transform: translateY(-1px);
}

.whatsapp-department:focus-visible {
  outline: 3px solid var(--color-brand-primary);
  outline-offset: 2px;
}

.whatsapp-department__whatsapp {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(69 191 209 / 24%);
  border-radius: 14px;
  background: rgb(69 191 209 / 7%);
  color: var(--color-brand-primary);
}

.whatsapp-department__whatsapp img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.whatsapp-department__content {
  min-width: 0;
  text-align: right;
}

.whatsapp-department__content strong {
  display: block;
  color: #050505;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
}

.whatsapp-department__content small {
  display: block;
  margin-top: 2px;
  color: #636363;
  font-size: 14px;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-align: right;
}

.whatsapp-department__specialty {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(91 85 155 / 14%);
  border-radius: 14px;
  background: rgb(91 85 155 / 5%);
  color: var(--color-brand-secondary);
}

.whatsapp-department__specialty img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@media (min-width: 64rem) {
  .whatsapp-backdrop {
    display: none;
  }
}

@media (max-width: 639px) {
  .whatsapp-widget {
    right: 4px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  .whatsapp-panel {
    right: 12px;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 72px);
    width: calc(100% - 24px);
    max-width: 376px;
    max-height: calc(100dvh - 112px);
    border-radius: 23px;
  }
}

@media (max-width: 389px) {
  .whatsapp-panel__header {
    padding-inline: 16px;
  }

  .whatsapp-panel__header h2 {
    font-size: 22px;
  }

  .whatsapp-panel__options {
    padding-inline: 16px;
  }

  .whatsapp-department {
    grid-template-columns: 42px minmax(0, 1fr) 40px;
    gap: 8px;
    padding: 8px;
  }

  .whatsapp-department__whatsapp {
    width: 42px;
    height: 42px;
  }

  .whatsapp-department__specialty {
    width: 40px;
    height: 40px;
  }

  .whatsapp-department__content strong {
    font-size: 15px;
  }

  .whatsapp-department__content small {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-trigger,
  .whatsapp-backdrop,
  .whatsapp-panel,
  .whatsapp-department {
    transform: none !important;
    transition-duration: 0.01ms !important;
  }
}
