/* AgriMer — مؤشّر الإجهاد الحراري للماشية
 * يُحمَّل داخل Shadow DOM، فلا يصل إليه CSS القالب ولا يصل هو إليه.
 */

:host {
	display: block;
	all: initial;
	font-family: "Cairo", "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.ls-root,
.ls-root * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: inherit;
}

.ls-root {
	direction: rtl;
	color: #17202a;
	font-size: 15px;
	line-height: 1.7;
}

/* ---------- الرأس ---------- */

.ls-head {
	margin-bottom: 14px;
}

.ls-head h2 {
	font-size: 22px;
	font-weight: 800;
	color: #0e3b2e;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.ls-head p {
	font-size: 13.5px;
	color: #5b6b73;
	margin-top: 4px;
}

.ls-badge {
	display: inline-block;
	background: #eaf6f0;
	color: #0e6b4f;
	border: 1px solid #bfe3d2;
	border-radius: 999px;
	padding: 2px 10px;
	font-size: 12px;
	font-weight: 700;
}

/* ---------- منتقي الولايات ---------- */

.ls-regions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 16px;
}

.ls-regions button {
	appearance: none;
	border: 1px solid #d6e2e6;
	background: #fff;
	color: #2c3e50;
	border-radius: 999px;
	padding: 6px 13px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: all .15s;
	line-height: 1.4;
}

.ls-regions button:hover {
	border-color: #1abc9c;
	color: #0e6b4f;
}

.ls-regions button[aria-pressed="true"] {
	background: #0e6b4f;
	border-color: #0e6b4f;
	color: #fff;
}

/* ---------- الشبكة ---------- */

.ls-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 14px;
	align-items: start;
}

.ls-card {
	background: #fff;
	border: 1px solid #e4ecef;
	border-radius: 16px;
	padding: 16px 18px;
	box-shadow: 0 2px 10px rgba(16, 42, 67, .05);
}

.ls-card h3 {
	font-size: 15px;
	font-weight: 800;
	color: #0e3b2e;
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 6px;
}

.ls-wide {
	grid-column: 1 / -1;
}

/* ---------- المقياس ---------- */

.ls-gauge {
	text-align: center;
	padding: 20px 18px 18px;
	border-radius: 16px;
	border: 1px solid #e4ecef;
	color: #fff;
	position: relative;
	overflow: hidden;
}

.ls-gauge .ls-num {
	font-size: 58px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: -1px;
}

.ls-gauge .ls-unit {
	font-size: 15px;
	font-weight: 700;
	opacity: .9;
	margin-top: 2px;
}

.ls-gauge .ls-lvl {
	font-size: 18px;
	font-weight: 800;
	margin-top: 10px;
}

.ls-gauge .ls-meta {
	font-size: 13px;
	opacity: .95;
	margin-top: 8px;
	background: rgba(0, 0, 0, .16);
	border-radius: 10px;
	padding: 6px 10px;
	display: inline-block;
}

/* ---------- سلّم العتبات ---------- */

.ls-scale {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 4px;
	margin-top: 12px;
}

.ls-scale > div {
	text-align: center;
	font-size: 10.5px;
	font-weight: 700;
	color: #fff;
	border-radius: 7px;
	padding: 5px 2px;
	opacity: .38;
	transition: opacity .2s;
	line-height: 1.35;
}

.ls-scale > div.on {
	opacity: 1;
	box-shadow: 0 0 0 2px #17202a inset;
}

.ls-scale .ltr {
	font-size: 9.5px;
	opacity: .95;
	font-variant-numeric: tabular-nums;
}

/* ---------- شريط الساعات ---------- */

/* شبكة بـ24 عموداً بدل flex بعرض max-content:
   في RTL يبدأ مسار flex من الحافّة اليمنى ويفيض يساراً.
   و direction:ltr إلزامي هنا: الشبكة في RTL تضع أوّل عمود يميناً
   بينما شريط التسميات تحته ltr — فتنقلب الساعات على قيمها. */
.ls-hours {
	display: grid;
	grid-template-columns: repeat(24, 1fr);
	gap: 2px;
	align-items: end;
	height: 130px;
	margin-top: 6px;
	direction: ltr;
}

.ls-hours .hbar {
	position: relative;
	border-radius: 4px 4px 2px 2px;
	min-height: 4px;
	cursor: default;
}

.ls-hours .hbar.na {
	background: #e8eef0;
	height: 6px;
}

.ls-hours .hbar.now {
	box-shadow: 0 0 0 2px #17202a;
}

.ls-hlabels {
	display: grid;
	grid-template-columns: repeat(24, 1fr);
	gap: 2px;
	margin-top: 5px;
	direction: ltr;
}

.ls-hlabels span {
	font-size: 9.5px;
	color: #7c8c93;
	text-align: center;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* الأرقام والأوقات والإشارات تُعزل عن اتجاه الفقرة،
   وإلّا انقلبت «09:00 → 21:00» و«−4.5» و«2026-09-19». */
.ltr {
	direction: ltr;
	unicode-bidi: isolate;
	display: inline-block;
}

.ls-tip {
	font-size: 12.5px;
	color: #5b6b73;
	margin-top: 8px;
	min-height: 20px;
}

/* ---------- الملخّص ---------- */

.ls-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
	gap: 8px;
	margin-top: 12px;
}

.ls-stat {
	background: #f6fafb;
	border: 1px solid #e4ecef;
	border-radius: 12px;
	padding: 9px 10px;
	text-align: center;
}

.ls-stat b {
	display: block;
	font-size: 19px;
	font-weight: 800;
	color: #0e3b2e;
	font-variant-numeric: tabular-nums;
}

.ls-stat span {
	font-size: 11.5px;
	color: #6b7c84;
	font-weight: 600;
}

/* ---------- المدخلات ---------- */

.ls-fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 10px;
	margin-bottom: 12px;
}

.ls-field label {
	display: block;
	font-size: 12px;
	font-weight: 700;
	color: #5b6b73;
	margin-bottom: 4px;
}

.ls-field input {
	width: 100%;
	border: 1px solid #d6e2e6;
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 15px;
	font-weight: 700;
	color: #17202a;
	background: #fff;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.ls-field input:focus {
	outline: none;
	border-color: #1abc9c;
	box-shadow: 0 0 0 3px rgba(26, 188, 156, .15);
}

/* ---------- الأرقام الكبيرة ---------- */

.ls-big {
	font-size: 34px;
	font-weight: 800;
	color: #0e3b2e;
	line-height: 1.15;
	font-variant-numeric: tabular-nums;
}

.ls-big small {
	font-size: 14px;
	font-weight: 700;
	color: #6b7c84;
}

.ls-sub {
	font-size: 12.5px;
	color: #6b7c84;
	margin-top: 6px;
}

.ls-break {
	margin-top: 10px;
	border-top: 1px dashed #e0e9ec;
	padding-top: 9px;
	font-size: 12.5px;
	color: #5b6b73;
}

.ls-break div {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 2px 0;
}

.ls-break b {
	color: #17202a;
	font-variant-numeric: tabular-nums;
}

.ls-loss {
	color: #a93226;
}

/* ---------- التوصيات ---------- */

.ls-advice ul {
	list-style: none;
}

.ls-advice li {
	position: relative;
	padding: 6px 22px 6px 0;
	font-size: 14px;
	border-bottom: 1px solid #f0f5f6;
}

.ls-advice li:last-child {
	border-bottom: 0;
}

.ls-advice li::before {
	content: "◂";
	position: absolute;
	right: 4px;
	top: 6px;
	color: #1abc9c;
	font-weight: 800;
}

/* ---------- حالات ---------- */

.ls-msg {
	background: #fff7e6;
	border: 1px solid #f3d999;
	color: #7a5a12;
	border-radius: 12px;
	padding: 11px 14px;
	font-size: 13.5px;
	font-weight: 600;
}

.ls-msg.err {
	background: #fdecea;
	border-color: #f5b7b1;
	color: #922b21;
}

.ls-skel {
	background: linear-gradient(90deg, #eef3f5 25%, #f7fafb 50%, #eef3f5 75%);
	background-size: 200% 100%;
	animation: lssh 1.2s infinite;
	border-radius: 12px;
	height: 150px;
}

@keyframes lssh {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* ---------- الهامش العلمي ---------- */

.ls-refs {
	margin-top: 16px;
	font-size: 11.5px;
	color: #7c8c93;
	line-height: 1.85;
	background: #f6fafb;
	border: 1px solid #e9eff1;
	border-radius: 12px;
	padding: 11px 14px;
}

.ls-refs b {
	color: #4a5a62;
}

.ls-refs code {
	font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
	background: #eaf1f3;
	padding: 1px 5px;
	border-radius: 4px;
	direction: ltr;
	display: inline-block;
	font-size: 11px;
}

@media (max-width: 560px) {
	.ls-gauge .ls-num { font-size: 46px; }
	.ls-hours { height: 105px; }
	.ls-hlabels span { font-size: 8.5px; }
	.ls-scale div { font-size: 9px; }
	.ls-root { font-size: 14.5px; }
}

/* ---------- منتقي النوع ---------- */

.ls-species {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 16px;
	padding-top: 12px;
	border-top: 1px dashed #dfe9ec;
}

.ls-species button {
	appearance: none;
	border: 1px solid #d6e2e6;
	background: #fff;
	color: #2c3e50;
	border-radius: 10px;
	padding: 7px 13px;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	transition: all .15s;
	line-height: 1.4;
}

.ls-species button:hover {
	border-color: #1abc9c;
	color: #0e6b4f;
}

.ls-species button[aria-pressed="true"] {
	background: #14806a;
	border-color: #14806a;
	color: #fff;
}

/* ---------- دليل معدّل التنفّس ---------- */

.ls-rr {
	display: grid;
	gap: 6px;
	margin-bottom: 10px;
}

.ls-rr-row {
	display: grid;
	grid-template-columns: 12px 96px 1fr;
	align-items: center;
	gap: 10px;
	background: #f6fafb;
	border: 1px solid #e4ecef;
	border-radius: 10px;
	padding: 8px 11px;
	font-size: 13.5px;
}

.ls-rr-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	display: block;
}

.ls-rr-row b {
	font-weight: 800;
	color: #17202a;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: isolate;
	text-align: right;
}

.ls-rr-row span:last-child {
	color: #5b6b73;
}

@media (max-width: 560px) {
	.ls-rr-row { grid-template-columns: 10px 84px 1fr; font-size: 12.5px; gap: 8px; }
	.ls-species button { font-size: 12.5px; padding: 6px 10px; }
}
