/* ===== Основные переменные ===== */
:root {
  --primary: #4361ee;
  --primary-dark: #3651d4;
  --secondary: #f72585;
  --success: #06d6a0;
  --warning: #ffd166;
  --danger: #ef476f;
  --dark: #1a1a2e;
  --light: #f8f9fa;
  --gradient-primary: linear-gradient(135deg, #4361ee 0%, #7b2cbf 100%);
  --gradient-secondary: linear-gradient(135deg, #f72585 0%, #7209b7 100%);
  --gradient-success: linear-gradient(135deg, #06d6a0 0%, #1b9aaa 100%);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
}

/* ===== Сброс стилей ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--dark);
  line-height: 1.6;
}

/* ===== Контейнер ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Карточки ===== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 25px;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Заголовки ===== */
h1 {
  font-size: 2.5rem;
  text-align: center;
  color: white;
  margin-bottom: 30px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

h1 span {
  display: block;
  font-size: 1rem;
  font-weight: normal;
  opacity: 0.9;
  margin-top: 10px;
}

h2 {
  font-size: 1.5rem;
  color: var(--dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h2::before {
  content: "📚";
  font-size: 1.8rem;
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(67, 97, 238, 0.5);
}

.btn-secondary {
  background: var(--gradient-secondary);
  color: white;
  box-shadow: 0 4px 15px rgba(247, 37, 133, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(247, 37, 133, 0.5);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 214, 160, 0.4);
}

.btn-success:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(6, 214, 160, 0.5);
}

.btn-outline {
  background: white;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #ef476f 0%, #d62246 100%);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
}

.btn-sm {
  padding: 10px 20px;
  font-size: 0.95rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-block {
  width: 100%;
}

/* ===== Формы ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--dark);
}

.form-control {
  width: 100%;
  padding: 15px;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
  background: var(--light);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}

/* ===== Список тем ===== */
.topics-list {
  display: grid;
  gap: 15px;
}

.topic-item {
  background: var(--light);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.topic-item:hover {
  border-color: var(--primary);
  background: white;
  transform: translateX(5px);
}

.topic-item .icon {
  font-size: 2rem;
  margin-right: 15px;
}

.topic-item .info {
  flex: 1;
}

.topic-item .title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--dark);
}

.topic-item .count {
  font-size: 0.9rem;
  color: #666;
  margin-top: 5px;
}

.topic-item .arrow {
  font-size: 1.5rem;
  color: var(--primary);
  transition: transform 0.3s ease;
}

.topic-item:hover .arrow {
  transform: translateX(5px);
}

.topic-actions {
  display: flex;
  gap: 8px;
  margin-left: 15px;
}

.topic-actions .btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.topic-item .info {
  flex: 1;
  cursor: pointer;
}

/* ===== Вопрос ===== */
.question-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 25px;
  margin-bottom: 20px;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.question-number {
  display: inline-block;
  background: var(--gradient-primary);
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.question-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--light);
  color: #666;
  border: 1px solid #e0e0e0;
}

.question-type-badge[data-type="single"] {
  background: rgba(67, 97, 238, 0.1);
  color: var(--primary);
  border-color: rgba(67, 97, 238, 0.3);
}

.question-type-badge[data-type="multiple"] {
  background: rgba(247, 37, 133, 0.1);
  color: var(--secondary);
  border-color: rgba(247, 37, 133, 0.3);
}

.question-type-badge[data-type="open"] {
  background: rgba(6, 214, 160, 0.1);
  color: #0a8d6f;
  border-color: rgba(6, 214, 160, 0.3);
}

.question-text {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--dark);
}

/* ===== Варианты ответов ===== */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: var(--light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.option-item:hover {
  background: white;
  border-color: var(--primary);
}

.option-item.selected {
  background: rgba(67, 97, 238, 0.1);
  border-color: var(--primary);
}

.option-item.correct {
  background: rgba(6, 214, 160, 0.2);
  border-color: var(--success);
}

.option-item.wrong {
  background: rgba(239, 71, 111, 0.2);
  border-color: var(--danger);
}

.option-item input {
  display: none;
}

.option-item .option-marker {
  width: 24px;
  height: 24px;
  border: 2px solid #ccc;
  border-radius: 50%;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.option-item.multiple .option-marker {
  border-radius: 4px;
}

.option-item.selected .option-marker {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-item.correct .option-marker {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.option-item.wrong .option-marker {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.option-text {
  flex: 1;
  font-size: 1rem;
}

/* ===== Открытый ответ ===== */
.open-answer {
  margin-top: 15px;
}

.open-answer input {
  width: 100%;
  padding: 15px;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
}

.open-answer input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Прогресс-бар ===== */
.progress-container {
  margin-bottom: 25px;
}

.progress-bar {
  height: 12px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-success);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.progress-text {
  text-align: center;
  margin-top: 10px;
  font-weight: 600;
  color: #666;
}

/* ===== Результаты ===== */
.results-card {
  text-align: center;
}

.score-display {
  font-size: 4rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 20px 0;
}

.score-text {
  font-size: 1.3rem;
  color: #666;
  margin-bottom: 30px;
}

.result-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* ===== Таблица статистики ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--light);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.95rem;
  color: #666;
  margin-top: 5px;
}

/* ===== Таблица ===== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

th {
  background: var(--light);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
}

th:hover {
  background: #e0e0e0;
}

th.sorted {
  background: rgba(67, 97, 238, 0.1);
}

tr:hover {
  background: var(--light);
}

/* ===== Фильтры ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #666;
}

.filter-group input,
.filter-group select {
  width: 100%;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* ===== Админ навигация ===== */
.admin-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.admin-nav .btn {
  flex: 1;
  min-width: 150px;
}

/* ===== Модальное окно ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.3rem;
  color: var(--dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 25px;
}

.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== Загрузка файла ===== */
.file-upload {
  border: 3px dashed #ccc;
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.file-upload:hover {
  border-color: var(--primary);
  background: rgba(67, 97, 238, 0.05);
}

.file-upload.dragover {
  border-color: var(--primary);
  background: rgba(67, 97, 238, 0.1);
}

.file-upload-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.file-upload-text {
  font-size: 1.1rem;
  color: #666;
}

.file-upload input {
  display: none;
}

/* ===== Форма редактирования вопроса ===== */
.question-edit {
  background: var(--light);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 15px;
}

.question-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.question-edit-header span {
  font-weight: 600;
  color: var(--primary);
}

.option-edit {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.option-edit input[type="text"] {
  flex: 1;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
}

.option-edit input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* ===== Логин ===== */
.login-card {
  max-width: 400px;
  margin: 50px auto;
}

.login-icon {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 20px;
}

/* ===== Уведомления ===== */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 500;
}

.alert-success {
  background: rgba(6, 214, 160, 0.2);
  color: #0a8d6f;
  border: 1px solid var(--success);
}

.alert-danger {
  background: rgba(239, 71, 111, 0.2);
  color: #a61b36;
  border: 1px solid var(--danger);
}

.alert-warning {
  background: rgba(255, 209, 102, 0.3);
  color: #8a6d00;
  border: 1px solid var(--warning);
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
  h1 {
    font-size: 1.8rem;
  }

  .container {
    padding: 15px;
  }

  .card {
    padding: 20px;
  }

  .btn {
    padding: 12px 24px;
    font-size: 1rem;
  }

  .admin-nav {
    flex-direction: column;
  }

  .admin-nav .btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  table {
    font-size: 0.9rem;
  }

  th,
  td {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  h1 span {
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topic-item {
    padding: 15px;
  }

  .topic-item .icon {
    font-size: 1.5rem;
  }
}

/* ===== Анимация появления ===== */
.fade-in {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== Детали сессии ===== */
.session-summary {
  background: var(--light);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.session-summary h4 {
  color: var(--dark);
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.session-summary p {
  margin-bottom: 8px;
}

.answers-list {
  margin-top: 20px;
}

.answers-list h4 {
  margin-bottom: 15px;
  color: var(--dark);
}

.detail-answer {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--light);
}

.detail-answer.correct {
  background: rgba(6, 214, 160, 0.15);
  border-left: 4px solid var(--success);
}

.detail-answer.wrong {
  background: rgba(239, 71, 111, 0.15);
  border-left: 4px solid var(--danger);
}

.answer-header {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.answer-number {
  font-weight: 600;
  color: var(--dark);
  min-width: 100px;
}

.answer-status {
  font-size: 1.2rem;
}

.answer-time {
  color: #666;
  font-size: 0.95rem;
  margin-left: auto;
}

/* ===== Скрытые элементы ===== */
.hidden {
  display: none !important;
}

/* ===== Состояние загрузки ===== */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
