/* ============================================================
   ShopVasylieva — Чат з підтримкою (плаваюча панель)
   Тригер — іконка в шапці (.icon-btn поруч з перемикачем мови),
   а сама панель переписки спливає знизу праворуч.
   ============================================================ */

.chat-widget-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 460px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9996;
}
.chat-widget-panel.open { display: flex; }

.chat-widget-header {
  background: var(--primary, #5B4FCF);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14.5px;
  flex-shrink: 0;
}
.chat-widget-header button {
  background: none;
  border: none;
  color: #fff;
  opacity: .85;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}
.chat-widget-header button:hover { opacity: 1; }

.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAFAFB;
}
.chat-widget-hint {
  background: var(--primary-light, #EDE9FF);
  color: #3730A3;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.chat-widget-msg { display: flex; }
.chat-widget-msg.customer { justify-content: flex-end; }
.chat-widget-msg.admin { justify-content: flex-start; }
.chat-widget-bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-widget-msg.customer .chat-widget-bubble {
  background: var(--primary, #5B4FCF);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-widget-msg.admin .chat-widget-bubble {
  background: #fff;
  color: var(--dark, #1C1C1E);
  border: 1px solid #EDEDED;
  border-bottom-left-radius: 3px;
}
.chat-widget-time {
  font-size: 10px;
  opacity: .6;
  margin-top: 3px;
  text-align: right;
}

.chat-widget-name-row {
  padding: 10px 14px;
  border-top: 1px solid #F0F0F0;
  flex-shrink: 0;
}
.chat-widget-name-row input {
  width: 100%;
  border: 1.5px solid #E5E5EA;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}
.chat-widget-name-row input:focus { border-color: var(--primary, #5B4FCF); }

.chat-widget-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #F0F0F0;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-widget-input-row textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid #E5E5EA;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  max-height: 100px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.chat-widget-input-row textarea:focus { border-color: var(--primary, #5B4FCF); }
.chat-widget-input-row button {
  background: var(--primary, #5B4FCF);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 15px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background .15s;
}
.chat-widget-input-row button:hover { background: var(--primary-dark, #4338A8); }
.chat-widget-input-row button:disabled { opacity: .5; cursor: default; }

.chat-widget-attach-btn {
  background: none;
  border: none;
  font-size: 19px;
  color: var(--gray4, #8E8E93);
  cursor: pointer;
  flex-shrink: 0;
  padding: 6px;
  border-radius: 8px;
  transition: background .15s;
}
.chat-widget-attach-btn:hover { background: var(--gray, #F5F5F7); }

.chat-widget-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid #F0F0F0;
}
.chat-widget-attach-preview img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #E5E5EA;
}
.chat-widget-attach-preview button {
  background: var(--gray, #F5F5F7);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  color: var(--dark, #1C1C1E);
}

.chat-widget-attach-img {
  display: block;
  max-width: 100%;
  width: 180px;
  height: auto;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: zoom-in;
}

/* ===== Перегляд фото з чату на весь екран (в тій самій вкладці) ===== */
.chat-image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,10,12,.92);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
}
.chat-image-lightbox.open { display: flex; }
.chat-image-lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
}
.chat-image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: .15s;
}
.chat-image-lightbox-close:hover { background: rgba(255,255,255,.25); }

@media (max-width: 480px) {
  /* Плаваюче вікно 70vh посеред екрана — саме те, що ламалось при
     появі клавіатури на мобільній: vh рахується від ПОВНОЇ висоти
     екрана, БЕЗ урахування клавіатури, тому фіксоване вікно "їхало"
     і крізь нього ставало видно сторінку позаду (обрізаний текст,
     кольори товару тощо — саме це було на скріншотах). Замість
     плаваючого вікна на мобільній — повноекранний чат (той самий
     підхід, що вже використовується в адмінському чаті з
     покупцями): просто, надійно, і жодних артефактів клавіатури.
     100dvh (dynamic viewport height) — сучасна одиниця, яка ВРАХОВУЄ
     клавіатуру/адресний рядок; 100vh лишається як fallback для
     старих браузерів, що dvh не підтримують. */
  .chat-widget-panel {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .chat-widget-header {
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .chat-widget-input-row {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
