/* ============================================================
   Тик — чат-консультант
   ============================================================ */

.tik-widget { position: fixed; right: 22px; bottom: 24px; z-index: 720; }

.tik-fab {
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px 0 14px; height: 56px;
  border-radius: var(--r-full);
  background: linear-gradient(165deg, #4d8fb8 0%, #2c5778 32%, #2c5778 68%, #3a6d94 100%);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.2),
    0 8px 24px rgba(44,87,120,.38);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease);
}
.tik-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(44,87,120,.45); }
.tik-fab__icon { display: flex; align-items: center; justify-content: center; }
.tik-fab__label {
  font-weight: 700; font-size: .95rem; letter-spacing: .02em;
  font-family: var(--font-display);
}

.tik-panel {
  position: absolute; right: 0; bottom: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100dvh - 120px));
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--stone);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.tik-panel[hidden] { display: none !important; }

.tik-panel__head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #2c5778, #3a6d94);
  color: #fff;
}
.tik-panel__avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: #fff;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.tik-panel__avatar img {
  width: 100%; height: 100%; object-fit: contain;
}
.tik-panel__meta { flex: 1; min-width: 0; }
.tik-panel__title-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.tik-panel__name {
  font-family: var(--font-display);
  font-size: 1.08rem; line-height: 1.2;
  color: #fff;
  font-weight: 600;
}
.tik-panel__online {
  font-size: .72rem; font-weight: 600;
  color: #5ee08f;
  letter-spacing: .02em;
}
.tik-panel__online::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px; margin-right: 5px;
  border-radius: 50%;
  background: #5ee08f;
  box-shadow: 0 0 0 2px rgba(94,224,143,.25);
  vertical-align: middle;
}
.tik-panel__role { display: block; font-size: .76rem; color: rgba(255,255,255,.88); margin-top: 2px; }
.tik-panel__close {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); color: #fff;
  transition: background var(--t-fast) var(--ease);
}
.tik-panel__close:hover { background: rgba(255,255,255,.22); }

.tik-panel__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--cream);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.tik-panel__messages {
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
}

.tik-panel__chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 16px 16px;
}
.tik-panel__chips:empty { display: none; padding: 0; }

.tik-msg {
  max-width: 88%; padding: 10px 14px;
  border-radius: 16px; font-size: .9rem; line-height: 1.5;
  animation: tikMsgIn .25s var(--ease);
}
@keyframes tikMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tik-msg--bot {
  align-self: flex-start;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--stone);
  border-bottom-left-radius: 4px;
}
.tik-msg--user {
  align-self: flex-end;
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tik-msg--typing {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--stone);
  color: var(--graphite);
  font-size: .82rem;
}
.tik-msg--typing::after {
  content: '…';
  animation: tikDots 1.2s steps(4, end) infinite;
}
@keyframes tikDots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

.tik-panel__chips:empty { display: none; padding: 0; }
.tik-chips--contact { gap: 10px; }

.tik-chip {
  padding: 8px 14px; border-radius: var(--r-full);
  background: var(--paper); border: 1px solid var(--stone);
  font-size: .82rem; font-weight: 500; color: var(--navy);
  transition: all var(--t-fast) var(--ease);
}
.tik-chip--with-icon {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 10px;
}
.tik-chips--contact .tik-chip--with-icon {
  flex: 1 1 calc(50% - 5px);
  min-width: calc(50% - 5px);
  justify-content: flex-start;
}
.tik-chip__icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tik-chip__icon svg { width: 20px; height: 20px; display: block; }
.tik-chip__text { line-height: 1.2; }
.tik-chip:hover {
  border-color: var(--navy);
  background: var(--navy-soft);
}

.tik-panel__compose {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--stone);
  background: var(--paper);
}
.tik-panel__compose[hidden] { display: none !important; }
.tik-panel__input {
  flex: 1; min-width: 0; height: 42px;
  padding: 10px 14px; border-radius: var(--r-full);
  border: 1px solid var(--stone); font-size: .9rem;
}
.tik-panel__input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
.tik-panel__send {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy); color: #fff;
  flex-shrink: 0;
}

.tik-panel__lead {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--stone);
  background: var(--paper);
  display: flex; flex-direction: column; gap: 8px;
}
.tik-panel__lead[hidden] { display: none !important; }
.tik-panel__field-group { display: flex; flex-direction: column; gap: 8px; }
.tik-panel__field-group[hidden] { display: none !important; }
.tik-panel__label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.tik-panel__label--icon {
  display: inline-flex; align-items: center; gap: 7px;
}
.tik-panel__label-icon {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tik-panel__label-icon svg { width: 16px; height: 16px; display: block; }

.tik-panel__field {
  height: 42px; padding: 10px 14px;
  border: 1px solid var(--stone); border-radius: var(--r-md);
  font-size: .9rem;
}
.tik-panel__field:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
.tik-panel__consent {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .74rem; color: var(--graphite); margin: 4px 0 6px;
}
.tik-panel__consent input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--navy); }
.tik-panel__consent a { color: var(--navy); }

.tik-widget.is-open .tik-fab {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

@media (max-width: 767px) {
  .tik-widget { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .tik-fab { height: 52px; padding: 0 16px 0 12px; }
  .tik-panel {
    width: min(360px, calc(100vw - 24px));
    max-height: min(70dvh, 480px);
    bottom: 0;
  }
}
