* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f4f6;
  font-family: "Poppins", Arial, sans-serif;
  color: #1f2937;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  padding: 10px 14px;
}

/* Integrated worksheet page (worksheet.php) — site nav + toolbar stacked in one chrome bar */
body.worksheet-layout {
  background: #f3f4f6;
  font-family: "Poppins", Arial, sans-serif;
}

body.worksheet-layout .worksheet-chrome {
  position: sticky;
  top: 0;
  z-index: 1050;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

body.worksheet-layout .worksheet-chrome .navbar {
  position: relative;
  background-color: #fff !important;
}

body.worksheet-layout .worksheet-chrome .toolbar {
  position: relative;
  top: auto;
  z-index: auto;
  border-top: 1px solid #e5e7eb;
  box-shadow: none;
}

body.worksheet-layout .worksheet-main {
  position: relative;
  z-index: 1;
  padding-top: 0;
}

body.worksheet-layout .worksheet-main .page {
  z-index: auto;
}

.toolbar-inner {
  max-width: 210mm;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.toolbar-title {
  font-size: 14px;
  font-weight: 800;
  color: #065f46;
  letter-spacing: 0.3px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  font-family: "Poppins", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #e0f2fe;
  color: #075985;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.16);
}

button:active {
  transform: translateY(0);
}

.print-btn {
  background: #dcfce7;
  color: #166534;
}

.reset-btn {
  background: #fef3c7;
  color: #92400e;
}

.page {
  width: 210mm;
  min-height: 297mm;
  margin: 12px auto;
  padding: 6mm 10mm 8mm;
  background: white;
  position: relative;
  overflow: hidden;
  page-break-after: always;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
}

.page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 5% 5%, rgba(16, 185, 129, 0.09), transparent 24%),
    radial-gradient(circle at 95% 7%, rgba(59, 130, 246, 0.08), transparent 25%),
    radial-gradient(circle at 50% 100%, rgba(245, 158, 11, 0.08), transparent 26%);
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 1;
}

.header {
  border: 1.5px solid #d1fae5;
  background: linear-gradient(135deg, #ecfdf5, #eff6ff);
  border-radius: 10px;
  padding: 4px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.title {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  line-height: 1.15;
  color: #065f46;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 0;
  font-size: 10px;
  line-height: 1.2;
  color: #475569;
  font-weight: 500;
}

.badge {
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.student-row {
  display: grid;
  grid-template-columns: 1.1fr 0.7fr 0.7fr;
  gap: 5px;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #374151;
}

.field {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 2px 7px;
  background: #fff;
  line-height: 1.3;
}

.field span {
  display: inline-block;
  min-width: 36mm;
  border-bottom: 1.5px dotted #9ca3af;
  margin-left: 6px;
  transform: translateY(-1px);
}

.instructions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 2px 8px;
  margin-bottom: 4px;
  font-size: 9.5px;
  line-height: 1.25;
  color: #78350f;
  font-weight: 600;
}

.arabic-note {
  font-family: "Noto Naskh Arabic", serif;
  font-size: 14px;
  line-height: 1.1;
  color: #92400e;
  white-space: nowrap;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.column {
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  min-height: 236mm;
}

.column-title {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #0f766e;
  background: linear-gradient(90deg, #ccfbf1, #e0f7fa);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 4px;
}

.question-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto auto auto;
  column-gap: 6px;
  align-items: start;
  border: 1px solid #eef2f7;
  border-radius: 9px;
  padding: 3.5px 6px;
  margin-bottom: 3.6px;
  background: linear-gradient(90deg, #ffffff, #fafafa);
  break-inside: avoid;
  transition: border-color 0.2s ease;
}

.question-card:hover {
  border-color: #a7f3d0;
}

.qnum {
  grid-row: 1 / 5;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  color: #047857;
  font-size: 9px;
  font-weight: 800;
  margin-top: 2px;
}

.qtext, .answer-text {
  font-family: "Noto Naskh Arabic", "Scheherazade New", serif;
  font-size: 17.4px;
  line-height: 1.1;
  font-weight: 700;
  color: #111827;
  text-align: right;
  padding-right: 2px;
}

.answer-text {
  display: none;
  color: #065f46;
  margin-top: 1px;
  padding-top: 1px;
  border-top: 1px dotted #bbf7d0;
}

.translate-text {
  display: none;
  font-size: 9.2px;
  line-height: 1.15;
  color: #475569;
  font-weight: 600;
  margin-top: 1px;
}

.answer-translate {
  color: #166534;
}

.answer-line {
  min-height: 8px;
  border-bottom: 1.5px dotted #9ca3af;
  margin-top: 1px;
}

body.show-answers .answer-text {
  display: block;
}

body.show-answers .answer-line {
  display: none;
}

body.show-translations .translate-text {
  display: block;
}

.footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 7px;
  font-size: 10px;
  color: #4b5563;
  font-weight: 600;
}

.mini-box {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 5px 8px;
  background: rgba(248, 250, 252, 0.9);
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    background: white;
  }

  /* Hide site menu + worksheet controls (logo, PROD DB badge, toggler box) */
  body.worksheet-layout .worksheet-chrome,
  body.worksheet-layout .worksheet-chrome .navbar,
  body.worksheet-layout .worksheet-chrome .navbar-brand,
  body.worksheet-layout .worksheet-chrome .navbar-toggler,
  body.worksheet-layout .worksheet-chrome .toolbar,
  body.worksheet-layout > footer,
  .toolbar {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  body.worksheet-layout .worksheet-main {
    margin: 0;
    padding-top: 0 !important;
  }

  .page {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 4mm 9mm 5mm;
    box-shadow: none;
    page-break-after: always;
  }

  .header {
    padding: 3px 8px;
    margin-bottom: 2px;
    gap: 4px;
  }

  .title {
    font-size: 15px;
  }

  .subtitle {
    font-size: 8.5px;
  }

  .badge {
    padding: 2px 6px;
    font-size: 9px;
  }

  .student-row {
    margin-bottom: 2px;
    gap: 4px;
    font-size: 9px;
  }

  .field {
    padding: 1px 5px;
  }

  .field span {
    min-width: 28mm;
  }

  .instructions {
    padding: 1px 6px;
    margin-bottom: 3px;
    font-size: 8.5px;
  }

  .arabic-note {
    font-size: 12px;
  }

  .footer {
    margin-top: 4px;
  }

  .mini-box {
    padding: 3px 6px;
  }

  .question-card:hover {
    border-color: #eef2f7;
  }
}
