/* ---------- Theme & Layout ---------- */

/* Header - use grid for robust alignment across devices */
.header {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

/* When narrow, stack */
@media (max-width: 760px) {
  .header { grid-template-columns: 1fr; }
}

.quiz {
    background: #ffffff;
    border-radius: 20px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(35,35,35,0.08);
    margin: -10px;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Left area (logo + name) */
.header-top {
  display:flex;
  gap:8px;
  align-items:stretch;
  min-width:180px;
}

.quiz h2 {
    text-align: center;
    font-size: 38px;
    color: #ef6c00;
}

/* Logo */
.logo {
  width:96px; height:96px; border-radius:12px;
  border: 2px dashed #ffd59e;
  background: linear-gradient(180deg,#fff8ec,#fff1db);
  display:flex; align-items:center; justify-content:center; flex-direction:column;
  color:#d97706; font-weight:700; font-size:14px; cursor:pointer; position:relative;
  flex-shrink:0;
}
.logo input[type="file"]{ position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }

@media (max-width:760px){
  .logo { width:72px; height:72px; font-size:12px; }
}

/* School name textarea */
.school-name-textarea {
  flex:1; min-height:90px; border-radius:10px; padding:10px; box-sizing:border-box; overflow: auto;
  font-size:28px; font-weight:800; color:#b45309; border:2px solid #ffe0b2; background:#fffaf0;
  text-align:center; resize:none; text-align: center;
}

input#testTitle {
    display: block;
    width: 100%;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid #f0c68a;
    box-sizing: border-box;
    font-size: 16px;
    text-align: center; /* ✅ centers text inside the input */
}

input#testSubtitle {
    text-align: center;
}

@media (max-width:760px){
  .school-name-textarea { min-height:72px; font-size:1.05rem; }
}

/* Right controls area */
.header-bottom {
  display:flex; gap:5px; align-items:stretch; justify-content:center; flex-wrap:wrap;
}

input#dateDisplay {
    width: 120px;
}

 .report-buttons {
  display: block;
 }

/* Keep controls small and tidy */
.header-control {
  background:#fffefb; border:2px solid #ffd59e; padding:10px 8px; border-radius:10px;
  display:flex; gap:6px; align-items:center; min-width:120px;
}
.header-control label { font-weight:700; color:#6b4a24; font-size:0.9rem; margin-right:6px; white-space:nowrap; }

/* Class selector specific */
.class-select { font-weight:700; padding:4px 2px; border-radius:6px; border:1px solid #ffcc80;min-height: 40px; }

/* Section styling */
.quiz .section { margin-top:10px; padding:10px; border-radius:14px; background:#fffdf8; border:1px solid #fbe0be; }

/* Quiz Info Card */
#quizInfo {
  background: linear-gradient(135deg,#fffdf8,#f7fbff);
  border-radius: 16px; padding: 15px 0px; max-width:100%; margin: 14px auto;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06); position:relative;
}
#quizInfo p { color:#5d4037; margin:6px 0 12px; }

/* stats + buttons */
.stats-row { display:flex; gap:5px; justify-content:center; margin: 18px 0 18px; flex-wrap:wrap; }
.stat-badge { background:#ffd59e; padding:8px 14px; border-radius:18px; font-weight:800; color:#6b3b00; box-shadow:0 4px 8px rgba(0,0,0,0.08); }

.bottom-btn-container { display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.topBtn {
  padding:9px 16px; border-radius:28px; border:none; cursor:pointer; font-weight:800;
  box-shadow:0 6px 14px rgba(0,0,0,0.08); transition:transform .18s;
}
.topBtn:hover { transform: translateY(-3px); }
.blue-btn { background:linear-gradient(135deg,#42a5f5,#64b5f6); color:white; }
.green-btn { background:linear-gradient(135deg,#66bb6a,#81c784); color:white; }
.orange-btn { background:linear-gradient(135deg,#ffb74d,#ffcc80); color:white; }

/* Start button */
.startBtn {
  display:block; margin:25px auto; background:linear-gradient(135deg,#ff7043,#ffab91); color:white;
  padding:14px 36px; font-size:20px; border-radius:40px; border:none; cursor:pointer; font-weight:900;
  box-shadow:0 10px 24px rgba(255,112,67,0.18);
}

/* Question box */
.question-box { background:linear-gradient(180deg,#fff,#fff7ec); padding:14px; border-radius:14px; max-width:720px; margin:16px auto; box-shadow:0 8px 18px rgba(0,0,0,0.06); display:none; }
#studentNameDisplay { font-size:22px; font-weight:900; color:#d84315; margin-bottom:8px; text-align:left; }
#questionText { font-size:20px; font-weight:700; color:#4e342e; margin-bottom:12px; text-align:left; }
.options button {
  display:block; width:100%; margin:8px 0; padding:12px; font-size:18px; border-radius:10px; border:2px solid #FFB74D;
  background:#FFFFFF; color:#2b2b2b; cursor:pointer; transition:transform .12s;
}
.options button:hover { transform: scale(1.02); background:#fff8e6; }
.feedback { margin-top:10px; padding:10px; border-radius:10px; font-size:18px; font-weight:800; text-align:center; }
.correct { background:#C8E6C9; color:#1b5e20; }
.wrong { background:#FFCDD2; color:#b71c1c; }
.navigation { margin-top:14px; display:flex; gap:8px; }
.navigation button { flex:1; padding:10px; font-size:16px; border-radius:10px; border:none; font-weight:800; cursor:pointer; }

/* result box */
.result-box { display:none; background:#F1F8E9; padding:20px; border-radius:12px; margin:16px auto; box-shadow:0 8px 18px rgba(0,0,0,0.06); }
.result-box h2 { font-size:26px; color:#33691E; margin-top: 10px; }
.report .item { background:#fff; padding:20px; border-radius:10px; margin-bottom:10px; box-shadow:0 3px 8px rgba(0,0,0,0.06); }

/* Performance card */
.perf-container { display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; margin-bottom:12px; min-height: 210px;box-sizing: border-box;}
.perf-card { width: 100%;height: 100%;box-sizing: border-box; background:linear-gradient(180deg,#fff,#fff9f4); padding:10px; border-radius:12px; box-shadow:0 5px 12px rgba(0,0,0,0.06); display:flex; gap:10px; align-items:center; flex:1; }
.perf-donut { width:100%; height:100%; display:flex; align-items:center; justify-content:center; position:relative; }
.perf-donut svg { transform: rotate(-90deg); width:100%; height:100%; }
.perf-donut .center { position:absolute; text-align:center; font-weight:900; font-size:18px;color:#3e2723; }
.perf-bars { height: 100%;flex:4; display:flex; gap:8px; flex-direction:column; width:100%; font-size: 20px;justify-content: space-around; }
.bar-row { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.bar { background:#ffeccf; border-radius:10px; height:14px; flex:1; overflow:hidden; position:relative; }
.bar-inner { height:100%; border-radius:10px 0 0 10px; box-shadow:0 2px 6px rgba(0,0,0,0.06); }
.badge-small { font-weight:900; padding:8px 10px; border-radius:10px; background:#fff3e0; }


/* Dialogs full-screen friendly */
dialog {
  border: none; border-radius: 12px; padding: 10px; width: 92vw; max-width:900px; height: auto; max-height: 88vh; overflow:auto;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }

/* student/question textarea */
textarea, input[type="text"], select { width:100%; padding:6px; border-radius:8px; border:1px solid #f0c68a; box-sizing:border-box; font-size:16px; }
.textarea-large { min-height:380px; }

textarea#sqInput {
    min-height: 120px;
}

input[id^="sqOpt"] {
    height: 60px;      /* change as needed */
    line-height: 60px; /* optional for better text alignment */
}


/* small helper UI */
.inline-row { display:flex; gap:8px; align-items:center; }
.small { font-size:0.95rem; color:#5d4037; }
.small-btn { padding:8px 10px; border-radius:8px; border:none; cursor:pointer; font-weight:700; }


/* print */
@media print {
  /* This new @page rule controls the actual page properties */
  @page {
    size: A4;           /* Set the paper size to A4 */
    margin: .25in;        /* Set a minimal margin (you can adjust 1cm to 0.5cm if needed) */
  }

  /* 1. Hide everything on the page by default */
  body, html {
    background: #fff !important; /* Ensure a white background */
  }
  
  body * {
    visibility: hidden !important;
  }



  /* 2. Make the entire .quiz container and all its contents visible */
  .quiz, .quiz * {
    visibility: visible !important;
  }

  /* 3. Hide the specific interactive elements inside .quiz that we DON'T want to print */
  .quiz button,
  .quiz dialog,
  .quiz .question-box,
  .quiz input[type="file"],
  .quiz #hiddenDate,
  .page-title,
  .site-header {
    display: none !important;
  }

  /* 4. Position the .quiz container to start at the top of the page */
  .quiz {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* 5. Optional: Make text inputs look like static text for a cleaner report */
  .quiz select {
      border: none !important;
      padding-left: 0 !important;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
  }


.quiz {
    background: #fff;
}

/* --- NEW: Increase Font Sizes for PDF Readability --- */
/* You can adjust these pixel values to fine-tune the text size. */
.report .item {
  font-size: 16px;
}

.bar-row div {
    font-size: 18px !important;
}

.perf-card div {
    font-size: 18px !important;
}


.perf-donut svg {
  width: 200px !important;
  height: 200px !important;
}


.perf-bars {
    height: 220px !important;
}

.result-box h2 {
    font-size: 28px !important;
}
.school-name-textarea {
  font-size: 24px;
}

}

/* small animations (kept minimal) */
@keyframes slideIn { from {opacity:0; transform:translateY(8px)} to {opacity:1; transform:none} }
@keyframes bounce { 0%{transform:scale(1)} 50%{transform:scale(1.05)} 100%{transform:scale(1)} }
@keyframes shake { 0%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} 100%{transform:translateX(0)} }

/* responsive tweaks */
@media (max-width:480px){
  .perf-container { flex-direction:column; }
  .perf-card { width:100%;}
}







    /* --- NEW: Styles for PDF Capture --- */
body.capture-mode {
    background: #fff !important; /* Ensure a white background for the capture */
}

/* Hide all buttons and interactive elements during capture */
body.capture-mode .report-buttons,
body.capture-mode #addClassBtn,
body.capture-mode #deleteClassBtn {
    display: none !important;
}


/* Style the main container for a clean, borderless capture */
body.capture-mode .quiz {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding-top: 20px !important;
}


body.capture-mode .quiz {
    background: #fff;
}

/* --- NEW: Increase Font Sizes for PDF Readability --- */
/* You can adjust these pixel values to fine-tune the text size. */
body.capture-mode .report .item {
  font-size: 16pt;
}

body.capture-mode .bar-row div {
    font-size: 18pt !important;
}

body.capture-mode .perf-card div {
    font-size: 18pt !important;
}


body.capture-mode .perf-donut svg {
  width: 200pt !important;
  height: 200pt !important;
}


body.capture-mode .perf-bars {
    height: 220pt !important;
}

body.capture-mode .result-box h2 {
    font-size: 28pt !important;
}


/* Update this existing rule in your CSS */
body.capture-mode .school-name-textarea {
    font-size: 28pt !important;
    padding:  10pt !important;
    white-space: pre-wrap !important; /* This correctly handles newlines */
    word-wrap: break-word !important;
    overflow: visible !important;     /* Ensures content isn't clipped */
    height: auto !important;          /* ADD THIS LINE: Allows the element to grow vertically */
}

/* ADD THIS NEW RULE to your CSS file */
body.capture-mode .class-select {
    border: none !important;
    background: transparent !important;
    font-size: 18pt !important;
    padding: 14pt 0 !important; /* Makes it look like clean text */
    -webkit-appearance: none;   /* Removes dropdown arrow visuals */
    -moz-appearance: none;
    appearance: none;
    vertical-align: middle;     /* Helps it align with other items */
    text-align: center !important;
    padding: 0 !important;
    white-space: nowrap !important; /* ADD THIS LINE */
}

body.capture-mode .logo {
  width: 80pt !important;
  height: 80pt !important;
}

body.capture-mode textarea, 
body.capture-mode input[type="text"],
body.capture-mode select {
    font-size: 18pt !important;
    padding: 14pt !important;
}

body.capture-mode .header-control label {
    font-size: 14pt !important;
}

/* --- NEW: Custom Styles for Captured Inputs --- */

/* Center Test Title and Subtitle and remove input styling */
body.capture-mode .test-title,
body.capture-mode .test-subtitle {
    text-align: center !important;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
}

/* --- Optional: Set custom font sizes for all replaced elements --- */
/* You can adjust these 'pt' values as needed */

/* Custom font sizes for titles */
body.capture-mode .test-title {
    font-size: 26pt !important;
    font-weight: 800 !important;
}

body.capture-mode .test-subtitle {
    font-size: 18pt !important;
    font-weight: 600 !important;
    margin-top: 0px !important;
}

/* Style the replacement spans for Session and Date */
body.capture-mode .header-control > span {
    font-size: 16pt !important;
    font-weight: 800 !important;
    text-align: center !important;
    padding: 0 !important;
    white-space: nowrap !important;
    /* The `vertical-align` property has been removed to allow flexbox to work */
}

/* Style the replacement spans for Session and Date */
body.capture-mode .header-control > span {
    font-size: 16pt !important;
    font-weight: 800 !important; /* Match the original input style */
    text-align: center !important;
    padding: 0 !important;
    white-space: nowrap !important; /* ADD THIS LINE */
}

/* --- Mobile-Friendly Single Question Dialog --- */
.sq-dialog {
  width: 95%;
  max-width: 500px;
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  font-family: sans-serif;
}
.sq-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.sq-header {
  background: #f8f9fa;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 18px;
  font-weight: bold;
  color: #333;
}
.sq-body {
  padding: 20px;
  max-height: 70vh; /* Scrollable on small phones */
  overflow-y: auto;
}
.sq-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
  font-size: 14px;
}
.sq-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  height: 120px;  /* Increased height */
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 15px;
  transition: border 0.3s;
}
.sq-input:focus {
  border-color: #2196F3;
  outline: none;
}
.sq-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid #eee;
  padding: 8px;
  border-radius: 8px;
}
.sq-option-row:hover {
  background: #fdfdfd;
  border-color: #ddd;
}
.sq-radio {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #4CAF50;
  flex-shrink: 0;
}
.sq-opt-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  font-size: 15px;
  outline: none;
}
.sq-opt-input:focus {
  background: #f0f8ff;
  border-radius: 4px;
}
.sq-footer {
  padding: 15px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9fa;
}
/* Stack buttons on very small screens */
@media (max-width: 400px) {
  .sq-footer { flex-direction: column; }
  .sq-footer button { width: 100%; }
}