/* Custom animations & overrides */
@keyframes spin { 
  to { transform: rotate(360deg); } 
}

@keyframes slideIn { 
  from { transform: translateX(100%); opacity: 0; } 
  to { transform: translateX(0); opacity: 1; } 
}

@keyframes flipIn { 
  0% { transform: rotateY(0deg); } 
  100% { transform: rotateY(180deg); } 
}

@keyframes flipOut { 
  0% { transform: rotateY(180deg); } 
  100% { transform: rotateY(0deg); } 
}

.spinner { 
  animation: spin 1s linear infinite; 
}

.toast-anim { 
  animation: slideIn 0.3s ease; 
}

/* Flashcard flip */
.flashcard-container { 
  perspective: 1000px; 
}

.flashcard-inner { 
  position: relative; 
  width: 100%; 
  transition: transform 0.6s; 
  transform-style: preserve-3d; 
}

.flashcard-container.flipped .flashcard-inner { 
  transform: rotateY(180deg); 
}

.flashcard-front, .flashcard-back { 
  position: absolute; 
  width: 100%; 
  backface-visibility: hidden; 
  min-height: 150px; 
}

.flashcard-back { 
  transform: rotateY(180deg); 
}

/* Accordion */
.accordion-content { 
  max-height: 0; 
  overflow: hidden; 
  transition: max-height 0.3s ease-out; 
}

.accordion-content.open { 
  max-height: 2000px; 
}

/* Timeline marker */
.timeline-marker { 
  cursor: pointer; 
  transition: all 0.2s; 
}

.timeline-marker:hover { 
  transform: scale(1.1); 
}

/* QCM table */
.qcm-table input[type="text"], .qcm-table textarea {
  border: 1px solid #e5e7eb; 
  border-radius: 0.375rem; 
  padding: 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qcm-table input[type="text"]:focus, .qcm-table textarea:focus {
  outline: none; 
  border-color: #667eea; 
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.qcm-table input[type="checkbox"] {
  width: 1.25rem; 
  height: 1.25rem; 
  accent-color: #667eea; 
  cursor: pointer;
}

/* Preview markdown */
.preview-content h1 { 
  font-size: 1.5rem; 
  font-weight: 700; 
  margin-bottom: 0.5rem; 
}

.preview-content h2 { 
  font-size: 1.25rem; 
  font-weight: 600; 
  margin-bottom: 0.5rem; 
}

.preview-content h3 { 
  font-size: 1.1rem; 
  font-weight: 600; 
  margin-bottom: 0.25rem; 
}

.preview-content p { 
  margin-bottom: 0.75rem; 
}

.preview-content ul, .preview-content ol { 
  margin-left: 1.5rem; 
  margin-bottom: 0.75rem; 
}

.preview-content li { 
  margin-bottom: 0.25rem; 
}

.preview-content code { 
  background: #f3f4f6; 
  padding: 0.125rem 0.375rem; 
  border-radius: 0.25rem; 
  font-size: 0.875rem; 
}

.preview-content pre { 
  background: #1f2937; 
  color: #f9fafb; 
  padding: 1rem; 
  border-radius: 0.5rem; 
  overflow-x: auto; 
  margin-bottom: 0.75rem; 
}

.preview-content pre code { 
  background: transparent; 
  color: inherit; 
}

/* Tree styles */
.tree {
  list-style: none;
  padding-left: 0;
}

.tree ul {
  list-style: none;
  padding-left: 1.5rem;
  margin-top: 0.5rem;
}

.folder {
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.folder:hover {
  background-color: #f3f4f6;
}

.folder::before {
  content: "📁";
  font-size: 1rem;
}

.folder.open::before {
  content: "📂";
}

.folder-name {
  font-weight: 500;
  color: #374151;
}

.folder-count {
  font-size: 0.875rem;
  color: #6b7280;
}

.pdf-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}

.pdf-item:hover {
  background-color: #f9fafb;
}

.pdf-icon {
  font-size: 1.25rem;
}

.pdf-name {
  flex: 1;
  font-weight: 500;
  color: #374151;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-generated {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-validated {
  background-color: #d1fae5;
  color: #065f46;
}

.pdf-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-generate, .btn-view, .btn-export {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}

.btn-generate {
  background-color: #10b981;
  color: white;
}

.btn-generate:hover {
  background-color: #059669;
}

.btn-view {
  background-color: #3b82f6;
  color: white;
}

.btn-view:hover {
  background-color: #2563eb;
}

.btn-export {
  background-color: #f59e0b;
  color: white;
}

.btn-export:hover {
  background-color: #d97706;
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-content { 
    max-width: 100%; 
    margin: 0.5rem; 
    max-height: 95vh; 
  }
  
  .qcm-table { 
    font-size: 0.8rem; 
  }
  
  .qcm-table input[type="text"] { 
    padding: 0.25rem; 
  }
  
  .qcm-table td { 
    padding: 0.5rem; 
  }
  
  .flashcard-item { 
    margin-bottom: 1rem; 
  }
  
  .section-item { 
    margin-bottom: 1rem; 
  }
  
  .timeline-marker { 
    margin-bottom: 0.5rem; 
  }
}

/* Visual Editor Styles */
.qcm-editor .qcm-table {
  min-width: 800px;
}

.flashcard-item {
  transition: all 0.2s ease;
}

.flashcard-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.section-header {
  transition: background-color 0.2s ease;
}

.section-header:hover {
  background-color: #f3f4f6;
}

.accordion-arrow {
  transition: transform 0.2s ease;
}

.timeline-marker {
  transition: all 0.2s ease;
}

.timeline-marker:hover {
  background-color: #dbeafe;
  transform: scale(1.02);
}

/* Dashboard active state */
#dashboard.active {
  display: block;
}

/* Modal active state */
#modal.active {
  display: flex;
}