/* ============================================================
   Bloom Kids — صفحة السيشن المباشرة
   بتكمّل على css/style.css (نفس المتغيرات والهوية)
   ============================================================ */

.meet-page { background: var(--cream); }

/* ============ شاشة الدخول ============ */
.meet-gate { padding: 2.5rem 0 3.5rem; }

.gate-card {
  width: min(520px, 100%);
  margin: 0 auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.8rem;
  text-align: center;
}

.gate-card h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin-bottom: 0.5rem; }
.gate-card h2 { margin-bottom: 0.6rem; }
.gate-sub { color: var(--ink-soft); font-weight: 600; margin-bottom: 1.5rem; }

.gate-form { display: grid; gap: 0.9rem; margin-bottom: 1.4rem; text-align: start; }

.field { display: grid; gap: 0.35rem; }
.field > span {
  font-family: var(--font-head); font-weight: 700;
  font-size: 0.92rem; color: var(--navy);
}
.field input {
  width: 100%; font-family: inherit; font-size: 1rem; font-weight: 600;
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  border: 2.5px solid rgba(51, 45, 110, 0.15);
  background: var(--cream); color: var(--navy);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.field input:focus {
  outline: none; border-color: var(--teal); background: var(--white);
}
.field input::placeholder { color: rgba(51, 45, 110, 0.4); font-weight: 500; }

.field-error {
  color: var(--pink-dark); font-weight: 700; font-size: 0.9rem;
  background: rgba(239, 95, 124, 0.1); border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem; margin: 0;
}
.field-error[hidden] { display: none; }

.gate-tips {
  display: grid; gap: 0.6rem; text-align: start;
  margin: 0 auto; max-width: 340px;
}
.gate-tips li {
  display: flex; align-items: center; gap: 0.7rem;
  font-weight: 700; font-size: 0.92rem; color: var(--ink-soft);
}
.gate-tips span {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.05rem;
}

/* ---- ركن المدرّس ---- */
.host-box {
  margin-top: 1.3rem; text-align: start;
  background: var(--cream); border-radius: var(--radius-sm);
  border: 2px dashed rgba(51, 45, 110, 0.18);
  padding: 0.9rem 1.1rem;
}
.host-box > summary {
  cursor: pointer; list-style: none;
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 0.98rem; text-align: center;
}
.host-box > summary::-webkit-details-marker { display: none; }
.host-box[open] > summary { margin-bottom: 0.9rem; }

.host-steps {
  list-style: decimal; padding-inline-start: 1.3rem;
  display: grid; gap: 0.4rem; margin-bottom: 1rem;
  color: var(--ink-soft); font-weight: 600; font-size: 0.9rem;
}
.host-steps b { color: var(--navy); }

.share-field { margin: 0.9rem 0 0.5rem; }
.share-field input { font-size: 0.85rem; background: var(--white); }

.host-note {
  color: var(--ink-soft); font-weight: 600;
  font-size: 0.82rem; margin-top: 0.7rem; text-align: center;
}

.host-box .btn { margin-bottom: 0.4rem; }

/* ============================================================
   الأوضة — الصفحة كلها مساحة سيشن

   شريط جيتسي نفسه متخفي بالكامل (toolbarButtons فاضية)، وإحنا
   بنرسم أزرارنا تحت. كده الأطفال بيشوفوا ٤ أزرار كبيرة بالعربي
   بدل شريط فيه ١٢ أيقونة إنجليزي.
   ============================================================ */
/* ٧٥px = ارتفاع الهيدر (مقاس في المتصفح) */
.meet-stage {
  display: flex; flex-direction: column; gap: 0.6rem;
  height: calc(100vh - 75px);
  height: calc(100dvh - 75px);
  padding: 0.6rem 0.7rem 0.9rem;
}
.meet-stage[hidden] { display: none; }

/* ---- السطر اللي فوق ---- */
.meet-top {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: 0.5rem;
  min-height: 30px;
}
.meet-room {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 0.98rem;
}
.meet-count {
  background: rgba(35, 168, 159, 0.14); color: var(--teal-dark);
  border-radius: 99px; padding: 0.2rem 0.8rem;
  font-weight: 800; font-size: 0.85rem;
}
.meet-count[hidden] { display: none; }

.meet-status {
  background: rgba(246, 169, 44, 0.18); color: #8a5a00;
  border-radius: 99px; padding: 0.2rem 0.9rem;
  font-weight: 800; font-size: 0.85rem;
}
.meet-status[hidden] { display: none; }

/* ---- جسم السيشن: مشاركة الشاشة + كروت المشاركين ---- */
.meet-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 0.6rem;
}

/* مساحة الشاشة المشاركة — بتظهر بس لما حد يشارك */
.share-stage {
  position: relative; flex: 1; min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--navy-deep);
  box-shadow: var(--shadow-lg);
}
.share-stage[hidden] { display: none; }
.share-stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.share-tag {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: rgba(39, 34, 83, 0.85); color: var(--white);
  font-family: var(--font-head); font-weight: 700; font-size: 0.8rem;
  padding: 0.25rem 0.8rem; border-radius: 99px;
}

/* كروت المشاركين — الحجم بيتظبط لوحده حسب العدد */
.people {
  display: grid; gap: 0.6rem; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  overflow-y: auto; padding: 0.2rem;
}
/* لما فيه مشاركة شاشة، الكروت بتصغّر وتبقى صف جنبي */
.meet-stage.is-sharing .people {
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  max-height: 122px;
}
.meet-stage:not(.is-sharing) .meet-body { justify-content: center; }

.person {
  background: var(--white);
  border: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 0.6rem;
  text-align: center;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  position: relative;
  min-width: 0;
}

/* اللي بيتكلم دلوقتي — إطار أخضر واضح للطفل */
.person.is-talking {
  border-color: var(--green);
  box-shadow: 0 0 0 5px rgba(125, 194, 66, 0.18), var(--shadow);
}

.person-face {
  width: 54px; height: 54px; margin: 0 auto 0.5rem;
  border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 1.3rem;
  color: var(--white); background: var(--purple);
}
.person-name {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 0.9rem; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.person-state { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); }

/* شارة الإيد المرفوعة — جوه الكارت عشان متركبش على اللي جنبه */
.person-hand {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--yellow); border: 3px solid var(--white);
  display: grid; place-items: center; font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(246, 169, 44, 0.5);
  animation: hand-wave 1.6s ease-in-out infinite;
}
/* لازم تيجي بعد display: grid عشان تغلبه */
.person-hand[hidden] { display: none; }
@keyframes hand-wave {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(12deg); }
}

.person-badge {
  display: inline-block; margin-top: 0.25rem;
  background: rgba(106, 79, 182, 0.14); color: var(--purple);
  border-radius: 99px; padding: 0.05rem 0.6rem;
  font-size: 0.7rem; font-weight: 800;
}

/* من غير مشاركة شاشة فيه مساحة رأسية فاضية — نكبّر الكروت
   عشان الأسماء تبقى واضحة من بعيد للطفل */
.meet-stage:not(.is-sharing) .person {
  min-height: 172px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.meet-stage:not(.is-sharing) .person-face {
  width: 74px; height: 74px; font-size: 1.75rem;
}
.meet-stage:not(.is-sharing) .person-name { font-size: 1rem; }

.meet-stage.is-sharing .person { padding: 0.5rem 0.4rem; }
.meet-stage.is-sharing .person-face { width: 34px; height: 34px; font-size: 0.95rem; margin-bottom: 0.3rem; }
.meet-stage.is-sharing .person-state,
.meet-stage.is-sharing .person-badge { display: none; }

#audioSink { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- شريط التحكم بتاعنا ---- */
.meet-controls {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 0.6rem;
}

.ctl {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.15rem;
  min-width: 104px; padding: 0.55rem 1.1rem;
  border: 3px solid transparent; border-radius: 20px;
  font-family: var(--font-head); font-weight: 800;
  cursor: pointer;
  background: var(--white); color: var(--navy);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, background 0.18s ease,
              color 0.18s ease, box-shadow 0.18s ease;
}
.ctl:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.ctl:active { transform: translateY(-1px); }
.ctl:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.ctl:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.ctl-icon { font-size: 1.55rem; line-height: 1; }
.ctl-text { font-size: 0.82rem; }

/* الميك: أحمر معناها مقفول، أخضر معناها مفتوح — لون واضح للطفل */
.ctl-mic { background: rgba(239, 95, 124, 0.14); color: var(--pink-dark); border-color: rgba(239, 95, 124, 0.35); }
.ctl-mic[aria-pressed="true"],
.ctl-mic.is-live { background: var(--green); color: var(--white); border-color: #6aa832; }

/* الميك مفتوح — حلقة بتنبض حواليه.
   الأطفال بيتلخبطوا في فرق الإيموچي لوحده، فالحركة دي بتقول
   "صوتك طالع دلوقتي" من غير ما حد يبص على الأيقونة */
.ctl-mic.is-live { animation: mic-live 1.6s ease-in-out infinite; }
@keyframes mic-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(125, 194, 66, 0.55), var(--shadow); }
  50%      { box-shadow: 0 0 0 9px rgba(125, 194, 66, 0), var(--shadow); }
}
.ctl-hand.is-live { background: var(--yellow); color: var(--navy-deep); border-color: #d98f14; }
.ctl-share.is-live { background: var(--teal); color: var(--white); border-color: var(--teal-dark); }

@media (prefers-reduced-motion: reduce) {
  .ctl-mic.is-live { animation: none; }
}

/* الإيد المرفوعة: أصفر واضح */
.ctl-hand[aria-pressed="true"] { background: var(--yellow); color: var(--navy-deep); border-color: #d98f14; }

/* المشاركة شغالة: فيروزي */
.ctl-share[aria-pressed="true"] { background: var(--teal); color: var(--white); border-color: var(--teal-dark); }

.ctl-leave { background: var(--navy); color: var(--white); }
.ctl-leave:hover { background: var(--pink-dark); }

/* ============ أزرار المدرّس الزيادة ============ */
.ctl-muteall[aria-pressed], .ctl-muteall { background: rgba(106, 79, 182, 0.12); color: var(--purple); border-color: rgba(106, 79, 182, 0.3); }
.ctl-muteall:hover { background: var(--purple); color: var(--white); }
.ctl-hands { background: rgba(246, 169, 44, 0.14); color: #8a5a00; border-color: rgba(246, 169, 44, 0.35); }
.ctl-hands:hover { background: var(--yellow); color: var(--navy-deep); }

/* ============ لوحة تحكم المدرّس ============ */
.host-panel {
  position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 70;
  width: min(360px, 92vw);
  background: var(--white);
  box-shadow: -14px 0 40px rgba(51, 45, 110, 0.18);
  display: flex; flex-direction: column;
  padding: 1rem 0.9rem;
}
.host-panel[hidden] { display: none; }

/* لما اللوحة تتفتح، السيشن تزاح بدل ما تتغطى */
@media (min-width: 900px) {
  body.panel-open .meet-stage { padding-inline-end: calc(min(360px, 92vw) + 0.7rem); }
  body.panel-open .site-header .container { padding-inline-end: calc(min(360px, 92vw) + 1rem); }
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-head); font-size: 1.05rem; color: var(--navy);
  margin-bottom: 0.3rem;
}
.panel-hint { color: var(--ink-soft); font-weight: 600; font-size: 0.85rem; margin-bottom: 0.8rem; }

.panel-list { flex: 1; overflow-y: auto; display: grid; gap: 0.55rem; align-content: start; }

.panel-row {
  border: 2px solid rgba(51, 45, 110, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  background: var(--cream);
}
/* اللي رافع إيده بيبان على طول */
.panel-row.has-hand { border-color: var(--yellow); background: rgba(246, 169, 44, 0.12); }

.panel-who {
  display: flex; align-items: center; gap: 0.45rem;
  margin-bottom: 0.5rem; min-width: 0;
}
.panel-who b {
  font-family: var(--font-head); color: var(--navy); font-size: 0.95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-who small { color: var(--ink-soft); font-weight: 700; font-size: 0.76rem; margin-inline-start: auto; white-space: nowrap; }
.panel-hand { font-size: 1rem; }

.panel-acts { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.pbtn {
  font-family: var(--font-head); font-weight: 700; font-size: 0.78rem;
  padding: 0.32rem 0.65rem; border-radius: 99px; cursor: pointer;
  border: 2px solid rgba(51, 45, 110, 0.15);
  background: var(--white); color: var(--navy);
  transition: background 0.15s ease, color 0.15s ease;
}
.pbtn:hover { background: var(--navy); color: var(--white); }
.pbtn:disabled { opacity: 0.5; cursor: not-allowed; }
.pbtn-mute:hover { background: var(--pink-dark); border-color: var(--pink-dark); }
.pbtn-kick:hover { background: var(--pink-dark); border-color: var(--pink-dark); }
.pbtn-ok { border-color: var(--green); color: #4e8720; }
.pbtn-ok:hover { background: var(--green); color: var(--white); }

/* لينك الأطفال في صفحة المدرّس */
.host-share {
  margin-top: 1.3rem; padding-top: 1.1rem;
  border-top: 2px dashed rgba(51, 45, 110, 0.15);
  text-align: start;
}

/* ============ شاشة الخطأ ============ */
.meet-fallback { padding: 3rem 0; }
.meet-fallback[hidden] { display: none; }
.meet-fallback .btn { margin: 0.3rem; }

/* ============ الموبايل ============ */
@media (max-width: 700px) {
  .meet-gate { padding: 1.5rem 0 2.5rem; }
  .gate-card { padding: 1.5rem 1.1rem; }

  .people { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .person { padding: 0.6rem 0.4rem; }
  .person-face { width: 42px; height: 42px; font-size: 1.05rem; }

  /* مشاركة الشاشة مش شغالة على متصفحات الموبايل أصلاً */
  .ctl-share { display: none; }

  .ctl { min-width: 78px; padding: 0.45rem 0.7rem; }
  .ctl-icon { font-size: 1.35rem; }
  .ctl-text { font-size: 0.74rem; }
}

/* ============ تقليل الحركة ============ */
@media (prefers-reduced-motion: reduce) {
  .ctl { transition: none; }
  .ctl:hover, .ctl:active { transform: none; }
}

/* ============================================================
   وضع ملء الشاشة وقت مشاركة الشاشة

   التكبير معمول بالـ CSS (body.is-zoom) مش معتمد على الـ
   Fullscreen API لوحده — عشان المتصفحات اللي جوه الأبليكيشنات
   بترفض ملء الشاشة كتير، ولازم الطفل يقدر يكبّر برضه.
   الـ API بيتطلب كمان فوقه عشان يشيل شريط المتصفح لو المتصفح سمح.
   ============================================================ */
.share-zoom {
  position: absolute; top: 10px; inset-inline-end: 10px; z-index: 4;
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(39, 34, 83, 0.85); color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 99px;
  font-family: var(--font-head); font-weight: 800; font-size: 0.82rem;
  padding: 0.3rem 0.85rem; cursor: pointer; line-height: 1.4;
  transition: background 0.2s ease, transform 0.2s ease;
}
.share-zoom:hover { background: var(--navy); transform: translateY(-2px); }
.share-zoom:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* بنشيل كل حاجة مش المشاركة، وبنخلي قسم السيشن هو الشاشة كلها.
   الأزرار بتفضل — الطفل لازم يقدر يرفع إيده وهو متفرّج */
body.is-zoom .site-header,
body.is-zoom .meet-top,
body.is-zoom .people { display: none; }

body.is-zoom .meet-stage {
  position: fixed; inset: 0; z-index: 300;
  height: 100vh; height: 100dvh;
  padding: 0; gap: 0; background: #000;
}
body.is-zoom .meet-body { gap: 0; }
body.is-zoom .share-stage {
  border-radius: 0; box-shadow: none; background: #000;
}

body.is-zoom .meet-controls {
  padding: 0.5rem 0.4rem calc(0.5rem + env(safe-area-inset-bottom));
  background: rgba(39, 34, 83, 0.78);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
body.is-zoom .ctl { min-width: 88px; padding: 0.45rem 0.8rem; }

/* لوحة المدرّس لازم تفضل فوق طبقة التكبير */
body.is-zoom .host-panel { z-index: 320; }

/* الموبايل بالعرض: الشاشة واطية جداً، فبنسيب الأيقونات بس */
@media (max-height: 460px) {
  body.is-zoom .ctl-text { display: none; }
  body.is-zoom .ctl { min-width: 54px; padding: 0.4rem 0.6rem; }
  body.is-zoom .meet-controls { padding-block: 0.35rem; }
  .share-zoom .share-zoom-text { display: none; }
}

/* جوه ملء الشاشة الحقيقي العنصر نفسه بيبقى هو الشاشة */
.meet-stage:fullscreen { background: #000; }
.meet-stage:-webkit-full-screen { background: #000; }

/* ============================================================
   تسجيل السيشن
   ============================================================ */
.ctl-rec.is-on {
  background: var(--pink-dark); color: var(--white);
  border-color: var(--pink);
  animation: rec-pulse 1.6s ease-in-out infinite;
}
.ctl-rec.is-on .ctl-text {
  font-variant-numeric: tabular-nums;   /* العدّاد ميرقصش كل ثانية */
  direction: ltr;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 95, 124, 0.5); }
  50% { box-shadow: 0 0 0 9px rgba(239, 95, 124, 0); }
}

/* علامة "بيتسجّل" — بيشوفها الكل، الأطفال والمدرّس */
.meet-rec {
  background: rgba(239, 95, 124, 0.16); color: var(--pink-dark);
  border: 2px solid rgba(239, 95, 124, 0.45);
  border-radius: 99px; padding: 0.15rem 0.8rem;
  font-family: var(--font-head); font-weight: 800; font-size: 0.85rem;
  animation: rec-blink 1.6s ease-in-out infinite;
}
.meet-rec[hidden] { display: none; }
@keyframes rec-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* في وضع ملء الشاشة السطر اللي فوق بيتخفي، فبنطلّع العلامة
   فوق الفيديو نفسه — التسجيل لازم يفضل باين دايماً */
body.is-zoom .meet-rec {
  display: inline-block !important;
  position: fixed; top: 10px; inset-inline-start: 50%;
  transform: translateX(50%); z-index: 310;
  background: rgba(239, 95, 124, 0.92); color: var(--white);
  border-color: rgba(255, 255, 255, 0.5);
}
body.is-zoom .meet-rec[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .ctl-rec.is-on, .meet-rec { animation: none; }
}
