/* KaspPlus — плавающая кнопка чата в MAX */
/* Справа: базовый отступ + 50px левее от прежней позиции + safe-area */
.kaspplus-max-fab {
  position: fixed;
  top: 50%;
  bottom: auto;
  right: calc(50px + max(10px, env(safe-area-inset-right, 0px)));
  transform: translateY(calc(-50% + 277px));
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #0066ff 0%, #5b4dff 100%);
  box-shadow: 0 6px 24px rgba(0, 102, 255, 0.38);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    padding 0.4s ease,
    border-radius 0.4s ease,
    gap 0.4s ease;
}

.kaspplus-max-fab__text {
  display: inline-block;
  max-width: 20em;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
  transition:
    max-width 0.4s ease,
    opacity 0.3s ease;
}

.kaspplus-max-fab--compact {
  width: 52px;
  height: 52px;
  min-width: 52px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.32);
}

/* Текст убран из flex-потока — иначе на мобилке остаётся min-width и значок уезжает */
.kaspplus-max-fab--compact .kaspplus-max-fab__text {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  max-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.kaspplus-max-fab--compact .kaspplus-max-fab__icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

/* Веб (не мобилка): на 4px правее базового right; компактный круг ⌀ 60; hover — капсула */
@media (min-width: 481px) {
  .kaspplus-max-fab {
    right: calc(46px + max(10px, env(safe-area-inset-right, 0px)));
  }

  .kaspplus-max-fab--compact {
    width: 60px;
    height: 60px;
    min-width: 60px;
  }

  .kaspplus-max-fab--compact .kaspplus-max-fab__icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .kaspplus-max-fab--compact:hover {
    width: auto;
    height: auto;
    min-width: 0;
    padding: 12px 18px 12px 14px;
    gap: 10px;
    border-radius: 999px;
    justify-content: flex-start;
    align-items: center;
    box-shadow: 0 10px 28px rgba(0, 102, 255, 0.45);
  }

  .kaspplus-max-fab--compact:hover .kaspplus-max-fab__text {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    max-width: 20em;
    opacity: 1;
    pointer-events: auto;
    overflow: hidden;
    white-space: nowrap;
  }

  .kaspplus-max-fab--compact:hover .kaspplus-max-fab__icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    transform: none;
  }
}

.kaspplus-max-fab:hover {
  color: #fff;
  transform: translateY(calc(-50% + 275px));
  box-shadow: 0 10px 28px rgba(0, 102, 255, 0.45);
}

.kaspplus-max-fab:focus {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.kaspplus-max-fab__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  line-height: 0;
}

.kaspplus-max-fab__icon-img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: contain;
  object-position: center;
  vertical-align: middle;
}

@media (max-width: 480px) {
  .kaspplus-max-fab {
    font-size: 13px;
    padding: 10px 14px 10px 12px;
    gap: 8px;
    transform: translateY(calc(-50% + 215px));
  }

  .kaspplus-max-fab:hover {
    transform: translateY(calc(-50% + 213px));
  }

  .kaspplus-max-fab__icon {
    width: 26px;
    height: 26px;
  }

  .kaspplus-max-fab--compact {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }

  .kaspplus-max-fab--compact .kaspplus-max-fab__icon {
    width: 28px;
    height: 28px;
    transform: translateX(5px);
  }

  .kaspplus-max-fab--compact:hover {
    box-shadow: 0 8px 22px rgba(0, 102, 255, 0.42);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kaspplus-max-fab,
  .kaspplus-max-fab__text {
    transition: none;
  }

  .kaspplus-max-fab:hover {
    transform: translateY(calc(-50% + 277px));
  }
}

@media (max-width: 480px) and (prefers-reduced-motion: reduce) {
  .kaspplus-max-fab:hover {
    transform: translateY(calc(-50% + 215px));
  }
}
