/* Reanet Chat v6.0 — премиальный стиль, input-row + btn-icon */
:root {
  --reanet-chat-primary: #fc6702;
  --reanet-chat-dark: #222222;
  --reanet-chat-bot: #075E54;

  /* Градиенты (значения по умолчанию; переопределяются reanet-chat-theme.php из конфига) */
  --reanet-header-from:   #404040;
  --reanet-header-mid:    #2a2a2a;
  --reanet-header-to:     #1a1a1a;
  --reanet-launcher-from: #454545;
  --reanet-launcher-mid:  #2a2a2a;
  --reanet-launcher-to:   #151515;
  --reanet-btn-from:      #454545;
  --reanet-btn-to:        #222222;
}

.reanet-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: linear-gradient(160deg, var(--reanet-launcher-from) 0%, var(--reanet-launcher-mid) 50%, var(--reanet-launcher-to) 100%);
  color: #fff;
  width: 280px;
  height: 70px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  padding: 10px;
  box-shadow:
    0 10px 25px rgba(0,0,0,.3),
    0 1px 0 rgba(255,255,255,.08) inset;
  cursor: pointer;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: .3s ease;
  font-family: system-ui, -apple-system, sans-serif;
  border: 1px solid rgba(0,0,0,.2);
}
.reanet-chat-launcher.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Точечка-уведомление на мобильном (как "пришло сообщение") */
.reanet-chat-launcher.has-notification::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #fc6702;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0,0,0,.3);
  animation: reanetNotifyPulse 1.5s ease-in-out infinite;
}
@keyframes reanetNotifyPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: .9; }
}

.reanet-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #444;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.15);
}
.reanet-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.reanet-chat-avatar svg {
  width: 100%;
  height: 100%;
}

.reanet-chat-launcher-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.reanet-chat-launcher-text span:first-child {
  font-weight: 600;
  font-size: 15px;
}
.reanet-chat-launcher-text span:last-child {
  font-size: 12px;
  color: rgba(255,255,255,.7);
}

/* Мобильный launcher — компактный пузырёк справа внизу */
@media (max-width: 767px) {
  .reanet-chat-launcher {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    align-items: center;
    right: 16px;
    bottom: 16px;
    box-shadow:
      0 4px 12px rgba(0,0,0,.25),
      0 1px 0 rgba(255,255,255,.1) inset;
  }
  .reanet-chat-avatar,
  .reanet-chat-launcher-text {
    display: none !important;
  }
  .reanet-chat-launcher::before {
    content: '💬';
    font-size: 24px;
    line-height: 1;
  }
}

/* Окно чата — премиальный стиль */
.reanet-chat-window {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 12px 40px rgba(0,0,0,.25),
    0 0 0 1px rgba(0,0,0,.06);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Мобильный: компактное окно, НЕ на весь экран */
@media (max-width: 767px) {
  .reanet-chat-window {
    right: 12px;
    left: 12px;
    bottom: 72px;
    width: auto;
    max-height: 75vh;
    min-height: 280px;
    border-radius: 16px;
    box-shadow:
      0 12px 40px rgba(0,0,0,.3),
      0 0 0 1px rgba(0,0,0,.08);
  }
}

/* Шапка — градиент из конфига */
.reanet-chat-header {
  background: linear-gradient(180deg, var(--reanet-header-from) 0%, var(--reanet-header-mid) 40%, var(--reanet-header-to) 100%);
  color: #fff;
  padding: 14px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  min-height: 56px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15) inset;
}
.reanet-chat-header.has-avatar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reanet-chat-header-avatar-wrap {
  flex-shrink: 0;
}
.reanet-chat-header-avatar-wrap .reanet-chat-avatar {
  width: 40px;
  height: 40px;
  margin-right: 0;
}
.reanet-chat-header-title {
  flex: 1;
  min-width: 0;
}
.reanet-chat-header-title .main {
  font-weight: 600;
  font-size: 14px;
}
.reanet-chat-header-title .sub {
  font-size: 12px;
  color: rgba(255,255,255,.8);
  font-weight: 400;
}
.reanet-chat-close {
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  opacity: .9;
  padding: 4px;
  margin: -4px -4px -4px 4px;
}
.reanet-chat-close:hover {
  opacity: 1;
}

/* Область сообщений */
.reanet-chat-body {
  padding: 16px;
  overflow-y: auto;
  background: #f8f9fa;
  height: 100%;
  scroll-behavior: smooth;
}
.reanet-chat-body {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.2) transparent;
}
.reanet-chat-body::-webkit-scrollbar {
  width: 8px;
}
.reanet-chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.reanet-chat-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.2);
  border-radius: 10px;
}
.reanet-chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,.3);
}

/* Пузырьки сообщений — премиальный стиль (как у конкурента: светлые) */
.reanet-chat-bubble {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
  max-width: 85%;
  display: block;
  width: fit-content;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.reanet-chat-bubble.bot {
  background: linear-gradient(180deg, #e8e8e8 0%, #dedede 100%);
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  margin-right: auto;
}

.reanet-chat-bubble.user {
  background: #fff;
  color: #1a1a1a;
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 4px;
  border: 1px solid #e5e5e5;
}

/* Typing indicator */
.reanet-typing {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #e8e8e8 0%, #dedede 100%);
  color: #1a1a1a;
  display: flex;
  gap: 4px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.reanet-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #888;
  animation: reanetTyping .9s infinite ease-in-out;
}
.reanet-typing span:nth-child(2) { animation-delay: .15s; }
.reanet-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes reanetTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* Футер с полями ввода */
.reanet-chat-footer {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #eee;
}

@media (max-width: 767px) {
  .reanet-chat-footer {
    padding: 12px;
  }
}

/* Строка ввода как в мессенджере: поле + иконка справа */
.reanet-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.reanet-chat-input-row .reanet-chat-input {
  flex: 1;
  margin-top: 0;
}
.reanet-chat-input-row .reanet-chat-input:first-child {
  margin-top: 0;
}

/* Поле ввода — округлое, мягкое */
.reanet-chat-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  box-sizing: border-box;
  margin-top: 6px;
  background: #fafafa;
  transition: border-color .2s, background .2s;
}
.reanet-chat-input:focus {
  outline: none;
  border-color: #bbb;
  background: #fff;
}
.reanet-chat-input::placeholder {
  color: #999;
}

/* Маленькая кнопка-иконка справа (как в мессенджере) */
.reanet-chat-btn-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--reanet-btn-from) 0%, var(--reanet-btn-to) 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 2px 4px rgba(0,0,0,.2),
    0 1px 0 rgba(255,255,255,.08) inset;
  transition: transform .15s, box-shadow .15s;
  margin-bottom: 1px; /* лёгкий визуальный подъём, чтобы низ совпадал с полем */
}
.reanet-chat-btn-icon:hover {
  transform: scale(1.05);
  box-shadow:
    0 4px 8px rgba(0,0,0,.25),
    0 1px 0 rgba(255,255,255,.1) inset;
}
.reanet-chat-btn-icon:active {
  transform: scale(0.98);
}
.reanet-chat-btn-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

/* Имя — отдельно, полная ширина */
.reanet-chat-footer > .reanet-chat-input:first-child {
  margin-top: 0;
}

/* Нижняя полоска с подписью (опционально) */
.reanet-chat-footer-strip {
  background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%);
  color: rgba(255,255,255,.8);
  font-size: 11px;
  padding: 8px 12px;
  text-align: center;
  box-shadow: 0 -1px 0 rgba(255,255,255,.05) inset;
}
