/* Grading Page Consolidated Styles */

:root {
  --primary: #4F46E5;
  /* indigo */
  --primary-600: #4338ca;
  --primary-700: #3730a3;
  --blue: #3B82F6;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #0F172A;
  --white: #ffffff;
}

/* Page containers */
.dashboard-main .filter-section,
.dashboard-main .grading-section {
  position: relative;
  z-index: 10;
}

/* Filter controls */
.filter-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.liquid-input {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  font-size: 14px;
  min-width: 220px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.6);
}

.liquid-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Bulk toolbar */
.bulk-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bulk-toolbar .left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.bulk-toolbar .right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.bulk-toolbar .results-count {
  color: var(--gray-500);
  font-size: 14px;
}

.bulk-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--gray-600);
}

.bulk-btn {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
  font-size: 13px;
  transition: all .2s ease;
}

.bulk-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  transform: translateY(-1px);
}

.bulk-btn.primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--primary) 100%);
  color: #fff;
  border-color: rgba(59, 130, 246, .6);
  box-shadow: 0 4px 16px rgba(59, 130, 246, .3);
}

.bulk-btn.primary:hover {
  filter: brightness(1.05);
}

.bulk-btn.bulk-delete {
  background: linear-gradient(135deg, var(--red) 0%, #DC2626 100%);
  color: #fff;
  border-color: rgba(239, 68, 68, .6);
  box-shadow: 0 4px 16px rgba(239, 68, 68, .3);
}

.bulk-btn.bulk-delete:hover {
  filter: brightness(1.05);
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
}

.bulk-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* Grading list */
.grading-list {
  display: grid;
  gap: 12px;
}

.grading-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  transition: box-shadow .2s ease, border-color .2s ease;
}

.grading-item .item-actions-container>* {
  vertical-align: middle;
}

.grading-item:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  border-color: var(--gray-300);
}

/* Item actions container to align score with buttons */
.item-actions-container {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}

.item-actions-container .status-badge {
  height: 32px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  margin-right: 2px;
}

.item-actions-container .item-score {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.item-actions-container .item-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.item-checkbox input {
  width: 18px;
  height: 18px;
}

.item-info {
  min-width: 0;
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 32px;
}

.worksheet-name {
  margin: 0;
  font-weight: 700;
  color: var(--gray-900);
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-details {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: nowrap;
  font-size: 13px;
  color: var(--gray-600);
  white-space: nowrap;
  overflow: hidden;
}

.detail-item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--gray-600);
  min-width: 0;
}

.detail-item i {
  color: var(--gray-500);
  font-size: 14px;
  flex: 0 0 16px;
  width: 16px;
  text-align: center;
  line-height: 1;
}

.detail-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
  height: 24px;
  line-height: 1;
  box-sizing: border-box;
}

/* Match action row height */
.item-score .score-display,
.grading-section .item-actions .btn-action,
.item-actions-container .status-badge {
  height: 32px;
}

.status-completed,
.status-graded {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-processing {
  background: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-pending {
  background: rgba(243, 244, 246, 0.2);
  color: var(--gray-300);
  border: 1px solid rgba(229, 231, 235, 0.2);
}

/* Score pill - aligned with buttons */
.item-score .score-display {
  min-width: 60px;
  text-align: center;
  padding: 0 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  height: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin-bottom: 0;
}

.score-a {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}

.score-b {
  background: rgba(59, 130, 246, 0.15);
  color: #1D4ED8;
}

.score-c {
  background: rgba(245, 158, 11, 0.15);
  color: #92400E;
}

.score-d {
  background: rgba(249, 115, 22, 0.15);
  color: #9A3412;
}

.score-f {
  background: rgba(239, 68, 68, 0.15);
  color: #B91C1C;
}

/* Actions - aligned with score pill */
.item-actions {
  display: flex;
  gap: 8px;
}

.grading-section .item-actions .btn-action {
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-700);
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  height: 32px;
  line-height: 1;
  box-sizing: border-box;
}

.grading-section .item-actions .btn-action:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--gray-800);
  transform: translateY(-1px);
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--gray-300);
  padding: 28px;
}

/* Results modal - matching upload.html styling */
.grading-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.grading-modal.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.grading-modal-content {
  width: 95vw;
  height: 90vh;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.grading-modal.show .grading-modal-content {
  transform: scale(1);
}

.grading-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 2px solid rgba(79, 70, 229, 0.1);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.grading-modal-header h2 {
  margin: 0;
  color: #374151;
  font-size: 22px;
  font-weight: 600;
}

.close-grading-modal {
  background: none;
  border: none;
  font-size: 32px;
  color: #6B7280;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.close-grading-modal:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

.split-screen-container {
  display: flex;
  flex: 1;
  min-height: 0;
}

.worksheet-panel {
  flex: 1;
  background: #F9FAFB;
  border-right: 2px solid rgba(79, 70, 229, 0.1);
  display: flex;
  flex-direction: column;
}

.grading-panel {
  flex: 1;
  background: white;
  display: flex;
  flex-direction: column;
  min-width: 320px;
}

/* Modal controls - matching upload.html */
.worksheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
  background: white;
}

.worksheet-header h3 {
  margin: 0;
  color: #374151;
  font-size: 18px;
  font-weight: 600;
}

.worksheet-controls {
  display: flex;
  gap: 8px;
}

.worksheet-controls .zoom-btn {
  padding: 8px;
  background: rgba(79, 70, 229, 0.1);
  border: 2px solid rgba(79, 70, 229, 0.2);
  border-radius: 8px;
  color: #4F46E5;
  cursor: pointer;
  transition: all 0.2s ease;
}

.worksheet-controls .zoom-btn:hover {
  background: rgba(79, 70, 229, 0.2);
  transform: translateY(-1px);
}

/* Modal grading content - enhanced styling */
.grading-summary {
  padding: 30px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(5, 150, 105, 0.05) 100%);
  border-bottom: 2px solid rgba(16, 185, 129, 0.1);
}

.score-display {
  text-align: center;
  margin-bottom: 20px;
}

.grading-summary .total-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  margin-bottom: 10px;
}

.grading-summary .score-number {
  font-size: 48px;
  font-weight: 800;
  color: #047857;
  text-shadow: 0 2px 4px rgba(4, 120, 87, 0.2);
}

.grading-summary .score-unit {
  font-size: 24px;
  font-weight: 600;
  color: #6B7280;
}

.grading-summary .score-label {
  font-size: 16px;
  color: #6B7280;
  font-weight: 500;
}

.summary-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 12px;
}

.summary-stats .stat-item {
  text-align: center;
}

.summary-stats .stat-number {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
}

.summary-stats .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.grading-tabs {
  display: flex;
  border-bottom: 2px solid rgba(229, 231, 235, 0.8);
  background: #F9FAFB;
}

.grading-tabs .tab-btn {
  flex: 1;
  padding: 15px 20px;
  background: none;
  border: none;
  color: #6B7280;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.grading-tabs .tab-btn:hover {
  background: var(--gray-100);
  color: var(--primary-700);
}

.grading-tabs .tab-btn.active {
  background: white;
  color: #4F46E5;
}

.grading-tabs .tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4F46E5, #7C3AED);
}

.grading-content {
  flex: 1;
  overflow: auto;
}

.tab-content {
  display: none;
  padding: 30px;
  height: 100%;
}

.tab-content.active {
  display: block;
}

/* Questions list */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-card {
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
}

.question-card.correct {
  background: rgba(16, 185, 129, .06);
  border-color: rgba(16, 185, 129, .3);
}

.question-card.incorrect {
  background: rgba(239, 68, 68, .06);
  border-color: rgba(239, 68, 68, .3);
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.question-number {
  display: flex;
  align-items: center;
  gap: 10px;
}

.q-num {
  font-weight: 700;
  color: var(--gray-800);
}

.q-status {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.q-status.correct {
  background: #10B981;
  color: #fff;
}

.q-status.incorrect {
  background: #EF4444;
  color: #fff;
}

.question-score {
  font-weight: 700;
  color: var(--gray-800);
  background: var(--gray-100);
  padding: 6px 10px;
  border-radius: 8px;
}

.question-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-text {
  font-size: 15px;
  color: var(--gray-800);
  font-weight: 600;
}

.answer-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.student-answer,
.correct-answer {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
  color: var(--gray-800);
}

.student-answer small,
.correct-answer small {
  color: var(--gray-700);
  font-weight: 700;
}

.feedback-text,
.question-feedback {
  padding: 12px;
  background: rgba(59, 130, 246, .08);
  border: 1px solid rgba(59, 130, 246, .25);
  border-radius: 8px;
  color: var(--gray-800);
}

.no-questions {
  text-align: center;
  padding: 40px;
  color: var(--gray-600);
}

/* Feedback sections */
.feedback-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feedback-section {
  border-radius: 12px;
  padding: 16px;
}

.feedback-section.strengths {
  background: rgba(16, 185, 129, .06);
  border: 1px solid rgba(16, 185, 129, .25);
}

.feedback-section.weaknesses {
  background: rgba(245, 158, 11, .06);
  border: 1px solid rgba(245, 158, 11, .25);
}

.feedback-section.recommendations {
  background: rgba(59, 130, 246, .06);
  border: 1px solid rgba(59, 130, 246, .25);
}

.feedback-section .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.feedback-list {
  margin: 0;
  padding-left: 18px;
  color: var(--gray-800);
}

/* Summary content */
.summary-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
  color: var(--gray-800);
}

@media (max-width: 768px) {
  .answer-comparison {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .grading-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .bulk-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-toolbar .right {
    margin-left: 0;
  }

  .item-details {
    flex-wrap: wrap;
    white-space: normal;
    gap: 10px 16px;
  }

  .detail-item {
    flex: 1 1 auto;
  }
}