/*
  ===================================================================
  FICHIER CSS - BANQUE D'EXERCICES
  Design cohérent avec le site ScienceXpert
  ===================================================================
*/

:root {
  --primary-orange: #ff6a00;
  --secondary-yellow: #ffe066;
  --text-primary: #222;
  --text-secondary: #555;
  --shadow-light: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.15);
  --background-warm: #fff2beff;
  --card-bg: rgba(255, 251, 241, 0.72);
  --card-border: rgba(220, 201, 160, 0.9);
  --card-shadow: 0 16px 34px rgba(120, 98, 52, 0.08);
  --badge-bg: #f6e5bc;
  --badge-border: #ead2a0;
  --badge-text: #bf780d;
  --border-radius: 26px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--background-warm);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.7;
}

.main-content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ----------------------------------- */
/* Hero Section                        */
/* ----------------------------------- */
.exercices-hero {
  background: white;
  border-radius: 20px;
  padding: 50px;
  box-shadow: var(--shadow-light);
  margin-bottom: 40px;
}

.exercices-header {
  text-align: center;
  margin-bottom: 40px;
}

.exercices-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 106, 0, 0.1);
  color: var(--primary-orange);
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 106, 0, 0.2);
  box-shadow: none;
}

.exercices-header h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 15px 0;
  letter-spacing: -1px;
  line-height: 1.1;
}

.gradient-text {
  background: linear-gradient(135deg, #ff6a00, #ff9500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.exercices-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ----------------------------------- */
/* Search Bar                          */
/* ----------------------------------- */
.search-bar {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 14px 50px 14px 48px;
  border: 1.5px solid var(--card-border);
  border-radius: 50px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  background: rgba(255, 251, 241, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-orange);
  box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.1);
  background: rgba(255, 255, 255, 0.85);
}

.search-input::placeholder {
  color: #aaa;
  font-weight: 400;
}

.search-clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: #e0e0e0;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  color: #666;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.search-clear-btn:hover {
  background: #f44336;
  color: white;
}

/* ----------------------------------- */
/* Filter Bar & Panel                  */
/* ----------------------------------- */
.filter-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 248, 232, 0.94);
  color: #5a4300;
  padding: 12px 26px;
  border-radius: 999px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: 1.5px solid rgba(192, 137, 25, 0.58);
  box-shadow:
    0 8px 20px rgba(193, 145, 39, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s ease,
    background 0.28s ease,
    border-color 0.28s ease;
}

.filter-toggle-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 244, 214, 0.98);
  border-color: rgba(176, 122, 13, 0.72);
  box-shadow:
    0 12px 24px rgba(193, 145, 39, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.filter-toggle-btn.active {
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(255, 106, 0, 0.3);
}

.filter-icon {
  font-size: 1.1rem;
}

.active-filters-badge {
  background: white;
  color: var(--primary-orange);
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Filter Panel */
.filter-panel {
  display: none;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 25px 30px;
  margin-bottom: 25px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: slideDown 0.3s ease;
  text-align: left;
}

.filter-panel.open {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

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

.filter-instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
  padding: 12px 15px;
  background: rgba(255, 106, 0, 0.06);
  border-radius: 12px;
  border-left: 3px solid var(--primary-orange);
}

.filter-group {
  margin-bottom: 20px;
}

.filter-group h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 248, 232, 0.8);
  padding: 10px 18px;
  border-radius: 25px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px solid var(--badge-border);
}

.filter-chip:hover {
  border-color: var(--primary-orange);
  color: var(--primary-orange);
  transform: translateY(-1px);
  background: rgba(255, 244, 214, 0.95);
}

.filter-chip.selected {
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  color: white;
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(255, 106, 0, 0.3);
}

/* Filter Actions */
.filter-actions {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px dashed var(--badge-border);
  text-align: center;
}

.clear-filters-btn {
  background: transparent;
  border: 1.5px solid var(--badge-border);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: 25px;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-filters-btn:hover {
  border-color: #f44336;
  color: #f44336;
  background: rgba(244, 67, 54, 0.05);
}

/* Results Info */
.results-info {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 25px;
  padding: 12px 20px;
  background: rgba(255, 106, 0, 0.06);
  border-radius: 12px;
}

.results-info #resultsCount {
  font-weight: 700;
  color: var(--primary-orange);
}

/* ----------------------------------- */
/* Exercise Cards                      */
/* ----------------------------------- */
.exercices-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.exercice-card {
  padding: 28px 32px;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    transform 0.35s ease,
    box-shadow 0.35s ease,
    background 0.35s ease;
  animation: cardFadeIn 0.5s ease both;
}

.exercice-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 248, 232, 0.92);
  box-shadow:
    0 24px 50px rgba(176, 135, 24, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* Stagger animation for exercise cards */
.exercice-card:nth-child(1) {
  animation-delay: 0.02s;
}

.exercice-card:nth-child(2) {
  animation-delay: 0.06s;
}

.exercice-card:nth-child(3) {
  animation-delay: 0.10s;
}

.exercice-card:nth-child(4) {
  animation-delay: 0.14s;
}

.exercice-card:nth-child(5) {
  animation-delay: 0.18s;
}

.exercice-card:nth-child(6) {
  animation-delay: 0.22s;
}

.exercice-card:nth-child(7) {
  animation-delay: 0.26s;
}

.exercice-card:nth-child(8) {
  animation-delay: 0.30s;
}

.exercice-card:nth-child(9) {
  animation-delay: 0.34s;
}

.exercice-card:nth-child(10) {
  animation-delay: 0.38s;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-level {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--badge-text);
}

.badge-subject {
  background: rgba(255, 106, 0, 0.1);
  border: 1px solid rgba(255, 106, 0, 0.2);
  color: var(--primary-orange);
}

.difficulty-stars {
  font-size: 1.1rem;
  display: flex;
  gap: 2px;
}

.pepper {
  filter: grayscale(100%);
  opacity: 0.3;
}

.pepper.active {
  filter: grayscale(0%);
  opacity: 1;
}

.card-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.card-theme,
.card-levels {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 6px 0;
}

.card-theme strong,
.card-levels strong {
  color: var(--text-primary);
}

/* ----------------------------------- */
/* Exercise Details (Collapsible)      */
/* ----------------------------------- */
.exercice-details {
  margin-top: 20px;
  border-top: 1px dashed var(--badge-border);
  padding-top: 15px;
}

.exercice-summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--primary-orange);
  background: rgba(255, 248, 232, 0.94);
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--badge-border);
  list-style: none;
  transition: all 0.28s ease;
}

.exercice-summary::-webkit-details-marker {
  display: none;
}

.exercice-summary:hover {
  background: rgba(255, 244, 214, 0.98);
  transform: translateX(5px);
  border-color: rgba(176, 122, 13, 0.72);
}

.exercice-summary::before {
  content: '▸';
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

details[open].exercice-details>.exercice-summary::before {
  transform: rotate(90deg);
}

.exercice-body {
  padding: 25px 0 10px 0;
}

/* ----------------------------------- */
/* Question Box                        */
/* ----------------------------------- */
.question-box {
  background: rgba(255, 248, 232, 0.94);
  border: 1px solid var(--badge-border);
  border-left: 4px solid var(--primary-orange);
  padding: 22px 25px;
  border-radius: 16px;
  margin-bottom: 20px;
}

.question-box h4 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  color: var(--primary-orange);
  display: flex;
  align-items: center;
  gap: 8px;
}

.question-box p {
  margin: 8px 0;
  line-height: 1.7;
}

/* ----------------------------------- */
/* Remarque Box                        */
/* ----------------------------------- */
.remarque {
  background: rgba(255, 248, 232, 0.94);
  border-left: 4px solid var(--primary-orange);
  border: 1px solid var(--badge-border);
  border-left: 4px solid var(--primary-orange);
  padding: 18px 25px;
  border-radius: 12px;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.remarque p {
  margin: 0;
}

/* ----------------------------------- */
/* Hint Dropdown                       */
/* ----------------------------------- */
.hint-dropdown {
  margin: 18px 0;
}

.hint-dropdown summary {
  cursor: pointer;
  font-weight: 600;
  color: #5a4300;
  background: rgba(255, 248, 232, 0.94);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--badge-border);
  list-style: none;
  transition: all 0.28s ease;
}

.hint-dropdown summary::-webkit-details-marker {
  display: none;
}

.hint-dropdown summary::before {
  content: '💡 ';
}

details[open].hint-dropdown>summary::before {
  content: '💡 ';
}

.hint-dropdown summary:hover {
  background: rgba(255, 244, 214, 0.98);
  transform: translateX(3px);
  border-color: rgba(176, 122, 13, 0.72);
}

.hint-content {
  background: rgba(255, 251, 241, 0.8);
  padding: 22px;
  border-radius: 0 0 12px 12px;
  margin-top: -1px;
  border: 1px solid var(--badge-border);
  border-top: 1px dashed var(--badge-border);
}

.hint-content p {
  margin: 10px 0;
}

.hint-content p:first-child {
  margin-top: 0;
}

.hint-content p:last-child {
  margin-bottom: 0;
}

/* ----------------------------------- */
/* Correction Dropdown                 */
/* ----------------------------------- */
.correction-dropdown {
  margin-top: 18px;
}

.correction-dropdown summary {
  cursor: pointer;
  font-weight: 600;
  color: #2e7d32;
  background: rgba(232, 245, 233, 0.8);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid #a5d6a7;
  list-style: none;
  transition: all 0.28s ease;
}

.correction-dropdown summary::-webkit-details-marker {
  display: none;
}

.correction-dropdown summary::before {
  content: '▸ ';
  transition: transform 0.3s ease;
}

details[open].correction-dropdown>summary::before {
  content: '▾ ';
}

.correction-dropdown summary:hover {
  background: rgba(200, 230, 201, 0.8);
  transform: translateX(3px);
}

.correction-content {
  background: rgba(255, 255, 255, 0.7);
  padding: 25px;
  border-radius: 0 0 16px 16px;
  margin-top: -1px;
  border: 1px solid rgba(220, 201, 160, 0.6);
  border-top: 1px dashed #a5d6a7;
}

.correction-content h4 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 28px 0 15px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--secondary-yellow);
}

.correction-content h4:first-child {
  margin-top: 0;
}

.correction-content p {
  margin: 12px 0;
  line-height: 1.8;
}

.correction-content ul {
  list-style-type: none;
  padding-left: 5px;
  margin: 15px 0;
}

.correction-content ul li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 10px;
}

.correction-content ul li::before {
  content: '▪';
  color: var(--primary-orange);
  font-size: 1.2em;
  position: absolute;
  left: 0;
  top: 0;
}

.correction-content hr {
  border: 0;
  border-top: 2px dashed var(--badge-border);
  margin: 30px 0;
}

/* Schema container */
.schema-container {
  text-align: center;
  margin: 25px 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
}

.schema-container svg {
  max-width: 100%;
  height: auto;
}

/* Result box */
.result-final {
  background: rgba(232, 245, 233, 0.7);
  border: 1.5px solid #81c784;
  padding: 20px 25px;
  border-radius: 16px;
  margin: 20px 0;
}

.result-final p.note {
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px dashed #a5d6a7;
}

/* ----------------------------------- */
/* Pagination                          */
/* ----------------------------------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 35px;
  padding-top: 25px;
  border-top: 1px dashed var(--badge-border);
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--badge-border);
  border-radius: 12px;
  background: rgba(255, 248, 232, 0.8);
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-btn:hover:not(.disabled):not(.active) {
  border-color: var(--primary-orange);
  color: var(--primary-orange);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 106, 0, 0.15);
}

.page-btn.active {
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(255, 106, 0, 0.35);
  font-weight: 600;
}

.page-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 42px;
  font-size: 1.1rem;
  color: #aaa;
  letter-spacing: 2px;
}

/* ----------------------------------- */
/* Responsive                          */
/* ----------------------------------- */
@media (max-width: 768px) {
  .exercices-hero {
    padding: 30px 15px;
  }

  .exercices-header h1 {
    font-size: 2rem;
    letter-spacing: -0.5px;
  }

  .exercices-subtitle {
    font-size: 0.95rem;
  }

  .filter-bar {
    flex-direction: column;
    gap: 10px;
  }

  .filter-toggle-btn {
    width: 100%;
    justify-content: center;
  }

  .filter-panel {
    padding: 20px;
    border-radius: 20px;
  }

  .filter-group h4 {
    font-size: 0.9rem;
  }

  .filter-chip {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .exercice-card {
    padding: 20px;
    border-radius: 20px;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .card-header {
    flex-direction: column;
    gap: 12px;
  }

  .correction-content,
  .hint-content {
    padding: 18px;
    overflow-x: auto;
  }

  mjx-container[display="true"] {
    overflow-x: auto !important;
    max-width: 100% !important;
  }

  .search-input {
    padding: 12px 44px 12px 42px;
    font-size: 0.9rem;
  }

  .pagination {
    gap: 6px;
  }

  .page-btn {
    min-width: 36px;
    height: 36px;
    font-size: 0.85rem;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .main-content-wrapper {
    padding: 15px;
  }

  .exercices-hero {
    padding: 25px 10px;
  }

  .exercices-badge {
    padding: 6px 14px;
    font-size: 0.85rem;
  }

  .exercices-header h1 {
    font-size: 1.7rem;
  }

  .filter-options {
    gap: 6px;
  }

  .filter-chip {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .search-input-wrapper {
    max-width: 100%;
  }

  .page-btn {
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
    padding: 0 8px;
  }
}