/**
 * Тренажёр «Машина Тьюринга»
 */

.mt-trainer-body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
}

.mt-trainer-shell {
  max-width: 1200px; /* Увеличили ширину контейнера, чтобы соответствовать другим страницам */
  margin: 0 auto;
  padding: 0 1rem 0; /* Убрали нижний отступ (был 2.5rem) */
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.mt-trainer-main {
  padding-top: 1rem;
}

.mt-trainer-header {
  margin-bottom: 0.01rem; /* Уменьшили отступ после заголовка (был 1.5rem) */
}

.mt-trainer-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--white);
}

.mt-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--header-premium-border);
  border-radius: 14px;
  padding: 1.4rem 1.25rem 1rem; /* Уменьшили внутренние отступы карточки */
  margin-bottom: 0; /* Убрали нижний отступ у карточек, зададим его через gap в контейнере */
  box-shadow: var(--header-premium-shadow);
  position: relative; /* Добавили для абсолютного позиционирования заголовка */
}

.mt-trainer-main {
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.25rem; /* Еще больше увеличили отступ между карточками */
  padding-bottom: 1.5rem; /* Уменьшили отступ до подвала */
}

[data-theme="light"] .mt-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(5, 184, 125, 0.18);
}

.mt-card__title {
  font-size: 1.15rem;
  font-weight: 700;
  position: absolute;
  top: -0.85rem; /* Поднимаем заголовок на верхнюю границу */
  left: 1.5rem; /* Отступ слева */
  margin: 0;
  padding: 0 0.75rem; /* Отступы по бокам от текста */
  background: transparent; /* Прозрачный фон */
  color: var(--green); /* Выделим цветом */
  border-radius: 4px;
}

.mt-tape-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mt-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mt-input {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(5, 184, 125, 0.35);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  font-size: 1rem;
}

[data-theme="light"] .mt-input {
  background: #fff;
  border-color: rgba(5, 184, 125, 0.28);
}

.mt-input--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
}

.mt-input:focus {
  outline: 2px solid rgba(5, 184, 125, 0.45);
  outline-offset: 1px;
}

.mt-fieldset__legend {
  padding: 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.mt-radio {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.45rem 0;
  cursor: pointer;
  line-height: 1.4;
}

.mt-radio input {
  margin-top: 0.2rem;
}

.mt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.mt-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(5, 184, 125, 0.45);
  background: rgba(5, 184, 125, 0.12);
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.mt-btn:hover {
  background: rgba(5, 184, 125, 0.22);
  border-color: rgba(5, 184, 125, 0.65);
}

.mt-btn--primary {
  background: rgba(5, 184, 125, 0.35);
  border-color: rgba(5, 184, 125, 0.75);
}

.mt-btn--running {
  background: rgba(234, 179, 8, 0.35); /* Желтый цвет для паузы */
  border-color: rgba(234, 179, 8, 0.75);
}

.mt-btn--running:hover {
  background: rgba(234, 179, 8, 0.45);
  border-color: rgba(234, 179, 8, 0.85);
}

.mt-btn--small {
  padding: 0.35rem 0.75rem;
  font-size: 0.88rem;
}

.mt-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mt-status {
  min-height: 1.35rem;
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 0.75rem;
}

.mt-status--error {
  color: #f87171;
}

.mt-status--ok {
  color: var(--green);
}

[data-theme="light"] .mt-status--error {
  color: #dc2626;
}

.mt-tape-viewport {
  margin-top: 0.5rem; /* Уменьшили отступ */
  overflow-x: auto;
  padding: 0.25rem 0; /* Уменьшили отступ */
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .mt-tape-viewport {
  background: rgba(0, 0, 0, 0.04);
}

.mt-tape-track {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 3.8rem; /* Уменьшили высоту ленты */
  padding: 0.25rem 0.5rem;
  width: max-content;
  margin: 0 auto;
}

.mt-cell {
  flex: 0 0 auto;
  width: 2.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-right-width: 0;
  background: rgba(15, 23, 42, 0.35);
  position: relative;
}

.mt-cell:last-child {
  border-right-width: 1px;
}

[data-theme="light"] .mt-cell {
  background: rgba(255, 255, 255, 0.85);
}

.mt-cell--head {
  box-shadow: inset 0 0 0 2px rgba(5, 184, 125, 0.85);
  background: rgba(5, 184, 125, 0.12);
}

.mt-cell__index {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0.2rem 0;
  font-variant-numeric: tabular-nums;
  order: 2; /* Перемещаем вниз */
}

.mt-cell__sym {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.8rem 0 0; /* Вернули чуть меньший отступ, т.к. высота ячейки уменьшилась */
  order: 1; /* Перемещаем наверх */
}

.mt-cell__head-marker {
  position: absolute;
  top: 2px; /* Было bottom: 2px */
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 800;
  transform: rotate(180deg); /* Разворачиваем на 180 градусов */
}

.mt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.mt-meta strong {
  color: var(--white);
  font-weight: 700;
}

[data-theme="light"] .mt-meta strong {
  color: var(--white);
}

.mt-program-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem; /* Уменьшили отступ */
}

.mt-program-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.mt-program-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem; /* Увеличили базовый размер шрифта таблицы */
}

.mt-program-table th,
.mt-program-table td {
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 0.25rem 0.35rem; /* Уменьшили отступы в ячейках таблицы */
  text-align: center;
  vertical-align: middle;
}

.mt-program-table thead th {
  background: rgba(5, 184, 125, 0.12);
  font-weight: 700;
  font-size: 1.1rem; /* Заголовки столбцов чуть крупнее */
}

.mt-program-corner {
  min-width: 3rem;
  background: rgba(148, 163, 184, 0.15);
}

.mt-program-table input.mt-program-input {
  width: 100%;
  min-width: 4.5rem;
  box-sizing: border-box;
  padding: 0.25rem 0.4rem; /* Уменьшили отступы внутри инпутов */
  border-radius: 6px;
  border: 1px solid rgba(5, 184, 125, 0.35);
  background: rgba(0, 0, 0, 0.15);
  color: inherit;
  font: inherit;
  text-align: center;
  font-size: 1.05rem; /* Увеличили шрифт в инпутах */
}

[data-theme="light"] .mt-program-table input.mt-program-input {
  background: #fff;
}

.mt-program-table input.mt-program-input--sym {
  max-width: 3.5rem;
  min-width: 2.5rem;
  font-weight: 700;
  font-size: 1.15rem; /* Символы в заголовках еще крупнее */
}

.mt-program-table input.mt-program-input--cmd {
  min-width: 7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem; /* Команды чуть крупнее моноширинным шрифтом */
}

.mt-program-table input.mt-program-input--state {
  min-width: 3rem;
  font-weight: 700;
  font-size: 1.1rem; /* Состояния крупнее */
}

.mt-program-del-cell {
  width: 2.5rem;
  padding: 0.25rem !important;
  border: none !important;
  background: transparent !important;
}

.mt-state-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  opacity: 0.6;
}

.mt-program-table tr:hover .mt-state-del-btn {
  opacity: 1;
}

.mt-state-del-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

[data-theme="light"] .mt-state-del-btn {
  background: rgba(220, 38, 38, 0.05);
  color: #dc2626;
}

[data-theme="light"] .mt-state-del-btn:hover {
  background: rgba(220, 38, 38, 0.15);
  color: #b91c1c;
}

.mt-program-table th.mt-program-th--lambda {
  background: rgba(5, 184, 125, 0.18);
}

.mt-program-table td.mt-program-cell--active {
  background: rgba(5, 184, 125, 0.25);
  box-shadow: inset 0 0 0 2px rgba(5, 184, 125, 0.8);
  border-color: rgba(5, 184, 125, 0.8);
}

[data-theme="light"] .mt-program-table td.mt-program-cell--active {
  background: rgba(5, 184, 125, 0.15);
  box-shadow: inset 0 0 0 2px rgba(5, 184, 125, 0.6);
  border-color: rgba(5, 184, 125, 0.6);
}

.mt-program-table td.mt-program-cell--active input.mt-program-input {
  background: transparent;
  border-color: transparent;
}

.mt-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.mt-toggle-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  user-select: none;
}

.mt-toggle {
  position: relative;
  display: inline-block;
  width: 3rem;
  height: 1.5rem;
}

.mt-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.mt-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(148, 163, 184, 0.45);
  transition: .2s ease;
  border-radius: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.55);
}

.mt-toggle-slider:before {
  position: absolute;
  content: "";
  height: 1.1rem;
  width: 1.1rem;
  left: 0.15rem;
  bottom: 0.15rem;
  background-color: white;
  transition: .2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.mt-toggle input:checked + .mt-toggle-slider {
  background-color: rgba(5, 184, 125, 0.45);
  border-color: rgba(5, 184, 125, 0.7);
}

.mt-toggle input:checked + .mt-toggle-slider:before {
  transform: translateX(1.4rem);
}

.mt-toggle input:focus-visible + .mt-toggle-slider {
  outline: 2px solid rgba(5, 184, 125, 0.6);
  outline-offset: 2px;
}
