/* =========================================================
   Market Prices - Frontend Styles (RTL by default)
   تصميم مودرن بشكل بطاقة (Card)، محمي بقوة من أي تنسيقات
   عامة يفرضها قالب الموقع على عناصر <table>/<th>/<td>.
   ========================================================= */

.mp-widget {
	--mp-bg: #ffffff;
	--mp-surface: #f8f9fb;
	--mp-text: #16181d;
	--mp-heading: #0f1115;
	--mp-border: rgba(15, 23, 42, 0.08);
	--mp-muted: rgba(15, 23, 42, 0.55);
	--mp-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 28px -8px rgba(16, 24, 40, 0.12);

	/* ألوان الهوية البصرية (اللوجو) - مستخرجة مباشرة من ملف اللوجو */
	--mp-brand-navy: #012452;
	--mp-brand-navy-2: #064395;
	--mp-brand-green: #09641d;
	--mp-brand-green-2: #12cb3b;

	--mp-up: #0aaa2d;
	--mp-up-bg: rgba(10, 170, 45, 0.1);
	--mp-down: #dc2626;
	--mp-down-bg: rgba(220, 38, 38, 0.1);
	--mp-flat: #6b7280;
	--mp-flat-bg: rgba(107, 114, 128, 0.1);
	--mp-accent-gold-1: #f4c95d;
	--mp-accent-gold-2: #c8860a;

	position: relative;
	background: var(--mp-bg);
	color: var(--mp-text) !important;
	border: 1px solid var(--mp-border);
	border-radius: 18px;
	padding: 22px;
	box-sizing: border-box;
	box-shadow: var(--mp-shadow);
	direction: rtl;
	text-align: right;
	font-size: 14px;
	line-height: 1.6;
	overflow: hidden;
	isolation: isolate;
}

.mp-widget::before {
	content: '';
	position: absolute;
	inset: 0 0 auto 0;
	height: 4px;
	background: linear-gradient(90deg, var(--mp-brand-navy), var(--mp-brand-green));
}

.mp-widget.mp-style-dark {
	--mp-bg: #12141a;
	--mp-surface: #191c24;
	--mp-text: #e9ecf2;
	--mp-heading: #ffffff;
	--mp-border: rgba(255, 255, 255, 0.08);
	--mp-muted: rgba(255, 255, 255, 0.58);
	--mp-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 16px 32px -12px rgba(0, 0, 0, 0.55);
	--mp-up-bg: rgba(18, 203, 59, 0.16);
	--mp-down-bg: rgba(248, 113, 113, 0.16);
}

.mp-widget,
.mp-widget * {
	box-sizing: border-box;
}

/* ---------------------------------------------------------
   الأقسام (Sections)
   --------------------------------------------------------- */

.mp-sections {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
	align-items: start;
	gap: 20px;
	position: relative;
	z-index: 1;
}

.mp-layout-ticker .mp-sections {
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 16px;
}

.mp-section {
	background: var(--mp-surface);
	border: 1px solid var(--mp-border);
	border-radius: 14px;
	padding: 16px 14px;
	position: relative;
	overflow: hidden;
}

.mp-layout-ticker .mp-section {
	padding: 14px 12px;
}

.mp-section-title {
	font-size: 14.5px;
	font-weight: 800;
	color: var(--mp-heading) !important;
	margin: 0 0 14px;
	display: flex;
	align-items: center;
	gap: 10px;
	letter-spacing: 0.2px;
}

.mp-icon {
	font-size: 15px;
	line-height: 1;
	width: 30px;
	height: 30px;
	flex: 0 0 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	color: #fff;
	box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.25);
}

.mp-section-gold .mp-icon {
	background: linear-gradient(135deg, var(--mp-accent-gold-1), var(--mp-accent-gold-2));
}

.mp-section-currency .mp-icon {
	background: linear-gradient(135deg, var(--mp-brand-navy-2), var(--mp-brand-navy));
}

.mp-section-oil .mp-icon {
	background: linear-gradient(135deg, var(--mp-brand-green-2), var(--mp-brand-green));
}

/* ---------------------------------------------------------
   صفوف الشريط المختصر (Ticker rows)
   --------------------------------------------------------- */

.mp-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 9px 10px;
	margin-bottom: 4px;
	border-radius: 10px;
	background: var(--mp-bg);
	transition: background-color 0.15s ease;
}

.mp-row:hover {
	background: var(--mp-border);
}

.mp-row:last-child {
	margin-bottom: 0;
}

.mp-label {
	color: var(--mp-muted) !important;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.mp-value {
	font-weight: 800;
	color: var(--mp-heading) !important;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: plaintext;
}

.mp-row-highlight {
	background: linear-gradient(135deg, rgba(212, 160, 23, 0.14), rgba(212, 160, 23, 0.03));
	border: 1px solid rgba(212, 160, 23, 0.25);
}

.mp-row-highlight .mp-value {
	font-size: 21px;
	font-weight: 900;
}

/* ---------------------------------------------------------
   شارة نسبة التغيّر (Change badge)
   --------------------------------------------------------- */

.mp-change {
	font-size: 11.5px;
	font-weight: 800;
	border-radius: 999px;
	padding: 3px 9px;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 3px;
	direction: ltr;
}

.mp-change-inline {
	display: inline-flex;
	margin-top: 8px;
}

.mp-change.mp-up {
	color: var(--mp-up) !important;
	background: var(--mp-up-bg) !important;
}

.mp-change.mp-down {
	color: var(--mp-down) !important;
	background: var(--mp-down-bg) !important;
}

.mp-change.mp-flat {
	color: var(--mp-flat) !important;
	background: var(--mp-flat-bg) !important;
}

.mp-change-row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.mp-change-type-label {
	font-size: 11px;
	color: var(--mp-muted) !important;
	margin: 8px 0 0;
}

.mp-calc-tag {
	font-size: 10px;
	font-weight: 600;
	color: var(--mp-muted) !important;
	background: var(--mp-border) !important;
	border-radius: 999px;
	padding: 1px 7px;
	margin-inline-start: 4px;
}

/* ---------------------------------------------------------
   الجداول (Table layout) - محمية بقوة من تنسيقات القالب العامة
   --------------------------------------------------------- */

.mp-widget .mp-table {
	width: 100% !important;
	border-collapse: separate !important;
	border-spacing: 0 !important;
	font-size: 14px !important;
	background: transparent !important;
	margin: 0 !important;
}

.mp-widget .mp-table thead tr {
	background: transparent !important;
}

.mp-widget .mp-table th {
	background: transparent !important;
	color: var(--mp-muted) !important;
	font-weight: 700 !important;
	font-size: 11.5px !important;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	text-align: right !important;
	padding: 0 10px 10px !important;
	border: none !important;
	border-bottom: 1px solid var(--mp-border) !important;
}

.mp-widget .mp-table td {
	background: transparent !important;
	color: var(--mp-text) !important;
	border: none !important;
	border-bottom: 1px solid var(--mp-border) !important;
	padding: 12px 10px !important;
	font-weight: 500;
}

.mp-widget .mp-table tbody tr {
	background: transparent !important;
	transition: background-color 0.15s ease;
}

.mp-widget .mp-table tbody tr:hover {
	background: var(--mp-bg) !important;
}

.mp-widget .mp-table tbody tr:last-child td {
	border-bottom: none !important;
}

.mp-widget .mp-table td:first-child {
	color: var(--mp-text) !important;
	font-weight: 600;
}

.mp-widget .mp-table th:last-child,
.mp-widget .mp-table td:last-child {
	text-align: left !important;
}

.mp-num {
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: plaintext;
	font-weight: 800 !important;
	color: var(--mp-heading) !important;
}

/* ---------------------------------------------------------
   الرسم البياني (Chart panel)
   --------------------------------------------------------- */

.mp-chart-panel {
	background: var(--mp-bg);
	border: 1px solid var(--mp-border);
	border-radius: 14px;
	padding: 16px 14px 8px;
	margin-top: 14px;
}

.mp-chart {
	width: 100% !important;
	max-width: 100%;
	display: block;
}

.mp-chart-empty,
.mp-chart-note {
	font-size: 12px;
	color: var(--mp-muted) !important;
	margin: 4px 0;
	text-align: center;
}

/* ---------------------------------------------------------
   نصوص مساعدة (Disclaimer / empty state)
   --------------------------------------------------------- */

.mp-disclaimer {
	font-size: 11px;
	color: var(--mp-muted) !important;
	margin: 10px 0 0;
	line-height: 1.5;
}

.mp-empty {
	font-size: 13px;
	color: var(--mp-muted) !important;
	margin: 4px 0;
	padding: 10px;
	background: var(--mp-bg);
	border-radius: 10px;
}

/* ---------------------------------------------------------
   تذييل "آخر تحديث" مع نقطة "مباشر" نابضة
   --------------------------------------------------------- */

.mp-last-updated {
	font-size: 12px;
	color: var(--mp-muted) !important;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid var(--mp-border);
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
}

.mp-last-updated::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--mp-up);
	box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
	animation: mp-pulse 2s infinite;
	flex: 0 0 auto;
}

@keyframes mp-pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
	}
	70% {
		box-shadow: 0 0 0 7px rgba(22, 163, 74, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.mp-last-updated::before {
		animation: none;
	}
}

@media (max-width: 767px) {
	.mp-widget {
		padding: 16px;
		border-radius: 14px;
	}
	.mp-sections,
	.mp-layout-ticker .mp-sections {
		grid-template-columns: 1fr;
	}
}

/* =========================================================
   Admin Settings Page Styles
   ========================================================= */

.mp-settings-wrap .mp-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 16px 0;
	flex-wrap: wrap;
}

.mp-status-grid {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-inline-start: auto;
}

.mp-status-card {
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	padding: 8px 14px;
	font-size: 13px;
	min-width: 160px;
}

.mp-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 11px;
	margin-top: 4px;
}

.mp-badge-warning {
	background: #fff3cd;
	color: #7a5b00;
}

.mp-badge-error {
	background: #fde8e8;
	color: #a10000;
}

.mp-badge-muted {
	background: #eee;
	color: #666;
}

.mp-source-note {
	font-size: 11px;
	opacity: 0.7;
}

.mp-error-log {
	font-size: 11px;
	margin-top: 4px;
}

.ltr-input {
	direction: ltr;
	text-align: left;
}

.mp-quota-hint {
	opacity: 0.7;
	font-size: 12px;
	margin-inline-start: 8px;
}

.mp-test-result {
	margin-inline-start: 8px;
	font-size: 12px;
}

.mp-inline-result {
	font-size: 13px;
}

.mp-plugin-credit {
	margin-top: 24px;
	padding-top: 12px;
	border-top: 1px solid #dcdcde;
	font-size: 12px;
	opacity: 0.75;
	text-align: center;
}

.mp-plugin-credit a {
	text-decoration: none;
	font-weight: 600;
}

/* =========================================================
   تصميم "الجدول الكامل" الموسّع (Dashboard) - 4 أعمدة ثابتة بعرض
   كامل للشاشة، مطابق لتصميم مرجعي محدَّد (بطاقات منفصلة، جدول
   عملات حقيقي برأس داكن، بطاقة ذهب مميزة بخلفية كريمية + إحصائيات
   دورية + جدول تفصيلي).
   ========================================================= */

.mp-widget.mp-layout-table_chart {
	max-width: 100%;
	width: 100%;
	border-radius: 16px;
	padding: 20px;
	box-sizing: border-box;
	/* ملاحظة: عرض الشاشة الكامل الفعلي (كسر عرض العنصر الأب) بيتم
	   حسابه وتطبيقه بدقة عبر JavaScript (راجع market-prices-frontend.js)
	   بدل الاعتماد على حيلة CSS ثابتة (100vw + Margin سالب) - الحيلة دي
	   بتفشل لو أي عنصر أب في تصميم القالب عنده overflow:hidden أو لما
	   يكون فيه شريط تمرير عمودي (Scrollbar) بيأثر على حساب 100vw. الحل
	   بـJS بيحسب المسافة الفعلية من حواف الشاشة الحقيقية، فبيشتغل صح
	   في حالات أكتر.
	*/
}

.mp-layout-table_chart .mp-sections {
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 18px;
	/* تساوي ارتفاع كل البطاقات مع بعض (بدل ما كل بطاقة تاخد ارتفاع
	   محتواها بس، وده كان بيخلّي البطاقات مش متساوية في الطول). */
	align-items: stretch;
}

/* ---------------------------------------------------------
   وضع "Sidebar" - نفس محتوى "الجدول الكامل" الغني (جدول عملات حقيقي،
   بطاقة ذهب مميّزة...) لكن بعمود واحد بعرض طبيعي (مش بعرض الشاشة) -
   مناسب لمساحة Sidebar ضيّقة في تصميم الموقع.
   --------------------------------------------------------- */

.mp-widget.mp-layout-sidebar {
	max-width: 100%;
	width: auto;
	border-radius: 16px;
	padding: 18px;
	box-sizing: border-box;
}

.mp-layout-sidebar .mp-sections {
	grid-template-columns: 1fr;
	gap: 16px;
}

.mp-layout-table_chart .mp-section , .mp-layout-sidebar .mp-section {
	background: #fff;
	border: 1px solid rgba(15, 23, 42, 0.06);
	border-radius: 14px;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
}

.mp-widget.mp-style-dark.mp-layout-table_chart .mp-section,
.mp-widget.mp-style-dark.mp-layout-sidebar .mp-section {
	background: var(--mp-surface);
}

.mp-layout-table_chart .mp-section-header , .mp-layout-sidebar .mp-section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.mp-layout-table_chart .mp-section-header h3 , .mp-layout-sidebar .mp-section-header h3 {
	font-size: 15px;
	font-weight: 800;
	color: var(--mp-heading) !important;
	margin: 0;
}

.mp-icon-badge {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
	flex: 0 0 38px;
}

.mp-icon-badge.fuel { background: rgba(9, 100, 29, 0.12); }
.mp-icon-badge.oil { background: rgba(9, 100, 29, 0.12); }
.mp-icon-badge.currency { background: rgba(1, 36, 82, 0.1); }
.mp-icon-badge.gold { background: rgba(200, 134, 10, 0.16); }

/* ---------------------------------------------------------
   جدول العملات الحقيقي (رأس داكن + أعلام)
   --------------------------------------------------------- */

.mp-currency-table-wrap {
	overflow: hidden;
	border-radius: 10px;
	border: 1px solid rgba(15, 23, 42, 0.06);
}

table.mp-real-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

table.mp-real-table thead th {
	background: var(--mp-brand-navy);
	color: #fff !important;
	font-weight: 700;
	padding: 10px 12px;
	text-align: center;
}

table.mp-real-table thead th:last-child {
	text-align: right;
}

table.mp-real-table tbody td {
	padding: 10px 12px;
	border-top: 1px solid rgba(15, 23, 42, 0.06);
	text-align: center;
	color: var(--mp-text) !important;
}

table.mp-real-table tbody td:last-child {
	text-align: right;
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 8px;
}

.mp-flag {
	font-size: 16px;
}

/* ---------------------------------------------------------
   بطاقة الذهب المميّزة (Hero style)
   --------------------------------------------------------- */

.mp-gold-hero-card {
	background: linear-gradient(160deg, #fdf6e6, #fbf0d9) !important;
	border-color: rgba(200, 134, 10, 0.2) !important;
}

.mp-gold-hero-top {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 14px;
}

.mp-gold-sparkline {
	flex: 0 0 70px;
	height: 46px;
}

.mp-gold-sparkline canvas {
	width: 100%;
	height: 100%;
}

.mp-gold-hero-label {
	display: block;
	font-size: 11.5px;
	color: var(--mp-accent-gold-2) !important;
	font-weight: 700;
	margin-bottom: 2px;
}

.mp-gold-hero-number {
	display: block;
	font-size: 26px;
	font-weight: 900;
	color: var(--mp-heading) !important;
	direction: ltr;
	text-align: right;
	line-height: 1.1;
}

.mp-gold-hero-unit {
	font-size: 11px;
	color: var(--mp-muted) !important;
}

.mp-period-pills {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-bottom: 14px;
}

.mp-period-pill {
	background: rgba(255, 255, 255, 0.6);
	border: 1px solid rgba(200, 134, 10, 0.18);
	border-radius: 10px;
	padding: 8px 6px;
	text-align: center;
}

.mp-period-pill .mp-period-label {
	display: block;
	font-size: 11px;
	color: var(--mp-muted) !important;
	margin-bottom: 3px;
}

.mp-period-pill .mp-period-value {
	font-size: 13px;
	font-weight: 800;
	direction: ltr;
}

table.mp-gold-breakdown {
	width: 100%;
	font-size: 12.5px;
	border-collapse: collapse;
}

table.mp-gold-breakdown td {
	padding: 7px 4px;
	border-top: 1px solid rgba(200, 134, 10, 0.14);
}

table.mp-gold-breakdown td:first-child {
	color: var(--mp-muted) !important;
}

table.mp-gold-breakdown td:last-child {
	text-align: left;
	font-weight: 800;
	direction: ltr;
}

/* ---------------------------------------------------------
   شريط ملاحظة أسفل الويدجت بالكامل
   --------------------------------------------------------- */

.mp-footer-note {
	margin-top: 16px;
	background: var(--mp-surface);
	border: 1px solid var(--mp-border);
	border-radius: 12px;
	padding: 12px 16px;
	font-size: 12px;
	color: var(--mp-muted) !important;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.mp-updated-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--mp-up);
	display: inline-block;
	animation: mp-pulse-dot 2s infinite;
}

@keyframes mp-pulse-dot {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}

/* ---------------------------------------------------------
   إعادة تنسيق العناصر الموجودة (بدون تغيير الـ HTML) خصيصًا
   لتصميم "الجدول الكامل" الجديد - تطابق الصورة المرجعية.
   --------------------------------------------------------- */

.mp-layout-table_chart .mp-section-title , .mp-layout-sidebar .mp-section-title {
	justify-content: space-between;
	flex-direction: row-reverse;
	margin-bottom: 16px;
}

.mp-layout-table_chart .mp-icon , .mp-layout-sidebar .mp-icon {
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	border-radius: 50%;
	font-size: 17px;
	box-shadow: none;
}

.mp-layout-table_chart .mp-section-fuel .mp-icon , .mp-layout-sidebar .mp-section-fuel .mp-icon {
	background: linear-gradient(135deg, var(--mp-brand-green-2), var(--mp-brand-green)) !important;
}

.mp-layout-table_chart .mp-section-gold .mp-icon , .mp-layout-sidebar .mp-section-gold .mp-icon {
	background: linear-gradient(135deg, var(--mp-accent-gold-1), var(--mp-accent-gold-2)) !important;
}

.mp-layout-table_chart table.mp-table , .mp-layout-sidebar table.mp-table {
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid rgba(15, 23, 42, 0.06);
}

.mp-layout-table_chart table.mp-table thead th , .mp-layout-sidebar table.mp-table thead th {
	background: var(--mp-brand-navy) !important;
	color: #fff !important;
	font-weight: 700 !important;
	padding: 10px 12px !important;
}

.mp-layout-table_chart table.mp-table tbody td , .mp-layout-sidebar table.mp-table tbody td {
	padding: 10px 12px !important;
}

.mp-layout-table_chart .mp-section-currency .mp-chart-panel , .mp-layout-sidebar .mp-section-currency .mp-chart-panel {
	display: none;
}

.mp-flag-icon {
	margin-left: 6px;
}
