/* =========================
   Общие стили
   ========================= */

@font-face {
  font-family: "Euclid";
  src: url("SuisseIntl-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --accent: rgb(13, 242, 77);
  --accent-hover: rgb(13, 242, 77);
  --panel-bg: #222;
  --panel-text: #fff;
  --modal-bg: rgba(15, 16, 38, 0.39);
  --chat-border: rgba(41, 52, 77, 0.27);
  --chat-header-bg: #29344d;
  --link: #007bff;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Euclid, sans-serif;
  overflow: hidden; /* как было: страница не скроллится */
}

/* =========================
   IFrame на всю страницу
   ========================= */

#mainFrame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 1;
  display: block;
}

/* =========================
   Виджет ассистента (панель)
   ========================= */

/* Начальное положение виджета задаётся здесь */
.assistant-panel {
  position: fixed;
  display: none; /* изначально скрыт */
  width: 200px;
  height: 130px;
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 10px;
  z-index: 50;

  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;

  /* Начальное положение – центр экрана */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  /* тень */
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

/* Если в JS добавляешь класс во время перетаскивания */
.assistant-panel.dragging {
  cursor: grabbing;
}

/* Анимация перемещения виджета от центра вниз */
@keyframes widgetMoveDown {
  0% {
    top: 50%;
    transform: translate(-50%, -50%);
  }
  100% {
    top: calc(100% - 195px);
    transform: translate(-50%, 0);
  }
}

/* Градиентный бордюр через псевдоэлемент (корректно работает с border-radius) */
.assistant-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: inherit;

  background: linear-gradient(45deg, #4b5c87, #333, #4b5c87);
  background-size: 200% 200%;
  animation: borderAnimation 4s linear infinite;

  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;

  pointer-events: none;
  z-index: 0;
}

/* Контент панели поверх рамки */
.assistant-panel > * {
  position: relative;
  z-index: 1;
}

@keyframes borderAnimation {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Класс, который запускает анимацию перемещения (бордюр анимируется отдельно на ::before) */
.animate-appear {
  animation: widgetMoveDown 4s forwards;
}

/* =========================
   Оверлей затемнения экрана
   ========================= */

#appearanceOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 40;
  pointer-events: none;
  animation: overlayFade 4s forwards;
}

@keyframes overlayFade {
  from { background: rgba(0, 0, 0, 0.7); }
  to { background: rgba(0, 0, 0, 0); }
}

/* =========================
   Панель внутри виджета
   ========================= */

.assistant-panel .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--panel-text);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.info-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: #868484;
  border-radius: 50%;
  text-align: center;
  line-height: 21px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

/* Чтобы tooltip позиционировался корректно */
.tooltip-container {
  position: relative;
  font-weight: 400;
  letter-spacing: 0;
}

.tooltip {
  display: none;
  position: absolute;
  top: 35px;
  right: 0;
  background: #222;
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  z-index: 10;
  max-width: 300px;
  height: 75px;
  white-space: normal;
  overflow-wrap: break-word;
}

.tooltip-container:hover .tooltip {
  display: block;
}

.icons {
  display: flex;
  justify-content: space-around;
  gap: 10px;
}

.icon {
  width: 50px;
  height: 50px;
  background: #4bff7e;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  transition: background 0.3s;
}

.icon:hover {
  background: var(--accent);
}

/* =========================
   Модальное окно
   ========================= */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
}

.modal.closing .modal-content {
  animation: modalHide 0.25s ease forwards;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 800px;
  margin: 50px auto;
  background: var(--modal-bg);
  border-radius: 20px;
  padding: 20px;
  height: calc(100% - 100px);
  display: flex;
  flex-direction: column;
  animation: modalShow 0.3s ease forwards;
}

/* Анимация появления модального окна */
@keyframes modalShow {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

/* Анимация скрытия модального окна */
@keyframes modalHide {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header .logo {
  font-size: 24px;
  font-weight: 700;
  color: #f1f2f7;
}

.close-button {
  font-size: 48px;
  color: #ff4a4a;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
  line-height: 1;
}

.close-button:hover {
  color: #fff;
  transform: scale(1.2);
}

.modal-description {
  margin: 20px 0;
  font-size: 16px;
  text-align: center;
  color: #f1f2f7;
  line-height: 20px;
  letter-spacing: 1px;
}

/* =========================
   Панель управления
   ========================= */

.control-panel {
  margin: auto auto 7px auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 95%;
}

.mode-selection,
.voice-reply {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 15px;
  color: #c1c1c1;
}

.control-panel label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.3s, color 0.3s;
}

.control-panel label input {
  vertical-align: middle;
  margin: 0;
}

.control-panel label span {
  vertical-align: middle;
  line-height: 1.2;
}

.control-panel label:hover {
  background: rgba(13, 242, 77, 0.1);
}

.mode-selection input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 50%;
  transition: border-color 0.3s, background 0.3s;
  cursor: pointer;
}

.mode-selection input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.voice-reply input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 4px;
  transition: border-color 0.3s, background 0.3s;
  cursor: pointer;
}

.voice-reply input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.mode-selection label span,
.voice-reply label span {
  transition: color 0.3s, font-weight 0.3s;
}

.mode-selection input[type="radio"]:checked + span,
.voice-reply input[type="checkbox"]:checked + span {
  color: #212121;
  font-weight: 600;
}

.mode-selection input[type="radio"]:not(:checked) + span,
.voice-reply input[type="checkbox"]:not(:checked) + span {
  color: #777;
}

/* =========================
   Чат
   ========================= */

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--chat-border);
  border-radius: 15px;
  overflow: hidden;
  min-height: 0; /* фикс “кривоты” flex+scroll */
}

.chat-header {
  background: var(--chat-header-bg);
  padding: 5px 10px;
  text-align: right;
}

.chat-header a {
  font-size: 12px;
  text-decoration: none;
  color: var(--link);
  cursor: pointer;
}

.chat-history {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  position: relative;
  min-height: 0;

  background-color: rgba(223, 219, 229, 0.4);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 40 40'%3E%3Cpath d='M0 39.5h40M39.5 0v40' stroke='%239C92AC' stroke-opacity='0.35' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* =========================
   FIX: встраиваемый ассистент внутри модалки
   ========================= */

.assistant-embedded{
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.embedded-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.logo-modal img{
  height: 34px;           /* фикс “гигантского логотипа” */
  width: auto;
  display: block;
}

.embedded-header .header{
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f1f2f7;
  font-weight: 600;
}

.embedded-header .title{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.input-area{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input{
  display: flex;
  gap: 10px;
  align-items: stretch;
}

#chatInput{
  flex: 1;
  resize: none;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
}

#sendButton{
  width: 56px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
}

.voice-input{
  width: 100%;
  height: clamp(110px, 18vh, 160px); /* чтобы mic iframe не “выпадал” */
  display: flex;
  align-items: center;
  justify-content: center;
}

#voiceStreamFrame{
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* =========================
   Оверлей результатов (#pageTickets)
   ========================= */

#pageTickets.tickets-page{
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  padding: 18px;
  overflow: auto;
  background: rgba(15, 16, 38, 0.60);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#pageTickets.tickets-page.vw-show{
  display: block;
}

.tickets-close{
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  font-size: 28px;
  line-height: 46px;
  background: rgba(255,255,255,.12);
  color: #fff;
}

body.assistant-modal-open{
  overflow: hidden;
}
