/* ==========================================================================
   Conferly — styles
   ========================================================================== */

:root {
  --bg: #080b16;
  --bg-2: #0d1224;
  --panel: rgba(22, 28, 48, 0.72);
  --panel-solid: #141a2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2ff;
  --muted: #93a0c0;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --good: #34d399;
  --danger: #f0426c;
  --danger-2: #ff7a59;
  --ring: rgba(91, 140, 255, 0.55);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input,
select {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
}

/* ==========================================================================
   Lobby
   ========================================================================== */

.lobby {
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 28px 16px;
}

.lobby-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 60% at 15% 10%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(55% 55% at 90% 20%, rgba(91, 140, 255, 0.24), transparent 60%),
    radial-gradient(70% 70% at 50% 110%, rgba(52, 211, 153, 0.16), transparent 60%),
    var(--bg);
  z-index: 0;
}

.lobby-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(26, 33, 56, 0.92), rgba(14, 19, 35, 0.92));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 26px;
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.4px;
}

.brand p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(91, 140, 255, 0.4);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.preview-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #05070f;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-wrap video.rear {
  transform: none;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: radial-gradient(circle at 50% 40%, #1b2340, #090d19);
  color: var(--muted);
  font-size: 13px;
}

.avatar-lg {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  text-transform: uppercase;
}

.preview-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.round-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.round-btn.off {
  background: rgba(240, 66, 108, 0.92);
  border-color: transparent;
}

.round-btn svg {
  width: 20px;
  height: 20px;
}

.join-form {
  display: grid;
  gap: 14px;
}

.device-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(8, 11, 22, 0.8);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.lobby-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #ffc9d6;
  background: rgba(240, 66, 108, 0.14);
  border: 1px solid rgba(240, 66, 108, 0.4);
}

.primary-btn {
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 26px rgba(91, 140, 255, 0.35);
  transition: transform 0.15s, filter 0.15s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn svg {
  width: 18px;
  height: 18px;
}

.lobby-foot {
  margin: 18px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* ==========================================================================
   Conference layout
   ========================================================================== */

.conference {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 27, 0.85);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mini {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand-mini svg {
  width: 19px;
  height: 19px;
}

.room-info {
  display: grid;
  min-width: 0;
}

.room-info strong {
  font-size: 15px;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-info span {
  font-size: 11.5px;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--accent);
}

.ghost-btn svg {
  width: 15px;
  height: 15px;
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
}

.conn-dot.down {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(240, 66, 108, 0.16);
}

.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.grid-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  padding: 14px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-auto-rows: minmax(200px, 1fr);
  align-content: center;
  min-height: 100%;
}

/* Single participant gets a large centered tile. */
.grid:has(.tile:only-child) {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .grid[data-count="1"] {
    grid-template-columns: minmax(0, 1.1fr);
    max-width: 1100px;
    margin: 0 auto;
  }
  .grid[data-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------ tiles */

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a0e1c;
  border: 1px solid var(--border);
  min-height: 200px;
  isolation: isolate;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05070f;
}

.tile.self video {
  transform: scaleX(-1);
}

.tile.screen video {
  object-fit: contain;
  background: #05070f;
}

.tile .avatar {
  position: absolute;
  inset: 0;
  display: none;
  place-content: center;
  justify-items: center;
  background: radial-gradient(circle at 50% 38%, #1c2542, #080c18);
}

.tile .avatar span {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}

.tile.video-off .avatar {
  display: grid;
}

.tile.speaking {
  border-color: var(--good);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.55), 0 0 30px rgba(52, 211, 153, 0.22);
}

.tile-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 22px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72));
  pointer-events: none;
}

.tile-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.badges {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: none;
  place-items: center;
  background: rgba(240, 66, 108, 0.92);
  color: #fff;
}

.badge.show {
  display: grid;
}

.badge.share {
  background: rgba(91, 140, 255, 0.95);
}

.badge svg {
  width: 15px;
  height: 15px;
}

.tile .conn-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--muted);
  display: none;
}

.tile.connecting .conn-badge {
  display: block;
}

.tile.failed .conn-badge {
  display: block;
  color: #ffc9d6;
  background: rgba(240, 66, 108, 0.28);
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  flex: 0 0 330px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  transition: margin-right 0.22s ease, opacity 0.22s ease;
}

.sidebar.collapsed {
  margin-right: -331px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.tab.active {
  background: rgba(91, 140, 255, 0.16);
  border-color: rgba(91, 140, 255, 0.4);
  color: #cfe0ff;
}

.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--accent);
  color: #fff;
}

.panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-note {
  margin: auto;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 220px;
}

.msg {
  max-width: 88%;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 11px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: pop 0.16s ease;
}

.msg.self {
  align-self: flex-end;
  border-radius: 12px 12px 4px 12px;
  background: rgba(91, 140, 255, 0.18);
  border-color: rgba(91, 140, 255, 0.4);
}

.msg .meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--muted);
}

.msg .meta b {
  color: #cfe0ff;
  font-weight: 600;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(8, 11, 22, 0.8);
  outline: none;
}

.chat-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.chat-form button {
  width: 42px;
  flex: 0 0 auto;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
}

.chat-form button svg {
  width: 18px;
  height: 18px;
}

.participants {
  list-style: none;
  margin: 0;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.participants li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

.p-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  text-transform: uppercase;
}

.p-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.p-icons {
  display: flex;
  gap: 5px;
  color: var(--muted);
}

.p-icons svg {
  width: 15px;
  height: 15px;
}

.p-icons .on {
  color: var(--danger-2);
}

/* ------------------------------------------------------------------ controls */

.controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 27, 0.9);
  backdrop-filter: blur(12px);
}

.controls-group {
  display: flex;
  gap: 10px;
}

.ctrl {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  transition: transform 0.14s, background 0.14s, border-color 0.14s;
}

.ctrl:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.11);
  border-color: var(--accent);
}

.ctrl svg {
  width: 22px;
  height: 22px;
}

.ctrl.off {
  background: rgba(240, 66, 108, 0.9);
  border-color: transparent;
}

.ctrl.active {
  background: rgba(91, 140, 255, 0.9);
  border-color: transparent;
}

.ctrl.danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-2));
  border-color: transparent;
  width: 76px;
}

.ctrl.danger:hover {
  filter: brightness(1.08);
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  color: #fff;
  background: rgba(20, 26, 46, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  .sidebar {
    position: absolute;
    top: 57px;
    right: 0;
    bottom: 77px;
    width: min(330px, 88vw);
    flex-basis: auto;
    z-index: 20;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
    border-left: 1px solid var(--border-strong);
  }

  .sidebar.collapsed {
    margin-right: -100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-auto-rows: minmax(160px, 1fr);
  }

  .ghost-btn span {
    display: none;
  }

  .ghost-btn {
    padding: 8px 10px;
  }
}

@media (max-width: 520px) {
  .controls {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .ctrl {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .ctrl.danger {
    width: 62px;
  }

  .grid-wrap {
    padding: 10px;
  }

  .grid {
    gap: 9px;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(180px, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
