/* Общие стили для образовательных модулей (тесты и задания) */

/* Скрытие элементов во время прохождения */
.edu-hidden {
  display: none !important;
}

/* Контейнеры */
#quiz-container {
  margin: 2rem 0;
  max-width: 100%;
}

#tasks-container {
  margin: 0;
  max-width: 100%;
}

/* Обертка для чата и прогресса */
.edu-task-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Чат-контейнер для заданий */
.edu-chat-container {
  display: flex;
  flex-direction: column;
  height: 450px;
  width: 80%;
  max-width: 900px;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: light) {
  .edu-chat-container {
    background: rgb(245, 245, 245);
  }
}

@media (prefers-color-scheme: dark) {
  .edu-chat-container {
    background: #1a1a1a;
  }
}

/* Заголовок задания в чате */
.edu-chat-header {
  text-align: center;
  padding: 0.75rem 1rem;
}

/* Область сообщений */
.edu-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Сообщение (контейнер) */
.edu-chat-message {
  display: flex;
  width: 100%;
  align-items: center;
}

.edu-chat-message.user {
  justify-content: flex-end;
}

.edu-chat-message.assistant {
  justify-content: flex-start;
}

/* Бабл сообщения */
.edu-chat-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Бабл пользователя */
@media (prefers-color-scheme: light) {
  .edu-chat-bubble.user {
    background: #1a1a1a;
    color: white;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-chat-bubble.user {
    background: #374151;
    color: #e5e7eb;
  }
}

/* Бабл AI - успешный (зеленый) */
.edu-chat-bubble.assistant.success {
  background: #28a745;
  color: white;
}

/* Бабл AI - неуспешный (красный) */
.edu-chat-bubble.assistant.error {
  background: #dc3545;
  color: white;
}

/* Бабл AI - думает (полупрозрачный) */
.edu-chat-bubble.assistant.thinking {
  opacity: 0.5;
}

@media (prefers-color-scheme: light) {
  .edu-chat-bubble.assistant.thinking {
    background: #e5e7eb;
    color: #1a1a1a;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-chat-bubble.assistant.thinking {
    background: #374151;
    color: #e5e7eb;
  }
}

/* Эмоджи рядом с баблами AI */
.edu-chat-emoji {
  font-size: 1rem;
  margin-left: 0.75rem;
  margin-top: 2px;
  flex-shrink: 0;
}

/* Контейнер поля ввода */
.edu-chat-input-area {
  padding: 1rem;
}

.edu-chat-input-area.hidden {
  display: none;
}

/* Кнопки */
.edu-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 0.75rem;
  transition: all 0.3s ease;
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.10);
  opacity: 0.8;
}

@media (prefers-color-scheme: light) {
  .edu-btn {
    background: white;
    color: #000;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-btn {
    background: #2d2d2d;
    color: #fff;
  }
}

.edu-btn:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

.edu-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Кнопка отправки промпта (стиль веб-чата) */
.edu-send-btn {
  padding: 0.5rem;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-top: 0;
}

@media (prefers-color-scheme: light) {
  .edu-send-btn {
    background: #1a1a1a;
    color: white;
  }

  .edu-send-btn:hover:not(:disabled) {
    background: #333;
  }

  .edu-send-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-send-btn {
    background: #e5e7eb;
    color: #1a1a1a;
  }

  .edu-send-btn:hover:not(:disabled) {
    background: #d1d5db;
  }

  .edu-send-btn:disabled {
    background: #374151;
    color: #6b7280;
    cursor: not-allowed;
  }
}

.edu-send-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

/* Анимация вращения для индикатора загрузки */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Группа кнопок */
.edu-button-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.edu-button-group .edu-btn {
  margin-top: 0;
}

/* Для контейнера с кнопкой "Продолжить" - кнопка на всю ширину */
#continue-btn-container .edu-btn {
  width: 100%;
}

/* Поле ввода */
.edu-input {
  width: 100%;
  max-width: 400px;
  padding: 0.85rem 0.75rem 0.65rem 0.75rem;
  border: 1px solid var(--theme-color);
  background: transparent;
  color: var(--theme-color);
  font-size: 1rem;
  margin: 1rem 0;
  border-radius: 0.5rem;
  display: block;
  line-height: 1.5;
}

.edu-input:focus {
  outline: none;
  border-color: var(--theme-color);
}

/* Контейнер для ввода промпта (стиль веб-чата) */
.edu-prompt-input-container {
  width: 100%;
  margin: 0;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

@media (prefers-color-scheme: light) {
  .edu-prompt-input-container {
    background: white;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-prompt-input-container {
    background: #2d2d2d;
  }
}

.edu-prompt-input-container:focus-within {
  box-shadow: 0 0 0 2px rgba(128, 128, 128, 0.3);
}

.edu-prompt-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

/* Textarea для промптов */
.edu-textarea {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  font-size: 0.875rem;
  line-height: 1.5;
  min-height: 20px;
  max-height: 110px;
  overflow-y: auto;
  font-family: inherit;
}

@media (prefers-color-scheme: light) {
  .edu-textarea {
    color: #1a1a1a;
  }

  .edu-textarea::placeholder {
    color: #999;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-textarea {
    color: white;
  }

  .edu-textarea::placeholder {
    color: #999;
  }
}

.edu-textarea:focus {
  outline: none;
}

.edu-textarea:disabled {
  opacity: 0.5;
}

/* Контейнер ввода имени */
.edu-name {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Индикаторы прогресса */
.edu-progress {
  margin-bottom: 2rem;
}

.progress-indicators {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.progress-circle {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  font-size: 0.8rem;
  color: var(--theme-color);
  line-height: 1.8rem;
  text-align: center;
  vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
  .progress-circle {
    border: 1px solid rgba(255, 255, 255, 0.5);
  }
}

@media (prefers-color-scheme: light) {
  .progress-circle {
    border: 1px solid rgba(0, 0, 0, 0.5);
  }
}

.progress-circle.current {
  font-weight: bold;
}

@media (prefers-color-scheme: dark) {
  .progress-circle.current {
    background: white;
    color: black;
    border-color: white;
  }
}

@media (prefers-color-scheme: light) {
  .progress-circle.current {
    background: black;
    color: white;
    border-color: black;
  }
}

.progress-circle.correct {
  background: #28a745;
  border-color: #28a745;
  color: white;
}

.progress-circle.incorrect {
  background: #dc3545;
  border-color: #dc3545;
  color: white;
}

/* Вопрос/Задание */
.edu-question h3,
.edu-task h3 {
  margin-bottom: 1rem;
}

.question-text,
.task-text {
  font-size: 1.2rem;
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  background: rgba(128, 128, 128, 0.15);
  border-radius: 0.5rem;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.task-subtitle {
  font-size: 0.875rem;
  opacity: 0.6;
  margin: -0.5rem 0 1rem 0;
  font-weight: normal;
  text-align: left;
}

.task-description {
  font-size: 0.8rem;
  margin: 0.5rem 0 0.5rem 0;
  padding: 0px 20% 0px 16px;
  line-height: 1.5;
  opacity: 0.8;
  white-space: pre-wrap;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  text-align: left;
}

/* Варианты ответов (для тестов) */
.edu-answers {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.edu-answer-btn {
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--theme-color);
  cursor: pointer;
  font-size: 1rem;
  text-align: left;
  transition: all 0.2s;
  border-radius: 0.5rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  position: relative;
  top: 0;
  padding-top: 0.8rem;
  padding-bottom: 0.7rem;
}

@media (prefers-color-scheme: dark) {
  .edu-answer-btn {
    border: 1px solid rgba(255, 255, 255, 0.5);
  }
}

@media (prefers-color-scheme: light) {
  .edu-answer-btn {
    border: 1px solid rgba(0, 0, 0, 0.5);
  }
}

.edu-answer-btn:hover:not(:disabled) {
  background: var(--theme-color);
  color: var(--base-background-color);
}

.edu-answer-btn:disabled {
  cursor: not-allowed;
}

.edu-answer-btn.correct {
  background: #28a745;
  border-color: #28a745;
  color: white;
  animation: bump 0.5s ease-out;
}

.edu-answer-btn.incorrect {
  background: #dc3545;
  border-color: #dc3545;
  color: white;
  animation: shake 0.5s ease-out;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-3px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(3px);
  }
}

/* Блок тестирования промпта (для заданий) */
.edu-test-result {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: rgba(128, 128, 128, 0.08);
}

.edu-test-result.hidden {
  display: none;
}

.edu-validation-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
}

.edu-validation-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.edu-validation-icon.valid {
  background: #28a745;
  color: white;
}

.edu-validation-icon.invalid {
  background: #dc3545;
  color: white;
}

.edu-ai-response {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: light) {
  .edu-ai-response {
    background: white;
    color: #1a1a1a;
  }
}

@media (prefers-color-scheme: dark) {
  .edu-ai-response {
    background: #2d2d2d;
    color: #e5e7eb;
  }
}

.edu-ai-response-label {
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: block;
  font-size: 0.875rem;
  opacity: 0.7;
}

/* Результат ответа */
.edu-result {
  margin-top: 1rem;
}

/* Финальные результаты */
.edu-final h3 {
  margin-bottom: 1.5rem;
}

.final-stats {
  margin: 1.5rem 0;
}

.final-stats p {
  margin: 0.75rem 0;
  font-size: 1.1rem;
}

.success-message {
  color: #28a745;
  font-weight: bold;
  margin-top: 1.5rem;
  font-size: 1.1rem;
}

/* Ошибки */
.edu-error {
  margin: 2rem 0;
}

.error-message {
  color: #dc3545;
  font-size: 1.1rem;
  margin: 1rem 0;
}

/* Адаптивность */
@media (max-width: 768px) {
  .edu-input,
  .edu-textarea {
    max-width: 100%;
  }


  .edu-answer-btn {
    padding: 0.75rem;
  }

  .result-message {
    font-size: 1.2rem;
  }

  .edu-button-group {
    flex-direction: column;
  }

  .edu-button-group .edu-btn {
    width: 100%;
  }

  /* Чат-контейнер на всю ширину */
  .edu-chat-container {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    height: 75dvh; /* Динамическая высота viewport без учета панелей браузера */
  }

  /* Область ввода чата с боковыми отступами */
  .edu-chat-input-area {
    padding: 0.75rem;
  }

  /* Убираем padding у описания задания */
  .task-description {
    padding-left: 8px;
    padding-right: 8px;
  }
}
