/* ==========================================================================
   mo3alemi - meeting.css - live meeting, whiteboard, full screen
   Stage 1 (mobile-first redesign). 360px first, then 520 / 768 / 1024px.

   Original split from the single-file build (معلمي.html), source lines
   337-434. Plain classic script: it shares one global scope with the other
   files, so the load order in index.html matters. Never load these files with
   type="module".

   meeting.css must stay LAST in the cascade; the full-screen block below still
   owns the exact 16:9 geometry (only the colours, radii and safe areas were
   modernised). The whiteboard canvas stays white paper with dark ink - that is
   the second intentional exception to the theme tokens.
   ========================================================================== */

/* --------------------------------------------------------------- shell --- */
.meet{display:grid;gap:12px}
.mt-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.mt-title{flex:1 1 160px;min-width:0;font-family:var(--display);font-weight:700;font-size:var(--fs-h3);line-height:1.35}

.rec{
  display:inline-flex;
  align-items:center;
  gap:6px;
  flex:none;
  padding:4px 12px 4px 10px;
  border-radius:var(--r-pill);
  background:var(--err);
  color:var(--err-bg);
  font-size:var(--fs-xs);
  font-weight:700;
  letter-spacing:.04em;
}
.rec::before{
  content:"";
  width:8px;
  height:8px;
  border-radius:50%;
  background:currentColor;
  animation:blink 1.4s infinite;
}
@keyframes blink{50%{opacity:.25}}

/* the "a teacher is live" banner on the home views */
.livebar{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:8px;
  padding:12px;
  border-radius:var(--r-lg);
  border:1px solid var(--line);
  background:var(--accent-soft);
  color:var(--fg);
  box-shadow:var(--shadow-1);
}
.livebar .rec{background:none;color:var(--err);padding:0;font-weight:700}
.livebar .rec::before{display:none}
.livebar .btn{flex:none;background:var(--surface);color:var(--fg);box-shadow:none}

/* --------------------------------------------------------------- buttons --- */
.mbtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  flex:none;
  min-height:var(--tap);
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:var(--r);
  background:var(--surface);
  color:var(--fg);
  font-size:var(--fs-sm);
  font-weight:700;
  cursor:pointer;
  transition:background var(--t-fast) var(--ease),transform var(--t-fast) var(--ease);
}
.mbtn:active{background:var(--surface-2);transform:scale(.97)}
.mbtn.sm{min-width:var(--tap);min-height:var(--tap);padding:0 10px}
.mbtn.end{background:var(--err);border-color:transparent;color:var(--err-bg);box-shadow:none}
.mbtn.end:active{background:var(--err);opacity:.9}

/* join / leave status strip (JS: #mban gets .in or .out) */
.mban{display:none!important}
.mban.in,.mban.out{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:var(--tap);
  padding:10px 14px;
  border-radius:var(--r);
  animation:pop .5s var(--ease);
}
.mban.in{background:var(--ok-bg);color:var(--ok)}
.mban.out{background:var(--raised);color:var(--muted)}
@keyframes pop{0%{transform:scale(.94);opacity:0}100%{transform:scale(1);opacity:1}}

/* ---------------------------------------------------------------- layout ---
   One column on a phone; the stage gets a fixed sidebar only from 900px. */
.mt-main{display:grid;grid-template-columns:minmax(0,1fr);gap:14px}
.mt-side{min-width:0}

/* ----------------------------------------------------------- video stage ---
   16:9 keeps every whiteboard stroke aligned for everyone in the room. */
.stg{
  position:relative;
  min-width:0;
  aspect-ratio:16/9;
  border-radius:var(--r-lg);
  overflow:hidden;
  background:#101820;               /* content surface, not a theme surface */
  box-shadow:var(--shadow-2);
}
.stg.board{background:#fff}         /* white paper while the board is up */
.stg video{
  position:absolute;
  inset:0;
  display:none;
  width:100%;
  height:100%;
  object-fit:contain;
  background:#000;
}
.stg canvas{position:absolute;inset:0;width:100%;height:100%;cursor:crosshair;touch-action:none}

/* image / sticker layers over the board */
.wbi{position:absolute;inset:0;pointer-events:none}
.wi{position:absolute;touch-action:none;cursor:move}
.wi img{display:block;width:100%;height:100%;object-fit:fill;user-select:none;-webkit-user-drag:none}
.wi.sel{outline:2px dashed var(--accent);outline-offset:2px}
.wi .rz{
  position:absolute;
  inset-inline-end:-12px;
  bottom:-12px;
  width:24px;
  height:24px;
  border-radius:50%;
  background:var(--accent);
  border:2px solid #fff;
  cursor:nwse-resize;
  box-shadow:var(--shadow-1);
}

/* stage placeholders */
.stgph{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}
.wait,.novid{
  display:grid;
  gap:10px;
  justify-items:center;
  max-width:90%;
  padding:16px 20px;
  border-radius:var(--r-lg);
  font-weight:700;
  text-align:center;
  font-size:var(--fs-sm);
}
.wait{background:rgba(255,255,255,.92);color:#1A2036}
.novid{background:rgba(16,24,32,.6);color:#fff}
/* .spin itself lives in components.css and is deliberately not redefined here */

/* on-canvas text box: dashed ink on paper */
.txin{
  position:absolute;
  z-index:5;
  min-width:120px;
  max-width:70%;
  min-height:0;
  transform:translateY(-50%);
  padding:2px 8px;
  border:1.5px dashed var(--accent);
  border-radius:6px;
  background:rgba(255,255,255,.6);
  font-weight:700;
  line-height:1.4;
  direction:auto;
  outline:none;
}

/* floating stage buttons */
.stgfab{
  position:absolute;
  inset-inline-end:8px;
  bottom:8px;
  z-index:6;
  display:flex;
  gap:8px;
  direction:ltr;                    /* JS sets right/bottom explicitly */
}
.fab{
  display:grid;
  place-items:center;
  width:var(--tap);
  height:var(--tap);
  border:0;
  border-radius:var(--r);
  background:rgba(16,18,32,.62);
  color:#fff;
  cursor:pointer;
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
}
.fab.on{background:var(--accent)}

/* ------------------------------------------------------------ whiteboard ---
   Single scrollable row of tools on a phone, wrapping from 520px up. */
.imgbar{
  display:flex;
  flex-wrap:nowrap;
  align-items:center;
  gap:8px;
  margin-top:10px;
  padding-bottom:2px;
  overflow-x:auto;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}
.wbtools{
  display:flex;
  flex-wrap:nowrap;
  align-items:center;
  gap:10px;
  margin-top:10px;
  padding-bottom:2px;
  overflow-x:auto;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}
.imgbar::-webkit-scrollbar,.wbtools::-webkit-scrollbar{display:none}

.tgrp{
  display:flex;
  align-items:center;
  flex:none;
  gap:6px;
  padding:4px;
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  background:var(--surface);
}
.qchips{display:flex;flex-wrap:wrap;gap:8px}

.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:var(--tap);
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:var(--r-pill);
  background:var(--raised);
  color:var(--fg);
  font-size:var(--fs-sm);
  font-weight:600;
  cursor:pointer;
}
.tgrp .chip,.qchips .chip{min-height:var(--tap);padding:0 12px;border-radius:var(--r-pill);font-weight:600}
.chip.on{background:var(--accent);color:var(--accent-fg);border-color:var(--accent)}

.tb{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  flex:none;
  min-width:var(--tap);
  height:var(--tap);
  padding:0 8px;
  border:0;
  border-radius:var(--r-sm);
  background:transparent;
  color:var(--fg);
  font-size:var(--fs-sm);
  font-weight:600;
  cursor:pointer;
}
.tb:hover{background:var(--raised)}
.tb.on{background:var(--accent);color:var(--accent-fg)}
.tb.danger{color:var(--err)}
.imgbar .tb{border:1px solid var(--line);background:var(--surface)}
.imgbar .tb.on{background:var(--accent);color:var(--accent-fg);border-color:var(--accent)}

/* colour swatches */
.swc{
  width:28px;
  height:28px;
  padding:0;
  border:2px solid var(--line);
  border-radius:50%;
  background:var(--c);
  cursor:pointer;
}
.swc.wh{border-color:var(--line-2)}
.swc.on{outline:3px solid var(--accent);outline-offset:2px}
.wbw{width:110px}

/* ------------------------------------------------------------ call bar ---
   A wrapping grid of 44px+ controls; .mc is 48px tall and 72px wide. */
.mt-ctl{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(72px,1fr));
  gap:8px;
  margin-top:10px;
}
.mc{
  display:grid;
  justify-items:center;
  align-content:center;
  gap:4px;
  min-width:72px;
  min-height:48px;
  padding:9px 10px 7px;
  border:1px solid var(--line);
  border-radius:var(--r);
  background:var(--surface);
  color:var(--fg);
  cursor:pointer;
  transition:background var(--t-fast) var(--ease),transform var(--t-fast) var(--ease);
}
.mc span{font-size:11px;font-weight:700;line-height:1.2;text-align:center}
.mc:active{transform:scale(.96)}
.mc.on{background:var(--ok-bg);color:var(--ok);border-color:var(--ok)}
.mc.off{background:var(--err-bg);color:var(--err);border-color:var(--err)}
.mc.warn{background:var(--warn-bg);color:var(--warn);border-color:var(--warn)}
.mc.dis{opacity:.5;cursor:not-allowed}

/* ----------------------------------------------------------- camera tiles ---
   2 per row at 360px, 3 from 520px, 4 from 768px. */
.mt-cams{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.mt-cams:empty{display:none}
.cam{
  position:relative;
  flex:0 0 calc(50% - 4px);
  max-width:calc(50% - 4px);
  aspect-ratio:4/3;
  border-radius:var(--r);
  border:1px solid var(--line);
  background:#111;                  /* camera content surface */
  overflow:hidden;
}
.cam video{width:100%;height:100%;object-fit:cover}
.cam.noimg video{opacity:0}
.cam.noimg::after{content:"";position:absolute;inset:0;background:var(--raised);opacity:.12}
.cam span{
  position:absolute;
  bottom:6px;
  inset-inline-start:6px;
  max-width:calc(100% - 12px);
  color:#fff;
  font-size:11px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  text-shadow:0 1px 2px #000;
}

/* ---------------------------------------------------------- member list --- */
.mt-side .tabs{margin-bottom:8px}
.mrow{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  min-height:52px;
  padding:8px 10px;
  border-radius:var(--r);
}
.mrow + .mrow{margin-top:4px}
.mrow.hot{animation:hotrow 3s ease-out}
@keyframes hotrow{0%,100%{background:transparent}20%,80%{background:color-mix(in srgb,var(--warn) 28%,transparent)}}
.mrow .mrs{gap:6px}
.mname{
  padding:0;
  border:0;
  background:none;
  color:var(--fg);
  font:inherit;
  font-weight:700;
  cursor:pointer;
  text-align:start;
}
.mname:hover{color:var(--accent);text-decoration:underline}

.st{display:inline-grid;place-items:center;width:24px;height:24px;border-radius:8px}
.st.ok{background:var(--ok-bg);color:var(--ok)}
.st.bad{background:var(--err-bg);color:var(--err)}
.away-t{color:var(--err)}

.mav{position:relative;flex:none;padding:2px;border-radius:50%;border:3px solid transparent}
.mav.hot{border-color:var(--warn);animation:hotring 1s ease-in-out 3}
@keyframes hotring{50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--warn) 45%,transparent)}}

/* raised hand: stays visible above the avatar in both directions */
.hnd{
  position:absolute;
  top:-16px;
  inset-inline-start:22px;      /* centres on the avatar inside the ring */
  transform:translateX(-50%);
  z-index:2;
  display:grid;
  place-items:center;
  width:26px;
  height:26px;
  border-radius:50%;
  border:2px solid var(--surface);
  background:var(--warn-bg);
  color:var(--warn);
  animation:wave 1s ease-in-out infinite;
}
@keyframes wave{50%{transform:translateX(-50%) rotate(14deg)}}

/* away badge: bottom-inline-end, mirrored correctly in RTL */
.away{
  position:absolute;
  bottom:-2px;
  inset-inline-end:0;
  transform:translateX(50%);
  z-index:2;
  display:grid;
  place-items:center;
  width:24px;
  height:24px;
  border-radius:50%;
  border:2px solid var(--surface);
  background:var(--err);
  color:var(--err-bg);
}
[dir="rtl"] .away{transform:translateX(-50%)}

/* member actions popup */
.pop{
  position:absolute;
  z-index:5;
  inset-inline-end:8px;
  top:100%;
  display:grid;
  min-width:190px;
  max-width:calc(100% - 16px);
  border-radius:var(--r);
  border:1px solid var(--line);
  background:var(--surface);
  box-shadow:var(--shadow-2);
  overflow:hidden;
}
.pop button{
  display:flex;
  align-items:center;
  gap:8px;
  min-height:var(--tap);
  padding:10px 12px;
  border:0;
  background:none;
  color:var(--fg);
  font:inherit;
  cursor:pointer;
  text-align:start;
}
.pop button:hover{background:var(--raised)}

/* switches inside the settings tab and the member sheet */
.sw2{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
  min-height:var(--tap);
  padding:12px 0;
  border:0;
  border-bottom:1px solid var(--line);
  background:none;
  color:var(--fg);
  font:inherit;
  cursor:pointer;
  text-align:start;
}
.sw2 span{display:grid;gap:2px;min-width:0}
.sw2 small{color:var(--muted);font-size:var(--fs-xs)}
.sw2 .sw2l{display:inline-flex;align-items:center;gap:10px}
.sw2 i{
  position:relative;
  flex:none;
  width:44px;
  height:26px;
  border-radius:var(--r-pill);
  background:var(--line-2);
  transition:background var(--t) var(--ease);
}
.sw2 i::after{
  content:"";
  position:absolute;
  top:3px;
  inset-inline-start:3px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:var(--surface);
  box-shadow:var(--shadow-1);
  transition:inset-inline-start var(--t) var(--ease);
}
.sw2.on i{background:var(--ok)}
.sw2.on i::after{inset-inline-start:21px}

/* -------------------------------------------------------- member sheet ---
   Bottom sheet on phones, centred dialog from 768px. */
#msheet .msh-bg{position:fixed;inset:0;z-index:60;background:var(--overlay)}
#msheet .sheet-in{
  position:fixed;
  inset-inline:0;
  bottom:0;
  z-index:61;
  display:grid;
  gap:12px;
  width:100%;
  max-width:var(--shell);
  max-height:86dvh;
  margin-inline:auto;
  padding:16px;
  padding-bottom:calc(16px + var(--sab));
  border:1px solid var(--line);
  border-bottom:0;
  border-radius:var(--r-xl) var(--r-xl) 0 0;
  background:var(--surface);
  box-shadow:var(--shadow-3);
  overflow:auto;
  animation:msheet-up var(--t) var(--ease);
}
@keyframes msheet-up{from{transform:translateY(3%);opacity:.6}}

.sh-h{display:flex;align-items:center;gap:12px}
.sh-sec{
  display:grid;
  gap:8px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  background:var(--surface-2);
}
.sh-acts{display:flex;flex-wrap:wrap;gap:8px}
.sh-acts .btn{flex:1 1 120px}
.sheet-in .btn.sm{display:inline-flex;gap:6px}

.banner.soft{opacity:.9}

/* ---------------------------------------------------------- upload bits ---
   Used by the hidden file input inside .upz labels. */
.upl{position:relative;overflow:hidden}
.upi{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;font-size:0}

/* ==========================================================================
   Full screen. The stage keeps its exact 16:9 mathematics: the fixed box is
   centred and the black letterbox comes from a 100vmax ring shadow.
   ========================================================================== */
.meet.isfull .mt-top,
.meet.isfull .mt-side,
.meet.isfull .mt-cams,
.meet.isfull #mmsg,
.meet.isfull .mban,
.meet.isfull .imgbar{display:none}

.meet.isfull .stg{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(100vw,calc(100dvh*1.7778));
  z-index:1000;
  border-radius:0;
  border:0;
  box-shadow:0 0 0 100vmax #000;
}
.meet.isfull.rot .stg{transform:translate(-50%,-50%) rotate(90deg);width:min(100dvh,calc(100vw*1.7778))}

.meet.isfull .mt-ctl,
.meet.isfull .wbtools{
  display:none;
  position:fixed;
  left:0;
  right:0;
  z-index:1002;
  margin:0;
  padding:10px;
  justify-content:center;
  background:rgba(14,16,32,.9);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}
.meet.isfull .wbtools{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;color:#fff}
.meet.isfull .wbtools::-webkit-scrollbar{display:none}
.meet.isfull .mt-ctl{
  bottom:0;
  grid-template-columns:repeat(auto-fit,minmax(64px,1fr));
  gap:6px;
  padding-bottom:max(10px,var(--sab));
}
.meet.isfull .wbtools{bottom:86px}
.meet.isfull.showc .mt-ctl{display:grid}
.meet.isfull.showc .wbtools{display:flex}

/* controls over the black stage */
.meet.isfull .mc{background:rgba(255,255,255,.12);color:#fff;border-color:rgba(255,255,255,.22)}
.meet.isfull .mc.on{background:rgba(22,96,63,.85);color:#8BF0BE;border-color:rgba(139,240,190,.4)}
.meet.isfull .mc.off{background:rgba(92,27,34,.85);color:#FFB4BA;border-color:rgba(255,180,186,.4)}
.meet.isfull .mc.warn{background:var(--warn-bg);color:var(--warn);border-color:var(--warn)}
.meet.isfull .mc.dis{opacity:.5}

/* --------------------------------------------------------- larger screens --- */
@media (min-width:520px){
  .meet{gap:14px}
  .imgbar,.wbtools{flex-wrap:wrap;overflow-x:visible}
  .cam{flex:0 0 calc(33.333% - 6px);max-width:calc(33.333% - 6px)}
  .mt-ctl{grid-template-columns:repeat(auto-fit,minmax(84px,1fr))}
  .mc{min-width:84px}
}
@media (min-width:768px){
  #msheet .sheet-in{border-radius:var(--r-xl);border-bottom:1px solid var(--line)}
  .cam{flex:0 0 calc(25% - 6px);max-width:calc(25% - 6px)}
  .mt-main{gap:16px}
}
@media (min-width:900px){
  /* the two-column room: stage + fixed-width side panel */
  .mt-main{grid-template-columns:minmax(0,1fr) 340px;align-items:start}
}
@media (min-width:1024px){
  .meet{gap:16px}
}

/* ------------------------------------------------------------- reduced motion --- */
@media (prefers-reduced-motion:reduce){
  .mav.hot,.mrow.hot,.hnd,.rec::before{animation:none}
  #msheet .sheet-in{animation:none}
}

/* ------------------------------------------------------- native controls --- */
select,select option,select optgroup{background-color:var(--surface);color:var(--fg)}
select option:checked{background-color:var(--accent-soft);color:var(--fg)}
/* native widgets (range, file, date) keep a light scheme in both themes */
:root{color-scheme:light}
.otp{text-align:center!important;font-size:30px!important;letter-spacing:.45em;font-weight:700;min-height:60px!important;padding-inline-start:.45em!important}
.btn[disabled]{opacity:.45;cursor:not-allowed;box-shadow:none}
