/* 
  OpenEduKit.css - Modern Design System for Digital Quizzes and High-Fidelity OMR Sheets
  Author: OpenEduKit Community
  License: MIT
*/

:root {
  /* Color Palette - Premium Slate & Blue (Screen Mode) */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border-color: #e2e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --accent: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* OMR Core Brand Color (Authentic Exam Red) */
  --omr-theme-color: #d32f2f;
}

/* Base Styles for Screen */
body.openedukit-quiz-mode {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  padding: 20px;
  line-height: 1.5;
}

/* --- HIGH-FIDELITY EXAM OMR CONTAINER --- */
.omr-sheet-container {
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  padding: 30px 40px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  font-family: 'Times New Roman', Times, serif;
  color: var(--omr-theme-color);
}

.omr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2.5px solid var(--omr-theme-color);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.omr-header-text {
  text-align: center;
  flex: 1;
}

.omr-header-text h2 {
  font-size: 16pt;
  font-weight: bold;
  margin: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.omr-header-text h4 {
  font-size: 10pt;
  margin: 6px 0 0 0;
  font-weight: bold;
  text-transform: uppercase;
}

.omr-series-box {
  text-align: right;
  font-weight: bold;
  font-size: 12pt;
}

.omr-series-value {
  font-size: 16pt;
  border: 2px solid var(--omr-theme-color);
  padding: 2px;
  display: inline-block;
  margin-left: 6px;
  min-width: 28px;
  height: 28px;
  text-align: center;
  vertical-align: middle;
}

/* OMR Content Layout */
.omr-main-top {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.omr-left-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.omr-input-group {
  border: 1px solid var(--omr-theme-color);
  padding: 8px 12px;
  border-radius: 6px;
}

.omr-label {
  font-size: 7.5pt;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}

.omr-input-line {
  border-bottom: 1.5px dashed var(--omr-theme-color);
  height: 18px;
}

/* Method Instructions Layout */
.omr-methods-box {
  border: 1px solid var(--omr-theme-color);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 7pt;
}

.omr-method-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.omr-method-row.wrong {
  border-top: 1px dashed rgba(211, 47, 47, 0.3);
  padding-top: 4px;
}

.omr-method-visuals {
  display: flex;
  gap: 4px;
  align-items: center;
}

.omr-method-dot {
  width: 10px;
  height: 10px;
  border: 1px solid var(--omr-theme-color);
  border-radius: 50%;
}

.omr-method-dot.filled {
  background-color: #000;
}

/* Barcode Render style */
.omr-barcode-box {
  border: 1px solid var(--omr-theme-color);
  padding: 6px;
  border-radius: 6px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

/* Right Coding Grids */
.omr-right-column {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.omr-coding-grid {
  border: 1px solid var(--omr-theme-color);
  padding: 6px;
  border-radius: 6px;
  text-align: center;
}

.omr-coding-grid span {
  font-size: 7.5pt;
  font-weight: bold;
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.omr-coding-columns {
  display: flex;
  gap: 3px;
}

.omr-coding-col {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  align-items: center;
}

.omr-coding-cell {
  width: 14px;
  height: 15px;
  border: 1px solid var(--omr-theme-color);
}

.omr-coding-bubble {
  width: 11px;
  height: 11px;
  border: 1px solid var(--omr-theme-color);
  border-radius: 50%;
  font-size: 5pt;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--omr-theme-color);
  cursor: pointer;
  user-select: none;
}

.omr-coding-bubble.filled {
  background-color: #000 !important;
  color: #fff !important;
}

/* Question OMR Bubbles Grid */
.omr-bubble-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.omr-bubble-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.omr-bubble-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10pt;
}

.omr-qnum {
  width: 25px;
  text-align: right;
  font-weight: bold;
}

.omr-bubbles {
  display: flex;
  gap: 6px;
}

.omr-bubble {
  width: 0.3cm;
  height: 0.3cm;
  border: 1px solid var(--omr-theme-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5.5pt;
  font-weight: bold;
  color: var(--omr-theme-color);
  user-select: none;
  cursor: pointer;
  background-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
  font-family: Arial, sans-serif;
}

.omr-bubble.filled {
  background-color: #000 !important;
  color: #fff !important;
}

/* Footer elements */
.omr-footer {
  border-top: 1.5px solid var(--omr-theme-color);
  padding-top: 15px;
  display: flex;
  justify-content: space-between;
  font-size: 9pt;
  font-weight: bold;
}

/* Quiz Interface Layout */
.quiz-container {
  max-width: 680px;
  margin: 40px auto;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  padding: 30px;
  transition: transform 0.3s ease;
}

.quiz-header {
  margin-bottom: 25px;
}

.quiz-progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.quiz-progress-bar-fill {
  height: 100%;
  background-color: var(--primary-color);
  width: 0%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-question-box {
  margin-bottom: 30px;
}

.quiz-question-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-color);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.quiz-option-item:hover {
  border-color: var(--primary-color);
  background-color: #eff6ff;
}

.quiz-option-item.selected {
  border-color: var(--primary-color);
  background-color: #dbeafe;
  color: var(--primary-hover);
}

.quiz-option-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-color);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 13px;
  margin-right: 14px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.quiz-option-item.selected .quiz-option-badge {
  background-color: var(--primary-color);
  color: #fff;
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.quiz-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quiz-btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.quiz-btn-primary:hover {
  background-color: var(--primary-hover);
}

.quiz-btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.quiz-btn-secondary:hover {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

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

/* Report Summary Card Styles */
.report-card {
  max-width: 600px;
  margin: 30px auto;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.report-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  text-align: center;
  margin-bottom: 25px;
}

.report-stat-box {
  background: var(--bg-color);
  padding: 15px;
  border-radius: var(--radius-md);
}

.report-stat-val {
  font-size: 24px;
  font-weight: 800;
}

.report-stat-val.correct { color: var(--success); }
.report-stat-val.incorrect { color: var(--error); }
.report-stat-val.score { color: var(--primary-color); }

.report-stat-lbl {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 5px;
}

/* --- PRINT RULES (Critical for Low-Ink OMR) --- */
@media print {
  /* Hide unnecessary web elements, headers, controls */
  .no-print, button, .quiz-container, .report-card, .control-panel, .dashboard-header, .navbar, .hero, .settings-col, .footer, .reset-btn-container, #reset-section, input[type="file"] {
    display: none !important;
  }
  
  /* Reset document for clean background */
  html, body {
    display: block !important;
    background-color: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Reset layout wrappers to let OMR take full page width */
  .workspace-grid, .shell-container, .display-col, #omr-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Force OMR container to fit exactly in portrait A4 page boundaries */
  .omr-sheet-container {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 8mm 10mm !important; /* Proper printing padding */
    box-shadow: none !important;
    border: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    box-sizing: border-box;
  }

  /* Force grid structures to stay in place */
  .omr-bubble-grid-container {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important; /* Standard 5 column layout for physical paper sheets */
    column-gap: 12px !important;
    row-gap: 5px !important;
  }

  /* Prevent row orphans */
  .omr-bubble-row {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Styling adjustments for exact low-ink representation */
  .omr-bubble {
    border: 1px solid var(--omr-theme-color) !important;
    background-color: transparent !important;
    color: var(--omr-theme-color) !important;
  }

  .omr-input-line {
    border-bottom: 1.5px solid var(--omr-theme-color) !important;
  }
}

/* Input styles for pre-filling meta fields */
input.omr-meta-input {
  width: 100%;
  border-top: none;
  border-left: none;
  border-right: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
  margin: 0;
  color: #000;
  box-sizing: border-box;
}

/* Force OMR container to be exactly A4 */
.omr-sheet-container {
    width: 210mm !important;
    height: 297mm !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    padding: 10mm 10mm !important;
    overflow: hidden !important;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  .omr-sheet-container {
    width: 210mm !important;
    height: 297mm !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    padding: 10mm 10mm !important;
    box-shadow: none !important;
    border: none !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    overflow: hidden !important;
  }
}
