/* ===== КНОПКА ВЫЗОВА ===== */
.chat-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #ffd54f;
  color: #111;
  padding: 14px 22px;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  z-index: 999999;
}

/* ===== ОКНО ===== */
.chat-box {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 340px;
  height: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  z-index: 999999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-box.hidden { display: none; }

/* ===== HEADER ===== */
.chat-header {
  background: #ffd54f;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-close {
  margin-left: auto;
  cursor: pointer;
  font-size: 22px;
}

/* ===== СООБЩЕНИЯ ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f3f3f3;
}

/* ===== СООБЩЕНИЕ ===== */
.msg {
  display: flex;
  margin-bottom: 10px;
  max-width: 100%;
}

/* ===== АВАТАР ===== */
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ddd;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ===== ОБЁРТКА ===== */
.msg-wrap {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

/* ===== ИМЯ ===== */
.msg-name {
  font-size: 11px;
  color: #666;
  margin-bottom: 2px;
}

/* ===== БАБЛ ===== */
.msg-bubble {
  background: #fff;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* ===== META ===== */
.msg-meta {
  align-self: flex-end;
  font-size: 10px;
  opacity: .8;
  display: flex;
  gap: 4px;
}

/* ===== ОПЕРАТОР ===== */
.msg.operator {
  align-items: flex-start;
}

.msg.operator .msg-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.msg.operator .msg-meta {
  color: #999;
}

/* ===== ВЫ ===== */
.msg.client {
  justify-content: flex-end;
}

.msg.client .msg-wrap {
  align-items: flex-end;
}

.msg.client .msg-bubble {
  background: #34c759;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.client .msg-meta {
  color: #eaffea;
}

/* ===== ГАЛОЧКИ ===== */
.msg-status {
  font-size: 11px;
}

.msg-status.read {
  color: #1a73e8;
}

/* ===== TYPING ===== */
.msg.typing .msg-bubble {
  opacity: .7;
  font-style: italic;
}

/* =====================================================
   OFFLINE CTA + FORM — ФИНАЛ (МИКРО)
===================================================== */

/* CTA */
.chat-cta {
  background: #f5f5f5;
  padding: 12px;
  font-size: 13px;
  line-height: 1.35;
  border-top: 1px solid #e6e6e6;
  flex-shrink: 0;
}

.chat-cta::after {
  content: '';
  display: block;
  height: 1px;
  margin-top: 10px;
  background: linear-gradient(to right, transparent, #ddd, transparent);
}

/* ===== ФОРМА (ПК — ЕЩЁ −2px) ===== */
.chat-body {
  padding: 10px 14px 12px; /* ⬅️ финально плотно */
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-shrink: 0;
}

.chat-body textarea,
.chat-body input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ddd;
  font-size: 14px;
}

.chat-body textarea {
  resize: none;
  height: 70px;
}

/* ===== КНОПКА ===== */
.chat-body button {
  margin-top: 4px;
  padding: 14px;
  border-radius: 14px;
  background: #ffd54f;
  border: none;
  font-weight: 700;
  color: #111;
  cursor: pointer;
}

/* ===== MOBILE — ЕЩЁ +4px ===== */
@media (max-width: 480px) {
  .chat-box {
    height: 385px;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
  }

  .chat-body {
    padding-bottom: 12px; /* ⬅️ Mobile: финальный воздух */
  }

  .chat-body button {
    color: #111 !important;
  }
}