/* ===================================================== */
/*   Страница генератора Telegram-ботов — общий layout   */
/* ===================================================== */

/* Обертка страницы */
.tg-bots-main {
  padding-bottom: 32px;
}

/* Контейнер чуть уже, чтобы форма читалась легче */
.tg-bots-container {
  max-width: 1120px;
  margin: 0 auto;
}

/* Две колонки: слева создание, справа "Мои боты" */
.tg-bots-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.tg-bots-column {
  min-width: 0;
}

.tg-bots-column--primary {
  flex: 1.2 1 56%;
}

.tg-bots-column--secondary {
  flex: 1 1 44%;
}



.tg-bots-card--create {
  min-height: 100%;
}

.tg-bots-card--list {
  min-height: 260px;
}

/* Заголовки карточек */
.tg-bots-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.tg-bots-card-header-main {
  min-width: 0;
}

.tg-bots-title {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 600;
  color: #f9fafb;
}

.tg-bots-title--sm {
  font-size: 20px;
}

.tg-bots-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #9ca3af;
}

/* Блок с тарифами */
.tg-bots-tariff-info {
  margin-bottom: 18px;
  padding: 12px 12px 10px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.95), rgb(14 25 41 / 95%));
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.tg-bots-tariff-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ca3af;
}

.tg-bots-tariff-grid {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #e5e7eb;
}

.tg-bots-tariff-grid p {
  margin: 0;
}

/* Форма создания бота */
.tg-bot-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Сетка: слева основные поля, справа файлы */
.tg-bot-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr);
  gap: 16px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-section--files {
  border-radius: 14px;
  padding: 10px 10px 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

/* Строки формы и элементы */
.tg-bots-card .form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tg-bots-card .form-label {
  font-size: 13px;
  font-weight: 500;
  color: #e5e7eb;
}

.tg-bots-card .form-input,
.tg-bots-card .form-textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #0f1325;
  color: #f9fafb;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.tg-bots-card .form-input::placeholder,
.tg-bots-card .form-textarea::placeholder {
  color: #6b7280;
}

.tg-bots-card .form-input:focus,
.tg-bots-card .form-textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.6);
  background: #0d1121;
}

.tg-bots-card .form-textarea {
  resize: vertical;
  min-height: 120px;
}

.tg-bots-card .form-help {
  font-size: 12px;
  line-height: 1.5;
  color: #9ca3af;
}

/* Низ формы: кнопка + статус */
.tg-bot-form-footer {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
  
  .tg-bot-rules-hint {
    margin-top: 4px;
    font-size: 12px;
    color: #ef4444; /* лёгкий акцент, видно что это важное уведомление */
  }
  
  .tg-bot-rules-error {
    margin-top: 4px;
    font-size: 12px;
    color: red;
  }

  .tg-bot-balance-link {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    color: #939393;
    text-decoration: none;
    text-align:center;
  }

  .tg-bot-balance-link strong {
    font-size: 16px; /* баланс крупнее */
  }

  .tg-bot-form-footer .tg-bot-rules-agree {
    margin-bottom: 0;
    font-size: 13px;
    color: #4b5563;
  }

.tg-bot-submit {
  padding-inline: 18px;
  width: 100%;
  border-radius: 999px;
  font-size: 14px;
}

.tg-bot-status {
  font-size: 13px;
  color: #9ca3af;
  min-height: 18px;
}

.model-picker-credits {
  font-size: 12px;
  color: #9ca3af;
}

/* Строка с файлами в форме создания */
.tg-bot-files-row {
  gap: 6px;
}

/* Блок "Мои боты" справа */
.tg-bots-header {
  margin-bottom: 10px;
}

.tg-bots-hosting-block {
  margin-bottom: 14px;
}

/* Обертка для summary (сам контент заполняет JS) */
.tg-bots-hosting-summary {
  border-radius: 12px;
  padding: 10px 10px 9px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(75, 85, 99, 0.9);
  font-size: 13px;
  color: #e5e7eb;
}

/* Список карточек ботов: 3 в ряд, каждая со своей высотой */
.tg-bot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start; /* ВАЖНО: чтобы соседи не растягивались по высоте */
}

/* Размещение самой карточки внутри списка */
.tg-bot-list .tg-bot-item {
  flex: 1 1 calc(33.333% - 12px);
  min-width: 260px;
  box-sizing: border-box;
}

/* Структурированный блок "Мои боты" */
.tg-bots-hosting-summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
}

.tg-hosting-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.tg-hosting-label {
  font-weight: 400;
  color: #9ca3af;
}

.tg-hosting-value {
  font-weight: 600;
  color: #e5e7eb;
}

.tg-hosting-stat--danger .tg-hosting-label {
  color: #f97316;
}

.tg-hosting-stat--danger .tg-hosting-value {
  color: #fde68a;
}

/* На телефоне — столбцом */
@media (max-width: 640px) {
  .tg-bots-hosting-summary-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .tg-hosting-stat {
    white-space: normal;
  }
}

/* Карточка одного бота в списке "Мои боты" */
.tg-bot-item {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1.4fr);
  gap: 6px 12px;
  align-items: flex-start;
  
  

  padding: 10px 12px;
  margin-bottom: 8px;

  border-radius: 10px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background: radial-gradient(
    circle at top left,
    rgba(15, 23, 42, 0.96),
    rgba(15, 23, 42, 0.9)
  );
}

.tg-bot-item:last-child {
  margin-bottom: 0;
}

/* Имя бота */
.tg-bot-item-title {
  grid-column: 1 / 2;
  grid-row: 1;

  font-size: 16px;
  font-weight: 600;
  color: #f9fafb;
}

/* ID + статус — отдельной строкой, многострочно */
.tg-bot-item-meta {
  grid-column: 1 / 2;
  grid-row: 2;

  font-size: 12px;
  color: #9ca3af;
  white-space: normal;
}

/* Логин и описание телеграм-бота — отдельный блок */
.tg-bot-item-tg-info {
  grid-column: 1 / 2;
  grid-row: 3;

  font-size: 12px;
  color: #e5e7eb;
  white-space: normal;
}

/* Информация о хостинге — ещё одна строка, подчёркнута цветом */
.tg-bot-item-hosting {
  grid-column: 1 / 2;
  grid-row: 4;

  font-size: 12px;
  color: #a5b4fc;
  white-space: normal;
}

/* Мета-инфо бота: ID / статус / логин — по строкам */
.tg-bot-meta-row {
  display: flex;
  gap: 4px;
  font-size: 12px;
}

.tg-bot-meta-label {
  color: #9ca3af;
}

.tg-bot-meta-value {
  color: #e5e7eb;
}

/* Строки хостинга друг под другом */
.tg-bot-hosting-row + .tg-bot-hosting-row {
  margin-top: 2px;
}

/* Ссылка-логин */
.tg-bot-login-link {
  color: #a5b4fc;
  text-decoration: underline;
}

.tg-bot-list-header {
    padding-bottom:10px;
}

.tg-bot-login-link:hover {
  text-decoration: none;
}

/* Блок с кнопками: выезжает снизу внутри карточки */
.tg-bot-item-actions {
  grid-column: 1 / -1;
  grid-row: auto;

  display: none;              /* по умолчанию скрыт */
  flex-direction: column;
  align-items: stretch;
  gap: 6px;

  margin-top: 6px;
}

/* показываем, когда JS повесил класс .tg-bot-item--actions-open */
.tg-bot-item--actions-open .tg-bot-item-actions {
  display: flex;
}

/* Кнопки — на всю ширину блока */
.tg-bot-item-actions .btn-primary,
.tg-bot-item-actions .btn-secondary {
  width: 100%;
  justify-content: center;
  background:#1c2137;
}

#tg-bot-edit-cancel {
    background:#98999d;
    color:#fff;
}

/* Нижняя часть карточки — кнопка "Действия" */
.tg-bot-actions-toggle {
  grid-column: 1 / -1;

  margin-top: 8px;
  padding: 6px 10px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;

  border-radius: 0 0 10px 10px;
  border-top: 1px solid rgba(55, 65, 81, 0.95);
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  font-size: 12px;
  cursor: pointer;
}

.tg-bot-actions-toggle:hover {
  background: rgba(31, 41, 55, 0.96);
}

.tg-bot-actions-toggle-icon {
  font-size: 11px;
  line-height: 1;
}

/* Поворот стрелки при открытии */
.tg-bot-actions-toggle.is-open .tg-bot-actions-toggle-icon {
  transform: rotate(180deg);
}

@media (max-width: 720px) {
  .tg-bot-item {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Список ботов: несколько карточек в строке */
.tg-bot-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.tg-bot-list .tg-bot-item {
  margin-bottom: 0;
}

/* Сворачиваемые действия бота */
.tg-bot-item--collapsible-actions .tg-bot-actions-toggle {
  grid-column: 1 / -1;
  grid-row: auto;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 0px solid #4b5563;
  background: rgba(15, 23, 42, 0.9);
  font-size: 11px;
  color: #e5e7eb;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
}

.tg-bot-actions-toggle-icon {
  font-size: 10px;
  opacity: 0.8;
  transition: transform 0.12s ease;
}

.tg-bot-actions-toggle.is-open .tg-bot-actions-toggle-icon {
  transform: rotate(180deg);
}

/* Панель с кнопками: по одной на строку, на всю ширину */
.tg-bot-item--collapsible-actions .tg-bot-item-actions {
  grid-column: 1 / -1;
  grid-row: auto;
  margin-top: 6px;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.tg-bot-item--actions-open .tg-bot-item-actions {
  display: flex;
}

.tg-bot-item--collapsible-actions .tg-bot-item-actions > * {
  width: 100%;
  justify-content: center;
  padding: 2px;
}

.model-pill-price {
    padding-left:3px;
}

/* На узких экранах — по одной карточке в строку */
@media (max-width: 720px) {
  .tg-bot-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===================================================== */
/*      Мини-компонент добавления файлов к боту          */
/* ===================================================== */

.tg-bot-file-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #374151;
  margin-bottom: 8px;
}

.tg-bot-file-input {
    display: block;
    width: 100%;
    max-width: 100%;
    font-size: 13px;
    color: #808183;
}

.tg-bot-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tg-bot-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  font-size: 12px;
  color: #111827;
}

.tg-bot-file-chip-name {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-bot-file-chip-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 14px;
  color: #6b7280;
}

.tg-bot-file-chip-remove:hover {
  color: #dc2626;
}

/* Кнопка "+ Добавить файл" и иконки X-маленького размера */
.btn-xxs {
  font-size: 16px;
  padding: 0;
  box-shadow: 0 0 0 rgba(15, 23, 42, 0);
  background: transparent;
  border: 0;
  color: #4b5563;
  padding-left: 5px;
}

.tg-bot-files-add {
  margin-top: 4px;
    background:#1c2137;
}

/* ===================================================== */
/*         Файловый менеджер бота (tg-bot-files-*)       */
/* ===================================================== */

/* Карточка файлового менеджера */
.tg-bot-files-card {
  margin-top: 24px;
  padding: 18px 20px 20px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: radial-gradient(circle at top left, #020617, #020617 40%, #0b1120);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
}

/* Заголовок карточки */
.tg-bot-files-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tg-bot-files-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  color: #f9fafb;
}

.tg-bot-files-subtitle {
  margin: 0;
  color: #9ca3af;
  font-size: 13px;
}

/* Метаданные бота */
.tg-bot-files-bot-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid #1d4ed8;
  font-size: 12px;
  white-space: nowrap;
  color: #e5e7eb;
}

.tg-bot-files-bot-meta-label {
  color: #9ca3af;
}

.tg-bot-files-bot-meta-value {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  color: #e5e7eb;
}

/* Корень файлового менеджера */
.tg-bot-files-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 10px;
  border-radius: 12px;
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(135deg, #020617, #111827);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.45);
  color: #e5e7eb;
}

.tg-bot-files-root--loading {
  cursor: progress;
}

/* Верхняя панель */
.tg-bot-files-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgb(31 41 55 / 19%);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
}

.tg-bot-files-header-left {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 2px;
}

.tg-bot-files-header-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Путь (breadcrumbs) */
.tg-bot-files-path {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-bot-files-header-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 1px rgba(55, 65, 81, 0.9);
}

.tg-bot-files-header-divider {
  width: 1px;
  height: 28px;
  background: #374151;
}

/* Скрываем file-input */
.tg-bot-files-upload-label input[type="file"] {
  display: none;
}

/* Кнопки в верхнем тулбаре файлов */
.tg-bot-files-header-actions .btn-secondary.btn-xs,
.tg-bot-files-header-actions .tg-bot-files-upload-label {
  border-color: transparent;
  background: transparent;
  padding: 4px 9px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  color: #e5e7eb;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.tg-bot-files-header-actions .btn-secondary.btn-xs:hover,
.tg-bot-files-header-actions .tg-bot-files-upload-label:hover {
  background: rgba(55, 65, 81, 0.9);
}

.tg-bot-files-header-btn-icon {
  font-size: 0.9rem;
}

.tg-bot-files-header-btn-label {
  white-space: nowrap;
}

/* Адаптив верхней панели */
@media (max-width: 900px) {
  .tg-bot-files-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .tg-bot-files-header-actions {
    justify-content: flex-start;
  }

  .tg-bot-file-editor-hint {
    display: none;
  }
}

/* Breadcrumbs */
.tg-bot-files-crumb {
  border: none;
  background: #4b5563;
  color: #e5e7eb;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 999px;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.tg-bot-files-crumb:hover {
  background: #6366f1;
  color: #e5e7eb;
}

.tg-bot-files-crumb-sep {
  opacity: 0.6;
}

/* Основной layout файлового менеджера */
.tg-bot-files-main {
  display: flex;
  gap: 16px;
  align-items: stretch;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .tg-bot-files-main {
    flex-direction: column;
  }
}

/* Левая колонка — список */
.tg-bot-files-sidebar {
  flex: 0 0 36%;
  min-width: 0;
  padding-right: 12px;
  border-right: 1px solid #374151;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 900px) {
  .tg-bot-files-sidebar {
    border-right: none;
    border-bottom: 1px solid #374151;
    padding-right: 0;
    padding-bottom: 10px;
  }
}

.tg-bot-files-sidebar-header {
  display: flex;
  align-items: center;
}

/* Поиск по файлам */
.tg-bot-files-search-wrapper {
  width: 100%;
  position: relative;
}

.tg-bot-files-search {
  width: 100%;
  font-size: 13px;
  padding: 6px 26px 6px 26px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
}

.tg-bot-files-search::placeholder {
  color: #6b7280;
}

/* Иконка поиска */
.tg-bot-files-search-wrapper::before {
  content: "🔍";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.7;
}

/* Список файлов (общая обертка) */
.tg-bot-files-list {
  max-height: 520px;
  min-height: 260px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #020617;
  padding: 0;
  position: relative;
}

/* В списке файлов текст не выделяется */
.tg-bot-files-list,
.tg-bot-files-row,
.tg-bot-files-row * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Drag&drop подсветка */
.tg-bot-files-root--dragover .tg-bot-files-list {
  border-style: dashed;
  border-color: #6366f1;
  background: rgba(79, 70, 229, 0.12);
}

.tg-bot-files-root--dragover .tg-bot-files-list::before {
  content: "Перетащи файлы сюда, чтобы загрузить";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #a5b4fc;
  font-weight: 500;
  pointer-events: none;
}

/* Таблица файлов */
.tg-bot-files-table {
  display: flex;
  flex-direction: column;
}

/* Строки в таблице */
.tg-bot-files-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.08s ease, box-shadow 0.08s ease;
}

.tg-bot-files-row--header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #020617;
  border-bottom: 1px solid #374151;
  cursor: default;
}

.tg-bot-files-row--header:hover {
  background: #020617;
}

.tg-bot-files-row-up {
  border-bottom: 1px solid #374151;
  font-weight: 600;
  background: #0f172a;
}

.tg-bot-files-row-empty {
  opacity: 0.7;
  cursor: default;
}

.tg-bot-files-row--active {
  background: rgba(55, 65, 81, 0.95);
  box-shadow: inset 2px 0 0 #6366f1;
}

/* Контент строки */
.tg-bot-files-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.tg-bot-files-row-main--header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Заголовки колонок */
.tg-bot-files-header-cell {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
  font-weight: 600;
}

.tg-bot-files-header-cell--name {
  flex: 1.2;
}

.tg-bot-files-header-cell--path {
  flex: 1;
  text-align: left;
}

/* Содержимое */
.tg-bot-files-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e5e7eb;
}

.tg-bot-files-row-icon {
  flex: 0 0 auto;
}

.tg-bot-files-row-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-bot-files-row-subtitle {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-bot-files-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
  align-items: center;
}

.tg-bot-files-row-tags--header {
  font-size: 11px;
  text-transform: uppercase;
  color: #9ca3af;
  font-weight: 600;
}

/* Теги */
.tg-bot-files-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  white-space: nowrap;
  color: #e5e7eb;
}

.tg-bot-files-tag--dir {
  border-color: #4f46e5;
  background: rgba(79, 70, 229, 0.15);
  color: #c7d2fe;
}

.tg-bot-files-tag--file {
  border-color: #4b5563;
  color: #e5e7eb;
}

/* Подсветка поискового совпадения */
.tg-bot-files-search-mark {
  background: #78350f;
  color: #fef3c7;
  border-radius: 3px;
  padding: 0 1px;
}

/* Футер сайдбара с инфой */
.tg-bot-files-sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: #9ca3af;
  word-break: break-all;
}

.tg-bot-files-sidebar-footer-row {
  display: flex;
  gap: 4px;
  align-items: baseline;
}

.tg-bot-files-sidebar-footer-label {
  min-width: 58px;
}

.tg-bot-files-selected,
.tg-bot-files-summary {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

/* Правая колонка — редактор */
.tg-bot-files-editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Шапка редактора */
.tg-bot-file-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  color: #e5e7eb;
}

.tg-bot-file-editor-title {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.tg-bot-file-editor-label {
  font-weight: 500;
}

#tg-bot-file-name {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  word-break: break-all;
}

/* Тулбар редактора */
.tg-bot-file-editor-toolbar {
  display: flex;
  gap: 4px;
}

/* Форма редактора */
.tg-bot-file-editor-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* CodeMirror по умолчанию (dark) */
.CodeMirror {
  min-height: 484px;
  max-height: none;
  resize: vertical;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #020617;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(55, 65, 81, 0.8);
  color: #e5e7eb;
}

@media (max-width: 900px) {
  .CodeMirror {
    min-height: 350px;
  }
}

/* Низ редактора */
.tg-bot-file-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #9ca3af;
}

.tg-bot-file-editor-hint {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .tg-bot-file-editor-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .tg-bot-file-editor-hint {
    white-space: normal;
  }
}

/* Статус операций с файлами */
.tg-bot-files-status {
  margin-top: 8px;
  font-size: 13px;
  color: #9ca3af;
  min-height: 18px;
}

.tg-bot-files-status.is-error {
  color: #fecaca;
}

.tg-bot-files-status.is-busy {
  color: #a5b4fc;
}

/* Опасные кнопки */
.tg-bot-files-btn-danger {
  color: #fecaca;
  border-color: #fecaca;
}

.tg-bot-files-btn-danger:hover {
  background: rgba(127, 29, 29, 0.4);
}

/* ===================================================== */
/*                Модалка ENV и консоль                  */
/* ===================================================== */

.tg-env-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9990;
}

.tg-env-modal.is-open {
  display: flex;
}

.tg-env-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.tg-env-modal-dialog {
  position: relative;
  z-index: 1;
  max-width: 560px;
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 20px 24px;
  border-radius: 12px;
  background: #020617f0;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

/* Заголовок модалки */
.tg-env-modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  color: #e5e7eb;
}

/* Поле ENV */
.tg-env-modal-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  margin-bottom: 12px;
}

/* Низ модалки */
.tg-env-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Консоль */
.tg-console-modal .tg-env-modal-dialog {
  max-width: 960px;
  width: 100%;
}

.tg-console-status {
  font-size: 13px;
  margin-bottom: 8px;
  color: #9ca3af;
  white-space: pre-line;
}

.tg-console-output {
  font-family: Menlo, Monaco, Consolas, monospace;
  background: #0b0b0b;
  color: #e5e5e5;
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  min-height: 260px;
  width: 100%;
  line-height: 1.4;
  white-space: pre;
}

.tg-console-input {
  font-family: Menlo, Monaco, Consolas, monospace;
  width: 100%;
  margin-bottom: 20px;
}

.tg-console-output::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tg-console-output::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

/* ===================================================== */
/*           Модалка изменения поведения бота            */
/* ===================================================== */

.tg-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Показываем модалку */
.tg-edit-modal.is-open {
  display: flex;
}

/* Затемнение фона */
.tg-edit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

/* Тело окна */
.tg-edit-modal-dialog {
  position: relative;
  z-index: 1;
  background: #020617f0;
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  color:#fff;
}

/* Заголовок */
.tg-edit-modal-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}

/* Основное textarea */
.tg-edit-modal-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 140px;
}

/* Блок с файлами в модалке изменения бота */
.tg-bot-edit-files-row {
  margin-top: 16px;
}

/* Список файлов внутри строк формы и в модалке изменения бота */
.tg-bot-files-row .tg-bot-files-list,
.tg-bot-edit-files-row .tg-bot-files-list {
  margin-top: 8px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #f9fafb;
  padding: 8px;
  min-height: 0;
  max-height: none;
  border: 1px solid #e5e7eb;
}

/* Если в форме/модалке нет файлов — полностью прячем область списка */
.tg-bot-files-row .tg-bot-files-list:empty,
.tg-bot-edit-files-row .tg-bot-files-list:empty {
  display: none;
}

/* На всякий случай убираем возможный кружок-плейсхолдер (::before) */
.tg-bot-files-row .tg-bot-files-list::before,
.tg-bot-edit-files-row .tg-bot-files-list::before {
  content: none;
}

/* Нижняя панель кнопок в модалке */
.tg-edit-modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Адаптив модалки изменения бота */
@media (max-width: 640px) {
  .tg-edit-modal-dialog {
    max-width: 100%;
    width: calc(100% - 24px);
    max-height: 90vh;
    padding: 16px 16px 14px;
    border-radius: 10px;
  }
}

/* ===================================================== */
/*               Адаптив страницы в целом                */
/* ===================================================== */

@media (max-width: 960px) {
  .tg-bots-layout {
    flex-direction: column;
  }

  .tg-bots-card {
    padding: 16px 14px 14px;
  }

  .tg-bot-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tg-bots-tariff-info {
    margin-bottom: 12px;
  }
}

.tg-bot-token-help-link {
  border: none;
  background: none;
  padding: 0;
  margin-left: 0px;
  font: inherit;
  color: #4f46e5;
  text-decoration: underline;
  cursor: pointer;
}

.tg-bot-token-help-link:hover {
  text-decoration: none;
}

 .tg-errors-modal .tg-env-modal-dialog {
    max-width: 760px;
    width: 100%;
  }

  .tg-errors-modal .tg-env-modal-title {
    margin-bottom: 16px;
  }

  .tg-errors-modal .form-row + .form-row {
    margin-top: 12px;
  }

  /* Логи ошибок — читаемый блок, как консоль */
  #tg-bot-errors-text {
    width:100%;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow: auto;
  }

  /* Селект модели не липнет к краям */
  .tg-errors-modal .form-input {
    width: 100%;
  }

  /* Кнопки внизу модалки */
  .tg-errors-modal .tg-env-modal-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  @media (max-width: 768px) {
    .tg-errors-modal .tg-env-modal-dialog {
      max-width: 100%;
      margin: 0 12px;
    }

    .tg-errors-modal .tg-env-modal-actions {
      flex-direction: column-reverse;
      align-items: stretch;
    }

    .tg-errors-modal .tg-env-modal-actions .btn-primary,
    .tg-errors-modal .tg-env-modal-actions .btn-secondary {
      width: 100%;
    }
  }
  
  /* ===== Оверлей статуса бота (с анимацией) ===== */

  .tg-bot-status-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease-out;
  }

  .tg-bot-status-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .tg-bot-status-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
  }

  .tg-bot-status-overlay-dialog {
    position: relative;
    max-width: 420px;
    width: calc(100% - 32px);
    padding: 20px 24px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    text-align: center;
    transform: scale(0.96) translateY(6px);
    opacity: 0;
    transition:
      transform 0.2s ease-out,
      opacity 0.2s ease-out;
  }

  .tg-bot-status-overlay.is-visible .tg-bot-status-overlay-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  .tg-bot-status-overlay-dialog .tg-bot-status {
    font-size: 15px;
    line-height: 1.5;
  }

  .tg-bot-status-overlay-dialog .tg-bot-status.is-error {
    color: #c0392b;
  }
  
  .tg-bots-card--faq{
      margin-top: 25px;
  }
  
    .tg-bots-card--rules{
      margin-top: 25px;
  }
  
    .tg-bot-rules-agree {
    margin-bottom: 8px;
    font-size: 13px;
    color: #4b5563;
  }

  .tg-bot-rules-agree-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }

  .tg-bot-rules-agree-text {
    text-decoration: underline;
    color: #d3d3d3;
  }
  
  /* Сообщение для неавторизованных пользователей в форме создания бота */
.tg-bot-guest-message {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(75, 85, 99, 0.9);
  font-size: 13px;
  color: #e5e7eb;
}

.tg-bot-guest-text {
  flex: 1;
}

.tg-bot-login-btn {
  white-space: nowrap;
}

/* Футер бота: правила слева, кнопка справа в ОДНУ строку */
.tg-bot-footer-main {
  display: flex !important;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100%;
}

.tg-bot-footer-main .tg-bot-rules-agree {
  flex: 1 1 auto;
  margin: 0;
}

.tg-bot-footer-main .chat-input-bottom-right {
  margin-left: auto;
  flex: 0 0 auto;
  width: auto !important;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

  /* Когда нет кредитов — блокируем любые действия по ботам */
/* Блокируем действия по существующим ботам, только когда кредитов 0 */
.tg-no-credits .tg-bot-item {
  position: relative;
  opacity: 0.5;
  pointer-events: none;
}

.tg-no-credits .tg-bot-item::after {
  content: "Кончились кредиты...";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  box-sizing: border-box;
}
  


#tg-bot-credits-error {
  margin-top: 8px;
  font-size: 12px;
  color: #c00;
  display: none;
}

.tg-no-credits #tg-bot-credits-error {
  display: block;
  text-align:center;
}