/*
 * Afagh Curriculum Explorer — Spacious Modern Academic Design
 * Redesigned page header, type-filter chips and progress tracking.
 * Designed for visual comfort, breathing room and A4 2-column print efficiency.
 */

.afg-charts-main {
	background: #f8fafc;
	min-height: 75vh;
}

.afg-charts-section {
	padding: 28px 0 72px;
}

/* Use the full viewport width on the charts page (override site 1320px shell) */
.afg-charts-section .afg-container {
	width: calc(100% - 32px);
	max-width: none;
	margin-inline: auto;
}

@media screen and (min-width: 768px) {
	.afg-charts-section .afg-container {
		width: calc(100% - 48px);
	}
}

/* ---------------------------------------------------------------------
 * Slim top utility bar: dept select + progress/print actions (no title)
 * ------------------------------------------------------------------- */
.afg-charts-topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 14px;
	margin-bottom: 14px;
}

.afg-charts-topbar .afg-charts-dept-dropdown {
	flex: 1 1 240px;
	max-width: 340px;
	min-width: 200px;
}

.afg-charts-topbar .afg-charts-dept-select {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
}

.afg-charts-dept-label {
	color: #64748b;
	font-size: 13px;
	font-weight: 800;
	white-space: nowrap;
}

.afg-charts-topbar__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 10px;
	margin-inline-start: auto;
}

/* Progress meter (checked courses, localStorage) */
.afg-charts-progress {
	display: grid;
	gap: 4px;
	align-content: center;
	min-width: 168px;
	padding: 10px 16px;
	border: 1.5px solid #e2e8f0;
	border-radius: 14px;
	background: #ffffff;
}

.afg-charts-progress__label {
	color: #64748b;
	font-size: 11.5px;
	font-weight: 800;
}

.afg-charts-progress__value {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px;
	color: #0f172a;
	font-size: 16px;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	line-height: 1.3;
}

.afg-charts-progress__value .of {
	color: #94a3b8;
	font-weight: 700;
}

.afg-charts-progress__value .unit {
	font-size: 12.5px;
	font-weight: 800;
	color: #475569;
}

.afg-charts-progress__value small {
	color: #64748b;
	font-size: 12px;
	font-weight: 800;
}

.afg-charts-progress.is-complete {
	border-color: #bbf7d0;
	background: #f0fdf4;
}

.afg-charts-progress.is-complete .afg-charts-progress__value {
	color: #15803d;
}

/* Department Dropdown — compact select */
.afg-charts-dept-dropdown {
	position: relative;
	display: inline-flex;
	align-items: center;
	min-width: 200px;
	max-width: 100%;
}

.afg-charts-dept-select {
	width: 100%;
	min-height: 42px;
	padding: 8px 38px 8px 14px;
	border: 1.5px solid #e2e8f0;
	border-radius: 12px;
	background: #ffffff;
	color: #0f172a;
	font: inherit;
	font-size: 13px;
	font-weight: 800;
	line-height: 1.5;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	transition: border-color .18s ease, box-shadow .18s ease;
}

.afg-charts-dept-select:hover {
	border-color: #94a3b8;
}

.afg-charts-dept-select:focus {
	border-color: #102a61;
	outline: none;
	box-shadow: 0 0 0 3px rgba(16, 42, 97, .12);
}

.afg-charts-select-arrow {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	color: #64748b;
	display: inline-grid;
	place-items: center;
}

.afg-charts-print-action {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 8px 18px;
	border: 1.5px solid #0f172a;
	border-radius: 999px;
	background: #0f172a;
	color: #ffffff;
	font: inherit;
	font-size: 13px;
	font-weight: 850;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .16s ease;
}

.afg-charts-print-action:hover,
.afg-charts-print-action:focus-visible {
	border-color: #1d458d;
	background: #1d458d;
	color: #ffffff;
	transform: translateY(-1px);
}

/* دانلود / چاپ — one button, two states.
 * Print icon by default, download icon when a PDF is attached. */
.afg-charts-dl-action {
	text-decoration: none;
}

.afg-charts-dl-icon--download {
	display: none;
}

.afg-charts-dl-action.is-download .afg-charts-dl-icon--print {
	display: none;
}

.afg-charts-dl-action.is-download .afg-charts-dl-icon--download {
	display: inline-block;
}

/* Degree Segments — tight row stuck right above the semesters */
.afg-charts-degrees {
	margin-bottom: 10px;
}

.afg-charts-degree-segments {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.afg-degree-segment {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 16px;
	border: 1.5px solid #e2e8f0;
	border-radius: 999px;
	background: #ffffff;
	color: #475569;
	font: inherit;
	font-size: 13.5px;
	font-weight: 800;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.afg-degree-segment:hover {
	border-color: #94a3b8;
	color: #0f172a;
}

.afg-degree-segment.is-active {
	border-color: #0f172a;
	background: #0f172a;
	color: #ffffff;
	box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
}

.afg-degree-badge {
	padding: 2px 7px;
	border-radius: 6px;
	background: rgba(100, 116, 139, .10);
	font-size: 11.5px;
	font-weight: 800;
	color: #475569;
	font-variant-numeric: tabular-nums;
}

.afg-degree-segment.is-active .afg-degree-badge {
	background: rgba(255, 255, 255, .16);
	color: #e2e8f0;
}

.afg-degree-segment.is-archive {
	color: #64748b;
	border-style: dashed;
}

/* ---------------------------------------------------------------------
 * Program Subtle Notes
 * ------------------------------------------------------------------- */
.afg-charts-program {
	display: grid;
	gap: 20px;
	min-width: 0;
}

.afg-charts-program[hidden] {
	display: none;
}

.afg-chart-subtle-note {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 10px 16px;
	border-radius: 10px;
	background: #fefce8;
	border: 1px solid #fef08a;
	color: #854d0e;
	font-size: 13px;
	font-weight: 750;
	line-height: 1.7;
}

.afg-chart-subtle-note small {
	color: #a16207;
	font-size: 12px;
}

/* ---------------------------------------------------------------------
 * Long Description (page editor content, end of page)
 * ------------------------------------------------------------------- */
.afg-charts-long-desc {
	margin-top: 24px;
	padding: 22px 26px;
	border: 1px solid #e2e8f0;
	border-radius: 18px;
	background: #ffffff;
	box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.afg-charts-long-desc__title {
	margin: 0 0 12px;
	color: #0f172a;
	font-size: 18px;
	font-weight: 900;
	line-height: 1.5;
}

.afg-charts-long-desc__body {
	color: #334155;
	font-size: 14px;
	line-height: 1.9;
	overflow-wrap: anywhere;
}

.afg-charts-long-desc__body p {
	margin: 0 0 12px;
}

.afg-charts-long-desc__body p:last-child {
	margin-bottom: 0;
}

.afg-charts-long-desc__body ul,
.afg-charts-long-desc__body ol {
	margin: 0 0 12px;
	padding-inline-start: 22px;
}

.afg-charts-long-desc__body a {
	color: #102a61;
	font-weight: 700;
}

.afg-charts-long-desc__body img {
	max-width: 100%;
	height: auto;
	border-radius: 10px;
}

/* Collapsed summary state (added by JS only, so no-JS shows full text) */
.afg-charts-long-desc__body.is-clamped {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
	line-clamp: 4;
	overflow: hidden;
}

.afg-charts-long-desc__toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 12px;
	padding: 8px 18px;
	border: 1.5px solid #cbd5e1;
	border-radius: 999px;
	background: #ffffff;
	color: #102a61;
	font: inherit;
	font-size: 13px;
	font-weight: 800;
	line-height: 1.5;
	cursor: pointer;
	transition: border-color .18s ease, background .18s ease;
}

.afg-charts-long-desc__toggle[hidden] {
	display: none;
}

.afg-charts-long-desc__toggle:hover {
	border-color: #102a61;
	background: #f1f5f9;
}

.afg-charts-long-desc__toggle:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(16, 42, 97, .12);
}

.afg-charts-long-desc__toggle svg {
	transition: transform .18s ease;
}

.afg-charts-long-desc__toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

.afg-charts-long-desc__toggle[aria-expanded="false"] .afg-charts-long-desc__label-less,
.afg-charts-long-desc__toggle[aria-expanded="true"] .afg-charts-long-desc__label-more {
	display: none;
}

/* ---------------------------------------------------------------------
 * Term Groups (chunks of 4) + 2-Column Grid of All Semesters
 * ------------------------------------------------------------------- */
.afg-charts-term-group {
	display: grid;
	gap: 14px;
	min-width: 0;
}

/* Light group bar: year/term range (right) + units meta (left) */
.afg-charts-group-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 8px 0 0;
	padding: 12px 18px;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	background: #ffffff;
	color: #0f172a;
	font-size: 15px;
	font-weight: 900;
	letter-spacing: -0.01em;
	line-height: 1.4;
}

.afg-charts-group-bar__title {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.afg-charts-group-bar__title .dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #102a61;
	flex: 0 0 8px;
}

.afg-charts-group-bar__meta {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	color: #64748b;
	font-size: 13px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.afg-charts-group-bar__meta strong {
	color: #0f172a;
	font-weight: 900;
}

.afg-charts-group-bar__meta .sep {
	color: #cbd5e1;
}

.afg-charts-terms-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 18px;
	align-items: start;
	min-width: 0;
}

/* Side-by-side when each column is wide enough for all 8 table columns */
@media screen and (min-width: 1100px) {
	.afg-charts-terms-grid {
		grid-template-columns: 1fr 1fr;
	}
}

/* Single column when even full-width would crush the 8-column table */
@media screen and (max-width: 1099px) {
	.afg-charts-terms-grid {
		grid-template-columns: 1fr;
	}
}

/* Per-term header (screen): light bar matching reference; print restyles dark */
.afg-term-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
	padding: 12px 16px;
	border: 1px solid #e2e8f0;
	border-bottom: 0;
	border-radius: 16px 16px 0 0;
	background: #f8fafc;
	color: #0f172a;
}

.afg-term-head__main {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px 10px;
	min-width: 0;
}

.afg-term-head__main strong {
	font-size: 14.5px;
	font-weight: 900;
	letter-spacing: -0.01em;
	white-space: nowrap;
}

.afg-term-head__count {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	background: #e2e8f0;
	color: #475569;
	font-size: 11.5px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.afg-term-head__units {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.afg-term-head .unit-th {
	background: #eff6ff;
	color: #1d4ed8;
}

.afg-term-head .unit-pr {
	background: #fef2f2;
	color: #b91c1c;
}

.afg-term-head .unit-tot {
	background: #f0fdf4;
	color: #15803d;
}

.afg-charts-term-panel {
	display: grid;
	gap: 0;
	min-width: 0;
}

.afg-charts-term-panel[hidden] {
	display: none !important;
}

/* Table sits flush under the dark term head */
.afg-charts-term-panel .afg-charts-table-wrap {
	border-top: 0;
	border-radius: 0 0 16px 16px;
}

.afg-charts-term-panel .afg-charts-table thead th:first-child,
.afg-charts-term-panel .afg-charts-table thead th:last-child {
	border-radius: 0;
}

/* ---------------------------------------------------------------------
 * Desktop Course Table — Breathable & Legible
 * ------------------------------------------------------------------- */
.afg-charts-table-wrap {
	overflow-x: auto;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	background: #ffffff;
	box-shadow: 0 4px 20px rgba(15, 23, 42, .03);
}

.afg-charts-table {
	width: 100%;
	min-width: 0;
	table-layout: fixed;
	border-collapse: collapse;
	font-size: 13px;
	line-height: 1.7;
}

.afg-charts-table thead th {
	padding: 11px 8px;
	background: #f8fafc;
	color: #475569;
	font-size: 12px;
	font-weight: 900;
	text-align: right;
	white-space: nowrap;
	border-bottom: 1px solid #e2e8f0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.afg-charts-table .th-row { width: 6%; text-align: center; }
.afg-charts-table .th-code { width: 11%; text-align: center; }
.afg-charts-table .th-title { width: 26%; }
.afg-charts-table .th-th { width: 7%; text-align: center; }
.afg-charts-table .th-pr { width: 7%; text-align: center; }
.afg-charts-table .th-tot { width: 7%; text-align: center; }
.afg-charts-table .th-req { width: 28%; white-space: normal; }
.afg-charts-table .th-type { width: 8%; text-align: center; white-space: normal; }

.afg-charts-table tbody td,
.afg-charts-table tbody th {
	padding: 10px 8px;
	border-bottom: 1px solid #f1f5f9;
	color: #1e293b;
	vertical-align: top;
	word-break: break-word;
	overflow-wrap: anywhere;
}

.afg-charts-table tbody tr:last-child td,
.afg-charts-table tbody tr:last-child th {
	border-bottom: 0;
}

.afg-charts-table tbody tr:hover {
	background: #f8fafc;
}

.afg-charts-table th.td-title {
	font-weight: 850;
	color: #0f172a;
	font-size: 13px;
	line-height: 1.55;
	white-space: normal;
}

.afg-charts-table td.td-row,
.afg-charts-table td.td-code,
.afg-charts-table td.td-th,
.afg-charts-table td.td-pr,
.afg-charts-table td.td-tot {
	text-align: center;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.afg-charts-table td.td-req {
	text-align: right;
	font-size: 12px;
	line-height: 1.55;
}

.afg-charts-table td.td-type {
	text-align: center;
	font-size: 11.5px;
}

.afg-charts-table td.afg-code-cell {
	color: #1d4ed8;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-weight: 750;
	font-size: 11.5px;
}

.afg-table-prereq {
	display: inline;
	color: #334155;
	font-weight: 750;
	white-space: normal;
	overflow-wrap: anywhere;
}

.afg-table-empty {
	color: #94a3b8;
}

.afg-charts-coreq {
	display: block;
	color: #64748b;
	font-size: 11.5px;
	margin-top: 2px;
	white-space: normal;
	overflow-wrap: anywhere;
}

/* Unit badges */
.afg-unit-badge {
	display: inline-block;
	min-width: 26px;
	padding: 2px 8px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 800;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.unit-th {
	background: #eff6ff;
	color: #1d4ed8;
}

.unit-pr {
	background: #fef2f2;
	color: #b91c1c;
}

.unit-tot {
	background: #f0fdf4;
	color: #15803d;
	font-weight: 900;
}

/* Type badges */
.afg-type-badge {
	display: inline-block;
	max-width: 100%;
	padding: 3px 7px;
	border-radius: 6px;
	background: var(--tbg, #f1f5f9);
	color: var(--tc, #475569);
	font-size: 11px;
	font-weight: 850;
	white-space: normal;
	line-height: 1.4;
	text-align: center;
	overflow-wrap: anywhere;
}

.t-base { --tbg: #e0f2fe; --tc: #0369a1; }
.t-core { --tbg: #ede9fe; --tc: #6d28d9; }
.t-special { --tbg: #fce7f3; --tc: #be185d; }
.t-general { --tbg: #f1f5f9; --tc: #475569; }
.t-remedial { --tbg: #fef3c7; --tc: #b45309; }
.t-elective { --tbg: #f3e8ff; --tc: #7e22ce; }
.t-required { --tbg: #ecfdf5; --tc: #047857; }
.t-other { --tbg: #f1f5f9; --tc: #475569; }

/* Table footer */
.afg-charts-table tfoot td {
	padding: 10px 8px;
	background: #f8fafc;
	color: #334155;
	font-weight: 850;
	border-top: 2px solid #e2e8f0;
	font-variant-numeric: tabular-nums;
	font-size: 12.5px;
}

.afg-charts-table tfoot .tfoot-label {
	text-align: right;
	color: #0f172a;
	font-size: 12.5px;
	white-space: normal;
}

/* Filtered search term breakdown header */
.afg-charts-termhead {
	margin: 14px 4px 8px;
	color: #102a61;
	font-size: 14px;
	font-weight: 900;
}

/* Type-filter: hide non-matching rows/cards */
.afg-charts-table tbody tr[hidden],
.afg-course-card[hidden] {
	display: none !important;
}

/* Completion checkbox (row/card) */
.afg-done-check {
	position: relative;
	display: inline-grid;
	place-items: center;
	vertical-align: middle;
	cursor: pointer;
	user-select: none;
}

.afg-done-check input {
	position: absolute;
	inset: 0;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.afg-done-box {
	display: inline-grid;
	place-items: center;
	width: 20px;
	height: 20px;
	border: 1.5px solid #cbd5e1;
	border-radius: 6px;
	background: #ffffff;
	transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.afg-done-box::after {
	content: '';
	width: 10px;
	height: 6px;
	border: 2px solid transparent;
	border-top: 0;
	border-right: 0;
	transform: rotate(-45deg) translateY(-1px);
	opacity: 0;
	transition: opacity .14s ease;
}

.afg-done-check:hover .afg-done-box {
	border-color: #102a61;
}

.afg-done-check input:focus-visible + .afg-done-box {
	box-shadow: 0 0 0 3px rgba(16, 42, 97, .14);
	border-color: #102a61;
}

.afg-done-check input:checked + .afg-done-box {
	border-color: #15803d;
	background: #15803d;
}

.afg-done-check input:checked + .afg-done-box::after {
	border-color: #ffffff;
	opacity: 1;
}

.afg-row-num {
	display: inline-block;
	min-width: 1.4em;
	color: #94a3b8;
	font-size: 12px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	margin-inline-start: 6px;
	vertical-align: middle;
}

/* Completed course row/card */
.afg-charts-table tbody tr.is-done {
	background: #f0fdf4;
}

.afg-charts-table tbody tr.is-done:hover {
	background: #ecfdf5;
}

.afg-charts-table tbody tr.is-done th.td-title,
.afg-course-card.is-done .afg-course-card__title {
	color: #15803d;
	text-decoration: line-through;
	text-decoration-color: rgba(21, 128, 61, .45);
	text-decoration-thickness: 1.5px;
}

.afg-course-card.is-done {
	border-color: #bbf7d0;
	background: #f0fdf4;
}

/* Mobile cards are hidden by default on desktop */
.afg-charts-cards {
	display: none;
}

/* Print header is hidden on screen */
.afg-charts-print-header {
	display: none;
}

/* ---------------------------------------------------------------------
 * Mobile Layout (< 768px): Spacious & Comfortable Touch Cards
 * ------------------------------------------------------------------- */
@media screen and (max-width: 767px) {
	.afg-charts-section {
		padding: 16px 0 54px;
	}

	.afg-charts-topbar {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
		margin-bottom: 12px;
	}

	.afg-charts-topbar .afg-charts-dept-dropdown {
		flex: 1 1 auto;
		max-width: none;
		min-width: 0;
		width: 100%;
	}

	.afg-charts-topbar__actions {
		flex-direction: column;
		align-items: stretch;
		margin-inline-start: 0;
	}

	.afg-charts-progress {
		min-width: 0;
		width: 100%;
	}

	.afg-charts-print-action {
		justify-content: center;
		min-height: 46px;
		width: 100%;
	}

	.afg-charts-degrees {
		margin-bottom: 12px;
	}

	.afg-charts-degree-segments {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		width: 100%;
		gap: 6px;
	}

	.afg-degree-segment {
		justify-content: center;
		min-height: 44px;
		min-width: 0;
		padding: 8px 10px;
		font-size: 12.5px;
		white-space: normal;
		flex-wrap: wrap;
		row-gap: 4px;
		text-align: center;
		overflow: hidden;
	}

	.afg-degree-segment .afg-degree-name {
		min-width: 0;
		white-space: normal;
		overflow-wrap: anywhere;
		line-height: 1.5;
	}

	.afg-degree-segment .afg-degree-badge {
		flex: 0 0 auto;
	}

	.afg-charts-dept-select {
		min-height: 46px;
		font-size: 14px;
	}

	.afg-charts-long-desc {
		margin-top: 18px;
		padding: 18px 16px;
		border-radius: 16px;
	}

	.afg-charts-long-desc__title {
		font-size: 16px;
	}

	.afg-charts-long-desc__body {
		font-size: 13.5px;
	}

	/* Term group bar + grid stack on mobile */
	.afg-charts-terms-grid {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.afg-charts-group-bar {
		padding: 10px 14px;
		font-size: 14px;
		border-radius: 12px;
	}

	.afg-term-head {
		padding: 10px 12px;
		border-radius: 14px 14px 0 0;
	}

	.afg-term-head__main strong {
		font-size: 13.5px;
	}

	.afg-done-box {
		width: 24px;
		height: 24px;
		border-radius: 8px;
	}

	/* Hide desktop table, show spacious cards */
	.afg-charts-table-wrap {
		display: none !important;
	}

	.afg-charts-cards {
		display: grid;
		gap: 12px;
		width: 100%;
		min-width: 0;
	}

	.afg-course-card {
		display: grid;
		gap: 10px;
		padding: 16px 18px;
		border: 1px solid #e2e8f0;
		border-radius: 14px;
		background: #ffffff;
		box-shadow: 0 2px 8px rgba(15, 23, 42, .03);
	}

	.afg-course-card__head {
		display: flex;
		align-items: center;
		gap: 10px;
	}

	.afg-course-card__num {
		display: inline-grid;
		place-items: center;
		width: 26px;
		height: 26px;
		flex: 0 0 26px;
		border-radius: 8px;
		background: #f1f5f9;
		color: #64748b;
		font-size: 12px;
		font-weight: 850;
		font-variant-numeric: tabular-nums;
	}

	.afg-course-card__title {
		margin: 0;
		flex: 1 1 auto;
		min-width: 0;
		color: #0f172a;
		font-size: 14.5px;
		font-weight: 900;
		line-height: 1.5;
	}

	.afg-course-card__tot-unit {
		flex: 0 0 auto;
		display: inline-block;
		padding: 3px 9px;
		border-radius: 6px;
		background: #f0fdf4;
		color: #15803d;
		font-size: 12px;
		font-weight: 900;
		white-space: nowrap;
		font-variant-numeric: tabular-nums;
	}

	.afg-course-card__badges {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 6px 8px;
	}

	.afg-course-card__code {
		display: inline-block;
		padding: 2px 7px;
		border: 1px solid #e2e8f0;
		border-radius: 6px;
		background: #f8fafc;
		color: #1d4ed8;
		font-family: ui-monospace, SFMono-Regular, monospace;
		font-size: 11.5px;
		font-weight: 750;
	}

	.afg-course-card__reqs {
		display: flex;
		flex-wrap: wrap;
		gap: 6px;
	}

	.afg-prereq-tag {
		display: inline-block;
		padding: 3px 9px;
		border: 1px solid #e2e8f0;
		border-radius: 6px;
		background: #f8fafc;
		color: #334155;
		font-size: 11.5px;
		line-height: 1.6;
	}

	.afg-prereq-tag strong {
		color: #0f172a;
		font-weight: 850;
	}

	.afg-course-card-summary {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 10px;
		margin-top: 6px;
		padding: 12px 18px;
		border-radius: 12px;
		background: #f8fafc;
		border: 1px solid #e2e8f0;
	}

	.afg-course-card-summary__label {
		font-size: 13px;
		font-weight: 850;
		color: #1e293b;
	}

	.afg-course-card-summary__values {
		display: flex;
		align-items: center;
		gap: 6px;
	}
}

/* ---------------------------------------------------------------------
 * A4 Vertical 2-Column Print Optimization ("A4 عمودی - ۲ صفحه")
 * Maximum paper efficiency: 4 terms per page (2 columns parallel).
 * 4-term degrees fit on 1 page; 8-term degrees fit on 2 pages (1 sheet front/back).
 * ------------------------------------------------------------------- */
@media print {
	@page {
		size: A4 portrait;
		margin: 8mm 8mm 8mm 8mm;
	}

	/* Site chrome must stay hidden on paper: the theme forces
	 * #Header2.afg-header to display:block !important, which beats a
	 * plain #Header2 hide rule, so match that specificity here. */
	#Header2.afg-header.afg-header--refined,
	#Header2.afg-header,
	#Header2,
	#footer,
	.afg-header-spacer,
	.afg-charts-topbar,
	.afg-charts-degrees,
	.afg-chart-subtle-note,
	.afg-charts-long-desc,
	.afg-charts-group-bar,
	.afg-charts-progress,
	.afg-charts-print-action,
	.afg-charts-dl-action,
	.afg-skip-link {
		display: none !important;
	}

	/* Bootstrap's own print block forces body/.container to min-width
	 * 992px (built for A3). On A4 portrait that pushes half the grid off
	 * the page, so reset it here — this stylesheet loads after Bootstrap,
	 * so equal-specificity !important rules below win. */
	html,
	body {
		width: auto !important;
		min-width: 0 !important;
		max-width: 100% !important;
		overflow-x: hidden !important;
	}

	.container {
		min-width: 0 !important;
		max-width: 100% !important;
	}

	body,
	.afg-charts-main {
		background: #ffffff !important;
		color: #000000 !important;
		padding: 0 !important;
		margin: 0 !important;
		max-width: 100% !important;
		overflow-x: hidden !important;
	}

	.afg-charts-section {
		padding: 0 !important;
	}

	.afg-container {
		width: 100% !important;
		max-width: none !important;
		padding: 0 !important;
	}

	/* Official University Print Header */
	.afg-charts-print-header {
		display: flex !important;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 5mm;
		margin-bottom: 6mm;
		border-bottom: 2px solid #0f172a;
	}

	.print-header-brand {
		display: flex;
		align-items: center;
		gap: 4mm;
	}

	.print-header-logo {
		width: 14mm;
		height: 14mm;
		object-fit: contain;
	}

	.print-header-titles strong {
		display: block;
		font-size: 14pt;
		color: #0f172a;
		font-weight: 900;
	}

	.print-header-titles span {
		display: block;
		font-size: 9pt;
		color: #475569;
		margin-top: 1mm;
	}

	.print-header-meta {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 1mm 6mm;
		font-size: 8.5pt;
		color: #334155;
		text-align: right;
	}

	.print-header-meta strong {
		color: #0f172a;
	}

	/* Programs: hide inactive, reveal active */
	.afg-charts-program[hidden] {
		display: none !important;
	}

	/* Full width; term groups are already chunked to 4 */
	.afg-charts-program:not([hidden]) {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 5mm !important;
		align-items: start !important;
		width: 100% !important;
		max-width: 100% !important;
		overflow: hidden !important;
	}

	/* Each semester panel is a distinct box that cannot be split across pages */
	.afg-charts-term-group {
		display: block !important;
		min-width: 0 !important;
		max-width: 100% !important;
		overflow: hidden !important;
	}

	.afg-charts-terms-grid {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
		column-gap: 4mm !important;
		row-gap: 5mm !important;
		align-items: start !important;
		width: 100% !important;
		max-width: 100% !important;
		overflow: hidden !important;
	}

	.afg-charts-term-panel {
		display: block !important;
		break-inside: avoid !important;
		page-break-inside: avoid !important;
		margin-bottom: 0 !important;
		min-width: 0 !important;
		max-width: 100% !important;
		overflow: hidden !important;
	}

	.afg-charts-term-panel *,
	.afg-charts-terms-grid > * {
		min-width: 0 !important;
	}

	/* Light term head becomes dark ink bar for print contrast */
	.afg-term-head {
		display: flex !important;
		flex-wrap: wrap !important;
		justify-content: space-between;
		align-items: center;
		gap: 1mm 2mm !important;
		padding: 1.2mm 2mm !important;
		margin: 0 !important;
		border: 1px solid #0f172a !important;
		border-bottom: 0 !important;
		border-radius: 2px 2px 0 0 !important;
		background: #0f172a !important;
		color: #ffffff !important;
		max-width: 100% !important;
		overflow: hidden !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.afg-term-head__main {
		min-width: 0 !important;
	}

	.afg-term-head__main strong {
		white-space: normal !important;
	}

	.afg-term-head__main strong {
		font-size: 7.5pt !important;
		color: #ffffff !important;
	}

	.afg-term-head__count,
	.afg-term-head .afg-unit-badge {
		font-size: 6pt !important;
	}

	/* Completion UI is screen-only */
	.afg-done-check {
		display: none !important;
	}

	.afg-charts-table tbody tr.is-done {
		background: #ffffff !important;
	}

	.afg-charts-table tbody tr.is-done th.td-title {
		color: #000000 !important;
		text-decoration: none !important;
	}

	.afg-charts-cards {
		display: none !important;
	}

	.afg-charts-table-wrap {
		display: block !important;
		box-shadow: none !important;
		border: 1px solid #0f172a !important;
		border-top: none !important;
		border-radius: 0 0 3px 3px !important;
		overflow: hidden !important;
		max-width: 100% !important;
		width: 100% !important;
	}

	.afg-charts-table {
		width: 100% !important;
		min-width: 0 !important;
		table-layout: fixed !important;
		font-size: 7pt !important;
		line-height: 1.35 !important;
	}

	/* Half-column tables: let headers wrap instead of ellipsizing to
	 * "ن..." — screen CSS forces nowrap + ellipsis on thead th. */
	.afg-charts-table thead th {
		background: #e2e8f0 !important;
		color: #0f172a !important;
		padding: 1mm 0.75mm !important;
		font-size: 6.5pt !important;
		line-height: 1.4 !important;
		font-weight: 800 !important;
		white-space: normal !important;
		overflow: visible !important;
		text-overflow: clip !important;
		overflow-wrap: anywhere;
		vertical-align: bottom !important;
		border-bottom: 1px solid #94a3b8 !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	/* Rebalance fixed columns for the ~95mm half-page width: roomier
	 * unit columns so "نظری / عملی / واحد" fit on one line. */
	.afg-charts-table .th-row { width: 5% !important; }
	.afg-charts-table .th-code { width: 11% !important; }
	.afg-charts-table .th-title { width: 25% !important; }
	.afg-charts-table .th-th { width: 8% !important; }
	.afg-charts-table .th-pr { width: 8% !important; }
	.afg-charts-table .th-tot { width: 8% !important; }
	.afg-charts-table .th-req { width: 27% !important; }
	.afg-charts-table .th-type { width: 8% !important; }

	.afg-charts-table tbody td,
	.afg-charts-table tbody th {
		padding: 1.5mm 1.5mm !important;
		border-bottom: 0.5px solid #cbd5e1 !important;
		color: #000000 !important;
	}

	.afg-charts-table th.td-title {
		font-size: 7pt !important;
		white-space: normal !important;
	}

	.afg-charts-table td.td-req,
	.afg-charts-table .th-req {
		white-space: normal !important;
		word-break: break-word;
	}

	.afg-type-badge {
		white-space: normal !important;
	}

	.afg-charts-table tfoot td {
		padding: 1.5mm 1.5mm !important;
		background: #f1f5f9 !important;
		font-size: 7pt !important;
		border-top: 1px solid #0f172a !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.afg-unit-badge {
		padding: 0 1mm !important;
		font-size: 6.5pt !important;
		border: 0.5px solid #94a3b8 !important;
		background: #ffffff !important;
		color: #000000 !important;
	}

	/* Clamp pathological type text (e.g. a note pasted into the type
	 * field): without this a paragraph-long "type" wraps one char per
	 * line and blows its row to 600px+, pushing page 1 off the paper. */
	.afg-type-badge {
		display: -webkit-box !important;
		-webkit-line-clamp: 3 !important;
		-webkit-box-orient: vertical !important;
		overflow: hidden !important;
		max-height: 12mm !important;
		padding: 0 1mm !important;
		font-size: 6pt !important;
		border: 0.5px solid #94a3b8 !important;
		background: #ffffff !important;
		color: #000000 !important;
	}
}
