/* Корневой контейнер виджета */
.wpoc-root {
  position: fixed;
  z-index: 9999;
  right: 18px;
  bottom: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
    -system-ui, sans-serif;
}

/* ================== КНОПКА-ПУЗЫРЬ ================== */

.wpoc-chat-bubble {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35),
    0 0 0 0.5px rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out,
    opacity 0.2s ease-out;
}

.wpoc-chat-bubble:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45),
    0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

.wpoc-chat-bubble:active {
  transform: translateY(0) scale(0.98);
}

.wpoc-chat-bubble-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f5f5f7;
  margin: 0 2px;
  opacity: 0.5;
  animation: wpoc-pulse 1.4s infinite ease-in-out;
}

.wpoc-chat-bubble-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.wpoc-chat-bubble-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wpoc-pulse {
  0%,
  80%,
  100% {
    transform: scale(0.9);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.wpoc-chat-bubble-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ================== ОКНО ЧАТА ================== */

.wpoc-chat-window {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 320px;
  max-height: 480px;
  background: rgba(250, 250, 252, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3),
    0 0 0 0.5px rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
}

.wpoc-chat-window-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Состояние drag&drop */

.wpoc-chat-window.wpoc-chat-drop-active {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45),
    0 0 0 2px rgba(37, 99, 235, 0.35);
}

.wpoc-chat-window.wpoc-chat-drop-active::after {
  content: "Suelta el archivo aquí";
  position: absolute;
  inset: 48px 18px 64px;
  border-radius: 30px;
  border: 1px dashed rgba(148, 163, 184, 0.8);
  background: rgba(249, 250, 251, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #4b5563;
  pointer-events: none;
}

/* ================== ШАПКА ================== */

.wpoc-chat-header {
  padding: 12px 14px 10px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(
    135deg,
    rgba(245, 246, 250, 0.98),
    rgba(252, 252, 255, 0.98)
  );
}

.wpoc-chat-header-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.wpoc-chat-header-subtitle {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.wpoc-chat-close {
  border: none;
  background: transparent;
  color: #9ca3af;
  float: right;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  margin-top: -18px;
  transition: color 0.15s ease-out;
}

.wpoc-chat-close:hover {
  color: #4b5563;
}

/* ================== ТЕЛО ЧАТА ================== */

.wpoc-chat-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  background: radial-gradient(
    circle at top left,
    #f4f4f7 0,
    #f9fafb 50%,
    #f3f4f6 100%
  );
}

/* --- Форма контакта гостя (имя + email) --- */

.wpoc-chat-contact {
  display: none; /* включается для гостя из JS */
  padding: 10px 14px 6px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
}

.wpoc-chat-field {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 0.5px solid rgba(120, 120, 128, 0.22);
  background: rgba(255, 255, 255, 0.98);
  font-size: 13px;
  outline: none;
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.9);
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out,
    background 0.15s ease-out, transform 0.1s;
}

.wpoc-chat-field:focus {
  border-color: #0a84ff;
  box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.25);
  background: #ffffff;
  transform: translateY(-0.5px);
}

.wpoc-chat-field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25);
}

.wpoc-chat-contact-hint {
  font-size: 11px;
  line-height: 1.4;
  color: #6b7280;
  padding: 2px 2px 4px;
}

/* --- Список сообщений --- */

.wpoc-chat-messages {
  flex: 1 1 auto;
  padding: 8px 10px 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ================== СООБЩЕНИЯ ================== */

.wpoc-message {
  max-width: 80%;
  display: inline-flex;
  flex-direction: column;
  padding: 7px 9px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.wpoc-message-client {
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, #0a84ff, #4d9dff);
  color: #f9fafb;
}

.wpoc-message-operator {
  margin-right: auto;
  border-bottom-left-radius: 4px;
  background: rgba(243, 244, 246, 0.96);
  color: #111827;
}

.wpoc-message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* вложения */

.wpoc-message-attachment {
  font-size: 13px;
  color: #2563eb;
  text-decoration: none;
  word-break: break-word;
}

.wpoc-message-attachment:hover {
  text-decoration: underline;
}

.wpoc-message-meta {
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.6;
  text-align: right;
}

/* ================== "ОПЕРАТОР ПЕЧАТАЕТ" ================== */

.wpoc-chat-typing {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 8px;
  font-size: 11px;
  color: #6b7280;
}

.wpoc-chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #9ca3af;
  animation: wpoc-chat-typing-bounce 1s infinite ease-in-out;
}

.wpoc-chat-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.wpoc-chat-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wpoc-chat-typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* ================== ПОДВАЛ ЧАТА ================== */

.wpoc-chat-footer {
  padding: 8px 8px 9px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  background: rgba(250, 250, 252, 0.96);
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

/* кнопка вложения */

.wpoc-chat-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease-out, box-shadow 0.15s ease-out,
    transform 0.08s;
}

.wpoc-chat-attach-btn:hover {
  background: #e5e7eb;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.35);
  transform: translateY(-0.5px);
}

/* скрываем input файла */
.wpoc-chat-file {
  display: none;
}

/* поле ввода сообщения */

.wpoc-chat-input {
  flex: 1;
  border-radius: 12px;
  border: 0.5px solid rgba(148, 163, 184, 0.6);
  padding: 6px 9px;
  resize: none;
  max-height: 72px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.9);
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out,
    background 0.15s ease-out;
}

.wpoc-chat-input:focus {
  border-color: #0a84ff;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1),
    0 0 0 3px rgba(59, 130, 246, 0.12);
  background: #ffffff;
}

/* кнопка отправки */

.wpoc-chat-send {
  border: none;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #0a84ff, #2563eb);
  color: #f9fafb;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.4),
    0 0 0 0.5px rgba(255, 255, 255, 0.7);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out,
    opacity 0.15s ease-out;
}

/* неактивная (гость не ввёл имя/почту) */
.wpoc-chat-send-disabled,
.wpoc-chat-send[disabled] {
  background: linear-gradient(135deg, #d1d5db, #9ca3af);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.75;
}

.wpoc-chat-send:hover:not(.wpoc-chat-send-disabled):not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.5),
    0 0 0 0.5px rgba(255, 255, 255, 0.9);
}

.wpoc-chat-send:active:not(.wpoc-chat-send-disabled):not([disabled]) {
  transform: translateY(0);
  opacity: 0.9;
}

/* ================== АДАПТИВ ================== */

@media (max-width: 480px) {
  .wpoc-chat-window {
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 70vh;
  }
}
/* Перекрываем стили темы для полей формы чата */
.wpoc-chat-window .wpoc-chat-field {
  width: 100% !important;
  box-sizing: border-box !important;

  /* мягкие "apple"-углы, а не супер-круглые */
  border-radius: 10px !important;

  /* серебристая граница вместо зелёной */
  border: 1px solid rgba(120, 120, 128, 0.3) !important;

  padding: 8px 12px !important;
  font-size: 13px !important;

  background: rgba(255, 255, 255, 0.98) !important;
  outline: none !important;

  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.9) !important;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out,
    background 0.15s ease-out, transform 0.1s;
}

.wpoc-chat-window .wpoc-chat-field:focus {
  border-color: #0a84ff !important;
  box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.25) !important;
  background: #ffffff !important;
  transform: translateY(-0.5px);
}

.wpoc-chat-window .wpoc-chat-field.wpoc-chat-field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25) !important;
}
/* Кнопка подтверждения контакта гостя */
.wpoc-contact-confirm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(135deg, #0a84ff, #2563eb);
  color: #f9fafb;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out,
    opacity 0.12s ease-out;
}

.wpoc-contact-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.45);
}

.wpoc-contact-confirm:active {
  transform: translateY(0);
  opacity: 0.9;
}

/* Кнопка подтверждения контакта гостя – Apple-стиль, поверх reset.css */
.wpoc-chat-window .wpoc-contact-confirm {
  appearance: none !important;
  -webkit-appearance: none !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  width: 100% !important;
  margin-top: 6px !important;
  padding: 7px 14px !important;
  box-sizing: border-box !important;

  border: none !important;
  border-radius: 999px !important;

  background: linear-gradient(135deg, #0a84ff, #2563eb) !important;
  color: #f9fafb !important;

  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;

  cursor: pointer !important;

  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35) !important;
  transition: transform 0.12s ease-out,
              box-shadow 0.12s ease-out,
              opacity 0.12s ease-out !important;
}

.wpoc-chat-window .wpoc-contact-confirm:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.45) !important;
}

.wpoc-chat-window .wpoc-contact-confirm:active {
  transform: translateY(0) !important;
  opacity: 0.9 !important;
}

/* Высота и скролл окна чата */
.wpoc-chat-window {
  max-height: calc(100vh - 32px) !important;
  display: flex !important;
  flex-direction: column !important;
}

.wpoc-chat-body {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
}

.wpoc-chat-messages {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
}
