/* Classario WebRTC — themed to match classario.com (Inter + brand blue) */
:root {
  --brand: #126dfb;          /* classario primary blue */
  --brand-bright: #0099ff;   /* brighter accent */
  --brand-hover: #0765e8;
  --danger: #ff4726;         /* classario accent red */
  --danger-hover: #e03e1f;

  --lobby-bg: #ffffff;       /* clean white background */
  --card: #ffffff;
  --text: #0c0c0c;
  --muted: #575757;
  --border: #e1eaf8;
  --input-bg: #f8f8f8;

  --stage: #0b1220;          /* dark video stage (video reads best on dark) */
  --tile: #000;

  --font: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--stage);
}

#app, .start, .lobby, .call { height: 100%; }
.hidden { display: none !important; }

/* ---------- Start screen ---------- */
.start {
  background: var(--lobby-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.start-inner { text-align: center; }
.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 30px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(18, 109, 251, .08);
  transition: border-color .15s, box-shadow .15s;
}
.btn-start:hover { border-color: var(--brand); box-shadow: 0 8px 22px rgba(18, 109, 251, .16); }
.btn-start:disabled { opacity: .6; cursor: not-allowed; }
.btn-start svg { width: 26px; height: 26px; }

/* ---------- Lobby (light, brand-matched) ---------- */
.lobby {
  background: var(--lobby-bg);
  display: flex;
  align-items: safe center;       /* center, but never clip when taller than viewport */
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.lobby-card {
  width: 100%;
  max-width: 720px;
  margin: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(18, 109, 251, .12);
}

/* Two columns: preview on the left, controls on the right. */
.lobby-form {
  display: flex;
  gap: 20px;
  align-items: center;
}
.lobby-form > #preview { flex: 1 1 0; min-width: 0; }
.lobby-controls { flex: 1 1 0; min-width: 0; }
.lobby-controls .field:first-child { margin-top: 0; }

#preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  object-fit: cover;
  transform: scaleX(-1); /* mirror your own preview */
}
.field { margin-top: 11px; }

/* Stack on narrow screens (phones). */
@media (max-width: 560px) {
  .lobby-form { flex-direction: column; gap: 14px; align-items: stretch; }
  .lobby-form > #preview { max-height: 30vh; }

  /* Put Camera + Microphone side by side; button/error span full width below. */
  .lobby-controls { display: flex; flex-wrap: wrap; gap: 10px; }
  .lobby-controls .field { flex: 1 1 0; min-width: 0; margin-top: 0; }
  .lobby-controls .btn,
  .lobby-controls .error { flex-basis: 100%; }
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}
.btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }
.lobby-loading {
  margin: 0;
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

/* ---------- Call (dark stage, floating controls) ---------- */
.call {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--stage);
}

/* Video grid fills ALL available space and divides it evenly.
   Column count is driven by data-count (number of participants) so 2 people
   sit side by side in one row, 3–4 form a 2x2 grid. */
.videos {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
  padding: 10px;
  grid-auto-rows: 1fr;
  grid-template-columns: 1fr;            /* 1 participant */
}
.videos[data-count="2"] { grid-template-columns: 1fr 1fr; }   /* side by side */
.videos[data-count="3"],
.videos[data-count="4"] { grid-template-columns: 1fr 1fr; }   /* 2x2 */

/* Portrait / narrow (phones): stacking reads better than thin slivers. */
@media (max-aspect-ratio: 4 / 5) {
  .videos[data-count="2"] { grid-template-columns: 1fr; }
}

.tile {
  position: relative;
  min-height: 0;
  background: var(--tile);
  border-radius: 14px;
  overflow: hidden;
}
.tile.sharing { outline: 3px solid var(--brand); outline-offset: -3px; }
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile.local video { transform: scaleX(-1); }      /* mirror your own camera */
.tile.sharing video { object-fit: contain; background: #000; } /* show whole screen */
.tile.sharing.local video { transform: none; }    /* don't mirror a shared screen */

/* Camera-off placeholder (Zoom-style: initials + name centered). */
.tile .avatar { display: none; }
.tile.camera-off video { visibility: hidden; }
.tile.camera-off .name { display: none; }
.tile.camera-off .avatar {
  display: flex;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #141c2e;
}
.avatar-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-bright));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .5px;
}
.avatar-name { color: #e5e7eb; font-size: 15px; font-weight: 500; padding: 0 12px; text-align: center; }

.tile .name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

/* Per-tile expand / fullscreen button */
.tile .expand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
  backdrop-filter: blur(4px);
}
.tile .expand:hover { background: rgba(0, 0, 0, .7); }
.tile:hover .expand { opacity: 1; }
@media (hover: none) { .tile .expand { opacity: .9; } } /* always visible on touch */
.tile .expand svg { width: 17px; height: 17px; }

/* ---------- Floating toolbar ---------- */
.toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(20, 28, 46, .72);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .45);
  z-index: 10;
}
.btn-round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  font-size: 19px;
  cursor: pointer;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.btn-round:hover { background: rgba(255, 255, 255, .26); }
.btn-round.off { background: var(--danger); }

/* Feather-style stroke icons inside the control buttons. */
.btn-round svg {
  width: 21px;
  height: 21px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
/* Swap to the slashed "off" icon when muted (mic / camera). */
.btn-round .ic-off { display: none; }
.btn-round.off .ic-on { display: none; }
.btn-round.off .ic-off { display: block; }
.btn-leave { background: var(--danger); }
.btn-leave:hover { background: var(--danger-hover); }

.status {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  text-align: center;
  color: #cbd5e1;
  font-size: 13px;
  pointer-events: none;
}
.status:empty { display: none; }

@media (max-width: 480px) {
  .toolbar { gap: 9px; padding: 9px 12px; bottom: 14px; }
  .btn-round { width: 44px; height: 44px; font-size: 17px; }
}
