/**
 * RateBar Pro — استایل نوار نرخ
 * سه پوسته: dark (تیره لوکس) | light (روشن مینیمال) | gradient (گرادیان متحرک)
 */

.ratebar {
	--rb-h: 46px;
	--rb-accent: #ffc93c;
	--rb-accent-rgb: 255, 201, 60;

	position: relative;
	width: 100%;
	z-index: 99999;
	direction: rtl;
	font-size: 14px;
	line-height: 1.2;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.ratebar--fixed {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
}

body.admin-bar .ratebar--fixed {
	top: var(--wp-admin--admin-bar--height, 32px);
}

.ratebar__inner {
	display: flex;
	align-items: center;
	gap: 16px;
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 20px;
	height: var(--rb-h);
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	white-space: nowrap;
}

.ratebar__inner::-webkit-scrollbar {
	display: none;
}

/* ---------- آیتم‌ها ---------- */

.ratebar__item {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	white-space: nowrap;
	flex: none;
}

.ratebar__flag {
	font-size: 15px;
	filter: drop-shadow(0 0 6px rgba(var(--rb-accent-rgb), 0.45));
}

.ratebar__name {
	font-size: 12.5px;
	font-weight: 500;
	opacity: 0.82;
}

.ratebar__value {
	font-weight: 700;
	font-size: 14.5px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.2px;
}

.ratebar__unit {
	font-size: 10.5px;
	opacity: 0.5;
}

.ratebar__change {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	font-size: 11px;
	font-weight: 700;
	padding: 3px 8px;
	border-radius: 99px;
	line-height: 1;
}

.ratebar__change--up {
	color: #4ade80;
	background: rgba(74, 222, 128, 0.12);
}

.ratebar__change--down {
	color: #f87171;
	background: rgba(248, 113, 113, 0.12);
}

.ratebar__change--flat {
	color: #94a3b8;
	background: rgba(148, 163, 184, 0.14);
}

.ratebar__sep {
	width: 1px;
	height: 18px;
	background: rgba(148, 163, 184, 0.28);
	flex: none;
}

.ratebar__brand {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.3px;
	color: rgb(var(--rb-accent-rgb));
	white-space: nowrap;
	flex: none;
}

.ratebar__brand svg {
	display: block;
}

.ratebar__error {
	font-size: 12px;
	opacity: 0.8;
}

/* ---------- متا و نقطه زنده ---------- */

.ratebar__meta {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-inline-start: auto;
	font-size: 10.5px;
	opacity: 0.75;
	white-space: nowrap;
	flex: none;
}

.ratebar__live {
	position: relative;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	display: inline-block;
	flex: none;
}

.ratebar__live::after {
	content: '';
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 1.5px solid rgba(34, 197, 94, 0.55);
	animation: rbPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes rbPing {
	0% {
		transform: scale(0.5);
		opacity: 1;
	}
	80%,
	100% {
		transform: scale(1.5);
		opacity: 0;
	}
}

.ratebar__stale {
	color: #fbbf24;
}

/* ---------- انیمیشن تغییر نرخ ---------- */

.ratebar__value.rb-flash {
	animation: rbFlash 0.9s ease;
}

@keyframes rbFlash {
	0% {
		color: rgb(var(--rb-accent-rgb));
		text-shadow: 0 0 16px rgba(var(--rb-accent-rgb), 0.85);
		transform: scale(1.06);
	}
	100% {
		transform: scale(1);
	}
}

/* =====================================================
 * پوسته تیره لوکس (پیش‌فرض)
 * ==================================================== */

.ratebar--dark {
	color: #f5f2ea;
	background: linear-gradient(120deg, rgba(12, 12, 16, 0.94) 0%, rgba(26, 21, 11, 0.94) 55%, rgba(12, 12, 16, 0.94) 100%);
	-webkit-backdrop-filter: blur(18px) saturate(160%);
	backdrop-filter: blur(18px) saturate(160%);
	border-bottom: 1px solid rgba(var(--rb-accent-rgb), 0.3);
	box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.6);
}

.ratebar--dark .ratebar__value {
	color: #ffffff;
}

.ratebar--dark .ratebar__sep {
	background: rgba(255, 255, 255, 0.12);
}

/* =====================================================
 * پوسته روشن مینیمال
 * ==================================================== */

.ratebar--light {
	color: #0f172a;
	background: rgba(255, 255, 255, 0.92);
	-webkit-backdrop-filter: blur(18px) saturate(150%);
	backdrop-filter: blur(18px) saturate(150%);
	border-bottom: 1px solid rgba(15, 23, 42, 0.08);
	box-shadow: 0 8px 28px -16px rgba(15, 23, 42, 0.3);
}

.ratebar--light .ratebar__value {
	color: #0f172a;
}

.ratebar--light .ratebar__brand {
	color: #b45309;
}

.ratebar--light .ratebar__sep {
	background: rgba(15, 23, 42, 0.1);
}

/* =====================================================
 * پوسته گرادیان متحرک
 * ==================================================== */

.ratebar--gradient {
	color: #ffffff;
	background: linear-gradient(115deg, #14141f 0%, #1c1730 35%, rgba(var(--rb-accent-rgb), 0.38) 78%, #14141f 100%);
	background-size: 220% 100%;
	animation: rbSlide 14s linear infinite;
	-webkit-backdrop-filter: blur(18px);
	backdrop-filter: blur(18px);
	border-bottom: 1px solid rgba(var(--rb-accent-rgb), 0.45);
	box-shadow: 0 12px 34px -14px rgba(var(--rb-accent-rgb), 0.35);
}

.ratebar--gradient .ratebar__value {
	color: #ffffff;
}

@keyframes rbSlide {
	from {
		background-position: 0% 0;
	}
	to {
		background-position: 220% 0;
	}
}

/* =====================================================
 * حالت درون‌خطی (شورت‌کد)
 * ==================================================== */

.ratebar--inline {
	display: inline-flex;
	width: auto;
	max-width: 100%;
	border-radius: 16px;
	overflow: hidden;
	border: 1px solid rgba(var(--rb-accent-rgb), 0.35);
	box-shadow: 0 14px 36px -16px rgba(0, 0, 0, 0.4);
	vertical-align: middle;
}

.ratebar--inline .ratebar__inner {
	height: auto;
	min-height: 44px;
	padding: 10px 16px;
	flex-wrap: wrap;
	gap: 14px;
	white-space: normal;
}

/* =====================================================
 * پسوند قیمت ووکامرس
 * ==================================================== */

.ratebar-price-suffix {
	display: block;
	font-size: 11px;
	opacity: 0.55;
	margin-top: 2px;
}

.ratebar-live-price {
	font-weight: 700;
}

/* =====================================================
 * ریسپانسیو
 * ==================================================== */

@media (max-width: 782px) {
	.ratebar {
		--rb-h: 42px;
		font-size: 13px;
	}

	.ratebar__inner {
		gap: 12px;
		padding: 0 12px;
	}

	.ratebar__brand {
		display: none;
	}

	.ratebar__meta .ratebar__updated {
		display: none;
	}
}

@media (max-width: 480px) {
	.ratebar__name {
		display: none;
	}

	.ratebar__flag {
		font-size: 16px;
	}
}

/* احترام به کاهش انیمیشن برای کاربران حساس */
@media (prefers-reduced-motion: reduce) {
	.ratebar--gradient {
		animation: none;
	}

	.ratebar__live::after {
		animation: none;
	}

	.ratebar__value.rb-flash {
		animation: none;
	}
}
