/**
 * MathQuill 4 Quill CSS
 * Styles pour l'interface d'édition de formules mathématiques
 */

/* Container principal de l'éditeur */
.mathquill4quill-editor {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 9999;
  max-width: 90vw;
  max-height: 90vh;
  min-width: 600px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Responsive pour mobile */
@media (max-width: 768px) {
  .mathquill4quill-editor {
    min-width: 320px;
    width: 95vw;
    max-height: 95vh;
  }
  .mathquill4quill-field {
    min-height: 160px;   /* plus haut par défaut sur mobile */
    padding: 18px;
    font-size: 18px;
  }
  .mathquill4quill-field .mq-math-mode {
    font-size: 18px !important;
  }
}

/* En-tête */
.mathquill4quill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e1e5e9;
  border-radius: 12px 12px 0 0;
}

.mathquill4quill-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.mathquill4quill-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mathquill4quill-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* Contenu principal */
.mathquill4quill-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

/* Section d'input */
.mathquill4quill-input-section {
  margin-bottom: 24px;
}

/* Taille et confort de saisie accrus */
.mathquill4quill-field {
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  padding: 20px;               /* + */
  font-size: 20px;             /* + */
  line-height: 1.6;            /* + meilleur confort */
  min-height: 140px;           /* + plus de place par défaut */
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 12px;
  overflow: auto;              /* requis pour resize */
  resize: vertical;            /* + redimensionnable */
}

.mathquill4quill-field:focus-within {
  border-color: #36B1B3;
  outline: none;
  box-shadow: 0 0 0 4px rgba(54,177,179,0.18); /* halo un peu plus large */
}

.mathquill4quill-preview {
  background: #f8fafc;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  padding: 16px;
  min-height: 50px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mathquill4quill-placeholder {
  color: #64748b;
  font-style: italic;
}

.mathquill4quill-error {
  color: #dc2626;
  font-style: italic;
}

/* Section des opérateurs */
.mathquill4quill-operators {
  margin-bottom: 24px;
}

.mathquill4quill-operators-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}

.mathquill4quill-operators-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.mathquill4quill-operator {
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Times New Roman', serif;
}

.mathquill4quill-operator:hover {
  background: #f1f5f9;
  border-color: #36B1B3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mathquill4quill-operator:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Section historique */
.mathquill4quill-history {
  margin-bottom: 24px;
}

.mathquill4quill-history-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}

.mathquill4quill-history-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.mathquill4quill-history-item {
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  text-align: left;
  font-family: 'Times New Roman', serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mathquill4quill-history-item:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
}

.mathquill4quill-history-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mathquill4quill-history-delete {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.mathquill4quill-history-delete:hover {
  background: #fee2e2;
}

/* Pied de page */
.mathquill4quill-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  background: #f8fafc;
  border-top: 1px solid #e1e5e9;
  border-radius: 0 0 12px 12px;
}

.mathquill4quill-cancel,
.mathquill4quill-insert {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 80px;
}

.mathquill4quill-cancel {
  background: #ffffff;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.mathquill4quill-cancel:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.mathquill4quill-insert {
  background: #36B1B3;
  color: #ffffff;
}

.mathquill4quill-insert:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.mathquill4quill-insert:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Overlay pour fermer en cliquant à côté */
.mathquill4quill-overlay {
  position: fixed;
  inset: 0;
  /* overlay très léger pour voir l’éditeur derrière */
  background: rgba(17, 24, 39, 0.18);  /* ~18% d’opacité */
  /* Optionnel : un très léger flou pour réduire la distraction */
  backdrop-filter: blur(1px);
  z-index: 9998;
}

/* Styles spécifiques pour MathQuill dans notre éditeur */
.mathquill4quill-field .mq-root-block {
  border: none !important;
  padding: 0 !important;
}

/* S’assurer que la taille interne de MQ suit */
.mathquill4quill-field .mq-math-mode {
  font-size: 20px !important;  /* aligné avec le conteneur */
  line-height: 1.6 !important;
}

/* Label + texte d’aide */
.mathquill4quill-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.mathquill4quill-hint {
  margin: 6px 0 12px;
  font-size: 13px;
  color: #6b7280;
}

/* Caret visible et animé dans le champ MathQuill */
.mathquill4quill-field .mq-cursor {
  /* ta couleur bleue */
  border-left-color: #3b82f6 !important;

  /* propriétés manquantes : on dessine le caret */
  border-left-width: 2px !important;     /* épaisseur du caret */
  border-left-style: solid !important;
  width: 0 !important;                   /* caret fin, sans largeur propre */
  margin-left: -1px;                     /* alignement visuel */
  height: 1em;                           /* hauteur raisonnable du caret */
  animation: mq-blink 1s step-end infinite; /* clignotement régulier */
}

/* Clignotement du caret */
@keyframes mq-blink {
  50% { border-left-color: transparent; }
}

/* Améliore la visibilité de la sélection dans MathQuill */
.mathquill4quill-field .mq-selection {
  background: rgba(59, 130, 246, 0.20);
}


.mathquill4quill-field .mq-hasCursor {
  box-shadow: none !important;
}

/* Barres de défilement personnalisées */
.mathquill4quill-operators-grid::-webkit-scrollbar,
.mathquill4quill-history-grid::-webkit-scrollbar {
  width: 6px;
}

.mathquill4quill-operators-grid::-webkit-scrollbar-track,
.mathquill4quill-history-grid::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.mathquill4quill-operators-grid::-webkit-scrollbar-thumb,
.mathquill4quill-history-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.mathquill4quill-operators-grid::-webkit-scrollbar-thumb:hover,
.mathquill4quill-history-grid::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Animation d'apparition */
@keyframes mathquill4quill-fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.mathquill4quill-editor {
  animation: mathquill4quill-fade-in 0.2s ease-out;
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
  .mathquill4quill-editor {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
  }
  
  .mathquill4quill-header {
    background: #111827;
    border-color: #374151;
  }
  
  .mathquill4quill-title {
    color: #f9fafb;
  }
  
  .mathquill4quill-close {
    color: #9ca3af;
  }
  
  .mathquill4quill-close:hover {
    background: #374151;
    color: #f9fafb;
  }
  
  .mathquill4quill-field {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
  }
  
  .mathquill4quill-field:focus-within {
    border-color: #60a5fa;
  }
  
  .mathquill4quill-preview {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
  }
  
  .mathquill4quill-operator,
  .mathquill4quill-history-item {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
  }
  
  .mathquill4quill-operator:hover,
  .mathquill4quill-history-item:hover {
    background: #1f2937;
    border-color: #60a5fa;
  }
  
  .mathquill4quill-footer {
    background: #111827;
    border-color: #374151;
  }
  
  .mathquill4quill-cancel {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }
  
  .mathquill4quill-cancel:hover {
    background: #4b5563;
  }

  .mathquill4quill-overlay {
    background: rgba(0, 0, 0, 0.28);
  }
} 

/* Option : bloquer le scroll de fond quand l’éditeur est ouvert */
body.mq4q-no-scroll {
   overflow: hidden;
}