/* Tilda form button — visible, left of AI chat */
.t708__btn {
  position: fixed !important;
  right: 96px !important;
  bottom: 20px !important;
  z-index: 10050 !important;
  margin: 0 !important;
}

.t708 .t708__btn_wrapper {
  width: 64px !important;
  height: 64px !important;
  box-shadow: 0 12px 40px rgba(0, 11, 48, 0.18) !important;
}

[data-record-type="708"] {
  opacity: 1 !important;
  visibility: visible !important;
}

.t708__popup {
  z-index: 10060 !important;
}

.t708_active .t708__popup,
.t708__popup.t708__popup_show {
  z-index: 10060 !important;
}

#ms-chat-root {
  --ms-chat-primary: #3e80b0;
  --ms-chat-primary-dark: #2f6a94;
  --ms-chat-bg: #ffffff;
  --ms-chat-text: #1d1d1d;
  --ms-chat-muted: #6b7280;
  --ms-chat-border: #e5e7eb;
  --ms-chat-shadow: 0 12px 40px rgba(0, 11, 48, 0.18);
  --ms-chat-panel-shadow:
    0 4px 8px rgba(0, 11, 48, 0.08),
    0 16px 36px rgba(0, 11, 48, 0.18),
    0 28px 56px rgba(0, 11, 48, 0.14);
  --ms-chat-panel-ring: rgba(62, 128, 176, 0.45);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10050;
  font-family: Raleway, "TildaSans", Arial, sans-serif;
}

#ms-chat-root * {
  box-sizing: border-box;
}

.ms-chat-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #f0f4f8;
  cursor: pointer;
  box-shadow: var(--ms-chat-shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ms-chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 44px rgba(0, 11, 48, 0.24);
}

.ms-chat-toggle-photo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
}

.ms-chat-toggle-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.ms-chat-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  background: var(--ms-chat-bg);
  border-radius: 16px;
  box-shadow: var(--ms-chat-panel-shadow);
  border: 2px solid var(--ms-chat-panel-ring);
  outline: 1px solid rgba(255, 255, 255, 0.9);
  outline-offset: -1px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#ms-chat-root.ms-chat-open .ms-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

#ms-chat-root.ms-chat-open .ms-chat-toggle {
  transform: scale(0.95);
}

.ms-chat-header {
  background: var(--ms-chat-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ms-chat-header-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.ms-chat-header-sub {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 4px;
  line-height: 1.35;
}

.ms-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  opacity: 0.9;
}

.ms-chat-close:hover {
  opacity: 1;
}

.ms-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.ms-chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.ms-chat-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ms-chat-text);
  border: 1px solid var(--ms-chat-border);
  border-bottom-left-radius: 4px;
}

.ms-chat-msg--user {
  align-self: flex-end;
  background: var(--ms-chat-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ms-chat-msg--typing {
  color: var(--ms-chat-muted);
  font-style: italic;
}

.ms-chat-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--ms-chat-border);
  background: #fff;
}

.ms-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ms-chat-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--ms-chat-border);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ms-chat-text);
}

.ms-chat-input:focus {
  outline: none;
  border-color: var(--ms-chat-primary);
  box-shadow: 0 0 0 2px rgba(62, 128, 176, 0.2);
}

.ms-chat-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--ms-chat-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ms-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ms-chat-send:not(:disabled):hover {
  background: var(--ms-chat-primary-dark);
}

.ms-chat-disclaimer {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ms-chat-muted);
  line-height: 1.35;
}

.ms-chat-form-link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--ms-chat-border);
  border-radius: 8px;
  background: #f0f7fc;
  color: var(--ms-chat-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.ms-chat-form-link:hover {
  background: #e3eff8;
  border-color: var(--ms-chat-primary);
}

.ms-chat-error {
  margin: 0 12px 8px;
  padding: 8px 10px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 12px;
  display: none;
}

.ms-chat-error.is-visible {
  display: block;
}

@media (max-width: 480px) {
  #ms-chat-root {
    right: 12px;
    bottom: 12px;
  }

  .t708__btn {
    right: 84px !important;
    bottom: 12px !important;
  }

  .ms-chat-panel {
    bottom: 68px;
    height: min(480px, calc(100vh - 100px));
  }
}
