/* Триллион Кредит — чат-виджет */

#tc-chat *, #tc-chat *::before, #tc-chat *::after {
  box-sizing: border-box;
}

#tc-chat {
  position: fixed;
  z-index: 99999;
  bottom: 24px;
  right: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
}

/* === Не перекрываем существующие плавающие кнопки .floats === */
/* Подвигаем мессенджеры влево от пузыря чата (пузырь 60px + 16px зазор = 76px) */
.floats {
  right: 100px !important;
}
@media (max-width: 768px) {
  .floats {
    right: 88px !important;
    bottom: 24px !important;
  }
  /* Sticky CTA не должен перекрываться */
  body.tc-chat-open .floats { display: none; }
}

/* Кнопка-пузырь */
.tc-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1557FF 0%, #0040DD 100%);
  box-shadow: 0 8px 24px rgba(21,87,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.tc-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(21,87,255,0.55);
}
.tc-chat-bubble svg { width: 28px; height: 28px; }

/* Бейдж с числом непрочитанных */
.tc-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #EF4444;
  color: white;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 50px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
}
.tc-chat-badge.tc-show { display: flex; }

/* Подсказка-всплывашка над кнопкой */
.tc-chat-tooltip {
  position: absolute;
  right: 70px;
  bottom: 12px;
  background: white;
  border: 1px solid #E4E9F4;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #0B1E3D;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(11,30,61,0.12);
  animation: tc-fadeIn 0.4s ease;
  cursor: pointer;
}
.tc-chat-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid white;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

/* Главное окно чата */
.tc-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 48px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(11,30,61,0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: tc-slideUp 0.25s ease;
}
.tc-chat-window.tc-open { display: flex; }

/* Шапка чата */
.tc-chat-header {
  background: linear-gradient(135deg, #1557FF 0%, #0040DD 100%);
  color: white;
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.tc-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tc-chat-header-info { flex: 1; min-width: 0; }
.tc-chat-header-info h4 { font-size: 15px; font-weight: 700; margin: 0 0 2px; line-height: 1.2; }
.tc-chat-header-info p { font-size: 12px; opacity: 0.85; margin: 0; line-height: 1.3; }
.tc-chat-header-info .tc-online { display: inline-flex; align-items: center; gap: 5px; }
.tc-chat-header-info .tc-online::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  animation: tc-pulse 2s infinite;
}
.tc-chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
}
.tc-chat-close:hover { background: rgba(255,255,255,0.25); }

/* Тело — лента сообщений */
.tc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #F4F6FB;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tc-chat-body::-webkit-scrollbar { width: 6px; }
.tc-chat-body::-webkit-scrollbar-thumb { background: #C8D1E6; border-radius: 3px; }

.tc-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: tc-fadeIn 0.25s ease;
}
.tc-msg-from-manager {
  background: white;
  color: #0B1E3D;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(11,30,61,0.05);
}
.tc-msg-from-visitor {
  background: linear-gradient(135deg, #1557FF 0%, #2D6EFF 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.tc-msg-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}
.tc-msg-system {
  text-align: center;
  font-size: 12px;
  color: #6B7A99;
  background: transparent;
  margin: 4px auto;
  align-self: center;
}

/* Форма входа (имя, телефон) */
.tc-chat-init {
  padding: 24px 18px;
  flex: 1;
  overflow-y: auto;
}
.tc-chat-init h5 { font-size: 16px; font-weight: 700; color: #0B1E3D; margin: 0 0 6px; }
.tc-chat-init p { font-size: 13px; color: #6B7A99; margin: 0 0 18px; line-height: 1.5; }
.tc-chat-init label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6B7A99;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.tc-chat-init input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #E4E9F4;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.18s;
}
.tc-chat-init input:focus { border-color: #1557FF; }
.tc-chat-init button {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #1557FF 0%, #2D6EFF 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s;
}
.tc-chat-init button:hover { transform: translateY(-1px); }
.tc-chat-init button:disabled { opacity: 0.6; cursor: wait; }
.tc-chat-init .tc-disclaimer {
  font-size: 11px;
  color: #6B7A99;
  text-align: center;
  margin-top: 10px;
  line-height: 1.5;
}

/* Поле ввода */
.tc-chat-input {
  padding: 12px;
  background: white;
  border-top: 1px solid #E4E9F4;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.tc-chat-input textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #E4E9F4;
  border-radius: 18px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}
.tc-chat-input textarea:focus { border-color: #1557FF; }
.tc-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1557FF 0%, #2D6EFF 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.tc-chat-send:hover { transform: scale(1.06); }
.tc-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.tc-chat-send svg { width: 18px; height: 18px; }

/* Анимации */
@keyframes tc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}
@keyframes tc-slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes tc-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Индикатор «печатает» */
.tc-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px;
}
.tc-typing span {
  width: 8px;
  height: 8px;
  background: #C8D1E6;
  border-radius: 50%;
  animation: tc-typing 1.4s infinite;
}
.tc-typing span:nth-child(2) { animation-delay: 0.2s; }
.tc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tc-typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* Мобиль */
@media(max-width: 480px) {
  #tc-chat { bottom: 16px; right: 16px; }
  .tc-chat-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 8px;
    left: 8px;
  }
  .tc-chat-tooltip { display: none; }
}
