/* =========================
   MathPath - Style v2
   (Design basé sur fractfract2.html)
   ========================= */

* {
  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;
  padding: 20px;
  padding-left: 320px; /* espace pour la sidebar à gauche */
  direction: rtl;
}

/* LaTeX en LTR dans contexte RTL */
.mjx-container {
  direction: ltr !important;
}

/* Pour forcer certains éléments à s'afficher en LTR (ex: -32.3) */
.ltr {
  direction: ltr;
  unicode-bidi: embed;
}

/* =========================
   Navigation
   ========================= */
.top-nav {
  background: white;
  padding: 15px;
  border-radius: 15px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s;
  font-weight: bold;
}

.nav-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* =========================
   Avatar Agent
   ========================= */
.agent-avatar {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 1000;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.avatar-image {
  font-size: 4em;
  background: white;
  border-radius: 50%;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: all 0.3s;
}

.avatar-image:hover {
  transform: scale(1.1);
}

.avatar-speech {
  position: absolute;
  bottom: 90px;
  left: -20px;
  background: white;
  padding: 15px 20px;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  max-width: 250px;
  display: none;
}

.avatar-speech::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 30px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid white;
}

.avatar-speech.show {
  display: block;
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =========================
   Système Ulysse
   ========================= */
.ulysse-container {
  position: fixed;
  top: 20px;
  left: 20px;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.2);
  width: 280px;
  z-index: 999;
}

.ulysse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
}

.ulysse-header h3 {
  color: #667eea;
  font-size: 1.3em;
}

.ulysse-points {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 15px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 15px;
}

.ulysse-points .points-value {
  font-size: 2em;
  font-weight: bold;
}

.ulysse-level-nav {
  margin-top: 15px;
}

.level-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  background: #f0f0f0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1em;
  font-weight: bold;
}

.level-btn:hover {
  background: #e0e0e0;
}

.level-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.level-btn.completed {
  background: linear-gradient(135deg, #4CAF50, #8BC34A);
  color: white;
}

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

.ulysse-badges {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid #f0f0f0;
}

.ulysse-badges h4 {
  margin-bottom: 10px;
  color: #667eea;
}

.badge-item {
  display: inline-block;
  font-size: 2em;
  margin: 5px;
  filter: grayscale(100%);
  transition: all 0.3s;
}

.badge-item.unlocked {
  filter: grayscale(0%);
  animation: bounceIn 0.5s;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* =========================
   Main Content
   ========================= */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
}

.level-content {
  display: none;
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.level-content.active {
  display: block;
  animation: slideIn 0.5s;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}

.level-header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 3px solid #f0f0f0;
}

.level-header h2 {
  color: #667eea;
  font-size: 2em;
  margin-bottom: 10px;
}

.level-header .level-icon {
  font-size: 3em;
  margin-bottom: 10px;
}

/* =========================
   Activity Boxes
   ========================= */
.activity-box {
  background: linear-gradient(135deg, #f8f9ff, #fff);
  border: 2px solid #e0e7ff;
  border-radius: 15px;
  padding: 25px;
  margin: 20px 0;
}

.activity-title {
  color: #667eea;
  font-size: 1.4em;
  font-weight: bold;
  margin-bottom: 15px;
}

.problem-statement {
  background: white;
  padding: 20px;
  border-radius: 10px;
  margin: 15px 0;
  border-left: 4px solid #667eea;
  font-size: 1.1em;
  text-align: center;
}

.input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.fraction-input {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fraction-input input {
  width: 80px;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2em;
  margin: 5px 0;
}

.fraction-input .fraction-line {
  width: 100%;
  height: 2px;
  background: #333;
  margin: 2px 0;
}

.input-group input[type="number"] {
  width: 100px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2em;
}

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

/* =========================
   Buttons
   ========================= */
.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: bold;
  margin: 5px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

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

.btn-success {
  background: linear-gradient(135deg, #4CAF50, #8BC34A);
  color: white;
  display: none;
}

/* Petit helper */
.center { text-align: center; }

/* =========================
   Feedback
   ========================= */
.feedback {
  display: none;
  padding: 20px;
  border-radius: 10px;
  margin: 20px 0;
  text-align: center;
  animation: fadeIn 0.5s;
}

.feedback.correct {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  border: 2px solid #28a745;
}

.feedback.incorrect {
  background: linear-gradient(135deg, #f8d7da, #f5c6cb);
  border: 2px solid #dc3545;
}

.feedback-icon {
  font-size: 3em;
  margin-bottom: 10px;
}

.feedback-title {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 10px;
}

.feedback-message {
  font-size: 1.1em;
}

/* =========================
   Error Video / Solution Box
   ========================= */
.error-video {
  display: none;
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
}

.error-video h4 { color: #856404; margin-bottom: 15px; }

.video-steps {
  background: white;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
}

.video-step {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.video-step:last-child { border-bottom: none; }

.solution-box {
  display: none;
  background: #e7f3ff;
  border: 2px solid #2196F3;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
}

.solution-box h4 { color: #1976D2; margin-bottom: 15px; }

.solution-steps {
  background: white;
  padding: 15px;
  border-radius: 8px;
}

.solution-step {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 1.05em;
}
.solution-step:last-child { border-bottom: none; }

/* =========================
   Quiz (placeholder)
   ========================= */
.quiz-question {
  background: white;
  padding: 20px;
  border-radius: 10px;
  margin: 15px 0;
  border: 2px solid #f0f0f0;
}

.quiz-question h4 { color: #667eea; margin-bottom: 15px; }

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  padding: 15px 20px;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1.05em;
}

.quiz-option:hover {
  background: #e9ecef;
  transform: translateX(-5px);
}

.quiz-option.selected {
  background: #cfe2ff;
  border-color: #0d6efd;
}

.quiz-option.correct {
  background: #d1e7dd;
  border-color: #198754;
}

.quiz-option.incorrect {
  background: #f8d7da;
  border-color: #dc3545;
}

/* =========================
   Success Screen
   ========================= */
.success-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.success-screen.show {
  display: flex;
  animation: fadeIn 0.5s;
}

.success-content {
  background: white;
  padding: 50px;
  border-radius: 20px;
  text-align: center;
  animation: bounceIn 0.8s;
}

.success-content h2 {
  color: #667eea;
  font-size: 3em;
  margin-bottom: 20px;
}

.success-icon { font-size: 6em; margin: 20px 0; }

.success-content .points {
  font-size: 2em;
  color: #4CAF50;
  margin: 20px 0;
}

/* =========================
   Responsive (Mobile)
   ========================= */
@media (max-width: 900px) {
  body {
    padding-left: 20px; /* plus de sidebar fixe */
  }

  .ulysse-container {
    position: static;
    width: 100%;
    margin-bottom: 15px;
  }

  .agent-avatar {
    left: 15px;
    bottom: 15px;
  }

  .avatar-image {
    width: 70px;
    height: 70px;
    font-size: 3.2em;
  }

  .success-content {
    width: 92%;
    padding: 30px;
  }

  .success-content h2 {
    font-size: 2.2em;
  }
}
