/* ==========================================================================
   Tanja24 Election Live — Frontend Styles
   RTL-first, mobile-first, scoped under .t24-election-app to avoid theme conflicts.
   ========================================================================== */

.t24-election-app {
	--t24-primary: #0b5fff;
	--t24-secondary: #0a2540;
	--t24-bg: #ffffff;
	--t24-bg-alt: #f7f8fa;
	--t24-text: #16181d;
	--t24-text-muted: #6b7280;
	--t24-border: #e5e7eb;
	--t24-track: #eceef1;
	--t24-success: #1a7d3c;
	--t24-danger: #c0392b;
	--t24-radius: 14px;
	--t24-shadow: 0 1px 3px rgba(0, 0, 0, .05), 0 1px 2px rgba(0, 0, 0, .04);
	--t24-space: 16px;

	direction: rtl;
	text-align: right;
	font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
	color: var(--t24-text);
	background: var(--t24-bg);
	line-height: 1.6;
	box-sizing: border-box;
	max-width: 100%;
	overflow-x: hidden;
}

.t24-election-app *,
.t24-election-app *::before,
.t24-election-app *::after {
	box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
	.t24-election-app:not([data-theme="light"]) {
		--t24-bg: #0f1216;
		--t24-bg-alt: #171b21;
		--t24-text: #eef1f5;
		--t24-text-muted: #9aa3af;
		--t24-border: #262b33;
		--t24-track: #22262d;
	}
}

.t24-election-app[data-theme="dark"] {
	--t24-bg: #0f1216;
	--t24-bg-alt: #171b21;
	--t24-text: #eef1f5;
	--t24-text-muted: #9aa3af;
	--t24-border: #262b33;
	--t24-track: #22262d;
}

@media (prefers-reduced-motion: reduce) {
	.t24-election-app * {
		animation-duration: .001ms !important;
		transition-duration: .001ms !important;
	}
}

/* ---------- Header ---------- */
.t24-header {
	background: linear-gradient(135deg, var(--t24-secondary), var(--t24-primary));
	color: #fff;
	border-radius: var(--t24-radius);
	padding: 24px;
	margin-bottom: 20px;
}

.t24-header-top {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.t24-brand-logo img {
	max-width: 64px;
	max-height: 64px;
	object-fit: contain;
}

.t24-header-text {
	flex: 1;
	min-width: 200px;
}

.t24-header-title {
	font-size: clamp(22px, 4vw, 32px);
	margin: 0;
	font-weight: 800;
}

.t24-header-subtitle {
	margin: 4px 0 0;
	font-size: clamp(14px, 2.5vw, 18px);
	opacity: .92;
}

.t24-header-tagline {
	margin: 2px 0 0;
	font-size: 13px;
	opacity: .8;
}

.t24-live-status {
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(0, 0, 0, .4);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	padding: 6px 14px;
	border-radius: 100px;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
}

.t24-live-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #ff5252;
	animation: t24-pulse-dot 1.6s infinite;
}

@keyframes t24-pulse-dot {
	0%, 100% { opacity: 1; }
	50% { opacity: .35; }
}

.t24-live-status.t24-pulse {
	background: rgba(76, 217, 100, .45);
}

.t24-header-has-cover {
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	min-height: 220px;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	padding: 16px;
}

.t24-header-top-cover {
	display: flex;
	justify-content: flex-end;
}

@media (max-width: 640px) {
	.t24-header-has-cover {
		min-height: 160px;
	}
}

.t24-countdown {
	margin-top: 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.t24-countdown-label {
	font-size: 13px;
	opacity: .85;
}

.t24-countdown-timer {
	font-size: 20px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	background: rgba(255, 255, 255, .15);
	padding: 6px 14px;
	border-radius: 8px;
}

/* ---------- District navigation ---------- */
.t24-district-nav-wrap {
	margin-bottom: 20px;
}

.t24-district-nav {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	scrollbar-width: thin;
}

.t24-election-app button.t24-district-tab {
	/* SmartMag يضيف line-height وpadding خاصين بالأزرار؛ هذه القيم تعزل
	 * تبويبات الدوائر وتضمن تمركز النص والشارة عمودياً وأفقياً. */
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 4px;
	flex-shrink: 0;
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	color: var(--t24-text);
	min-height: 48px;
	margin: 0 !important;
	padding: 0 18px !important;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35 !important;
	text-align: center;
	vertical-align: middle;
	border-radius: 100px;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
	white-space: nowrap;
}

.t24-district-tab:hover {
	border-color: var(--t24-primary);
}

.t24-district-tab.is-active {
	background: var(--t24-primary);
	border-color: var(--t24-primary);
	color: #fff;
}

.t24-tab-badge {
	font-size: 10px;
	margin-inline-start: 4px;
	opacity: .85;
}

.t24-district-select-mobile {
	display: none;
	width: 100%;
	padding: 10px 14px;
	border-radius: 10px;
	border: 1px solid var(--t24-border);
	background: var(--t24-bg);
	color: var(--t24-text);
	font-size: 15px;
}

@media (max-width: 640px) {
	.t24-district-nav {
		display: none;
	}
	.t24-district-select-mobile {
		display: block;
	}
}

/* ---------- Sections ---------- */
.t24-main {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 20px;
}

.t24-main > * {
	grid-column: 1 / -1;
}

.t24-main > .t24-half-section {
	grid-column: auto;
}

.t24-panel-section {
	background: var(--t24-bg);
	border: 1px solid var(--t24-border);
	border-radius: var(--t24-radius);
	padding: 20px;
	margin-bottom: 18px;
	box-shadow: var(--t24-shadow);
}

.t24-live-embed {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 10px;
	background: #101114;
}

.t24-live-embed iframe {
	position: absolute;
	width: 100%;
	height: 100%;
	border: 0;
}

@media (max-width: 780px) {
	.t24-main {
		grid-template-columns: 1fr;
	}

	.t24-main > .t24-half-section {
		grid-column: 1;
	}
}

.t24-section-title {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 14px;
	position: relative;
	padding-inline-start: 12px;
}

.t24-section-title::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	top: 4px;
	bottom: 4px;
	width: 4px;
	border-radius: 4px;
	background: var(--t24-primary);
}

/* ---------- Stats ---------- */
.t24-stats-section {
	margin-bottom: 18px;
}

.t24-district-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	margin-bottom: 14px;
}

.t24-district-heading h2 {
	margin: 0;
	font-size: 22px;
}

.t24-status-pill {
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	padding: 3px 12px;
	border-radius: 100px;
	font-size: 12px;
	color: var(--t24-text-muted);
}

.t24-stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
}

.t24-stat-tile {
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	border-radius: var(--t24-radius);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.t24-stat-tile-label {
	font-size: 13px;
	color: var(--t24-text-muted);
}

.t24-stat-tile-value {
	font-size: 26px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	color: var(--t24-primary);
}

.t24-stat-tile-small {
	font-size: 16px;
	color: var(--t24-text);
}

.t24-change-badge {
	font-size: 12px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 100px;
	background: var(--t24-track);
	vertical-align: middle;
}

.t24-change-up { color: var(--t24-success); }
.t24-change-down { color: var(--t24-danger); }

/* ---------- Donut ---------- */
.t24-donut {
	width: 180px;
	height: 180px;
	border-radius: 50%;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
}

.t24-donut-hole {
	width: 130px;
	height: 130px;
	border-radius: 50%;
	background: var(--t24-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

/* ---------- Bars (participation by district) ---------- */
.t24-sort-controls {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
	font-size: 13px;
}

.t24-sort-controls select {
	padding: 6px 10px;
	border-radius: 8px;
	border: 1px solid var(--t24-border);
	background: var(--t24-bg);
	color: var(--t24-text);
}

.t24-bar-row {
	display: grid;
	grid-template-columns: 110px 1fr 70px 90px;
	align-items: center;
	gap: 10px;
	padding: 8px 0;
	border-bottom: 1px solid var(--t24-border);
	font-size: 13px;
}

.t24-bar-label {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.t24-bar-track {
	background: var(--t24-track);
	border-radius: 100px;
	height: 10px;
	overflow: hidden;
}

.t24-bar-fill {
	height: 100%;
	background: var(--t24-primary);
	border-radius: 100px;
	transition: width .4s ease;
}

.t24-bar-value {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.t24-bar-votes {
	color: var(--t24-text-muted);
	font-size: 11px;
}

@media (max-width: 560px) {
	.t24-bar-row {
		grid-template-columns: 1fr;
		gap: 4px;
	}
}

.t24-completeness-indicator {
	margin-top: 12px;
	font-size: 12px;
	color: var(--t24-text-muted);
	background: var(--t24-bg-alt);
	display: inline-block;
	padding: 4px 12px;
	border-radius: 100px;
}

/* ---------- Party cards ---------- */
#t24-party-results {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 14px;
}

.t24-party-card {
	display: flex;
	gap: 12px;
	border: 1px solid var(--t24-border);
	border-inline-start: 4px solid var(--party-color, var(--t24-primary));
	border-radius: 12px;
	padding: 14px;
	background: var(--t24-bg-alt);
}

.t24-party-logo {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border: 1px solid var(--t24-border);
}

.t24-party-logo img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.t24-party-fallback {
	font-weight: 800;
	font-size: 18px;
	color: var(--t24-text-muted);
}

.t24-party-info {
	flex: 1;
	min-width: 0;
}

.t24-party-info h3 {
	margin: 0 0 6px;
	font-size: 15px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.t24-party-metrics {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	font-size: 12px;
	color: var(--t24-text-muted);
	margin-bottom: 8px;
}

.t24-party-bar-track {
	height: 6px;
	background: var(--t24-track);
	border-radius: 100px;
	overflow: hidden;
}

.t24-party-bar-fill {
	height: 100%;
	border-radius: 100px;
	transition: width .4s ease;
}

/* ---------- Chart wrap ---------- */
.t24-chart-wrap {
	position: relative;
	width: 100%;
	min-height: 260px;
}

.t24-chart-wrap canvas {
	max-width: 100%;
}

/* ---------- Seats ---------- */
.t24-seats-total {
	font-size: 13px;
	color: var(--t24-text-muted);
	margin-bottom: 10px;
}

.t24-seats-grid-visual {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 14px;
}

.t24-seat {
	width: 18px;
	height: 18px;
	border-radius: 4px;
}

.t24-seat-empty {
	background: var(--t24-track);
	border: 1px dashed var(--t24-border);
}

.t24-seats-legend {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
}

.t24-seat-legend-item {
	display: flex;
	align-items: center;
	gap: 6px;
}

/* ---------- Compare ---------- */
#t24-compare-picker {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 14px;
}

.t24-compare-check {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	padding: 6px 12px;
	border-radius: 100px;
	cursor: pointer;
}

/* ---------- Regional ---------- */
.t24-regional-card {
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	border-radius: 12px;
	padding: 16px;
}

.t24-mini-party-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 0;
	border-bottom: 1px solid var(--t24-border);
	font-size: 14px;
	flex-wrap: wrap;
}

.t24-mini-party-value {
	margin-inline-start: auto;
	font-size: 12px;
	color: var(--t24-text-muted);
}

/* ---------- Timeline ---------- */
#t24-timeline {
	display: flex;
	flex-direction: column;
	gap: 0;
	position: relative;
	padding-inline-start: 20px;
	border-inline-start: 2px solid var(--t24-border);
}

.t24-timeline-item {
	position: relative;
	padding: 0 0 20px 0;
	display: flex;
	gap: 14px;
}

.t24-timeline-item::before {
	content: "";
	position: absolute;
	inset-inline-start: -26px;
	top: 4px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--t24-primary);
}

.t24-timeline-time {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--t24-primary);
	flex-shrink: 0;
	min-width: 46px;
}

.t24-timeline-content h4 {
	margin: 0 0 4px;
	font-size: 14px;
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.t24-timeline-content p {
	margin: 0 0 6px;
	font-size: 13px;
	color: var(--t24-text-muted);
}

.t24-timeline-image {
	max-width: 100%;
	border-radius: 8px;
	margin-bottom: 6px;
}

/* ---------- Methodology / source ---------- */
.t24-methodology {
	font-size: 14px;
	color: var(--t24-text-muted);
}

/* ---------- Share buttons ---------- */
.t24-share-buttons {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.t24-share-btn {
	background: var(--t24-bg-alt);
	border: 1px solid var(--t24-border);
	color: var(--t24-text);
	padding: 8px 16px;
	border-radius: 100px;
	font-size: 13px;
	cursor: pointer;
}

.t24-share-btn:hover {
	border-color: var(--t24-primary);
	color: var(--t24-primary);
}

/* ---------- Shared bits ---------- */
.t24-empty-state {
	text-align: center;
	color: var(--t24-text-muted);
	padding: 30px 10px;
	font-size: 14px;
}

.t24-badge {
	display: inline-block;
	background: var(--t24-track);
	color: var(--t24-text-muted);
	font-size: 10px;
	padding: 2px 8px;
	border-radius: 100px;
}

.t24-color-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, .1);
}

.t24-muted {
	color: var(--t24-text-muted);
}

/* ---------- Accessibility ---------- */
.t24-election-app a:focus-visible,
.t24-election-app button:focus-visible,
.t24-election-app select:focus-visible,
.t24-election-app input:focus-visible {
	outline: 2px solid var(--t24-primary);
	outline-offset: 2px;
}

/* ---------- Standalone block spacing ---------- */
.t24-standalone-block {
	padding: 0;
}

/* ---------- Table-friendly overflow (mobile) ---------- */
@media (max-width: 480px) {
	.t24-panel-section {
		padding: 14px;
	}
	#t24-party-results {
		grid-template-columns: 1fr;
	}
}
