/* Чат поддержки (форма → диалог с ИИ). Светлый премиум. */

.chat-wrap { max-width: 780px; margin: 0 auto; }
.chat-start { margin-bottom: 18px; }
.chat-start-error {
  color: var(--amber); background: rgba(192, 127, 46, .1);
  border: 1px solid rgba(192, 127, 46, .3); border-radius: 12px;
  padding: 10px 14px; margin: 0 0 12px; font-size: 14px;
}
.chat-start .lead { margin-bottom: 8px; }
.chat-start .lead.muted { color: var(--muted); font-size: 13.5px; }
.chat-open-form { display: flex; gap: 10px; flex-wrap: wrap; }
.chat-open-input {
  flex: 1; min-width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 10px 14px; color: var(--ink); font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.chat-open-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(180,140,58,.12); }

.chat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(90deg, #fffefb, var(--gold-pale));
  border-bottom: 1px solid var(--line);
}
.chat-head-tools { display: flex; align-items: center; gap: 10px; }
.chat-notif-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-size: 12px; transition: all .15s ease;
}
.chat-notif-btn svg { width: 15px; height: 15px; }
.chat-notif-btn:hover { background: var(--gold-pale); color: var(--gold-deep); border-color: var(--line-gold); }
.chat-notif-btn.on {
  background: rgba(47, 166, 112, .12); color: var(--green);
  border-color: rgba(47, 166, 112, .35);
}
.chat-notif-btn.unavailable { opacity: .5; cursor: not-allowed; }
@media (max-width: 620px) {
  .chat-notif-label { display: none; }
  .chat-notif-btn { padding: 5px 9px; }
}
.chat-head b { font-family: var(--serif); font-size: 17px; color: var(--ink); }
.chat-head small { display: block; color: var(--muted); font-size: 12px; }
.chat-badge { padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chat-badge.open { background: rgba(47, 166, 112, .12); color: var(--green); border: 1px solid rgba(47,166,112,.3); }
.chat-badge.closed { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.chat-body {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; max-height: 60vh; overflow-y: auto;
  background: var(--bg-2);
}
.chat-empty { color: var(--muted); text-align: center; padding: 26px 0; }

.chat-msg { display: flex; gap: 10px; max-width: 84%; flex-wrap: wrap; }
.chat-msg.from { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.operator, .chat-msg.bot { align-self: flex-start; }

.chat-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-pale); color: var(--gold-deep);
  border: 1px solid var(--line);
}
.chat-avatar svg { width: 18px; height: 18px; }
.chat-msg.bot .chat-avatar { background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #fff; }
.chat-msg.operator .chat-avatar { background: #2fa670; color: #fff; }
.chat-msg.from .chat-avatar { background: #29405f; color: var(--gold-soft); }

.chat-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink);
  border-top-left-radius: 3px;
  box-shadow: var(--shadow-s);
}
.chat-msg.from .chat-bubble {
  background: linear-gradient(135deg, #f6e9c8, var(--gold-pale));
  color: var(--ink); border-color: var(--line-gold);
  border-top-left-radius: 14px; border-top-right-radius: 3px;
}
.chat-meta { display: flex; justify-content: space-between; gap: 14px; font-size: 11.5px; margin-bottom: 3px; }
.chat-msg.from .chat-meta b { color: var(--gold-deep); }
.chat-msg.from .chat-meta time { color: var(--muted); }
.chat-msg:not(.from) .chat-meta b { color: var(--gold-deep); }
.chat-msg:not(.from) .chat-meta time { color: var(--muted); }
.chat-text { white-space: normal; word-break: break-word; }

.chat-composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-composer textarea {
  flex: 1; resize: none;
  border: 1px solid var(--line-2); border-radius: 12px;
  padding: 10px 14px; font: inherit; font-size: 14.5px;
  background: var(--bg-2); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.chat-composer textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(180,140,58,.12); }
.chat-composer .btn { flex: none; }
.chat-hint { padding: 6px 18px 12px; font-size: 11.5px; color: var(--muted); background: var(--surface); }

.chat-typing { color: var(--ink-soft); font-size: 13px; font-style: italic; display: flex; align-items: center; gap: 6px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); display: inline-block;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-read-status {
  font-size: 11px; color: var(--muted); align-self: flex-end;
  margin: -6px 4px 0 0;
}
.chat-read-status[data-read="1"] { color: var(--gold-deep); }

.chat-save-link {
  margin: 4px 0; padding: 8px 12px; font-size: 12px; line-height: 1.5;
  background: var(--gold-pale); border: 1px dashed var(--line-gold); border-radius: 10px;
  color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.chat-save-link a { color: var(--gold-deep); word-break: break-all; }
.chat-copy {
  margin-left: auto; border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  color: var(--ink); flex: none; transition: all .15s;
}
.chat-copy:hover { border-color: var(--line-gold); color: var(--gold-deep); }

@media (max-width: 560px) {
  .chat-msg { max-width: 100%; }
}