/* Онлайн-чат Пермь Букет (shop). Самодостаточные стили: собственные токены,
 * без опоры на тему Woodmart. Всё под .pb-chat-root, чтобы не задеть сайт.
 * Значения 1:1 с PWA-виджетом (SiteChat.tsx + globals.css .pb-chat-*). */

.pb-chat-root {
  --pb-bg: #ffffff;
  --pb-fg: #1a1a1a;
  --pb-muted: #6b7280;
  --pb-card: #f4f4f5;
  --pb-border: #e5e7eb;
  --pb-flame: #f97316;
  --pb-flame-fg: #ffffff;
  --pb-online: #16a34a;
}

.pb-chat-root,
.pb-chat-root * {
  box-sizing: border-box;
}

/* ---- Лаунчер ---- */
.pb-chat-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999990;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--pb-fg);
  color: var(--pb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.pb-chat-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--pb-flame);
  color: var(--pb-flame-fg);
  font: 400 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Пульсация лаунчера при непрочитанных. */
@keyframes pb-chat-pulse {
  0% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(249, 115, 22, 0.55);
  }
  70% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), 0 0 0 12px rgba(249, 115, 22, 0);
  }
  100% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(249, 115, 22, 0);
  }
}
.pb-chat-fab--alert {
  animation: pb-chat-pulse 2s ease-out infinite;
}

/* ---- Панель ---- */
.pb-chat-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999990;
  width: 340px;
  max-width: calc(100vw - 36px);
  height: 480px;
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--pb-fg);
  transform-origin: bottom right;
  animation: pb-chat-panel-in 0.18s ease-out;
}
@keyframes pb-chat-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pb-chat-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--pb-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.pb-chat-head__title {
  display: block;
}
.pb-chat-brand {
  display: block;
  font-weight: 500;
  font-size: 14px;
  color: var(--pb-fg);
}
.pb-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--pb-muted);
}
.pb-chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pb-online);
}
.pb-chat-dot--off {
  background: var(--pb-muted);
}
.pb-chat-iconbtn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--pb-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pb-chat-mute {
  margin-left: auto;
}

/* ---- Лог ---- */
.pb-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pb-chat-messages,
.pb-chat-extras {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pb-chat-msg {
  max-width: 82%;
  border-radius: 14px;
  padding: 8px 11px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: pb-chat-msg-in 0.22s ease-out;
}
@keyframes pb-chat-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.pb-chat-msg--me {
  align-self: flex-end;
  background: var(--pb-fg);
  color: var(--pb-bg);
  border-bottom-right-radius: 4px;
}
.pb-chat-msg--op {
  align-self: flex-start;
  background: var(--pb-card);
  color: var(--pb-fg);
  border: 1px solid var(--pb-border);
  border-bottom-left-radius: 4px;
}
.pb-chat-msg--img {
  padding: 4px;
}
.pb-chat-photo {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  display: block;
}
.pb-chat-link {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}
.pb-chat-cta {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--pb-flame);
  color: var(--pb-flame-fg);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  width: fit-content;
}
/* Маркер статуса сообщения посетителя (галочки) — нижний правый край бабла. */
.pb-chat-ticks {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  margin-right: -2px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.7;
}
.pb-chat-ticks svg {
  display: block;
}
.pb-chat-msg--me .pb-chat-ticks {
  color: var(--pb-bg);
}

/* ---- Быстрые вопросы ---- */
.pb-chat-quickwrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.pb-chat-quick {
  max-width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--pb-border);
  background: var(--pb-bg);
  color: var(--pb-fg);
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pb-chat-quick:hover {
  border-color: var(--pb-fg);
  background: var(--pb-card);
}

/* ---- Ночная форма / телефон ---- */
.pb-chat-offcard,
.pb-chat-phonecard {
  align-self: stretch;
  background: var(--pb-card);
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  padding: 12px;
}
.pb-chat-offtext {
  font-size: 13px;
  line-height: 1.5;
  color: var(--pb-fg);
  margin-bottom: 10px;
}
.pb-chat-phonecard .pb-chat-offtext {
  line-height: 1.45;
  margin-bottom: 8px;
}
.pb-chat-field {
  width: 100%;
  font-size: 16px;
  padding: 0 10px;
  height: 38px;
  border: 1px solid var(--pb-border);
  border-radius: 8px;
  background: var(--pb-bg);
  color: var(--pb-fg);
  margin-bottom: 8px;
  font-family: inherit;
}
.pb-chat-textarea {
  height: auto;
  padding: 8px 10px;
  resize: none;
}
.pb-chat-bigbtn {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--pb-flame);
  color: var(--pb-flame-fg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.pb-chat-bigbtn:disabled,
.pb-chat-okbtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pb-chat-phonerow {
  display: flex;
  gap: 8px;
}
.pb-chat-phonerow .pb-chat-field {
  flex: 1;
  margin-bottom: 0;
}
.pb-chat-okbtn {
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: var(--pb-flame);
  color: var(--pb-flame-fg);
  font-size: 13px;
  cursor: pointer;
}
.pb-chat-skip {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--pb-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

/* ---- Композер ---- */
.pb-chat-composer {
  padding: 10px 12px;
  border-top: 1px solid var(--pb-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.pb-chat-attach {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--pb-border);
  border-radius: 10px;
  background: var(--pb-card);
  color: var(--pb-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pb-chat-input {
  flex: 1;
  height: 38px;
  font-size: 16px;
  padding: 0 12px;
  border: 1px solid var(--pb-border);
  border-radius: 10px;
  background: var(--pb-card);
  color: var(--pb-fg);
  font-family: inherit;
}
.pb-chat-sendbtn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: none;
  border-radius: 10px;
  background: var(--pb-flame);
  color: var(--pb-flame-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
 * Защита от стилей темы Woodmart.
 * Тема красит button/input своими background/border/border-radius/
 * padding/height/box-shadow и форсит button{position:relative}.
 * Бьём по .pb-chat-root <el> с !important (специфичность 0,2,0 +
 * !important перекрывает тему). Значения — те же, что в классах выше.
 * ============================================================ */
.pb-chat-root button,
.pb-chat-root input,
.pb-chat-root textarea {
  font-family: inherit !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  text-shadow: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  line-height: normal !important;
  margin: 0 !important;
  outline: none;
}

.pb-chat-root .pb-chat-fab {
  position: fixed !important;
  right: 18px !important;
  bottom: 18px !important;
  z-index: 999990 !important;
  width: 56px !important;
  height: 56px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: var(--pb-fg) !important;
  color: var(--pb-bg) !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18) !important;
}

.pb-chat-root .pb-chat-panel {
  position: fixed !important;
  right: 18px !important;
  bottom: 18px !important;
  z-index: 999990 !important;
}

.pb-chat-root .pb-chat-iconbtn {
  width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--pb-muted) !important;
  box-shadow: none !important;
}

.pb-chat-root .pb-chat-quick {
  padding: 8px 12px !important;
  border-radius: 14px !important;
  border: 1px solid var(--pb-border) !important;
  background: var(--pb-bg) !important;
  color: var(--pb-fg) !important;
  box-shadow: none !important;
  line-height: 1.35 !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  text-align: left !important;
}

/* Reset выше ставит margin:0 на все button/input — возвращаем нужные отступы. */
.pb-chat-root .pb-chat-mute {
  margin-left: auto !important;
}
.pb-chat-root .pb-chat-field {
  margin-bottom: 8px !important;
}
.pb-chat-root .pb-chat-phonerow .pb-chat-field {
  margin-bottom: 0 !important;
}
.pb-chat-root .pb-chat-skip {
  margin-top: 8px !important;
}

.pb-chat-root .pb-chat-offcard,
.pb-chat-root .pb-chat-phonecard {
  border-radius: 12px !important;
  padding: 12px !important;
}

.pb-chat-root .pb-chat-field {
  height: 38px !important;
  padding: 0 10px !important;
  border: 1px solid var(--pb-border) !important;
  border-radius: 8px !important;
  background: var(--pb-bg) !important;
  color: var(--pb-fg) !important;
  font-size: 16px !important;
}
.pb-chat-root .pb-chat-textarea {
  height: auto !important;
  padding: 8px 10px !important;
}

.pb-chat-root .pb-chat-bigbtn {
  width: 100% !important;
  height: 40px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 8px !important;
  background: var(--pb-flame) !important;
  color: var(--pb-flame-fg) !important;
  box-shadow: none !important;
}
.pb-chat-root .pb-chat-okbtn {
  height: 38px !important;
  padding: 0 12px !important;
  border: none !important;
  border-radius: 8px !important;
  background: var(--pb-flame) !important;
  color: var(--pb-flame-fg) !important;
  box-shadow: none !important;
}
.pb-chat-root .pb-chat-skip {
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--pb-muted) !important;
  box-shadow: none !important;
}

.pb-chat-root .pb-chat-cta {
  padding: 7px 12px !important;
  border-radius: 9px !important;
  border: none !important;
  background: var(--pb-flame) !important;
  color: var(--pb-flame-fg) !important;
  box-shadow: none !important;
}

.pb-chat-root .pb-chat-composer .pb-chat-attach {
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  border: 1px solid var(--pb-border) !important;
  border-radius: 10px !important;
  background: var(--pb-card) !important;
  color: var(--pb-muted) !important;
  box-shadow: none !important;
}
.pb-chat-root .pb-chat-composer .pb-chat-input {
  height: 38px !important;
  padding: 0 12px !important;
  border: 1px solid var(--pb-border) !important;
  border-radius: 10px !important;
  background: var(--pb-card) !important;
  color: var(--pb-fg) !important;
  font-size: 16px !important;
}
.pb-chat-root .pb-chat-composer .pb-chat-sendbtn {
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 10px !important;
  background: var(--pb-flame) !important;
  color: var(--pb-flame-fg) !important;
  box-shadow: none !important;
}

/* На мобиле/планшете у Woodmart своя нижняя панель навигации
 * (Меню/Избранное/Корзина) — приподнимаем над ней. */
@media (max-width: 1024px) {
  .pb-chat-root .pb-chat-fab {
    bottom: 74px !important;
  }
  .pb-chat-root .pb-chat-panel {
    bottom: 74px !important;
  }
}

@media (max-width: 480px) {
  .pb-chat-panel {
    width: calc(100vw - 24px);
    height: 70vh;
    max-height: calc(100dvh - 96px);
  }
  .pb-chat-root .pb-chat-panel {
    right: 12px !important;
    bottom: 74px !important;
  }
  .pb-chat-root .pb-chat-fab {
    right: 14px !important;
    bottom: 74px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb-chat-fab--alert,
  .pb-chat-panel,
  .pb-chat-msg {
    animation: none;
  }
}
