/* شاشة العرض: تملأ الشاشة كلها بلا تمرير. المقاسات بالنسبة للشاشة، وحجم الخط يضبطه
   tv.js حتى يتسع المحتوى. بلا flex ولا grid لتعمل على متصفحات التلفاز القديمة. */
:root {
  --bg: #0b1622;
  --card: #132638;
  --card-2: #1a3249;
  --text: #f2f6fa;
  --muted: #9fb3c6;
  --line: #2a4560;
  --success: #3ccf8e;
  --warning: #f2b544;
  --brand: #1e6c9e;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1622;
  background: var(--bg);
  color: #f2f6fa;
  color: var(--text);
  font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
}

* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

#app {
  position: absolute;
  top: 1.5%;
  bottom: 1.5%;
  right: 1.5%;
  left: 1.5%;
  overflow: hidden;
}

#header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 11%;
  border-bottom: 0.15em solid #1e6c9e;
  overflow: hidden;
}

#brand,
#title,
#when,
#clock {
  position: absolute;
  top: 0;
  height: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#brand {
  right: 0;
  width: 34%;
  font-size: 0.8em;
  color: #9fb3c6;
  color: var(--muted);
}

#title {
  right: 34%;
  width: 30%;
  text-align: center;
  font-weight: bold;
}

#when {
  left: 8%;
  width: 28%;
  font-size: 0.75em;
  text-align: left;
  color: #9fb3c6;
  color: var(--muted);
}

/* التاريخ في سطرين إن لم يتسع (الشاشة العمودية): inline-block في وسط سطر الترويسة
   (line-height بارتفاعها من tv.js)، بارتفاع سطره الخاص */
#date {
  display: inline-block;
  vertical-align: middle;
  white-space: normal;
  line-height: 1.25;
}

#clock {
  left: 0;
  width: 8%;
  text-align: left;
  color: #f2f6fa;
  color: var(--text);
  font-weight: bold;
}

#content {
  position: absolute;
  top: 13%;
  bottom: 6%;
  right: 0;
  left: 0;
  overflow: hidden;
}

#footer {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 4.5%;
  color: #9fb3c6;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
}

#status {
  position: absolute;
  right: 0;
  top: 0;
}

#status.offline {
  color: #f2b544;
  color: var(--warning);
}

#dots {
  position: absolute;
  right: 30%;
  left: 30%;
  top: 0;
  text-align: center;
  letter-spacing: 0.3em;
}

#dots .on {
  color: #1e6c9e;
  color: var(--brand);
}

#screen-name {
  position: absolute;
  left: 0;
  top: 0;
}

.subtitle {
  color: #9fb3c6;
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.4em;
  /* المكان والفترة كاملين في سطرين بدل قطعهما، وfit() في tv.js يصغّر الخط إن لم يتسعا */
  white-space: normal;
  line-height: 1.3;
}

/* شبكة البطاقات: عدد الأعمدة والصفوف يحسبه tv.js من مقاس الشاشة وعدد البطاقات */
.grid {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.cell {
  float: right;
  padding: 0.6%;
  height: 100%;
}

.card {
  height: 100%;
  overflow: hidden;
  background: #132638;
  background: var(--card);
  border: 1px solid #2a4560;
  border: 1px solid var(--line);
  border-radius: 0.5em;
  padding: 0.5em 0.7em;
  text-align: center;
}

.card .name {
  font-weight: bold;
  /* الاسم كاملًا في سطرين بدل قطعه، وfit() يصغّر الخط إن لم يتسع */
  white-space: normal;
  line-height: 1.25;
  margin-bottom: 0.25em;
}

.card .teachers {
  color: #9fb3c6;
  color: var(--muted);
  font-size: 0.8em;
  /* الاسم كاملًا في سطرين بدل قطعه، وfit() يصغّر الخط إن لم يتسع */
  white-space: normal;
  line-height: 1.25;
  margin-bottom: 0.3em;
}

.tile .label {
  color: #9fb3c6;
  color: var(--muted);
  /* عنوان البطاقة كاملًا في سطرين (مثل "المجمعات/المدارس") بدل قطعه */
  white-space: normal;
  line-height: 1.2;
}

.tile .value {
  font-size: 2.3em;
  font-weight: bold;
  line-height: 1.25;
  direction: ltr;
}

.tile .change {
  font-size: 0.85em;
  white-space: nowrap;
}

.up {
  color: #3ccf8e;
  color: var(--success);
}

.down {
  color: #f2b544;
  color: var(--warning);
}

.stats {
  width: 100%;
  border-collapse: collapse;
}

.stats td {
  padding: 0.12em 0.3em;
  white-space: nowrap;
}

.stats .k {
  color: #9fb3c6;
  color: var(--muted);
  text-align: right;
}

.stats .v {
  font-weight: bold;
  text-align: left;
  direction: ltr;
}

table.rows {
  width: 100%;
  border-collapse: collapse;
}

table.rows th,
table.rows td {
  padding: 0.35em 0.5em;
  border-bottom: 1px solid #2a4560;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

table.rows th {
  color: #9fb3c6;
  color: var(--muted);
  font-weight: normal;
}

table.rows td.place {
  text-align: right;
  font-weight: bold;
  max-width: 14em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend {
  text-align: center;
  margin-bottom: 0.3em;
}

.legend span {
  margin: 0 0.8em;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* رمز الحضور ورمز الربط */
.qr-side {
  float: right;
  width: 45%;
  height: 100%;
  text-align: center;
}

.qr-box {
  display: inline-block;
  background: #fff;
  padding: 0.6em;
  border-radius: 0.4em;
}

.qr-box canvas,
.qr-box img {
  display: block;
}

.info-side {
  float: right;
  width: 55%;
  height: 100%;
  padding-right: 3%;
  text-align: center;
}

.code {
  direction: ltr;
  font-size: 3.4em;
  font-weight: bold;
  letter-spacing: 0.25em;
  margin: 0.3em 0;
}

.big-title {
  font-size: 1.7em;
  font-weight: bold;
  margin-bottom: 0.3em;
}

.muted {
  color: #9fb3c6;
  color: var(--muted);
}

.bar {
  height: 0.35em;
  background: #2a4560;
  background: var(--line);
  border-radius: 0.2em;
  overflow: hidden;
  margin: 0.6em auto 0;
  width: 70%;
}

.bar div {
  height: 100%;
  background: #1e6c9e;
  background: var(--brand);
}

.message {
  text-align: center;
  padding-top: 12%;
}

.message .big-title {
  margin-bottom: 0.6em;
}

/* الشاشة العمودية (الجوال): بلا اسم الجهة في الترويسة */
.portrait #brand {
  display: none;
}

.portrait #title {
  right: 0;
  width: 45%;
  text-align: right;
}

.portrait #when {
  left: 16%;
  width: 39%;
}

.portrait #clock {
  width: 16%;
}
