:root {
  /* Colors */
  --primary: #6366f1;
  --primary-light: #e0e7ff;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #047857;
  --error: #ef4444;
  --error-light: #fee2e2;
  --orange: #ffae18c4;
  --orange-light: hsl(30 86% 97% / 1);

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Typography & Spacing */
  --font-family-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-family-serif: "Poppins", serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-4xl: 2.25rem;
  --space-1: 0.2rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-16: 4rem;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-base: 250ms ease-out;
  --transition-slow: 350ms ease-out;
}

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

.hidden {
  display: none !important;
}

/* Amélioration du focus pour l'accessibilité */
:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

body {
  font-family: var(--font-family-sans);
  background-image: linear-gradient(to-bottom, var(--gray-50), var(--gray-100));
  color: var(--gray-800);
  line-height: 1.6;
}

.app {
  max-width: 1000px;
  margin: var(--space-8) auto;
  min-height: calc(100vh - var(--space-16));
  display: flex;
  flex-direction: column;
  background: white;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  margin-bottom: 0px;
}

/* --- GLOBAL UI ENHANCEMENTS --- */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: relative;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-container {
  position: absolute;
  top: 0px;
  left: 0;
  right: 0;
  height: 2px;
}

.progress-bar {
  width: 100%;
  height: 100%;
  background: var(--gray-200);
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width var(--transition-slow);
}

.progress-text {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-500);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Language Selector */
.language-selector {
  position: relative;
}

.lang-button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 42px;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--font-size-sm);
}

.lang-button:hover,
.lang-button:focus-visible {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.lang-button img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  transition: transform var(--transition-fast);
}

.lang-button[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-fast);
  z-index: 1000;
}

.lang-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: var(--font-size-sm);
  border-radius: var(--radius);
}

.lang-option:hover,
.lang-option:focus-visible {
  background: var(--gray-50);
}

.lang-option img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
}

/* Main Content & Screens */
.app-main {
  flex: 1;
  padding: var(--space-6) var(--space-10);
  overflow-y: auto;
  position: relative;
}

.btn-close {
  position: absolute;
  right: 20px;
  top: 0px;
  font-size: 2.5rem;
  color: #ed143d;
  cursor: pointer;
}

.screen {
  margin: 0 auto;
  text-align: center;
}

.screen-instruction {
  font-size: var(--font-size-base);
  color: var(--gray-600);
  font-weight: bold;
  max-width: 600px;
  margin: var(--space-4) auto;
}

.screen-text {
  font-size: var(--font-size-base);
  color: var(--gray-500);
  margin: 0 auto var(--space-6);
  padding: var(--space-4);
  background-color: var(--gray-50);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border-left: 4px solid var(--primary);
  text-align: left;
}

/* --- Navigation --- */
.nav-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  /* width: 100%; */
  justify-content: center;
}

.nav-btn {
  padding: var(--space-2);
  background: none;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-base);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  /* Add subtle shadow */
}

.nav-btn:hover:not(:disabled),
.nav-btn:focus-visible:not(:disabled) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.1);
  box-shadow: var(--shadow);
  /* Enhance shadow on hover */
}

.nav-btn:disabled {
  color: var(--gray-400);
  border-color: var(--gray-200);
  cursor: not-allowed;
  background: var(--gray-50);
  box-shadow: none;
  /* Remove shadow when disabled */
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.nav-dots {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-flow: wrap;
  justify-content: center;
}

.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-dot.active {
  background: var(--primary);
  transform: scale(1.5);
}

.nav-dot:hover {
  background: var(--primary);
}

.nav-dot.disabled {
  pointer-events: none;
  opacity: 0.5;
  background-color: var(--gray-300) !important;
}

.nav-dot-separator {
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 0 5px;
}

.nav-dot-separator .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gray-400);
}

/* --- Global Audio Player --- */
.global-audio-player {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  height: 42px;
  background-color: transparent;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  flex-grow: 1;
  max-width: 170px;
  overflow: hidden;
  /* To contain the button's shape */
  margin-left: auto;
  margin-right: 10px;
}

.player-control-btn {
  background: white;
  border: none;
  border-right: 1px solid var(--gray-200);
  width: 54px;
  /* Same as height for a square look */
  height: 100%;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.player-control-btn:hover {
  background-color: var(--gray-100);
  transform: scale(1.02);
  /* Slight scale on hover */
  box-shadow: var(--shadow-sm);
  /* Add subtle shadow */
}

.player-control-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow);
  /* Add shadow when active */
}

.player-slow-mode-btn img {
  width: 50px;
  max-height: 32px;
  object-fit: contain;
  transition: filter var(--transition-fast);
}

.player-control-btn.active img {
  filter: saturate(1.5);
}

.player-progress-wrapper {
  flex-grow: 1;
  padding: 0;
  height: 100%;
  position: relative;
  /* For positioning time overlay */
  display: flex;
  /* To center the time */
  align-items: center;
  /* To center the time */
  justify-content: center;
}

.player-progress-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--gray-100);
  /* Lighter background */
  border-radius: 0;
  /* Full height, no radius needed */
  cursor: default;
  /* Not clickable */
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  width: 0;
  background-color: var(--primary-light);
  /* Lighter fill color */
  border-radius: 0;
  transition: width 50ms linear;
}

.player-time {
  font-size: var(--font-size-sm);
  color: var(--gray-800);
  /* Darker text for contrast */
  font-weight: 600;
  position: relative;
  /* To be on top of the progress bar */
  z-index: 2;
  text-shadow: 0 0 5px white;
  /* Make text more readable */
}

.player-speed-control {
  position: relative;
}

.player-speed-btn {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  /* Add subtle shadow */
}

.player-speed-btn:hover {
  background-color: var(--gray-100);
  border-color: var(--gray-400);
  transform: scale(1.05);
  /* Slight scale on hover */
  box-shadow: var(--shadow);
  /* Enhance shadow on hover */
}

.player-speed-options {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: all var(--transition-fast);
  z-index: 1100;
}

.player-speed-options.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.player-speed-options button {
  padding: var(--space-2) var(--space-4);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: var(--font-size-sm);
}

.player-speed-options button:hover {
  background-color: var(--gray-50);
}

.player-speed-options button.active {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Quiz Score & Completion Icon */
.quiz-score {
  margin-top: var(--space-8);
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--primary-dark);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  min-height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.quiz-score.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Style pour l'icône de complétion du quiz de match audio */
.feedback-icon.completion-icon {
  width: 60px;
  height: 60px;
  stroke: var(--success);
}

.feedback-icon path {
  stroke-width: 3;
}

.feedback-icon.success path {
  stroke: var(--success);
}

.feedback-icon.error path {
  stroke: var(--error);
}

.reading-word {
  transition: background-color var(--transition-fast), color var(--transition-fast);
  display: inline-block;
  border-radius: 4px;
}

.word-highlight {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  position: relative;
}

.word-highlight:after {
  content: "👈";
  position: absolute;
  transform: rotate(45deg);
  translate: -100% 15px;
}

.first-word-clickable {
  cursor: pointer;
  /* border-bottom: 2px solid var(--primary); */
  border-radius: 0;
  /* color: var(--primary-dark); */
}

.first-word-clickable::before {
    content: "▶";
    margin-left: -16px;
    margin-right: 8px;
    color: var(--primary-dark);
}

.feedback-container {
  margin-top: var(--space-3);
  font-weight: 600;
  font-size: var(--font-size-base);
  
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-correct {
  color: var(--success);
  min-height: 24px; /* To prevent layout shifts */
}

.feedback-incorrect {
  color: var(--error);
  min-height: 24px; /* To prevent layout shifts */
}

.order-words-drop-zone.correct {
  border: 2px solid var(--success);
}

.order-words-drop-zone.incorrect {
  border: 2px solid var(--error);
}

.screen-tag{
  background: #6466f1;
  color: white;
  border: none;
  border-right: 1px solid var(--gray-200);
  width: 159px;
  height: 60px;
  border-radius: 0;
  display: flex;
  align-items: center;
  font-size: var(--font-size-xl);
  justify-content: center;
  transition: all var(--transition-fast);
  position: absolute;
  top: 0px;
  left: -55px;
  transform: rotateZ(-45deg);
}
.check-btn {
    background: var(--primary);
    color: var(--gray-100);
}

#next-btn .next-arrow-icon path {
  transition: d 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#next-btn .next-arrow-icon path {
          transition: d 0.2s ease-in-out;
        }

.not-selected {
    background: var(--orange-light) !important;
    border-color: var(--orange) !important;
    color: var(--error-dark) !important;
}
@media screen and (max-width: 768px) {
  .global-audio-player {
    margin: auto;
  }
  .app{
    margin: 0;
    border-radius: 0;
    border: 0;
    min-height: 100dvh;
  }
  .screen-tag{
    top: -7px;
    left: -63px;
  }
}


/* Added for image zoom functionality */
.img-wrapper {
    position: relative;
    cursor: pointer;
    height: 100%;
}

.quiz-img-zoom-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px;
    z-index: 99;
}

.quiz-img-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.img-modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.img-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 25px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.img-modal-close:hover,
.img-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Added for image zoom functionality */
.img-zoom-wrapper {
    position: relative;
    cursor: pointer;
    height: 100%;
}

.img-zoom-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px;
    z-index: 99;
}

.img-zoom-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.img-zoom-modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.img-zoom-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 25px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.img-zoom-modal-close:hover,
.img-zoom-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}


/* Floating Edit Button (shown when not in edit mode) */
.floating-edit-btn {
  position: fixed;
  bottom: 114px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.3s ease;
  z-index: 9999;
}

.floating-edit-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.floating-edit-btn:active {
  transform: scale(0.95);
}

.floating-edit-btn svg {
  width: 24px;
  height: 24px;
}
