/* ---------------------------------------------------------------------------
   ShareScreen — linguagem visual inspirada no macOS/iOS:
   materiais translúcidos, tipografia SF, cantos contínuos e cor de destaque
   sistêmica. Acompanha o tema do sistema (claro/escuro).
--------------------------------------------------------------------------- */

:root {
  color-scheme: dark light;

  /* superfícies */
  --bg:        #000000;
  --surface:   #1c1c1e;
  --surface-2: #2c2c2e;
  --elevated:  rgba(30, 30, 32, .72);
  --separator: rgba(255, 255, 255, .12);
  --fill:      rgba(120, 120, 128, .24);
  --fill-2:    rgba(120, 120, 128, .16);

  /* texto */
  --label:     #f2f2f7;
  --label-2:   rgba(235, 235, 245, .62);
  --label-3:   rgba(235, 235, 245, .38);

  /* cores sistêmicas */
  --blue:   #0a84ff;
  --green:  #30d158;
  --red:    #ff453a;
  --yellow: #ffd60a;

  /* forma e movimento */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.36);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.5);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f2f2f7;
    --surface:   #ffffff;
    --surface-2: #f2f2f7;
    --elevated:  rgba(255, 255, 255, .78);
    --separator: rgba(0, 0, 0, .1);
    --fill:      rgba(120, 120, 128, .16);
    --fill-2:    rgba(120, 120, 128, .1);
    --label:     #1c1c1e;
    --label-2:   rgba(60, 60, 67, .68);
    --label-3:   rgba(60, 60, 67, .4);
    --blue:  #007aff;
    --green: #34c759;
    --red:   #ff3b30;
    --shadow-md: 0 8px 24px rgba(0,0,0,.1);
    --shadow-lg: 0 24px 64px rgba(0,0,0,.14);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-feature-settings: "cv02", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  overflow: hidden;
}

.hidden { display: none !important; }
.ph { font-size: 1.15em; }

/* ---------------- controles ---------------- */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 500; letter-spacing: -0.01em;
  border: 0.5px solid transparent;
  background: var(--fill);
  color: var(--label);
  padding: 8px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s var(--ease), transform .12s var(--ease), opacity .18s var(--ease);
}
button:hover { background: var(--fill-2); }
button:active { transform: scale(.96); }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent); outline-offset: 2px; }

button.primary {
  background: var(--blue); color: #fff;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--blue) 40%, transparent);
}
button.primary:hover { background: color-mix(in srgb, var(--blue) 88%, #fff); }

button.danger { background: var(--red); color: #fff; }
button.danger:hover { background: color-mix(in srgb, var(--red) 88%, #fff); }

button.ghost { background: var(--fill-2); }
button.ghost:hover { background: var(--fill); }

button.icon { padding: 8px; width: 36px; height: 36px; border-radius: 50%; }
button.icon .ph { font-size: 1.2em; }
button.wide { width: 100%; margin-top: 10px; }

input, select {
  font: inherit; width: 100%;
  background: var(--fill-2);
  color: var(--label);
  border: 0.5px solid var(--separator);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-top: 6px;
  transition: border-color .18s var(--ease), background .18s var(--ease);
  appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface-2);
}
input::placeholder { color: var(--label-3); }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--label-2) 50%),
                    linear-gradient(135deg, var(--label-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) center, calc(100% - 12px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

label {
  display: block; margin: 16px 0;
  color: var(--label-2);
  font-size: 12.5px; font-weight: 500;
  letter-spacing: 0;
}
label.row { display: flex; align-items: center; gap: 10px; }
label.row span { color: var(--label); font-size: 14.5px; font-weight: 400; }

/* switch estilo iOS */
input[type="checkbox"] {
  appearance: none; flex: 0 0 auto;
  width: 45px; height: 27px; margin: 0; padding: 0;
  border-radius: 999px; border: none;
  background: var(--fill);
  position: relative; cursor: pointer;
  transition: background .26s var(--spring);
}
input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 23px; height: 23px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.28);
  transition: transform .26s var(--spring);
}
input[type="checkbox"]:checked { background: var(--green); }
input[type="checkbox"]:checked::after { transform: translateX(18px); }

input[type="range"] {
  appearance: none; background: transparent;
  padding: 0; border: none; margin-top: 10px; height: 22px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 999px; background: var(--fill);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 21px; height: 21px; margin-top: -8px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3), 0 0 0 .5px rgba(0,0,0,.06);
}

/* ---------------- lobby ---------------- */
.lobby { display: grid; place-items: center; height: 100%; padding: 24px; }

.card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 0.5px solid var(--separator);
  border-radius: var(--r-xl);
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
  animation: rise .5s var(--spring);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.logo {
  width: 58px; height: 58px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--blue), color-mix(in srgb, var(--blue) 62%, #af52de));
  border-radius: var(--r-lg);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--blue) 34%, transparent);
}
.logo .ph { font-size: 30px; color: #fff; }

.card h1 {
  margin: 0 0 6px; font-size: 25px; font-weight: 640;
  letter-spacing: -0.03em; text-align: center;
}
.sub {
  color: var(--label-2); margin: 0 0 26px;
  font-size: 14px; text-align: center; letter-spacing: -0.005em;
}
.hint { color: var(--label-3); font-size: 12.5px; margin-top: 18px; text-align: center; }
.card button { width: 100%; margin-top: 9px; padding: 11px 16px; }

/* ---------------- sala ---------------- */
.room { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--elevated);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 0.5px solid var(--separator);
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
}
.brand .ph { color: var(--blue); font-size: 19px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.sep { width: 0.5px; height: 22px; background: var(--separator); margin: 0 2px; }

/* Sinal de conexão por pessoa, no chip — igual ao indicador do Discord. */
.sinal { font-size: 14px; margin-left: 1px; flex: 0 0 auto; cursor: help; }
.sinal.alta  { color: var(--green); }
.sinal.media { color: var(--green); }
.sinal.baixa { color: var(--yellow); }
.sinal.ruim  { color: var(--red); }
.sinal.off   { color: var(--red); opacity: .75; }
.sinal.aguardando { color: var(--label-3); }

.badge-privacy {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  background: color-mix(in srgb, var(--green) 15%, transparent);
  color: var(--green);
  border: 0.5px solid color-mix(in srgb, var(--green) 32%, transparent);
  border-radius: 50%;
  cursor: help;
}
.badge-privacy .ph { font-size: 15px; }

/* ---------------- barra de controles (rodapé) ---------------- */
.controles {
  flex: 0 0 auto;
  display: flex; justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--elevated);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--separator);
  z-index: 20;
}

.controles-centro { display: flex; align-items: center; gap: 10px; }

.ctrl {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  width: 62px; height: 54px;
  padding: 0;
  border-radius: var(--r-lg);
  background: var(--fill-2);
  color: var(--label);
  font-size: 10.5px; font-weight: 550; letter-spacing: -0.005em;
}
.ctrl .ph { font-size: 21px; }
.ctrl-txt { line-height: 1; }
.ctrl:hover { background: var(--fill); }

/* transmitindo: verde, como no Discord */
.ctrl.ativo {
  background: color-mix(in srgb, var(--green) 20%, transparent);
  border-color: color-mix(in srgb, var(--green) 34%, transparent);
  color: var(--green);
}
.ctrl.ativo:hover { background: color-mix(in srgb, var(--green) 30%, transparent); }

/* mudo: vermelho */
.ctrl.mudo {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  border-color: color-mix(in srgb, var(--red) 34%, transparent);
  color: var(--red);
}
.ctrl.mudo:hover { background: color-mix(in srgb, var(--red) 30%, transparent); }

.ctrl.sair { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); width: 54px; }
.ctrl.sair:hover { background: var(--red); color: #fff; }

.ctrl-sep { width: 0.5px; height: 34px; background: var(--separator); margin: 0 4px; }

/* ---------------- participantes ---------------- */
.people {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  min-width: 0; max-width: 46vw;
}

.person {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--fill-2);
  border: 0.5px solid var(--separator);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  font-size: 12.5px; font-weight: 500;
  max-width: 190px;
  animation: pop .3s var(--spring);
}
.person .avatar {
  width: 21px; height: 21px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 650; color: #fff;
  letter-spacing: 0;
}
.person .nome {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.person.eu { background: color-mix(in srgb, var(--blue) 14%, transparent); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.person .live { display: inline-flex; gap: 3px; color: var(--green); font-size: 12px; }
.person .live .mudo { color: var(--red); }
.person .live .ph { font-size: 13px; }
.person .mais { color: var(--label-2); }

.people .overflow {
  background: var(--fill-2); border: 0.5px solid var(--separator);
  border-radius: 999px; padding: 4px 10px;
  font-size: 12.5px; font-weight: 500; color: var(--label-2);
  cursor: default;
}

/* ---------------- grade ---------------- */
.stage { flex: 1; min-height: 0; display: flex; }

.grid {
  flex: 1; overflow: auto; padding: 16px;
  display: grid; gap: 14px; align-content: start;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.grid:has(.tile:only-child) { grid-template-columns: 1fr; }

.empty {
  grid-column: 1/-1; text-align: center; color: var(--label-2); margin-top: 14vh;
}
.empty .ph { font-size: 46px; color: var(--label-3); display: block; margin-bottom: 14px; }
.empty p { margin: 4px 0; font-size: 16px; font-weight: 500; }
.empty .hint { font-weight: 400; margin-top: 8px; }

.tile {
  position: relative; background: #000; cursor: pointer;
  border: 0.5px solid var(--separator);
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  box-shadow: var(--shadow-md);
  transition: transform .28s var(--spring), box-shadow .28s var(--ease);
  animation: pop .38s var(--spring);
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile video.mirror { transform: scaleX(-1); }

.tile .label {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(0,0,0,.55);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  color: #fff;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500; letter-spacing: -0.005em;
}
.tile .quality {
  position: absolute; left: 10px; top: 10px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.55);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-radius: 999px;
  padding: 4px 6px 4px 11px;
  color: #fff;
  transition: background .18s var(--ease);
}
.tile .quality:hover { background: rgba(0,0,0,.72); }
.tile .quality .ph { font-size: 14px; opacity: .8; }

.tile .qsel {
  width: auto; margin: 0; padding: 2px 24px 2px 4px;
  background-color: transparent; border: none;
  color: #fff; font-size: 12px; font-weight: 550;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,.7) 50%),
                    linear-gradient(135deg, rgba(255,255,255,.7) 50%, transparent 50%);
  background-position: calc(100% - 12px) center, calc(100% - 8px) center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.tile .qsel:focus { outline: none; }
.tile .qsel option { background: var(--surface); color: var(--label); }

/* na miniatura do spotlight não cabe */
.spot-strip .quality { display: none; }

.tile .badge { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s var(--ease); }
.tile:hover .badge { opacity: 1; }
.tile .badge button {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

/* ---------------- spotlight ---------------- */
.spotlight { flex: 1; min-width: 0; display: flex; gap: 14px; padding: 16px; overflow: hidden; }
.spot-main { flex: 1; min-width: 0; display: flex; }
.spot-main .tile { flex: 1; aspect-ratio: auto; }
.spot-main .tile:hover { transform: none; }

.spot-strip {
  flex: 0 0 auto; width: 236px; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 11px;
  scrollbar-width: thin;
}
.spot-strip:empty { display: none; }
.spot-strip .tile { flex: 0 0 auto; opacity: .62; box-shadow: var(--shadow-sm); }
.spot-strip .tile:hover { opacity: 1; border-color: var(--blue); }
.spot-strip .label { font-size: 10.5px; padding: 3px 8px; left: 7px; bottom: 7px; }
.spot-strip .badge { display: none; }

/* ---------------- painéis ---------------- */
.panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(370px, 92vw);
  background: var(--elevated);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-left: 0.5px solid var(--separator);
  padding: 24px; overflow: auto; z-index: 60;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide .38s var(--spring);
}
@keyframes slide { from { transform: translateX(100%); } }

.panel h2 {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 4px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--label-2);
}
.panel h2:not(:first-of-type) { margin-top: 26px; padding-top: 22px; border-top: 0.5px solid var(--separator); }
.panel h2 .ph { font-size: 15px; }

.stats {
  margin-top: auto;
  background: var(--fill-2);
  border: 0.5px solid var(--separator);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font: 11.5px/1.75 ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  color: var(--label-2);
  white-space: pre-wrap;
  letter-spacing: 0;
}

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--elevated);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 0.5px solid var(--separator);
  padding: 11px 20px; border-radius: 999px;
  z-index: 100; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .4s var(--spring);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } }

.banner {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%);
  max-width: min(680px, 94vw);
  display: flex; align-items: center; gap: 13px;
  background: color-mix(in srgb, var(--red) 16%, var(--elevated));
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 0.5px solid color-mix(in srgb, var(--red) 42%, transparent);
  color: var(--label);
  padding: 13px 18px; border-radius: var(--r-lg);
  font-size: 13.5px; z-index: 90;
  box-shadow: var(--shadow-md);
  animation: toastIn .4s var(--spring);
}
.banner .ph { font-size: 21px; color: var(--red); flex: 0 0 auto; }
.banner.aviso {
  background: color-mix(in srgb, var(--yellow) 16%, var(--elevated));
  border-color: color-mix(in srgb, var(--yellow) 45%, transparent);
}
.banner.aviso .ph { color: var(--yellow); }
.banner button { flex: 0 0 auto; }
.banner strong { font-weight: 600; }

.modal {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 22px;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .25s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 0.5px solid var(--separator);
  border-radius: var(--r-xl);
  padding: 30px 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: rise .42s var(--spring);
}
.modal-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 640; letter-spacing: -0.02em; }
.modal-card p { color: var(--label-2); font-size: 14px; margin: 0 0 12px; }
.modal-card .hint { font-size: 12.5px; color: var(--label-3); margin-bottom: 20px; }
.modal-card .logo { margin-bottom: 18px; }

/* ---------------- responsivo ---------------- */
@media (max-width: 760px) {
  .spotlight { flex-direction: column; }
  .spot-strip { width: auto; flex-direction: row; height: 92px; }
  .spot-strip .tile { height: 100%; width: auto; }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; padding: 12px; }
  .controles { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .controles-centro { gap: 7px; }
  .ctrl { width: 56px; height: 50px; }
  .ctrl .ph { font-size: 19px; }
  .topbar { padding: 10px 12px; }
  .actions { width: 100%; margin-left: 0; }
  .actions button:not(.icon) { flex: 1; }
  .sep { display: none; }
  .brand { font-size: 14px; }
  .people { max-width: 100%; order: 3; width: 100%; }
  .person { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
