* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding-right: 0;
  transition: padding-right 0.3s;
  width: 100%;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 100%;
  margin-bottom: 25px;
}

.hidden {
  display: none !important;
}

/* Error Message */
.error-msg {
  background: #fee;
  border: 2px solid #fcc;
  color: #c33;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* Import Section */
#importSection {
  text-align: center;
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

#importSection h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #333;
}

.import-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

#fileInput {
  display: block;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 250px;
}

#fileInput::-webkit-file-upload-button {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

#fileInput::-webkit-file-upload-button:hover {
  background: #5568d3;
}

.file-status {
  color: #27ae60;
  font-weight: 600;
  margin-top: 15px;
}

/* Saved Quizzes Section */
.saved-quizzes-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.saved-quiz-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  transition: all 0.3s;
  background: #fafafa;
}

.saved-quiz-item:hover {
  border-color: #667eea;
  background: #f8f9ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.quiz-info {
  flex: 1;
}

.quiz-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}

.quiz-meta {
  font-size: 0.9rem;
  color: #666;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quiz-meta span {
  display: inline-block;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-start {
  padding: 10px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-start:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-delete {
  padding: 10px 16px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-delete:hover {
  background: #c0392b;
}

.empty-state {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 40px 20px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 25px;
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 15px;
  flex-shrink: 0;
}

.modal-actions button {
  flex: 1;
  padding: 10px 20px;
  font-size: 0.95rem;
}

/* Form */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
}

.form-group input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
}

.form-group input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #888;
  font-size: 0.9rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-template {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #e0e0e0;
  color: #555;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

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

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-template {
  background: #10b981;
  color: white;
  white-space: nowrap;
}

.btn-template:hover {
  background: #059669;
  transform: translateY(-2px);
}

.btn-success:hover {
  background: #229954;
  transform: translateY(-2px);
}

/* Styled Select */
.styled-select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.3s;
}

.styled-select:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Save Quiz Modal */
#saveQuizModal .modal-content {
  max-width: 450px;
}

#saveQuizModal input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

#saveQuizModal input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
}

/* Test History Styles */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
}

.history-header h2 {
  font-size: 1.3rem;
  color: #333;
  margin: 0;
}

.history-filters {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.history-filters .styled-select {
  min-width: 120px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.test-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-card {
  background: #f9f9f9;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 15px;
  transition: all 0.2s;
}

.history-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
}

.history-quiz-name {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  margin: 0;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.score-badge.passed {
  background: #27ae60;
  color: white;
}

.score-badge.failed {
  background: #e74c3c;
  color: white;
}

.history-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  flex: 1;
}

.history-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: #666;
}

.stat-icon {
  font-size: 1rem;
}

.stat-text {
  font-weight: 500;
}

.history-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.btn-view-detail {
  background: #667eea;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-view-detail:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-delete-result {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-result:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #333;
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 1rem;
  font-weight: 500;
  z-index: 10000;
  animation: slideIn 0.3s ease-out;
  max-width: 400px;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast-success {
  background: #27ae60;
}

.toast.toast-error {
  background: #e74c3c;
}

.toast.toast-info {
  background: #3498db;
}

.toast.toast-undo {
  background: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.toast-undo-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.toast-undo-btn:hover {
  background: #5568d3;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  header h1 {
    font-size: 2rem;
  }

  .card {
    padding: 20px;
  }

  .modal-content {
    padding: 20px;
  }

  .saved-quiz-item {
    flex-direction: column;
    gap: 15px;
  }

  .quiz-actions {
    width: 100%;
    justify-content: stretch;
  }

  .quiz-actions button {
    flex: 1;
  }
}
