/**
 * Frontend organizational chart + person modals.
 */

.kpe-org {
	--kpe-org-ink: #122033;
	--kpe-org-muted: #5b6777;
	--kpe-org-font: "Vazirmatn", "IRANSansX", Tahoma, sans-serif;
	--kpe-org-radius: 18px;
	font-family: var(--kpe-org-font);
	color: var(--kpe-org-ink);
	direction: rtl;
}

.kpe-org__header {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin-bottom: 20px;
	text-align: center;
}

.kpe-org__mark {
	color: var(--kpe-org-node-bg, #1a5cad);
	flex: 0 0 auto;
	filter: drop-shadow(0 8px 16px rgba(26, 92, 173, 0.22));
}

.kpe-org__title {
	margin: 0;
	font-size: clamp(1.2rem, 2.3vw, 1.85rem);
	font-weight: 800;
	line-height: 1.45;
	letter-spacing: -0.02em;
}

.kpe-org__toolbar {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-bottom: 12px;
}

.kpe-org__zoom {
	min-width: 42px;
	height: 38px;
	border: 1px solid rgba(26, 92, 173, 0.14);
	background: #fff;
	border-radius: 12px;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	color: var(--kpe-org-ink);
	box-shadow: 0 6px 16px rgba(12, 33, 64, 0.06);
	transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.kpe-org__zoom:hover {
	border-color: var(--kpe-org-node-bg, #1a5cad);
	color: var(--kpe-org-node-bg, #1a5cad);
	transform: translateY(-1px);
	box-shadow: 0 10px 20px rgba(26, 92, 173, 0.12);
}

.kpe-org__scroller {
	overflow: auto;
	padding: 4px 2px 20px;
	border-radius: 22px;
}

.kpe-org-chart {
	position: relative;
	width: 100%;
	margin: 0 auto;
	aspect-ratio: var(--kpe-org-ratio, 1.48);
	background:
		radial-gradient(ellipse 80% 70% at 50% 0%, rgba(247, 194, 37, 0.08), transparent 46%),
		radial-gradient(ellipse 60% 50% at 100% 100%, rgba(26, 92, 173, 0.07), transparent 50%),
		var(--kpe-org-canvas, #fff);
	border: 1px solid rgba(26, 92, 173, 0.12);
	border-radius: 22px;
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.8) inset,
		0 24px 60px rgba(12, 33, 64, 0.1);
	overflow: visible;
	transform-origin: top center;
}

.kpe-org-chart::before {
	content: "";
	position: absolute;
	inset: 10px;
	border-radius: 16px;
	border: 1px solid rgba(247, 194, 37, 0.16);
	pointer-events: none;
	z-index: 3;
}

.kpe-org-chart__lines,
.kpe-org-chart__nodes {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.kpe-org-chart__lines {
	z-index: 1;
	overflow: visible;
}

.kpe-org-chart__lines path {
	fill: none;
	stroke: var(--kpe-org-line, #1a5cad);
	stroke-width: 0.28;
	stroke-linecap: round;
	stroke-linejoin: round;
	vector-effect: non-scaling-stroke;
	filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
	opacity: 0.92;
}

.kpe-org-chart__lines path.is-dashed {
	stroke-dasharray: 1.05 0.7;
	opacity: 0.78;
}

.kpe-org-chart__nodes {
	z-index: 2;
}

.kpe-org-node {
	position: absolute;
	left: calc(var(--x) * 1%);
	top: calc(var(--y) * 1%);
	width: calc(var(--w) * 1%);
	height: calc(var(--h) * 1% * var(--kpe-org-ratio, 1.48) / 1.48);
	transform: translate(-50%, -50%);
	z-index: 2;
}

.kpe-org-node.is-open,
.kpe-org-node:hover {
	z-index: 8;
}

.kpe-org .kpe-org-node__box,
.kpe-org a.kpe-org-node__box,
.kpe-org button.kpe-org-node__box,
.kpe-org a.kpe-org-node__box:visited {
	position: relative;
	width: 100%;
	height: 100%;
	border: 0;
	margin: 0;
	padding: 8px 12px;
	border-radius: 10px;
	background: var(--kpe-org-node-bg, #1a5cad) !important;
	color: var(--kpe-org-node-text, #fff) !important;
	font: 700 clamp(0.68rem, 0.95vw, 0.98rem)/1.35 var(--kpe-org-font);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	text-decoration: none !important;
	box-sizing: border-box;
	appearance: none;
	-webkit-appearance: none;
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.22) inset,
		0 10px 22px rgba(16, 42, 86, 0.18);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, filter 0.2s ease;
	overflow: hidden;
}

.kpe-org .kpe-org-node__box::after {
	content: "";
	position: absolute;
	left: 14%;
	right: 14%;
	bottom: 0;
	height: 3px;
	border-radius: 3px 3px 0 0;
	background: rgba(247, 194, 37, 0.85);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.kpe-org--hover:not(.kpe-org--unit-link) .kpe-org-node__box,
.kpe-org--click:not(.kpe-org--unit-link) .kpe-org-node__box,
.kpe-org--unit-link a.kpe-org-node__box,
.kpe-org--unit-link button.kpe-org-node__box {
	cursor: pointer;
}

.kpe-org .kpe-org-node:hover .kpe-org-node__box,
.kpe-org .kpe-org-node.is-open .kpe-org-node__box,
.kpe-org .kpe-org-node__box:focus-visible {
	transform: translateY(-3px);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.28) inset,
		0 16px 32px rgba(16, 42, 86, 0.24);
	background: var(--kpe-org-node-hover-bg, #0c2140) !important;
	color: var(--kpe-org-node-hover-text, #fff) !important;
	outline: none;
	filter: saturate(1.05);
}

.kpe-org .kpe-org-node:hover .kpe-org-node__box::after,
.kpe-org .kpe-org-node.is-open .kpe-org-node__box::after {
	opacity: 1;
}

.kpe-org .kpe-org-node.is-advisor .kpe-org-node__box {
	background: var(--kpe-org-advisor-bg, #f5c518) !important;
	color: var(--kpe-org-advisor-text, #1a2744) !important;
	box-shadow: 0 10px 22px rgba(180, 140, 20, 0.2);
	outline: 1px dashed var(--kpe-org-line, #1a5cad);
	outline-offset: -3px;
}

.kpe-org .kpe-org-node.is-advisor:hover .kpe-org-node__box,
.kpe-org .kpe-org-node.is-advisor.is-open .kpe-org-node__box {
	background: var(--kpe-org-advisor-hover-bg, #0c2140) !important;
	color: var(--kpe-org-advisor-hover-text, #f7c225) !important;
}

.kpe-org .kpe-org-node.is-committee .kpe-org-node__box {
	background: var(--kpe-org-committee-bg, #fff) !important;
	color: var(--kpe-org-committee-text, #1a5cad) !important;
	box-shadow: 0 8px 20px rgba(26, 92, 173, 0.08);
	outline: 1.6px dashed var(--kpe-org-line, #1a5cad);
	outline-offset: -3px;
}

.kpe-org .kpe-org-node.is-committee:hover .kpe-org-node__box,
.kpe-org .kpe-org-node.is-committee.is-open .kpe-org-node__box {
	background: var(--kpe-org-committee-hover-bg, #f7c225) !important;
	color: var(--kpe-org-committee-hover-text, #0c2140) !important;
}

.kpe-org-node__label {
	display: block;
	max-width: 100%;
}

.kpe-org-node__sub {
	display: block;
	opacity: 0.86;
	font-size: 0.78em;
	font-weight: 600;
}

.kpe-org-node__count {
	position: absolute;
	top: -9px;
	inset-inline-start: -9px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: #0c2140;
	color: #f7c225;
	font-size: 11px;
	line-height: 22px;
	font-weight: 800;
	box-shadow: 0 0 0 2px #fff, 0 6px 14px rgba(12, 33, 64, 0.22);
	z-index: 2;
}

.kpe-org-node.is-committee .kpe-org-node__count,
.kpe-org-node.is-advisor .kpe-org-node__count {
	background: var(--kpe-org-node-bg, #1a5cad);
}

.kpe-org-node__people {
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	min-width: max(100%, 168px);
	max-width: 220px;
	display: grid;
	gap: 6px;
	padding: 12px 8px 8px;
	border-radius: 14px;
	background: transparent;
	border: 0;
	box-shadow: none;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
	z-index: 9;
}

.kpe-org-node__people::before {
	content: "";
	position: absolute;
	inset: 8px 0 0;
	border-radius: 14px;
	background: rgba(255, 255, 255, 0.97);
	border: 1px solid rgba(12, 33, 64, 0.08);
	box-shadow: 0 14px 32px rgba(12, 33, 64, 0.16);
	z-index: 0;
}

.kpe-org--always .kpe-org-node__people,
.kpe-org--hover .kpe-org-node.is-open .kpe-org-node__people,
.kpe-org--hover .kpe-org-node:focus-within .kpe-org-node__people,
.kpe-org--click .kpe-org-node.is-open .kpe-org-node__people {
	opacity: 1;
	pointer-events: auto;
	transform: translateX(-50%) translateY(0);
}

.kpe-org-node.is-people-up .kpe-org-node__people {
	top: auto;
	bottom: 100%;
	padding: 8px 8px 12px;
	transform: translateX(-50%) translateY(-4px);
}

.kpe-org-node.is-people-up .kpe-org-node__people::before {
	inset: 0 0 8px;
}

.kpe-org--always .kpe-org-node.is-people-up .kpe-org-node__people,
.kpe-org--hover .kpe-org-node.is-people-up.is-open .kpe-org-node__people,
.kpe-org--hover .kpe-org-node.is-people-up:focus-within .kpe-org-node__people,
.kpe-org--click .kpe-org-node.is-people-up.is-open .kpe-org-node__people {
	transform: translateX(-50%) translateY(0);
}

.kpe-org-chip {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 7px;
	border-radius: 10px;
	text-decoration: none;
	color: #0c2140;
	background: #f6f8fb;
	transition: background 0.15s ease, transform 0.15s ease;
}

.kpe-org-chip:hover,
.kpe-org-chip:focus-visible {
	background: #eef3fb;
	transform: translateY(-1px);
	outline: none;
}

.kpe-org-chip img,
.kpe-org-chip__initials {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	flex: 0 0 auto;
	object-fit: cover;
	background: #1a5cad;
}

.kpe-org-chip__initials {
	display: grid;
	place-items: center;
	color: #fff;
	font-size: 11px;
	font-weight: 800;
}

.kpe-org-chip__meta {
	min-width: 0;
	display: grid;
	gap: 1px;
	text-align: right;
}

.kpe-org-chip__meta strong {
	font-size: 11px;
	font-weight: 800;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.kpe-org-chip__meta em {
	font-style: normal;
	font-size: 10px;
	color: #5b6777;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.kpe-org-chip--image {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	line-height: 0;
}

.kpe-org-chip--image img {
	width: 100%;
	height: auto;
	border-radius: 10px;
	object-fit: contain;
	background: transparent;
}

.kpe-org-modal[hidden] {
	display: none;
}

.kpe-org-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	place-items: center;
	padding: 16px;
}

.kpe-org-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(12, 33, 64, 0.58);
}

.kpe-org-modal__dialog {
	position: relative;
	z-index: 1;
	width: min(1480px, calc(100vw - 24px));
	max-height: calc(100vh - 24px);
	overflow: auto;
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 24px 80px rgba(12, 33, 64, 0.35);
}

.kpe-org-modal__image {
	display: block;
	width: 100%;
	height: auto;
}

.kpe-org-modal__close {
	position: absolute;
	top: 10px;
	inset-inline-start: 10px;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 999px;
	background: #0c2140;
	color: #f7c225;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	z-index: 2;
}

body.kpe-org-modal-open {
	overflow: hidden;
}

@media (max-width: 760px) {
	.kpe-org-chart {
		width: 100%;
		min-width: 720px;
	}

	.kpe-org-chart::before {
		display: none;
	}
}
