/* ============================================
   CITB Mock Test Quiz Widget
   Professional, accessible, responsive design
   ============================================ */

/* Widget Container */
.quiz-widget {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(16, 23, 43, 0.08), 0 1px 3px rgba(16, 23, 43, 0.04);
  overflow: hidden;
  width: 100%;
  border: 1px solid rgba(32, 92, 177, 0.08);
}

/* Header */
.quiz-widget__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #10172b 0%, #1a3a6e 100%);
  color: #fff;
}

.quiz-widget__icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 194, 14, 0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffc20e;
}

.quiz-widget__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.quiz-widget__subtitle {
  font-size: 0.82rem;
  margin: 2px 0 0;
  opacity: 0.7;
}

/* Body */
.quiz-widget__body {
  padding: 24px;
}

.quiz-widget__prompt {
  font-size: 0.92rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 16px;
}

/* Category Buttons */
.qw-category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.qw-category-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: inherit;
}

.qw-category-btn:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.qw-category-btn:active {
  transform: translateY(0);
}

.qw-category-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}

.qw-category-count {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 10px;
}

@media (max-width: 575px) {
  .qw-category-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 576px) and (max-width: 767px) {
  .qw-category-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .qw-category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Test Buttons */
.qw-test-grid {
  display: grid;
  gap: 10px;
}

.qw-test-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: inherit;
}

.qw-test-btn:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: translateX(4px);
}

.qw-test-btn__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qw-test-btn__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
}

.qw-test-btn__count {
  font-size: 0.78rem;
  color: #94a3b8;
}

.qw-test-btn__arrow {
  font-size: 1.2rem;
  color: #94a3b8;
  transition: color 0.2s;
}

.qw-test-btn:hover .qw-test-btn__arrow {
  color: #3b82f6;
}

/* Back Button */
.qw-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 16px;
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.qw-back-btn:hover {
  border-color: #94a3b8;
  color: #334155;
  background: #f8fafc;
}

/* Quiz Header */
.qw-quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.qw-quiz-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.qw-quiz-counter {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
}

/* Progress Bar */
.qw-progress {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-bottom: 24px;
  overflow: hidden;
}

.qw-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0;
}

/* Question */
.qw-question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.55;
  margin-bottom: 20px;
}

/* Options */
.qw-options {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.qw-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-family: inherit;
  font-size: 0.93rem;
  line-height: 1.45;
  color: #334155;
}

.qw-option:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.qw-option--selected {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}

.qw-option--selected .qw-option__marker {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.qw-option__marker {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  transition: all 0.15s ease;
}

.qw-option__text {
  padding-top: 3px;
}

/* Quiz Navigation */
.qw-quiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Buttons */
.qw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  font-family: inherit;
}

.qw-btn--primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-color: #2563eb;
}

.qw-btn--primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

.qw-btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.qw-btn--outline {
  background: #fff;
  color: #4b5563;
  border-color: #d1d5db;
}

.qw-btn--outline:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.qw-btn--outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qw-btn--full {
  width: 100%;
}

/* Details Form */
.qw-details-header {
  text-align: center;
  margin-bottom: 24px;
}

.qw-details-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.qw-details-header h4 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 6px;
}

.qw-details-header p {
  font-size: 0.88rem;
  color: #6b7280;
  margin: 0;
}

.qw-form-group {
  margin-bottom: 16px;
}

.qw-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.qw-form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.93rem;
  font-family: inherit;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.qw-form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #fff;
}

.qw-form-group input::placeholder {
  color: #9ca3af;
}

.qw-form-error {
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.qw-form-actions {
  display: grid;
  gap: 10px;
}

/* Results */
.qw-results-summary {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.qw-score-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
}

.qw-score-ring svg {
  width: 100%;
  height: 100%;
}

.qw-score-circle {
  transition: stroke-dashoffset 1s ease, stroke 0.3s;
}

.qw-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.qw-score-percent {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.qw-score-detail {
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 12px;
}

.qw-result-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
}

.qw-badge--success {
  background: #dcfce7;
  color: #166534;
}

.qw-badge--info {
  background: #dbeafe;
  color: #1e40af;
}

.qw-badge--warning {
  background: #fef3c7;
  color: #92400e;
}

.qw-badge--danger {
  background: #fef2f2;
  color: #991b1b;
}

/* Detailed Results */
.qw-detailed-results {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.qw-result-item {
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 10px;
  border-left: 4px solid;
}

.qw-result-item--correct {
  background: #f0fdf4;
  border-left-color: #22c55e;
}

.qw-result-item--wrong {
  background: #fef2f2;
  border-left-color: #ef4444;
}

.qw-result-item__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.qw-result-item__icon {
  font-size: 1rem;
  font-weight: 700;
}

.qw-result-item--correct .qw-result-item__icon {
  color: #22c55e;
}

.qw-result-item--wrong .qw-result-item__icon {
  color: #ef4444;
}

.qw-result-item__num {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
}

.qw-result-item__question {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
  line-height: 1.45;
}

.qw-result-item__answer {
  font-size: 0.83rem;
  color: #4b5563;
  margin-bottom: 4px;
}

.qw-result-item__label {
  font-weight: 600;
  color: #6b7280;
}

.qw-result-item__explanation {
  font-size: 0.83rem;
  color: #4b5563;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  line-height: 1.5;
}

.qw-text-success { color: #16a34a; font-weight: 600; }
.qw-text-danger { color: #dc2626; font-weight: 600; }

.qw-results-actions {
  display: flex;
  gap: 10px;
}

.qw-results-actions .qw-btn {
  flex: 1;
}

/* Alert */
.qw-alert {
  padding: 14px 18px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  color: #92400e;
  font-size: 0.9rem;
  text-align: center;
}

/* Shake animation */
@keyframes qwShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.qw-shake {
  animation: qwShake 0.4s ease-in-out;
}

/* Responsive */
@media (max-width: 575.98px) {
  .quiz-widget__header {
    padding: 16px 18px;
  }

  .quiz-widget__body {
    padding: 18px;
  }

  .qw-option {
    padding: 12px 14px;
  }

  .qw-quiz-nav {
    flex-direction: column;
  }

  .qw-results-actions {
    flex-direction: column;
  }
}

/* Scrollbar styling for results */
.qw-detailed-results::-webkit-scrollbar {
  width: 6px;
}

.qw-detailed-results::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.qw-detailed-results::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.qw-detailed-results::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Review Section */
.qw-review-section {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #f8faff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  text-align: center;
}

.qw-review-stars {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.qw-star {
  font-size: 1.75rem;
  color: #d1d5db;
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
  user-select: none;
}

.qw-star.active,
.qw-star.hover {
  color: #ffc20e;
}

.qw-star:hover {
  transform: scale(1.15);
}

.qw-review-form .form-control {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
}

.qw-review-form .form-control:focus {
  border-color: #205cb1;
  box-shadow: 0 0 0 3px rgba(32, 92, 177, 0.1);
}
