/* ====== ЭКЗОКОСМИК CHAT WIDGET ====== */

/* Кнопка */
#exocosmic-btn {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  animation: excBounce 2.2s ease-in-out infinite;
  transition: transform 0.2s;
}

#exocosmic-btn:hover { animation-play-state: paused; transform: scale(1.08); }

#exocosmic-avatar-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid transparent;
  background: linear-gradient(135deg, #E13F8A, #c44dff) border-box;
  box-shadow: 0 0 20px rgba(225,63,138,0.6), 0 0 40px rgba(225,63,138,0.3);
  filter: drop-shadow(0 4px 12px rgba(225,63,138,0.5));
}

.exocosmic-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: linear-gradient(135deg, #E13F8A, #c44dff);
  padding: 3px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 10px rgba(225,63,138,0.5);
  white-space: nowrap;
}

.exc-btn-active { animation: none !important; transform: scale(0.95); }

@keyframes excBounce {
  0%, 100% { transform: translateY(0); }
  30%       { transform: translateY(-14px); }
  50%       { transform: translateY(-6px); }
  70%       { transform: translateY(-12px); }
}

/* Окно чата */
#exocosmic-window {
  position: fixed;
  bottom: 190px;
  right: 28px;
  width: 360px;
  max-height: 560px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: rgba(18, 10, 35, 0.97);
  border: 1px solid rgba(225, 63, 138, 0.3);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px rgba(225,63,138,0.2);
  backdrop-filter: blur(20px);
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease;
}

#exocosmic-window.exc-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Хедер */
.exc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(225,63,138,0.25), rgba(196,77,255,0.25));
  border-bottom: 1px solid rgba(225,63,138,0.2);
  flex-shrink: 0;
}

.exc-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(225,63,138,0.6);
  box-shadow: 0 0 12px rgba(225,63,138,0.4);
  flex-shrink: 0;
}

.exc-header-info { flex: 1; }

.exc-header-name {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff79c0, #c44dff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.exc-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.exc-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: excPulse 2s ease-in-out infinite;
}

@keyframes excPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.exc-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.exc-close:hover { color: #fff; background: rgba(225,63,138,0.25); }

/* Сообщения */
.exc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(225,63,138,0.3) transparent;
}

.exc-messages::-webkit-scrollbar { width: 4px; }
.exc-messages::-webkit-scrollbar-thumb { background: rgba(225,63,138,0.4); border-radius: 4px; }

.exc-msg { display: flex; }
.exc-msg-bot  { justify-content: flex-start; }
.exc-msg-user { justify-content: flex-end; }

.exc-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.6;
  word-break: break-word;
}

.exc-msg-bot .exc-bubble {
  background: rgba(225, 63, 138, 0.12);
  border: 1px solid rgba(225, 63, 138, 0.2);
  color: rgba(255,255,255,0.9);
  border-bottom-left-radius: 4px;
}

.exc-msg-user .exc-bubble {
  background: linear-gradient(135deg, #E13F8A, #c44dff);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(225,63,138,0.3);
}

/* Кнопка скачивания внутри пузыря */
.exc-download-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(225,63,138,0.4);
  border-radius: 20px;
  color: #ff79c0;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.exc-download-btn:hover { background: rgba(225,63,138,0.2); border-color: #E13F8A; color: #fff; }

/* Превью изображения (листовка) */
.exc-image-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 10px;
  width: 100%;
}
.exc-preview-img {
  width: 100%;
  max-width: 240px;
  border-radius: 10px;
  border: 1px solid rgba(225,63,138,0.3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  cursor: zoom-in;
  transition: transform 0.2s, box-shadow 0.2s;
  object-fit: cover;
}
.exc-preview-img:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 28px rgba(225,63,138,0.35);
}

/* Ссылки-кнопки внутри текста пузыря */
.exc-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 4px 2px;
  padding: 5px 13px;
  background: linear-gradient(135deg, rgba(225,63,138,0.15), rgba(196,77,255,0.15));
  border: 1px solid rgba(225,63,138,0.45);
  border-radius: 20px;
  color: #ff79c0;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
  word-break: break-all;
  cursor: pointer;
}
.exc-link-btn:hover {
  background: linear-gradient(135deg, rgba(225,63,138,0.35), rgba(196,77,255,0.3));
  border-color: #E13F8A;
  color: #fff;
  box-shadow: 0 0 12px rgba(225,63,138,0.4);
}

/* Индикатор печати */
.exc-typing-bubble {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  align-items: center;
}
.exc-typing-bubble span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(225,63,138,0.7);
  animation: excTyping 1.2s ease-in-out infinite;
}
.exc-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.exc-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes excTyping {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* Поле ввода */
.exc-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(225,63,138,0.15);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}

#excInput {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(225,63,138,0.25);
  border-radius: 12px;
  padding: 9px 13px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  scrollbar-width: none;
}
#excInput:focus { border-color: rgba(225,63,138,0.6); }
#excInput::placeholder { color: rgba(255,255,255,0.3); }

#excSend {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #E13F8A, #c44dff);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(225,63,138,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
#excSend:hover { transform: scale(1.1); box-shadow: 0 6px 18px rgba(225,63,138,0.6); }
#excSend:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

@media (max-width: 480px) {
  #exocosmic-window { width: calc(100vw - 20px); right: 10px; bottom: 170px; }
  #exocosmic-btn { right: 16px; bottom: 90px; }
}
