/* chatbot.css */
#ts-chatbot-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: "Inter", "Roboto", sans-serif;
}

#ts-chatbot-trigger {
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

#ts-chatbot-trigger.ts-show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#ts-chatbot-trigger.ts-show:hover {
  transform: scale(1.05) translateY(0);
}

.ts-chatbot-bubble {
  background: white;
  padding: 12px 20px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  font-weight: 500;
  color: #333;
  position: relative;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ts-chatbot-bubble.ts-show {
  opacity: 1;
  transform: translateX(0);
}

.ts-chatbot-bubble::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 0 8px 8px;
  border-style: solid;
  border-color: transparent transparent transparent white;
}

.ts-chatbot-icon {
  width: 60px;
  height: 60px;
  background: #ff5e14;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  animation: ts-icon-glow 2s infinite;
}

.ts-chatbot-icon svg {
  width: 30px;
  height: 30px;
  fill: white;
}

#ts-chatbot-window {
  display: none;
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  flex-direction: column;
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

#ts-chatbot-window.ts-open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.ts-chatbot-header {
  background: #ff5e14;
  color: white;
  padding: 15px 20px;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ts-chatbot-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ts-chatbot-avatar-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ts-chatbot-avatar-img-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.ts-chatbot-status-dot {
  position: absolute;
  bottom: 0px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #34C759;
  border: 2px solid #ff5e14;
  border-radius: 50%;
}

.ts-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

#ts-chatbot-close {
  cursor: pointer;
  background: none;
  border: none;
  color: white;
  font-size: 26px;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#ts-chatbot-close:hover {
  opacity: 1;
}

.ts-chatbot-body {
  height: 480px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: #f4f6f8;
  scroll-behavior: smooth;
}

/* Scrollbar styles */
.ts-chatbot-body::-webkit-scrollbar {
  width: 6px;
}
.ts-chatbot-body::-webkit-scrollbar-track {
  background: transparent;
}
.ts-chatbot-body::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 10px;
}

.ts-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: ts-fade-in 0.3s ease;
}

.ts-chat-msg-bot {
  align-items: flex-start;
}

.ts-chat-msg-user {
  align-items: flex-end;
  align-self: flex-end;
}

.ts-chat-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ts-chat-msg-bot .ts-chat-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
}

.ts-chat-msg-user .ts-chat-bubble {
  background: #ff5e14;
  color: white;
  border-bottom-right-radius: 4px;
}

.ts-chat-msg-full {
  max-width: 100%;
  width: 100%;
}

.ts-chat-msg-full-input {
  max-width: 95%;
  width: 100%;
}

.ts-chat-msg-options {
  width: 100%;
}

.ts-chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.ts-chat-options-wrap {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.ts-chat-options-nowrap {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
}

.ts-chat-option-btn {
  background: white;
  border: 1px solid #ff5e14;
  color: #ff5e14;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Для кнопок периодов (в один ряд) */

.ts-chat-option-btn-row {
  flex: 1 1 0;
  padding: 10px 4px;
}

/* Для кнопок локаций (одинаковые карточки) */
.ts-chat-option-btn-card {
  flex: 0 0 calc(50% - 4px);
  width: calc(50% - 4px);
  box-sizing: border-box;
  padding: 10px 12px;
}

@media (hover: hover) {
  .ts-chat-option-btn:hover {
    background: #ff5e14;
    color: white;
  }
}

.ts-btn-twolines {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ts-period-val {
  font-weight: 600;
  font-size: 14px;
}

.ts-period-price {
  font-weight: 500;
  font-size: 12px;
  opacity: 0.8;
  margin-top: 3px;
}

.ts-chat-return-wrap {
  margin-bottom: 5px;
  margin-top: 10px;
}

.ts-chat-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: white;
  border: 1px solid #ccc;
  color: #888;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

@media (hover: hover) {
  .ts-chat-return-btn:hover {
    background: #f4f6f8;
    color: #555;
    border-color: #bbb;
  }
}

.ts-chat-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 5px;
}

.ts-chat-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
}

.ts-chat-input:focus {
  border-color: #ff5e14;
}

.ts-chat-action-btn {
  background: #ff5e14;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease;
}

@media (hover: hover) {
  .ts-chat-action-btn:hover {
    background: #e55412;
  }
}

.ts-chat-input-actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  margin-top: 5px;
}

.ts-chat-back-outline-btn {
  background: white;
  border: 1px solid #ff5e14;
  color: #ff5e14;
  padding: 12px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

@media (hover: hover) {
  .ts-chat-back-outline-btn:hover {
    background: #fff3ed;
  }
}

.ts-btn-center {
  display: block;
  margin: 0 auto;
  min-width: 150px;
}

.ts-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  animation: ts-fade-in 0.3s ease;
}

.ts-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: ts-bounce 1.4s infinite ease-in-out both;
}

.ts-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.ts-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.ts-chat-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-top: 10px;
}

.ts-chat-summary-table tr {
  border-bottom: 1px solid #eee;
}
.ts-chat-summary-table tr:last-child {
  border-bottom: none;
}
.ts-chat-summary-table td {
  padding: 10px;
}
.ts-chat-summary-table td:first-child {
  color: #888;
  width: 40%;
  font-weight: 500;
}
.ts-chat-summary-table td:last-child {
  font-weight: 600;
  color: #333;
}

.ts-error-text {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 4px;
}

.ts-agreement-box {
  margin-top: 15px;
  width: 100%;
}

.ts-ag-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: #555;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
}

.ts-ag-label input {
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

@keyframes ts-bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes ts-icon-glow {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

@keyframes ts-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  /* Центрируем окно чата по горизонтали на весь экран */
  #ts-chatbot-window {
    position: fixed;
    width: 90vw;
    height: 75vh;
    max-height: calc(100svh - 120px);
    left: 5vw;
    right: auto;
    bottom: 90px;
    z-index: 99999999;
  }
  
  .ts-chatbot-body {
    flex: 1;
    height: 100%;
    max-height: none;
    overflow-y: auto;
  }

  /* Размещаем приветственное сообщение строго под фото с ограничением ширины экрана */
  #ts-chatbot-trigger {
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 10px;
  }
  
  .ts-chatbot-bubble {
    white-space: normal;
    text-align: center;
    max-width: 65vw;
  }
  
  /* Разворачиваем стрелочку вверх к аватару Марека */
  .ts-chatbot-bubble::after {
    top: -8px;
    right: 22px;
    transform: none;
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent white transparent;
  }

  /* Предотвращаем автоматический зум на iOS при клике на поле ввода */
  .ts-chat-input {
    font-size: 16px;
  }
}
