/* Markdown UI React Widgets - Optional Styling */
/* Users can import this CSS file to apply consistent styling to all widget components */

/* Base widget container */
.widget {
  margin: 1rem 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}

/* Form container */
.widget-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.widget-form > button[type="button"]:last-child {
  align-self: flex-start;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  background-color: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

/* Button Group */
.widget-button-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.widget-button-group label {
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.widget-button-group div[role="group"] {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.widget-form .widget-button-group button,
.widget-button-group button {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.widget-form .widget-button-group button:hover,
.widget-button-group button:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.widget-form .widget-button-group button[aria-pressed="true"],
.widget-button-group button[aria-pressed="true"] {
  background-color: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

.widget-form .widget-button-group button:focus,
.widget-button-group button:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Text Input */
.widget-button {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.widget-button label {
  font-weight: 500;
  color: #374151;
}

.widget-button input[type="text"] {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background-color: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.widget-button input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.widget-button input[type="text"]::placeholder {
  color: #9ca3af;
}

/* Select and Select Multi */
.selector,
.selector-multi {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.selector label,
.selector-multi-label {
  font-weight: 500;
  color: #374151;
}

.selector select {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background-color: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.selector select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.selector option {
  padding: 0.5rem;
}

/* Checkbox-based Multi Select */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
  max-height: 200px;
  overflow-y: auto;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.25rem 0;
  font-weight: normal;
}

.checkbox-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.checkbox-item span {
  font-size: 0.875rem;
  color: #374151;
}

.checkbox-item:hover {
  background-color: #f9fafb;
  border-radius: 4px;
  margin: -0.25rem 0;
  padding: 0.5rem 0.25rem;
}

/* Slider */
.widget-slider {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.widget-slider label {
  font-weight: 500;
  color: #374151;
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.slider-values {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.current-value {
  font-weight: 600;
  color: #3b82f6;
  background: #eff6ff;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  min-width: 2rem;
  text-align: center;
}

.min-value, .max-value {
  font-weight: 500;
}

.widget-slider input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
}

.widget-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.widget-slider input[type="range"]::-webkit-slider-thumb:hover {
  background: #2563eb;
}

.widget-slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s ease;
}

.widget-slider input[type="range"]::-moz-range-thumb:hover {
  background: #2563eb;
}

/* Form submit button styling - hover and focus states */
.widget-form > button[type="button"]:last-child:hover {
  background-color: #2563eb;
}

.widget-form > button[type="button"]:last-child:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Error styling for unknown widgets */
.widget span[style*="color:red"] {
  color: #ef4444 !important;
  font-weight: 500;
  padding: 0.75rem;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  display: inline-block;
}

/* Multiple Choice Question */
.widget-mcq {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background-color: #ffffff;
}

.mcq-question {
  font-weight: 600;
  font-size: 1.1rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.mcq-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mcq-choice {
  padding: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background-color: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.mcq-choice:hover:not(:disabled) {
  border-color: #9ca3af;
  background-color: #f9fafb;
}

.mcq-choice-selected {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

.mcq-choice-correct {
  border-color: #10b981;
  background-color: #ecfdf5;
  color: #065f46;
}

.mcq-choice-incorrect {
  border-color: #ef4444;
  background-color: #fef2f2;
  color: #991b1b;
}

.mcq-choice:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.mcq-feedback {
  padding: 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}

.mcq-feedback.correct {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.mcq-feedback.incorrect {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Short Answer Question */
.widget-saq {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background-color: #ffffff;
}

.saq-question {
  font-weight: 600;
  font-size: 1.1rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.saq-input-container {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.saq-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.saq-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.saq-input-correct {
  border-color: #10b981;
  background-color: #ecfdf5;
}

.saq-input-incorrect {
  border-color: #ef4444;
  background-color: #fef2f2;
}

.saq-submit {
  padding: 0.75rem 1.25rem;
  background-color: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.saq-submit:hover:not(:disabled) {
  background-color: #2563eb;
}

.saq-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.saq-feedback {
  padding: 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}

.saq-feedback.correct {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.saq-feedback.incorrect {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Responsive design */
@media (max-width: 640px) {
  .widget-button-group div[role="group"] {
    flex-direction: column;
  }
  
  .widget-button-group button {
    width: 100%;
  }
  
  .widget-form {
    padding: 1rem;
  }
  
  .saq-input-container {
    flex-direction: column;
  }
  
  .widget-mcq,
  .widget-saq,
  .widget-quiz {
    padding: 1rem;
  }
}

/* Quiz Component */
.widget-quiz {
  max-width: 800px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quiz-header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border-radius: 12px 12px 0 0;
}

.quiz-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  text-align: center;
  color: white;
}

.quiz-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  color: white;
}

.quiz-progress {
  flex: 1;
  min-width: 200px;
}

.quiz-progress-text {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
  color: white;
}

.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.quiz-score {
  text-align: right;
}

.quiz-score-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
}

.quiz-questions {
  padding: 1.5rem;
}

.quiz-question {
  margin-bottom: 2rem;
  padding: 1.5rem;
  border: 2px solid #f1f5f9;
  border-radius: 8px;
  background: #fafbfc;
  transition: all 0.2s ease;
}

.quiz-question:hover {
  border-color: #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.quiz-question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.quiz-question-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  flex: 1;
}

.quiz-question-points {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-choice {
  padding: 1rem 1.25rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-weight: 500;
}

.quiz-choice:hover:not(:disabled) {
  border-color: #3b82f6;
  background: #eff6ff;
  transform: translateY(-1px);
}

.quiz-choice-selected {
  border-color: #3b82f6;
  background: #eff6ff;
}

.quiz-choice-correct {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.quiz-choice-incorrect {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.quiz-choice:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

.quiz-input-container {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.quiz-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.quiz-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.quiz-input-correct {
  border-color: #10b981;
  background: #ecfdf5;
}

.quiz-input-incorrect {
  border-color: #ef4444;
  background: #fef2f2;
}

.quiz-submit {
  padding: 0.75rem 1.5rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.quiz-submit:hover:not(:disabled) {
  background: #2563eb;
}

.quiz-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

.quiz-feedback.correct {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.quiz-feedback.incorrect {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.quiz-summary {
  margin-top: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 8px;
  text-align: center;
  border: 2px solid #e2e8f0;
}

.quiz-summary h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 1rem 0;
}

.quiz-final-score {
  font-size: 1.2rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 1rem;
}

.quiz-result {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  display: inline-block;
}

.quiz-result.passed {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.quiz-result.failed {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}