/**
 * YooAI Messicon — стили витрины
 */
.ymi-widget {
  --ymi-size: 56px;
  --ymi-item: 48px;
  --ymi-gap: 10px;
  --ymi-stack-gap: 18px;
  --ymi-z: 99990;
  --ymi-main: #4A90E2;
  --ymi-top: 20px;
  --ymi-right: 20px;
  --ymi-bottom: 20px;
  --ymi-left: 20px;
  position: fixed;
  z-index: var(--ymi-z);
  display: flex;
  align-items: flex-end;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  pointer-events: none;
}

.ymi-widget * {
  box-sizing: border-box;
}

.ymi-widget .ymi-main,
.ymi-widget .ymi-item,
.ymi-widget .ymi-dialog,
.ymi-widget .ymi-dialog-close {
  pointer-events: auto;
}

/* Позиции */
.ymi-pos-bottom-right {
  right: var(--ymi-right);
  bottom: var(--ymi-bottom);
  flex-direction: row;
}

.ymi-pos-bottom-left {
  left: var(--ymi-left);
  bottom: var(--ymi-bottom);
  flex-direction: row-reverse;
}

.ymi-pos-top-right {
  right: var(--ymi-right);
  top: var(--ymi-top);
  flex-direction: row;
  align-items: flex-start;
}

.ymi-pos-top-left {
  left: var(--ymi-left);
  top: var(--ymi-top);
  flex-direction: row-reverse;
  align-items: flex-start;
}

/* Стек кнопок */
.ymi-stack {
  display: flex;
  align-items: center;
  position: relative;
}

.ymi-expand-up .ymi-stack,
.ymi-expand-down .ymi-stack {
  flex-direction: column;
}

.ymi-expand-up .ymi-stack {
  flex-direction: column-reverse;
}

.ymi-expand-left .ymi-stack,
.ymi-expand-right .ymi-stack {
  flex-direction: row;
}

.ymi-expand-left .ymi-stack {
  flex-direction: row-reverse;
}

.ymi-widget.is-open .ymi-stack {
  gap: var(--ymi-stack-gap);
}

.ymi-panel {
  display: flex;
  align-items: center;
  gap: var(--ymi-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ymi-expand-up .ymi-panel,
.ymi-expand-down .ymi-panel {
  flex-direction: column;
}

.ymi-expand-up .ymi-panel {
  flex-direction: column-reverse;
}

.ymi-expand-left .ymi-panel,
.ymi-expand-right .ymi-panel {
  flex-direction: row;
}

.ymi-expand-left .ymi-panel {
  flex-direction: row-reverse;
}

.ymi-panel[hidden] {
  display: none !important;
}

/* Главная кнопка */
.ymi-main {
  position: relative;
  width: var(--ymi-size);
  height: var(--ymi-size);
  border: 0;
  border-radius: 50%;
  background: var(--ymi-main);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transition: transform .2s ease, box-shadow .2s ease;
  text-decoration: none;
  padding: 0;
  outline: none;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.ymi-main:hover,
.ymi-main:focus {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #fff;
  text-decoration: none;
}

.ymi-main-icon {
  display: flex;
  width: 55%;
  height: 55%;
  align-items: center;
  justify-content: center;
}

.ymi-main-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ymi-icon-close {
  display: none;
}

.ymi-widget.is-open .ymi-icon-open {
  display: none;
}

.ymi-widget.is-open .ymi-icon-close {
  display: flex;
}

/* Пульсация */
.ymi-pulse:not(.is-open) .ymi-main::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ymi-main);
  opacity: 0.45;
  animation: ymi-pulse 2s ease-out infinite;
  z-index: -1;
}

@keyframes ymi-pulse {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }
  70% {
    transform: scale(1.55);
    opacity: 0;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

/* Иконки мессенджеров */
.ymi-item {
  position: relative;
  width: var(--ymi-item);
  height: var(--ymi-item);
  border-radius: 50%;
  background: var(--ymi-brand, #888);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transform: scale(0.4);
  opacity: 0;
  transition: transform .22s ease, opacity .22s ease, box-shadow .2s ease;
  flex-shrink: 0;
}

.ymi-widget.is-open .ymi-item {
  transform: scale(1);
  opacity: 1;
}

.ymi-widget.is-open .ymi-item:nth-child(1) { transition-delay: .02s; }
.ymi-widget.is-open .ymi-item:nth-child(2) { transition-delay: .05s; }
.ymi-widget.is-open .ymi-item:nth-child(3) { transition-delay: .08s; }
.ymi-widget.is-open .ymi-item:nth-child(4) { transition-delay: .11s; }
.ymi-widget.is-open .ymi-item:nth-child(5) { transition-delay: .14s; }
.ymi-widget.is-open .ymi-item:nth-child(6) { transition-delay: .17s; }

.ymi-item:hover,
.ymi-item:focus {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  color: #fff;
  text-decoration: none;
}

.ymi-item-icon {
  display: flex;
  width: 54%;
  height: 54%;
  align-items: center;
  justify-content: center;
}

.ymi-item.ymi-viber .ymi-item-icon,
.ymi-main.ymi-viber .ymi-main-icon {
  width: 62%;
  height: 62%;
}

.ymi-item-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Instagram — фирменный градиент */
.ymi-item.ymi-instagram,
.ymi-main.ymi-instagram {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
}

/* MAX — фирменный градиент */
.ymi-item.ymi-max,
.ymi-main.ymi-max {
  background: linear-gradient(135deg, #471AFF 0%, #9500FF 100%);
}

.ymi-item.ymi-max .ymi-max-text {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
}

/* Телефон — коралл сайта, чтобы не путать с WhatsApp */
.ymi-item.ymi-phone,
.ymi-main.ymi-phone {
  color: #fff;
}

/* Подсказки */
.ymi-tip {
  position: absolute;
  white-space: nowrap;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  padding: 5px 9px;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 2;
}

.ymi-tooltips .ymi-item:hover .ymi-tip,
.ymi-tooltips .ymi-main:hover .ymi-tip {
  opacity: 1;
  visibility: visible;
}

.ymi-pos-bottom-right .ymi-tip,
.ymi-pos-top-right .ymi-tip {
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
}

.ymi-pos-bottom-left .ymi-tip,
.ymi-pos-top-left .ymi-tip {
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
}

/* ——— Диалог вовлечения ——— */
.ymi-dialog {
  position: relative;
  width: min(280px, calc(100vw - 100px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
  padding: 12px 14px 14px;
  animation: ymi-dialog-in .28s ease;
}

.ymi-dialog[hidden] {
  display: none !important;
}

@keyframes ymi-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ymi-dialog-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #999;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
}

.ymi-dialog-close:hover {
  color: #333;
  background: #f0f0f0;
}

.ymi-dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 20px;
}

.ymi-dialog-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ymi-dialog-avatar svg {
  width: 60%;
  height: 60%;
}

.ymi-dialog-name {
  font-size: 13px;
  font-weight: 600;
  color: #222;
}

.ymi-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ymi-bubble {
  align-self: flex-start;
  max-width: 100%;
  background: #f2f4f7;
  color: #222;
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  animation: ymi-bubble-in .25s ease;
  cursor: pointer;
}

@keyframes ymi-bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ymi-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #f2f4f7;
  border-radius: 14px;
  align-self: flex-start;
}

.ymi-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa3af;
  animation: ymi-dot 1.2s ease-in-out infinite;
}

.ymi-typing span:nth-child(2) { animation-delay: .15s; }
.ymi-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes ymi-dot {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 767px) {
  .ymi-hide-mobile {
    display: none !important;
  }

  .ymi-dialog {
    width: min(240px, calc(100vw - 90px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ymi-pulse:not(.is-open) .ymi-main::before {
    animation: none;
  }
  .ymi-item,
  .ymi-main,
  .ymi-dialog,
  .ymi-bubble,
  .ymi-typing span {
    transition: none;
    animation: none;
  }
}
