/* Чат «Написать оператору»: острые углы, тёмно-синий и оранжевый */
.tl-chat-root [hidden], .tl-chats-columns [hidden] { display: none !important; }
.tl-chat-root, .tl-chat-root * { box-sizing: border-box; }

.tl-chat-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; min-width: 200px;
  border: 1px solid var(--navy); border-radius: 0;
  background: var(--navy); color: #fff;
  font: inherit; font-size: 14px; font-weight: 600; text-align: left;
  cursor: pointer; box-shadow: 0 2px 10px rgba(11, 37, 64, 0.2);
}
.tl-chat-btn:hover { box-shadow: 0 4px 14px rgba(11, 37, 64, 0.3); }
.tl-chat-btn-top { display: flex; align-items: center; gap: 8px; }
.tl-chat-btn-label { flex: 1 1 auto; }
.tl-chat-btn-status { padding-left: 18px; font-size: 12px; font-weight: 400; color: rgba(255, 255, 255, 0.75); }
.tl-chat-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: #9aa5b1; }
.tl-chat-dot.on { background: #1f9d55; box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.25); }
.tl-chat-unread { background: var(--accent); color: #fff; padding: 1px 6px; font-size: 12px; border-radius: 0; }

.tl-chat-panel {
  position: fixed; right: 20px; bottom: 88px; z-index: 1000;
  width: 360px; height: 520px; max-height: calc(100vh - 110px);
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 0;
  box-shadow: 0 8px 28px rgba(11, 37, 64, 0.22);
}
.tl-chat-panel-header { display: flex; align-items: flex-start; gap: 8px; padding: 12px 16px; background: var(--navy); color: #fff; }
.tl-chat-panel-title { font-size: 15px; font-weight: 700; }
.tl-chat-panel-status { margin-top: 4px; font-size: 12px; line-height: 1.35; color: rgba(255, 255, 255, 0.8); }
.tl-chat-close { margin-left: auto; padding: 0 4px; border: 0; border-radius: 0; background: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }

.tl-chat-messages { flex: 1 1 auto; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.tl-chat-empty { padding: 20px 8px; color: var(--muted); font-size: 14px; text-align: center; }
.tl-chat-msg { max-width: 85%; display: flex; flex-direction: column; }
.tl-chat-msg.from-client { align-self: flex-end; align-items: flex-end; }
.tl-chat-msg.from-operator { align-self: flex-start; align-items: flex-start; }
.tl-chat-bubble { padding: 8px 10px; border: 1px solid var(--line); border-radius: 0; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-chat-msg.from-client .tl-chat-bubble { background: #eaf0f6; border-color: #d5e0ec; }
.tl-chat-msg.from-operator .tl-chat-bubble { background: #f3f5f7; }
.tl-chat-time { margin-top: 2px; font-size: 11px; color: var(--muted); }

.tl-chat-form { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.tl-chat-contact, .tl-chat-textarea, .tl-chat-reply-text {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 0;
  font: inherit; font-size: 14px; color: var(--navy); background: #fff;
}
.tl-chat-textarea, .tl-chat-reply-text { resize: vertical; }
.tl-chat-send, .tl-chat-reply-btn {
  padding: 10px 14px; border: 1px solid var(--accent); border-radius: 0;
  background: var(--accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tl-chat-send:disabled { opacity: 0.6; cursor: default; }
.tl-chat-send:hover, .tl-chat-reply-btn:hover { filter: brightness(0.95); }
.tl-chat-error, .tl-chat-inline-error { color: #b42318; font-size: 13px; }
.tl-chat-error { padding: 0 12px; }

/* Раздел оператора */
.tl-chats-header { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tl-chats-header h1 { margin: 0 12px 0 0; }
.tl-presence-toggle {
  padding: 10px 16px; border: 1px solid var(--navy); border-radius: 0;
  background: #fff; color: var(--navy); font: inherit; font-weight: 600; cursor: pointer;
}
.tl-presence-toggle.on { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.tl-presence-note { color: var(--muted); font-size: 13px; }
.tl-chats-columns { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.tl-chats-list { max-height: calc(100vh - 220px); overflow-y: auto; border: 1px solid var(--line); background: var(--bg); }
.tl-chat-item { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; color: inherit; text-decoration: none; }
.tl-chat-item:hover { background: #f3f5f7; text-decoration: none; }
.tl-chat-item.active { background: #eaf0f6; }
.tl-chat-item.unread { border-left-color: var(--accent); }
.tl-chat-item.unread .tl-chat-item-contact::after { content: " • новое"; color: var(--accent); font-size: 12px; }
.tl-chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tl-chat-item-contact { font-weight: 700; color: var(--navy); }
.tl-chat-item-time, .tl-chat-item-page { font-size: 12px; color: var(--muted); }
.tl-chat-item-page { margin-top: 2px; overflow-wrap: anywhere; }
.tl-chat-item-last { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-chat-detail { display: flex; flex-direction: column; min-height: 480px; border: 1px solid var(--line); background: var(--bg); }
.tl-chat-detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tl-chat-detail-contact { font-weight: 700; color: var(--navy); }
.tl-chat-detail-page { font-size: 13px; overflow-wrap: anywhere; }
.tl-chat-detail-messages { flex: 1 1 auto; max-height: calc(100vh - 360px); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tl-chat-detail-messages .tl-chat-msg { max-width: 75%; }
.tl-chat-reply { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.tl-chat-reply-btn { align-self: flex-start; }

@media (max-width: 800px) { .tl-chats-columns { grid-template-columns: 1fr; } }
@media (max-width: 480px) {
  .tl-chat-btn { right: 8px; bottom: 8px; min-width: 0; }
  .tl-chat-panel { right: 0; bottom: 0; width: 100%; height: 100%; max-height: 100%; }
}
@media print { .tl-chat-root { display: none !important; } }

/* Менеджер: быстрая корзина из сообщения клиента */
.tl-quick-cart { border-top: 1px solid var(--line); padding: 10px 12px; background: #fff7f3; }
.tl-quick-cart summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.tl-qc-hint { margin: 8px 0; font-size: 13px; color: var(--muted); }
.tl-qc-text { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 0; font: inherit; font-size: 14px; resize: vertical; }
.tl-qc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tl-qc-actions button, .tl-qc-insert { padding: 8px 12px; border: 1px solid var(--navy); border-radius: 0; background: #fff; color: var(--navy); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tl-qc-go { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.tl-qc-go:disabled { opacity: 0.6; }
.tl-qc-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; background: #fff; }
.tl-qc-table th, .tl-qc-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.tl-qc-table td:last-child, .tl-qc-table th:last-child { text-align: right; white-space: nowrap; }
.tl-qc-miss { color: #b42318; font-size: 13px; }
.tl-qc-wait { color: var(--muted); font-size: 13px; }
.tl-qc-link { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-qc-link input { flex: 1 1 260px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 0; font: inherit; font-size: 13px; }
.tl-qc-link a { font-size: 13px; }

.tl-qc-pack td { background: #fff1f0; }
.tl-qc-pack strong { color: #b42318; font-size: 12px; }

.tl-chat-root[hidden] { display: none !important; }

/* Пульс зелёной точки «онлайн» */
.tl-chat-dot.on { animation: tl-dot-pulse 2s ease-out infinite; }
@keyframes tl-dot-pulse { 0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0.55); } 70% { box-shadow: 0 0 0 7px rgba(31, 157, 85, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); } }
