/* ========================================================
   HiDocument — Report Grader styles
   Uses tokens defined in style.css
   ======================================================== */

/* ===== Page layout ===== */
.grader-layout {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: var(--space-3);
  align-items: flex-start;
  margin-top: var(--space-2);
}
@media (max-width: 980px) {
  .grader-layout { grid-template-columns: 1fr; }
}

.grader-section-head { margin-bottom: var(--space-2); }
.grader-section-head h2 { font-size: 1.25rem; margin-bottom: 4px; }
.grader-section-head p { margin: 0; font-size: 0.9rem; }

/* ===== Direct answer summary ===== */
.answer-summary {
  background: #eff6ff;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 var(--space-2) 0;
}
.answer-summary p { margin: 0; font-size: 0.95rem; line-height: 1.6; color: var(--text); }

/* ===== Builder + Upload panels ===== */
.rubric-builder,
.document-upload {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
}

/* ===== Preset toggle ===== */
.preset-toggle {
  margin: var(--space-2) 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg-alt);
}
.preset-toggle summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.preset-toggle summary::-webkit-details-marker { display: none; }
.preset-toggle summary i { color: var(--accent); }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.preset-btn {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms, background 150ms, color 150ms;
  color: var(--text);
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); background: #eff6ff; }

/* ===== Form groups ===== */
.form-group { margin: 14px 0; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input[type=text],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
}
.form-group input[type=text]:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* ===== Criteria list ===== */
.criteria-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.criterion-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  align-items: flex-start;
}
.criterion-card .crit-name { grid-column: 1 / 2; }
.criterion-card .crit-weight { grid-column: 2 / 3; }
.criterion-card .crit-desc { grid-column: 1 / -1; }
.criterion-card label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.criterion-card input[type=text],
.criterion-card textarea,
.criterion-card select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: #fff;
  font-family: var(--font);
}
.criterion-card textarea { resize: vertical; min-height: 60px; }
.criterion-card .remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 150ms, background 150ms;
}
.criterion-card .remove-btn:hover { color: var(--danger); background: #fef2f2; }

/* ===== Rubric actions row ===== */
.rubric-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: var(--space-2);
}

.weight-total {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.weight-total.balanced {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}
.weight-total i { font-size: 0.875rem; }

.rubric-save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ===== Upload zone ===== */
.upload-mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: var(--radius);
}
.mode-tab {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 150ms, color 150ms;
}
.mode-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.upload-zone {
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}
.upload-zone i {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 10px;
  display: block;
}
.upload-zone h3 { font-size: 1rem; margin: 0 0 4px; }
.upload-zone p { margin: 0; font-size: 0.875rem; color: var(--text-muted); }
.upload-zone .file-types { margin-top: 6px; font-size: 0.75rem; }
.upload-zone:hover, .upload-zone.is-drag {
  border-color: var(--accent);
  background: #eff6ff;
}
.upload-zone.has-file {
  border-color: var(--success);
  background: #ecfdf5;
  border-style: solid;
}
.upload-zone.has-file i { color: var(--success); }

.paste-mode textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  resize: vertical;
}

/* ===== Grade CTA ===== */
.grade-cta {
  width: 100%;
  padding: 14px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 150ms, transform 150ms;
}
.grade-cta:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.grade-cta:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

/* ===== Grading progress ===== */
.grading-progress {
  margin-top: var(--space-2);
  padding: 16px;
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius);
}
.grading-progress .progress-bar {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
  margin: 6px 0 12px;
}
.grading-progress .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: grader-progress-pulse 1.6s ease-in-out infinite;
}
@keyframes grader-progress-pulse {
  0%, 100% { width: 18%; margin-left: 0; }
  50%      { width: 78%; margin-left: 22%; }
}
.grading-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  min-height: 20px;
}

/* ===== People Also Ask ===== */
.paa-section h2 { font-size: 1.25rem; margin-bottom: 8px; }
.paa-list { display: flex; flex-direction: column; gap: 8px; }
.paa-list .faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: #fff;
}
.paa-list .faq-item summary {
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  font-size: 0.95rem;
}
.paa-list .faq-item summary::-webkit-details-marker { display: none; }
.paa-list .faq-item p { margin: 8px 0 0; color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }

/* ========================================================
   Result page
   ======================================================== */
.grader-result-page h1 { font-size: 1.75rem; margin: 0; }

.result-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}
.result-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.result-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-3) 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.grade-ring {
  position: relative;
  width: 180px;
  height: 180px;
  margin-bottom: 14px;
}
.grade-ring svg { width: 100%; height: 100%; }
.grade-ring-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.grade-letter { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.grade-num { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

.result-headline {
  font-size: 1.05rem;
  margin: 8px 0 4px;
  color: var(--text);
}
.result-verdict {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 auto;
  max-width: 640px;
  padding: 0 var(--space-2);
  line-height: 1.6;
}

/* ===== Trend bars ===== */
.trend-panel .panel-head h2 { font-size: 1.05rem; margin: 0; }
.trend-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 14px;
  height: 160px;
  padding: 12px 0;
}
.trend-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
  max-width: 80px;
}
.trend-bar-track {
  flex: 1;
  width: 32px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.trend-bar-fill {
  width: 100%;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 800ms ease;
}
.trend-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text);
}
.trend-bar-date {
  font-size: 0.7rem;
  color: var(--text-light);
}
.trend-bar.is-current .trend-bar-track { box-shadow: 0 0 0 2px var(--accent); }
.trend-bar.is-current .trend-bar-label { color: var(--accent); }

/* ===== Criterion result cards ===== */
.criterion-result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.criterion-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.criterion-name { font-size: 1rem; font-weight: 600; color: var(--text); }
.criterion-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.criterion-score-badge { font-size: 1.5rem; font-weight: 700; line-height: 1; flex-shrink: 0; }
.criterion-feedback { font-size: 0.9rem; color: var(--text); margin: 8px 0 0; line-height: 1.6; }

.score-bar-track {
  height: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}
.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}

.evidence-quote {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  border-left: 3px solid var(--border-strong);
  padding: 6px 12px;
  margin: 10px 0 0;
  background: var(--bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ===== Strengths / Weaknesses ===== */
.strengths-weaknesses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: var(--space-3) 0;
}
@media (max-width: 640px) {
  .strengths-weaknesses { grid-template-columns: 1fr; }
}
.strengths-box,
.weaknesses-box {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid;
}
.strengths-box { background: #ecfdf5; border-color: #a7f3d0; }
.weaknesses-box { background: #fef2f2; border-color: #fecaca; }
.sw-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.strengths-box .sw-title { color: #065f46; }
.weaknesses-box .sw-title { color: #991b1b; }
.sw-list { list-style: none; padding: 0; margin: 0; }
.sw-list li {
  font-size: 0.9rem;
  padding: 6px 0 6px 22px;
  position: relative;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  color: var(--text);
  line-height: 1.5;
}
.sw-list li:last-child { border-bottom: none; }
.sw-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.strengths-box .sw-list li::before { background: var(--success); }
.weaknesses-box .sw-list li::before { background: var(--danger); }

/* ===== Action plan ===== */
.action-plan-list { list-style: none; padding: 0; margin: var(--space-2) 0 0; }
.action-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.action-item:last-child { border-bottom: none; }
.action-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-text { font-size: 0.95rem; color: var(--text); line-height: 1.5; }
.action-impact { font-size: 0.8125rem; color: var(--text-muted); margin-top: 4px; }

.result-bottom-cta {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: var(--space-3) 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.grader-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}
.grader-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Print styles ===== */
@media print {
  body { background: #fff; }
  .sidebar, .app-sidebar, .topbar, .sidebar-mobile-toggle, .floating-nav, .site-footer, .cookie-banner,
  .result-toolbar-actions, .result-bottom-cta { display: none !important; }
  .app-shell, .app-main, .main-content { margin: 0 !important; padding: 0 !important; }
  .criterion-result-card,
  .strengths-box, .weaknesses-box,
  .result-hero, .panel { break-inside: avoid; }
}

/* ===== Mobile tweaks ===== */
@media (max-width: 640px) {
  .criterion-card { grid-template-columns: 1fr; }
  .criterion-card .crit-weight { grid-column: 1 / -1; }
  .grade-ring { width: 140px; height: 140px; }
  .grade-letter { font-size: 2.25rem; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .grading-progress .progress-fill { animation: none; width: 50%; }
  .score-bar-fill, .trend-bar-fill { transition: none; }
}
