/* ============================================================
   creditfabrika.ru — UX Enhancements + Chat Assistant
   Version: 10 (2026)
   ============================================================ */

/* === 1. STICKY CTA-БАР НА МОБИЛЬНЫХ === */
.cf-sticky-cta {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(135deg, #1a3c5e 0%, #2563eb 100%);
  padding: 12px 16px;
  z-index: 9000;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15);
  justify-content: center;
  gap: 10px;
}
.cf-sticky-cta a {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  white-space: nowrap;
}
.cf-sticky-cta .cf-cta-calc {
  background: #ffcc02;
  color: #1a3c5e !important;
}
.cf-sticky-cta .cf-cta-call {
  background: rgba(255,255,255,.15);
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.3);
}
@media (max-width: 768px) {
  .cf-sticky-cta { display: flex; }
  body { padding-bottom: 70px; }
}

/* === 2. TOAST-УВЕДОМЛЕНИЯ === */
.cf-toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.cf-toast {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: cfToastIn .3s ease;
  border-left: 4px solid #2563eb;
  font-size: .95rem;
}
.cf-toast.cf-toast-success { border-left-color: #16a34a; }
.cf-toast.cf-toast-error { border-left-color: #dc2626; }
.cf-toast.cf-toast-warning { border-left-color: #ffcc02; }
.cf-toast .cf-toast-icon { font-size: 1.3rem; flex-shrink: 0; }
.cf-toast .cf-toast-text { flex: 1; color: #333; }
.cf-toast.cf-toast-out { animation: cfToastOut .3s ease forwards; }
@keyframes cfToastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes cfToastOut { to { transform: translateX(120%); opacity: 0; } }

/* === 3. SCROLL-TO-TOP === */
.cf-scroll-top {
  position: fixed;
  bottom: 92px;
  right: 95px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e0e4e8;
  color: #1a7fd6;
  cursor: pointer;
  z-index: 10001;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .25s ease;
}
.cf-scroll-top:hover {
  background: #2a9ef1;
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(42,158,241,.35);
}
.cf-scroll-top svg {
  width: 20px;
  height: 20px;
}
@media (max-width: 768px) {
  .cf-scroll-top { bottom: 150px; right: 20px; width: 44px; height: 44px; }
}

/* === 4. БЕЙДЖ "ОНЛАЙН" НА СОТРУДНИКОВ === */
.team_photo_block { position: relative; }
.team_photo_block .cf-online-badge {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 14px; height: 14px;
  background: #16a34a;
  border: 3px solid #fff;
  border-radius: 50%;
  z-index: 2;
  animation: cfPulse 2s infinite;
}
@keyframes cfPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); } 50% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } }

/* === 5. СЧЁТЧИК КЛИЕНТОВ === */
.cf-counter-section {
  background: #f8f9fa;
  padding: 30px 0;
  text-align: center;
}
.cf-counter-num {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1a3c5e;
  line-height: 1;
}
.cf-counter-label {
  font-size: 1rem;
  color: #666;
  margin-top: 8px;
}

/* === 6. ЧАТ ПОДДЕРЖКИ — стиль Telegram === */
.cf-chat-toggle {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a9ef1 0%, #1a7fd6 100%);
  border: none;
  cursor: pointer;
  z-index: 10001;
  box-shadow: 0 8px 30px rgba(42,158,241,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.cf-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 12px 40px rgba(42,158,241,.55); }
.cf-chat-toggle:active { transform: scale(0.95); }
.cf-chat-toggle svg { width: 30px; height: 30px; fill: #fff; }
.cf-chat-toggle .cf-chat-badge {
  position: absolute;
  top: 0; right: 0;
  background: #ff3b30;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  min-width: 22px; height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(255,59,48,.4);
}

.cf-chat-window {
  position: fixed;
  bottom: 94px; right: 20px;
  width: 390px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.04);
  z-index: 10001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: cfChatOpen .35s cubic-bezier(.4,0,.2,1);
}
.cf-chat-window.cf-open { display: flex; }
@keyframes cfChatOpen { from { transform: translateY(30px) scale(.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

.cf-chat-header {
  background: linear-gradient(135deg, #1a7fd6 0%, #2a9ef1 100%);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.cf-chat-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,.15);
}
.cf-chat-header .cf-chat-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  overflow: hidden;
}
.cf-chat-header .cf-chat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.cf-chat-header .cf-chat-info { flex: 1; }
.cf-chat-header .cf-chat-name { font-weight: 600; font-size: 1.02rem; letter-spacing: -.01em; }
.cf-chat-header .cf-chat-status {
  font-size: .78rem;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.cf-chat-header .cf-chat-status::before {
  content: '';
  width: 8px; height: 8px;
  background: #4cd964;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(76,217,100,.6);
}
.cf-chat-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.cf-chat-close:hover { background: rgba(255,255,255,.3); }

.cf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #e7ebf0;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><circle cx="20" cy="20" r="1" fill="%23c8d0db"/></svg>');
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.cf-chat-messages::-webkit-scrollbar { width: 5px; }
.cf-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cf-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

.cf-chat-msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
  animation: cfMsgIn .25s ease;
}
@keyframes cfMsgIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cf-chat-msg.cf-bot {
  align-self: flex-start;
  background: #fff;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  color: #1a1a1a;
}
.cf-chat-msg.cf-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2a9ef1 0%, #1a7fd6 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 8px rgba(42,158,241,.25);
}

.cf-chat-typing {
  align-self: flex-start;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: none;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.cf-chat-typing span {
  width: 7px; height: 7px;
  background: #adb5bd;
  border-radius: 50%;
  animation: cfTyping 1.4s infinite;
}
.cf-chat-typing span:nth-child(2) { animation-delay: .2s; }
.cf-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cfTyping { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* === 7. БЫСТРЫЕ ОТВЕТЫ (кнопки-подсказки) === */
.cf-chat-quick {
  padding: 8px 12px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  background: #fff;
  border-top: 1px solid #e9ecef;
}
.cf-chat-quick:empty { display: none; }
.cf-chat-quick button {
  background: #eef4fb;
  border: 1px solid #d0e3f7;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: .84rem;
  cursor: pointer;
  transition: all .15s;
  color: #1a7fd6;
  font-weight: 500;
}
.cf-chat-quick button:hover {
  background: #2a9ef1;
  color: #fff;
  border-color: #2a9ef1;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(42,158,241,.3);
}

/* === 8. ФОРМА КОНТАКТОВ === */
.cf-chat-form {
  padding: 12px 14px;
  background: #f8fafe;
  border-top: 1px solid #e9ecef;
  flex-direction: column;
  gap: 8px;
}
.cf-chat-form input {
  width: 100%;
  border: 1px solid #d0e3f7;
  border-radius: 10px;
  padding: 11px 15px;
  font-size: .9rem;
  outline: none;
  background: #fff;
  box-sizing: border-box;
  transition: all .15s;
}
.cf-chat-form input:focus {
  border-color: #2a9ef1;
  box-shadow: 0 0 0 3px rgba(42,158,241,.1);
}
.cf-chat-form input::placeholder { color: #adb5bd; }
.cf-chat-form button {
  background: linear-gradient(135deg, #2a9ef1 0%, #1a7fd6 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(42,158,241,.25);
}
.cf-chat-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(42,158,241,.35);
}
.cf-chat-form button:active { transform: translateY(0); }

.cf-chat-input {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 8px;
  align-items: center;
}
.cf-chat-input input {
  flex: 1;
  border: 1px solid #e0e4e8;
  border-radius: 22px;
  padding: 11px 18px;
  font-size: .9rem;
  outline: none;
  background: #f5f7fa;
  transition: all .15s;
}
.cf-chat-input input:focus {
  border-color: #2a9ef1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(42,158,241,.1);
}
.cf-chat-input input::placeholder { color: #adb5bd; }
.cf-chat-input button {
  background: linear-gradient(135deg, #2a9ef1 0%, #1a7fd6 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px; height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(42,158,241,.3);
}
.cf-chat-input button:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(42,158,241,.4); }
.cf-chat-input button:active { transform: scale(0.95); }
.cf-chat-input button svg { width: 18px; height: 18px; fill: #fff; }

@media (max-width: 768px) {
  .cf-chat-window { bottom: 0; right: 0; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .cf-chat-toggle { bottom: 80px; width: 56px; height: 56px; }
  .cf-chat-toggle svg { width: 26px; height: 26px; }
}

/* === ФИКС ШАПКИ (мягкие правила, не перебивают оригинал) === */
.h_menu_block ul li { margin: 0 5px; }
.h_phone_block a { font-weight: 700; }
.foo_phone_box a { font-weight: 700; }
