/* ============================================
   CHARACTER COUNTER
============================================ */

#charCounter {
  position: fixed;
  font-size: 11px;
  color: #adb5bd;
  background: rgba(255, 255, 255, 0.9);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 9999;
  display: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
#charCounter.warning { color: #fd7e14; }
#charCounter.danger  { color: #dc3545; font-weight: bold; }

/* ============================================
   BASE STYLES
============================================ */

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  padding-bottom: 0;
}

.exercice {
  border: 1px solid #ccc;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
}

.exercice label {
  display: block;
  margin-top: 8px;
  font-weight: bold;
}

label {
  font-weight: normal;
  margin-top: 0;
}

input, textarea, select {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
}

.preview {
  margin-top: 10px;
  max-width: 300px;
  border: 1px solid #aaa;
}

/* ============================================
   CROP MODAL
============================================ */

.crop-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  overflow: hidden;
}

.crop-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  animation: fadeIn 0.2s ease-in-out;
}

.crop-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 800px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
  z-index: 2001;
  overflow: hidden;
}

.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.crop-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
}

.crop-modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 2rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s;
  border-radius: 4px;
}

.crop-modal-close:hover {
  color: #1f2937;
  background: #e5e7eb;
}

.crop-modal-body {
  flex: 1;
  padding: 1.5rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.crop-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#cropImage {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.crop-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.cropper-container {
  max-width: 100% !important;
  max-height: 100% !important;
}

/* ============================================
   VIDEO EDITOR MODAL
============================================ */

.video-editor-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.video-editor-card h6 {
  font-weight: 600;
  color: #1f2937;
}

.video-editor-preview {
  text-align: center;
}

#videoCropModal .crop-modal-body {
  padding: 1rem 1.5rem;
  background: #f3f4f6;
}

#videoProcessingProgress .progress {
  background-color: #e5e7eb;
}

#videoProcessingProgress .progress-bar {
  font-weight: 600;
}

/* ============================================
   ANIMATIONS
============================================ */

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   QUILL EDITOR
============================================ */

.ql-toolbar.ql-snow {
  background-color: #f7f7f7;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 8px;
}

.ql-container.ql-snow {
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  background-color: #fff;
}

.ql-toolbar button:hover {
  background-color: #e9ecef;
  border-radius: 4px;
}

/* ============================================
   PREVIEW WRAPPERS
============================================ */

.image-preview-wrapper {
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
}

.image-preview-wrapper img {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.audio-preview-wrapper {
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
}

.audio-preview-wrapper audio {
  outline: none;
  border-radius: 0.25rem;
}

.audio-preview-wrapper audio::-webkit-media-controls-panel {
  background-color: white;
}

/* ============================================
   FIXED ACTION BAR
============================================ */


/* ============================================
   SIDEBAR NAVIGATION
============================================ */

.sidebar-nav {
  z-index : 1080;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #f8f9fa;
}

.sidebar-content {
  min-height: 100vh;
}

/* Custom scrollbar */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  background: white;
  border: 1px solid #dee2e6;
}

.section-header:hover {
  background: #f8f9fa;
  border-color: #adb5bd;
}

.section-header.active {
  background: #e7f3ff;
  border-color: #0d6efd;
  box-shadow: 0 2px 4px rgba(13, 110, 253, 0.1);
}

/* Chevron toggle */
.section-toggle {
  font-size: 0.75rem;
  transition: transform 0.2s;
  color: #6c757d;
  margin-right: 0.5rem;
}

.section-header.expanded .section-toggle {
  transform: rotate(90deg);
}

.section-name {
  flex: 1;
}

/* Exercise List */
.exercise-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
  display: none;
  touch-action: pan-y;
  user-select: none;
}

.exercise-list.show {
  display: block;
}

.exercise-list li {
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  margin: 0.25rem 0;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.2s;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border: 1px solid #e9ecef;
  position: relative;
}

.exercise-list li:hover {
  background: #f8f9fa;
  border-color: #0d6efd;
}

.exercise-list li.active {
  background: #0d6efd;
  color: white;
  font-weight: 500;
  border-color: #0d6efd;
}

.exercise-list li .exercise-type {
  font-size: 0.75rem;
  opacity: 0.7;
}

.exercise-list li.active .exercise-type {
  opacity: 0.9;
}

/* Drag handle */
.exercise-list li .drag-handle {
  position: absolute;
  left: 0.5rem;
  opacity: 0.3;
  font-size: 0.85rem;
  cursor: grab;
  touch-action: none;  /* Prevents scrolling when grabbing */
}

.exercise-list li:hover .drag-handle {
  opacity: 0.6;
}

.exercise-list li.active .drag-handle {
  opacity: 0.8;
  color: white;
}

/* Delete button */
.exercise-list li .delete-exercise {
  margin-left: auto;
  padding: 0.15rem 0.35rem;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.exercise-list li:hover .delete-exercise {
  opacity: 1;
}

.exercise-list li.active .delete-exercise {
  opacity: 1;
}

/* Sortable.js styles */
.sortable-ghost {
  opacity: 0.4;
  background: #e9ecef !important;
}

.sortable-drag {
  cursor: grabbing !important;
  z-index: 9999 !important;
  opacity: 0.9 !important;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
}

/* Native drag-and-drop drop zones (cartes nav) */
.carte-drop-zone {
  height: 6px;
  list-style: none;
  border-radius: 3px;
  transition: height 0.12s ease, background-color 0.12s ease;
  margin: 0 0.5rem;
}

.carte-drop-zone.active {
  height: 22px;
  background-color: #0d6efd;
  border-radius: 4px;
}

/* Theme picker cards */
.carte-theme-card {
  border: 3px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.carte-theme-card:hover {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}

.carte-theme-card.active {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.25);
}

.carte-theme-preview {
  display: flex;
  gap: 2px;
  height: 120px;
  background: #f0f0f0;
  overflow: hidden;
}

.carte-theme-preview img {
  flex: 1;
  width: 50%;
  height: 100%;
  object-fit: cover;
}

.carte-theme-label {
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 0;
  background: #fff;
}

.carte-theme-card.active .carte-theme-label {
  background: #0d6efd;
  color: #fff;
}

/* Add Exercise Button */
.add-exercise-btn {
  font-size: 0.8rem;
  padding: 0.4rem;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}



/* ============================================
   MAIN CONTENT AREA
============================================ */

.main-content {
  min-height: 100vh;
  background: #f8f9fa;
}

#cartesAddBtn_revision:not(:disabled) {
  color: #0a6c8a;
  border-color: #0a6c8a;
}
#cartesAddBtn_revision:not(:disabled):hover {
  background-color: #0a6c8a;
  color: #fff;
}


.content-area {
  max-width: 1200px;
  margin: 0 auto;
}

/* Welcome Screen */
#welcome-screen {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Section Overview */
#section-overview .card {
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#overview-icon {
  font-size: 1.8rem;
}

/* Exercise View */
#exercise-view .exercice {
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: all 0.3s;
}

#exercise-view .exercice:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: #0d6efd;
}

/* ============================================
   LEGACY STYLES (for compatibility)
============================================ */

#fixedTabsWrapper {
  position: sticky;
  top: 0;
  background: white;
  z-index: 1030;
}

#pane-preview h2 {
  margin-top: 1rem;
}

#jsonPreview {
  background: #f9f9f9;
  border-left: 4px solid #0dcaf0;
}

/* ============================================
   RESPONSIVE DESIGN
============================================ */

@media (max-width: 768px) {
  .crop-modal-content {
    width: 95vw;
    height: 90vh;
  }
  
  .crop-modal-header,
  .crop-modal-footer {
    padding: 0.75rem 1rem;
  }
  
  .crop-modal-body {
    padding: 1rem;
  }
  
  .crop-modal-title {
    font-size: 1.125rem;
  }

  .sidebar-nav {
    position: fixed;
    left: -100%;
    top: 0;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    z-index: 1040;
    transition: left 0.3s;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }

  .sidebar-nav.show {
    left: 0;
  }


  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
  }

  .sidebar-overlay.show {
    display: block;
  }
}

/* ============================================
   UTILITIES
============================================ */

.flex-grow-1 {
  flex-grow: 1;
}

#scormPlayerModal{
  z-index: 50000;
}

/* ============================================
   MODAL Z-INDEX FIX (above fixed overlay screens)
============================================ */

/* Our full-screen overlays sit at z-index 9997–9999.
   Bootstrap modals default to 1055 — they'd appear behind.
   Raise modals and their backdrop above all overlays. */
.modal-backdrop {
  z-index: 10000 !important;
}
.modal {
  z-index: 10001 !important;
}
