<style id="table-print">
	.gm-report-wrap {
		font-family: Arial, sans-serif;
		font-size: 13px;
	}
	.gm-title {
		text-align: center;
		font-weight: bold;
		font-size: 17px;
		margin-bottom: 12px;
	}
	.gm-header-row {
		width: 100%;
		border-collapse: collapse;
		margin-bottom: 18px;
	}
	.gm-header-row2 {
		width: 100%;
		border-collapse: collapse;
		margin-bottom: 8px;
	}
	.gm-header-row td {
		padding: 3px 10px 3px 0;
		font-size: 13px;
		border: none !important;
	}
	.gm-header-row2 td {
		padding: 3px 10px 3px 0;
		font-size: 13px;
		border: none !important;
	}
	.gm-student-header {
		color: #000;
		font-weight: bold;
		font-size: 13px;
		margin-top: 18px;
		margin-bottom: 4px;
	}
	.gm-student-name-italic {
		font-style: italic;
	}
	.gm-table {
		width: 100%;
		border-collapse: collapse;
		margin-bottom: 10px;
	}
	.gm-table th {
		border: 1px solid #000;
		padding: 4px 6px;
		text-align: center;
		font-weight: bold;
		background: none !important;
		font-size: 13px;
	}
	.gm-table td {
		border: 1px solid #000;
		padding: 4px 6px;
		text-align: center;
		font-size: 13px;
		height: 20px;
	}
	.hidden {
		display: none !important;
	}
	.gm-print-header {
		display: none;
	}
	@media print {
		.gm-print-header {
			display: block;
		}
	}
</style>

{% if students|length > 0 %}
{% set firstStudent = students|first %}
{% set firstTerm = firstStudent.academicTerms is not empty ? firstStudent.academicTerms|first : null %}

<div class="gm-report-wrap">

	<div class="gm-print-header">
		{% if additionalDetails.collegeData.isHeaderEnabled %}
			<div style="text-align: center; margin-bottom: 8px;">
				<img src="{{ additionalDetails.collegeData.collegeHeader }}" style="max-width: 100%; height: auto;">
			</div>
		{% else %}
			{% if additionalDetails.collegeData.collageLogo %}
			<div style="text-align: center; margin-bottom: 10px;">
				<img src="{{ additionalDetails.collegeData.collageLogo }}" style="width: 100px; height: auto;">
			</div>
			{% endif %}
			<div style="text-align: center; margin-bottom: 10px;">
				<div style="font-size: 18px; font-weight: bold; line-height: 1.4;">{{ additionalDetails.collegeData.collegeName ?? '' }}{% if additionalDetails.collegeData.universityName %} ({{ additionalDetails.collegeData.universityName }}){% endif %}</div>
				<div style="font-size: 14px; margin-top: 2px;">{{ additionalDetails.collegeData.collegeAddress ?? '' }}</div>
			</div>
		{% endif %}
	</div>

	<div class="gm-title">GRACE MARK REPORT</div>

	{% for student in students %}
		{% for academicTerm in student.academicTerms %}

			<table class="gm-table">
				<thead>
					{% if loop.parent.loop.first and loop.first %}
					<tr class="hidden">
						<th data-a-h="center" data-f-bold="true" colspan="7">{{ additionalDetails.collegeData.collegeName ?? '' }}{% if additionalDetails.collegeData.universityName %} ({{ additionalDetails.collegeData.universityName }}){% endif %}</th>
					</tr>
					<tr class="hidden">
						<th data-a-h="center" data-f-bold="true" colspan="7">{{ additionalDetails.collegeData.collegeAddress ?? '' }}</th>
					</tr>
					<tr class="hidden">
						<th data-a-h="center" data-f-bold="true" colspan="7">GRACE MARK REPORT</th>
					</tr>
					<tr>
						<th colspan="7" style="border: none !important; padding: 6px 0 2px 0; font-size: 13px; text-align: left;">
							<strong>Programme Name:</strong> {{ firstStudent.programName }} <span style="display: inline-block; width: 120px;"></span>
							<strong>Batch:</strong> {{ firstStudent.batchName }} <span style="display: inline-block; width: 120px;"></span>
							<strong>Academic Year:</strong> {{ firstStudent.academicYear }} <span style="display: inline-block; width: 120px;"></span>
							<strong>Semester:</strong> {{ firstTerm ? firstTerm.name : '' }}
						</th>
					</tr>
					{% endif %}
					<tr>
						<th colspan="7" style="border: none !important; padding: 4px 0 10px 0; font-size: 13px; text-align: left;">
							<strong>Reg. No:</strong> {{ student.registerNo }} <span style="display: inline-block; width: 220px;"></span>
							<strong>Student Name:</strong> {{ student.name }} <span style="display: inline-block; width: 220px;"></span>
							<strong>Event:</strong> {{ student.graceMarkEventCategoryName }}
						</th>
					</tr>
					<tr>
						<th data-a-h="center" data-f-bold="true">Subject Code</th>
						<th data-a-h="center" data-f-bold="true">Subject Name</th>
						<th data-a-h="center" data-f-bold="true">Grace Mark</th>
						<th data-a-h="center" data-f-bold="true">Mark Before Grace Mark</th>
						<th data-a-h="center" data-f-bold="true">Grade</th>
						<th data-a-h="center" data-f-bold="true">Mark After Grace Mark</th>
						<th data-a-h="center" data-f-bold="true">Grade</th>
					</tr>
				</thead>
				<tbody>
					{% for subject in academicTerm.subjects %}
						{% for examRegistration in subject.examRegistrations %}
							<tr>
								<td>{{ subject.code }}</td>
								<td style="text-align: left;">{{ subject.name }}</td>
								<td>{{ examRegistration.graceMark }}</td>
								<td>{{ examRegistration.subjectExternalMarkWithOutGraceMark }}</td>
								<td>{{ examRegistration.subjectExtrenalGradeWithOutGraceMark }}</td>
								<td>{{ (examRegistration.subjectExternalMarkWithOutGraceMark + examRegistration.graceMark) }}</td>
								<td>{{ examRegistration.subjectExtrenalGradeWithGraceMark }}</td>
							</tr>
						{% endfor %}
					{% endfor %}
				</tbody>
			</table>

		{% endfor %}
	{% endfor %}

	<div class="gm-print-header" style="text-align: right; font-size: 12px; margin-top: 20px;">
		Generated on: {{ "now"|date("d-m-Y H:i:s") }}
	</div>

</div>
{% endif %}
