<template>
	<div class="vote-page row col-md-10 col-md-offset-1">
		<div v-if="!canVoteBySaham" class="col-xs-12 vote-saham-block-banner">
			<div class="alert alert-danger vote-saham-block-alert" role="alert">
				<i class="fa fa-ban" aria-hidden="true"></i>
				<span>{{ sahamVoteBlockedMessage }}</span>
			</div>
		</div>
		<div class="col-md-8 vote-content-column">
			<div class="vote-content-header">
				<div>
					<div class="vote-section-kicker">Senarai Calon</div>
					<h4 class="vote-content-title">Pilih Calon Anda</h4>
					<p class="vote-page-hint">
						Tekan kad calon untuk melihat maklumat penuh (pendidikan &amp; pengalaman).
					</p>
				</div>
				<div class="alert alert-warning vote-alert" role="alert">
					Anda hanya boleh memilih <b>satu (1) orang calon</b> sahaja.
				</div>
			</div>
			<div class="panel panel-info vote-panel" v-for="position in data.positions" :key="position.id">
				<div class="panel-heading vote-panel-heading">
					<span>{{ position.name }}</span>
					<span class="vote-panel-badge">Calon Aktif</span>
				</div>
				<div class="panel-body vote-panel-body vote-nominee-cards-wrap">
					<div class="vote-nominee-card-list">
						<div v-for="(nominee, index) in data.nominees" v-if="nominee.position_id == position.id"
							:key="nominee.id" class="vote-nominee-card"
							:class="{ 'vote-nominee-card--selected': allSelectedNomineeIds.includes(nominee.id) }"
							@click="viewNomineeDetails(nominee)">
							<div class="vote-nominee-card__pick" @click.stop>
								<input type="checkbox" class="vote-nominee-card__checkbox" :id="'vote-nominee-' + nominee.id"
									:disabled="disabledCheckboxes[index]"
									:checked="allSelectedNomineeIds.includes(nominee.id)"
									@change="vote(position.id, nominee.id)" />
							</div>
							<img :src="createBase64ImageUrl(nominee.photo)" class="vote-nominee-card__photo" alt="" />
							<div class="vote-nominee-card__body">
								<span class="vote-nominee-card__no">#{{ nominee.no_calon }}</span>
								<div class="vote-nominee-card__name">{{ nominee.name }}</div>
								<div class="vote-nominee-card__unit">
									<span class="vote-nominee-card__label">Unit</span>
									{{ nominee.unit }}
								</div>
							</div>
							<div class="vote-nominee-card__chev" aria-hidden="true">
								<i class="fa fa-angle-right"></i>
							</div>
						</div>
						<div v-if="!data.nominees.some(n => n.position_id == position.id)" class="vote-empty-state">
							Tiada calon untuk jawatan ini.
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="col-xs-12 vote-summary-bottom">
			<div class="vote-summary-card">
				<div class="vote-section-kicker">Ringkasan Undian</div>
				<h4 class="vote-page-title">UNDIAN CALON ANGGOTA LEMBAGA</h4>
				<p class="vote-page-subtitle">Semak calon yang telah dipilih sebelum menghantar undi anda.</p>
				<div class="vote-limit-pill">
					Anda hanya boleh memilih <b>satu (1) orang calon</b> sahaja.
				</div>

				<ul class="list-group vote-summary-list">
					<li class="list-group-item vote-summary-item">
						<div class="vote-position-name">Calon Dipilih</div>
						<div v-if="allSelectedNomineeIds.length" class="vote-selected-list">
							<div class="vote-selected-item" v-for="nominee_id in allSelectedNomineeIds"
								:key="nominee_id">
								<span class="vote-selected-badge">#{{ getNomineeNo(nominee_id) }}</span>
								<span>{{ getSelectedNomineeName(nominee_id) }}</span>
							</div>
						</div>
						<div v-else class="vote-empty-selection">
							Belum ada calon dipilih.
						</div>
					</li>

					<li class="list-group-item vote-summary-action">
						<button class="btn btn-success btn-block vote-submit-button" :disabled="!canVoteBySaham"
							@click="checkUndi()">UNDI</button>
					</li>
				</ul>
			</div>
		</div>

		<div class="vote-mobile-actionbar" v-if="canVoteBySaham">
			<div class="vote-mobile-actionbar__inner">
				<div class="vote-mobile-actionbar__meta">
					<div class="vote-mobile-actionbar__title">Undi</div>
					<div class="vote-mobile-actionbar__hint">
						Dipilih: <b>{{ allSelectedNomineeIds.length }}</b> / {{ max }}
					</div>
				</div>
				<button class="btn btn-success vote-mobile-actionbar__btn" @click="checkUndi()">
					UNDI
				</button>
			</div>
		</div>

		<div v-if="showNomineeModal" class="vote-nominee-modal-backdrop" @click.self="closeNomineeModal">
			<div class="modal-dialog vote-nominee-modal-dialog" role="dialog" aria-modal="true"
				aria-labelledby="vote-nominee-modal-title">
				<div class="modal-content vote-nominee-modal-content">
					<div class="modal-header vote-nominee-modal-header">
						<div>
							<h5 class="modal-title vote-nominee-modal-title" id="vote-nominee-modal-title">Maklumat
								Calon</h5>
						</div>
					</div>
					<div class="modal-body vote-nominee-modal-body">
						<div class="vote-nominee-photo-section">
							<div class="vote-nominee-photo-card">
								<img :src="nomineeViewed.photo" class="thumbnail vote-nominee-viewed-photo" alt="" />
								<div class="vote-nominee-photo-meta">
									<div class="vote-nominee-modal-name">{{ nomineeViewed.name }}</div>
								</div>
							</div>
						</div>
						<div class="vote-nominee-detail-section">
							<div class="vote-nominee-summary-grid">
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">Nama</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.name || '-' }}</span>
								</div>
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">No. Calon</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.no_calon || '-' }}</span>
								</div>
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">No. Anggota</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.no_anggota || '-'
									}}</span>
								</div>
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">Unit</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.unit || '-' }}</span>
								</div>
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">Umur</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.umur || '-' }}</span>
								</div>
								<div class="vote-nominee-summary-item">
									<span class="vote-nominee-summary-label">Jawatan Sekarang</span>
									<span class="vote-nominee-summary-value">{{ nomineeViewed.jawatan_sekarang || '-'
									}}</span>
								</div>
							</div>

							<div class="vote-nominee-section-card">
								<div class="vote-nominee-section-title">Taraf Pendidikan</div>
								<ol v-if="nomineeViewed.education && nomineeViewed.education.length"
									class="vote-nominee-detail-list">
									<li v-for="(item, idx) in nomineeViewed.education" :key="'ed-' + idx">{{ item }}
									</li>
								</ol>
								<p v-else class="vote-nominee-detail-empty">Tiada maklumat pendidikan.</p>
							</div>

							<div class="vote-nominee-section-card">
								<div class="vote-nominee-section-title">Pengalaman Kerja</div>
								<ol v-if="nomineeViewed.experience && nomineeViewed.experience.length"
									class="vote-nominee-detail-list">
									<li v-for="(item, idx) in nomineeViewed.experience" :key="'ex-' + idx">{{ item }}
									</li>
								</ol>
								<p v-else class="vote-nominee-detail-empty">Tiada maklumat pengalaman kerja.</p>
							</div>
						</div>
					</div>
					<div class="modal-footer vote-nominee-modal-footer">
						<button type="button" class="btn btn-success" @click="closeNomineeModal">Tutup</button>
					</div>
				</div>
			</div>
		</div>

		<div class="modal fade app-modal vote-confirm-modal" id="vote-modal" tabindex="-1" role="dialog"
			aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog" role="document">
				<div class="modal-content vote-modal-content">
					<div class="modal-header vote-modal-header">
						<div>
							<div class="vote-section-kicker">Pengesahan</div>
							<h5 class="modal-title vote-modal-title" id="exampleModalLabel">Sahkan Undian Anda</h5>
						</div>
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
					</div>
					<div class="modal-body vote-modal-body">
						<h5 class="vote-modal-note">Nota: Sila pastikan anda telah membuat undian dengan betul.</h5>
						<div class="vote-modal-selection" v-if="allSelectedNomineeIds.length">
							<div class="vote-modal-selection-title">Calon dipilih</div>
							<div class="vote-selected-item" v-for="nominee_id in allSelectedNomineeIds"
								:key="nominee_id">
								<span class="vote-selected-badge">#{{ getNomineeNo(nominee_id) }}</span>
								<span>{{ getSelectedNomineeName(nominee_id) }}</span>
							</div>
						</div>
					</div>
					<div class="modal-footer vote-modal-footer">
						<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
						<button type="button" class="btn btn-primary" :disabled="!canVoteBySaham"
							@click="submit()">Hantar</button>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
const SAHAM_MINIMUM_UNDIAN = 500;

export default {
	created: function () {
		const saham = Number(this.data?.user?.saham);
		if (Number.isNaN(saham) || saham < SAHAM_MINIMUM_UNDIAN) {
			this.util.notify(this.sahamVoteBlockedMessage, 'error');
			this.$router.push({ name: 'Voter Home' });
			return;
		}
		if (this.data.result.length > 0 || this.data.election.status != 2)
			this.$router.push({ name: 'Voter Home' })
		for (var i in this.data.positions) {
			this.selected.push({
				position_id: this.data.positions[i]['id'],
				nominee_id: [],
			});
		}
	},

	data: function () {
		return {
			selected: [],
			name: {},
			selectedNominees: {
			},
			max: 1,
			nomineeViewed: {},
			showNomineeModal: false
		}
	},

	computed: {
		canVoteBySaham() {
			const s = Number(this.data?.user?.saham);
			return !Number.isNaN(s) && s >= SAHAM_MINIMUM_UNDIAN;
		},

		sahamVoteBlockedMessage() {
			return 'Undian tidak tersedia: jumlah saham anda mestilah sekurang-kurangnya RM 500.';
		},

		/** All nominee ids chosen across every position (sidebar + modal must use this, not selected[0]). */
		allSelectedNomineeIds() {
			var ids = [];
			for (var i = 0; i < this.selected.length; i++) {
				var arr = this.selected[i] && Array.isArray(this.selected[i].nominee_id)
					? this.selected[i].nominee_id
					: [];
				for (var j = 0; j < arr.length; j++) ids.push(arr[j]);
			}
			return ids;
		},

		disabledCheckboxes() {
			if (!this.canVoteBySaham) {
				return this.data.nominees.map(() => true);
			}
			const selectedNomineeIds = this.allSelectedNomineeIds;
			return this.data.nominees.map(nominee => {
				return selectedNomineeIds.includes(nominee.id) ? false : this.checkDisabled();
			});
		}
	},

	methods: {
		totalSelectedCount: function () {
			return this.allSelectedNomineeIds.length;
		},

		selectedEntryForPosition: function (position_id) {
			for (var i = 0; i < this.selected.length; i++) {
				if (String(this.selected[i].position_id) === String(position_id)) return this.selected[i];
			}
			return null;
		},

		test: function () {
			console.log('tab');
			this.util.showModal('#vote-modal')
		},
		submit: function () {
			if (!this.canVoteBySaham) {
				this.util.notify(this.sahamVoteBlockedMessage, 'error');
				return;
			}
			if (this.totalSelectedCount() !== this.max) {
				// No selections made
				this.util.notify(`Sila pastikan anda memilih (${this.max}) orang calon.`, 'error');
				return;
			}

			var vm = this;
			this.util.notify('Submitting your vote, please wait...', 'loading');
			console.log(this.selected);
			// Prepare data to send to the server
			let data = {
				vote: this.selected
			};

			// Send a POST request to the server
			axios.post(config.API + 'election/vote', data)
				.then(response => {
					$.notifyClose();
					// Some endpoints may not return a `message`; ensure we never notify "undefined".
					if (response && response.data && typeof response.data.message === 'string' && response.data.message) {
						vm.util.notify(response.data.message, 'success');
					}
					if (vm.util.showResult(response, 'success')) {
						vm.data.result = response.data.result;
						vm.$router.push({ name: 'Voter Home' });
						$('.modal').modal('hide');
					}
				})
				.catch(error => {
					$.notifyClose();
					vm.util.showResult(error, 'error');
				});
		},

		hasNullVote: function () {
			console.log('null' + this.selectedNominees);
			let selected = this.selectedNominees;
			for (var i in selected)
				if (selected[i]['nominee_id'] == null) {
					this.util.notify('You must vote on all position', 'error');
					return true;
				}
			return false;
		},

		reset: function () {
			let selected = this.selectedNominees;
			for (var i in selected) {
				$('#' + selected[i]['nominee_id']).selected(false);
				selected[i]['nominee_id'] = null;
			}
		},
		vote: function (position_id, nominee_id) {

			var entry = this.selectedEntryForPosition(position_id);
			if (!entry) return;

			var idx = entry.nominee_id.indexOf(nominee_id);
			if (idx === -1) {
				// Enforce global max selection across all positions
				if (this.totalSelectedCount() >= this.max) {
					this.util.notify(`Boleh mengundi (${this.max}) calon sahaja!`, 'warning');
					return;
				}
				entry.nominee_id.push(nominee_id);
			} else {
				entry.nominee_id.splice(idx, 1);
			}
		},

		getSelectedNomineeName: function (id) {
			return this.getNominee(id);
		},

		getNomineeNo(id) {
			const nominee = this.data.nominees.find(n => n.id === id);
			return nominee ? nominee.no_calon : '';
		},


		getName: function (id) {
			let positions = this.data.positions;
			let selected = this.selected;

			for (var i in selected)
				if (selected[i]['position_id'] == id)
					return this.getNominee(selected[i]['nominee_id']);
			return '';
		},

		getNominee: function (id) {
			let positions = this.data.positions;
			let nominees = this.data.nominees;
			for (var i in nominees)
				if (nominees[i]['id'] == id) return nominees[i].name;
			return '';
		},

		// getNominee: function (id) {
		// 	let nominees = this.data.nominees;
		// 	for (var i in nominees)
		// 		if (nominees[i]['id'] == id) return nominees[i]['name'];
		// },

		getPartylist: function (id) {
			let partylists = this.data.partylists;
			for (var i in partylists)
				if (partylists[i]['id'] == id) return partylists[i]['name'];
			return 'No Partylist';
		},

		viewNomineeDetails: function (nominee) {
			this.nomineeViewed = { ...nominee };
			this.nomineeViewed.photo = this.createBase64ImageUrl(nominee.photo);
			this.showNomineeModal = true;
		},

		closeNomineeModal: function () {
			this.showNomineeModal = false;
		},

		createBase64ImageUrl: function (base64ImageData) {
			return "data:image/png;base64," + base64ImageData;
		},

		checkUndi: function () {
			if (!this.canVoteBySaham) {
				this.util.notify(this.sahamVoteBlockedMessage, 'error');
				return;
			}
			if (this.totalSelectedCount() <= 0) {
				this.util.notify('Sila pastikan anda memilih (1) orang calon.', 'error');
			} else {
				this.util.showModal('#vote-modal');
			}
			return;
		},

		checkDisabled: function () {
			if (this.totalSelectedCount() >= this.max) {
				return true;
			}
		}

		// uncheck: function (checkedName) {
		// 	this.checkedName = this.checkedNames.filter(name => name !== checkedName);
		// }
	}
}
</script>

<style scoped>
.vote-page {
	margin-top: 18px;
	margin-bottom: 36px;
}

.vote-saham-block-banner {
	margin-bottom: 16px;
}

.vote-saham-block-alert {
	margin-bottom: 0;
	border-radius: 14px;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	font-size: 1.3rem;
	line-height: 1.5;
}

.vote-saham-block-alert .fa {
	flex-shrink: 0;
	margin-top: 3px;
}

.vote-sidebar-column,
.vote-content-column {
	margin-bottom: 6px;
}


.vote-summary-card {
	padding: 22px 20px;
	border-radius: 20px;
	background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
	border: 1px solid #e2ebf5;
	box-shadow: 0 16px 34px rgba(35, 64, 97, 0.08);
	position: static;
}

.vote-section-kicker {
	margin-bottom: 8px;
	color: #2f80ed;
	font-size: 1.2rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.vote-page-title,
.vote-content-title {
	margin: 0 0 8px;
	color: #17324d;
	font-weight: 700;
}

.vote-page-subtitle {
	margin-bottom: 16px;
	color: #5f7388;
	line-height: 1.6;
}

.vote-page-hint {
	margin: 8px 0 0;
	font-size: 1.35rem;
	color: #5f7388;
	line-height: 1.5;
	max-width: 520px;
}

.vote-limit-pill {
	margin-bottom: 18px;
	padding: 12px 14px;
	border-radius: 12px;
	background: #eef5ff;
	border: 1px solid #d7e7ff;
	color: #31506f;
	line-height: 1.6;
}

.vote-summary-list {
	margin-bottom: 0;
}

.vote-summary-item,
.vote-summary-action {
	border: 0;
	border-bottom: 1px solid #edf2f7;
	padding: 14px 0;
	background: transparent;
}

.vote-summary-list .vote-summary-item:last-of-type {
	border-bottom: 1px solid #edf2f7;
}

.vote-position-name {
	margin-bottom: 10px;
	color: #17324d;
	font-size: 1.5rem;
	font-weight: 700;
}

.vote-selected-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.vote-selected-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 12px;
	background: #fff;
	border: 1px solid #e6edf5;
	color: #30475f;
}

.vote-selected-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 48px;
	padding: 5px 10px;
	border-radius: 999px;
	background: #dcecff;
	color: #1e5fbf;
	font-size: 1.2rem;
	font-weight: 700;
}

.vote-empty-selection {
	color: #7a8ea3;
	font-style: italic;
}

.vote-summary-action {
	padding-top: 18px;
	border-bottom: 0;
}

.vote-submit-button {
	padding-top: 12px;
	padding-bottom: 12px;
	border-radius: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	box-shadow: 0 12px 24px rgba(40, 167, 69, 0.24);
}

.vote-content-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 18px;
	margin-bottom: 18px;
}

.vote-alert {
	margin-bottom: 0;
	border-radius: 12px;
	box-shadow: 0 10px 24px rgba(255, 193, 7, 0.15);
}

.vote-panel {
	margin-bottom: 20px;
	border: 0;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 16px 34px rgba(35, 64, 97, 0.1);
}

.vote-panel-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	background: linear-gradient(135deg, #1d4e89, #2f80ed);
	color: #fff !important;
	font-size: 1.7rem;
	font-weight: 700;
}

.vote-panel-badge {
	padding: 6px 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.18);
	font-size: 1.2rem;
	font-weight: 600;
}

.vote-panel-body {
	padding: 0;
	background: #fff;
}

.vote-nominee-cards-wrap {
	padding: 16px 18px 20px;
	background: #f7fafc;
}

.vote-nominee-card-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.vote-nominee-card {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	border-radius: 16px;
	border: 1px solid #e6edf5;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.vote-nominee-card:hover {
	border-color: #b8d4f5;
	box-shadow: 0 8px 22px rgba(47, 128, 237, 0.12);
}

.vote-nominee-card--selected {
	border-color: #2f80ed;
	box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.28);
	background: #f5f9ff;
}

.vote-nominee-card__pick {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	align-self: stretch;
	padding-right: 4px;
}

.vote-nominee-card__checkbox {
	width: 20px;
	height: 20px;
	cursor: pointer;
	vertical-align: middle;
	margin: 0;
}

.vote-nominee-card__pick .vote-nominee-card__checkbox:disabled {
	cursor: not-allowed;
	opacity: 0.55;
}

.vote-nominee-card__photo {
	flex-shrink: 0;
	width: 72px;
	height: 72px;
	margin: 0;
	border-radius: 16px;
	border: 2px solid #dbe8ff;
	object-fit: cover;
	box-shadow: 0 8px 18px rgba(47, 128, 237, 0.12);
}

.vote-nominee-card__body {
	flex: 1;
	min-width: 0;
	text-align: left;
}

.vote-nominee-card__no {
	display: inline-block;
	margin-bottom: 4px;
	padding: 3px 10px;
	border-radius: 999px;
	background: #dcecff;
	color: #1e5fbf;
	font-size: 1.2rem;
	font-weight: 700;
}

.vote-nominee-card__name {
	font-size: 1.65rem;
	font-weight: 700;
	color: #17324d;
	line-height: 1.35;
	margin-bottom: 6px;
	word-break: break-word;
}

.vote-nominee-card__unit {
	font-size: 1.35rem;
	color: #48627e;
	line-height: 1.45;
	word-break: break-word;
}

.vote-nominee-card__label {
	display: block;
	font-size: 1.1rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #8a9caf;
	margin-bottom: 2px;
}

.vote-nominee-card__chev {
	flex-shrink: 0;
	color: #b0c4de;
	font-size: 2rem;
	line-height: 1;
	width: 24px;
	text-align: center;
}

.vote-empty-state {
	padding: 22px 16px;
	text-align: center;
	color: #6f8193;
	font-size: 1.4rem;
	border-radius: 14px;
	border: 1px dashed #cfddec;
	background: #fff;
}

.vote-modal-content {
	border: 0;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.vote-modal-header {
	padding: 18px 22px;
	background: linear-gradient(135deg, #0d6efd, #2f80ed);
	color: #fff;
}

.vote-modal-title {
	margin: 4px 0 0;
	font-size: 2rem;
	font-weight: 700;
}

.vote-modal-header .close {
	color: #fff;
	opacity: 0.9;
	text-shadow: none;
}

.vote-modal-body {
	padding: 22px;
	background: #f7fbff;
}

.vote-modal-note {
	margin-top: 0;
	margin-bottom: 14px;
	color: #17324d;
}

.vote-modal-selection-title {
	margin-bottom: 10px;
	font-size: 1.4rem;
	font-weight: 700;
	color: #17324d;
}

.vote-modal-footer {
	padding: 16px 22px 20px;
	background: #fff;
}

@media (max-width: 991px) {
	.vote-summary-card {
		position: static;
		top: auto;
	}

	.vote-content-header {
		flex-direction: column;
	}
}

@media (max-width: 767px) {
	.vote-page {
		margin-top: 8px;
	}

	.vote-panel-heading {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.vote-nominee-cards-wrap {
		padding: 12px 12px 16px;
	}

	.vote-nominee-card {
		gap: 12px;
		padding: 12px 14px;
	}

	.vote-nominee-card__photo {
		width: 64px;
		height: 64px;
		border-radius: 14px;
	}

	.vote-nominee-card__name {
		font-size: 1.5rem;
	}

	.vote-nominee-card__chev {
		display: none;
	}

	.vote-content-column {
		padding-bottom: 86px;
		/* room for sticky action bar */
	}

	.vote-mobile-actionbar {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 1040;
		/* below modal (1050), above page */
		padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
		background: rgba(255, 255, 255, 0.92);
		backdrop-filter: blur(10px);
		border-top: 1px solid #e5edf7;
		box-shadow: 0 -10px 24px rgba(35, 64, 97, 0.12);
	}

	.vote-mobile-actionbar__inner {
		max-width: 960px;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
	}

	.vote-mobile-actionbar__title {
		font-weight: 800;
		color: #17324d;
	}

	.vote-mobile-actionbar__hint {
		color: #5f7388;
		font-size: 12px;
	}

	.vote-mobile-actionbar__btn {
		min-width: 140px;
		border-radius: 999px;
		font-weight: 800;
		letter-spacing: 0.04em;
		box-shadow: 0 12px 24px rgba(40, 167, 69, 0.24);
	}
}

/* Nominee detail overlay — above voter/index navbar (.floating-header z-index 2000) */
.vote-nominee-modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 2500;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background: rgba(7, 25, 48, 0.72);
	backdrop-filter: blur(3px);
}

.vote-nominee-modal-dialog {
	width: 100%;
	max-width: 960px;
	margin: 0;
}

.vote-nominee-modal-content {
	border: 0;
	border-radius: 20px;
	overflow: hidden;
	box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

.vote-nominee-modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 20px 24px 16px;
	border-bottom: 1px solid #e7edf5;
	background: linear-gradient(135deg, #0d6efd, #2f80ed);
	color: #fff;
}

.vote-nominee-modal-title {
	margin: 4px 0 0;
	font-size: 2.2rem;
	font-weight: 700;
	color: #fff;
}

.vote-nominee-modal-body {
	display: flex;
	gap: 24px;
	padding: 24px;
	background: #f5f8fc;
}

.vote-nominee-photo-section {
	flex: 0 0 300px;
}

.vote-nominee-photo-card {
	padding: 18px;
	border-radius: 18px;
	background: #fff;
	border: 1px solid #e5ebf3;
	box-shadow: 0 10px 24px rgba(35, 64, 97, 0.08);
}

.vote-nominee-viewed-photo {
	width: 100%;
	height: 320px;
	object-fit: contain;
	object-position: center;
	border: 0;
	border-radius: 14px;
	margin: 0 0 16px;
	background: #eef3f8;
}

.vote-nominee-photo-meta {
	text-align: center;
}

.vote-nominee-modal-name {
	font-size: 2rem;
	font-weight: 700;
	color: #17324d;
}

.vote-nominee-detail-section {
	flex: 1;
	min-width: 0;
}

.vote-nominee-summary-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
	margin-bottom: 18px;
}

.vote-nominee-summary-item {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 14px 16px;
	border-radius: 14px;
	background: #fff;
	border: 1px solid #e5ebf3;
	box-shadow: 0 8px 22px rgba(35, 64, 97, 0.06);
}

.vote-nominee-summary-label {
	font-size: 1.2rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #6f8193;
}

.vote-nominee-summary-value {
	font-size: 1.6rem;
	font-weight: 600;
	line-height: 1.4;
	color: #17324d;
}

.vote-nominee-section-card {
	margin-bottom: 16px;
	padding: 18px 20px;
	border-radius: 16px;
	background: #fff;
	border: 1px solid #e5ebf3;
	box-shadow: 0 8px 22px rgba(35, 64, 97, 0.06);
}

.vote-nominee-section-title {
	margin-bottom: 12px;
	font-size: 1.5rem;
	font-weight: 700;
	color: #17324d;
}

.vote-nominee-detail-list {
	margin: 0;
	padding-left: 20px;
	color: #30475f;
}

.vote-nominee-detail-list li {
	margin-bottom: 8px;
	line-height: 1.6;
}

.vote-nominee-detail-empty {
	margin: 0;
	color: #6f8193;
}

.vote-nominee-modal-footer {
	padding: 16px 24px 22px;
	border-top: 1px solid #e7edf5;
	background: #fff;
}

@media (max-width: 767px) {
	.vote-nominee-modal-backdrop {
		align-items: flex-start;
		overflow-y: auto;
		padding: 16px 10px;
	}

	.vote-nominee-modal-body {
		flex-direction: column;
		padding: 18px;
	}

	.vote-nominee-photo-section {
		flex: 1 1 auto;
	}

	.vote-nominee-viewed-photo {
		height: 260px;
	}

	.vote-nominee-summary-grid {
		grid-template-columns: 1fr;
	}
}
</style>
