/*
 * LiveKit Platform — Self-contained styles
 * All rules scoped under .lk-container
 *
 * Theming via CSS custom properties:
 *   --lk-bg: container background
 *   --lk-surface: tile/card background
 *   --lk-text: primary text color
 *   --lk-text-muted: secondary text
 *   --lk-accent: primary accent (buttons, indicators)
 *   --lk-danger: disconnect/error color
 *   --lk-radius: border-radius base
 *   --lk-speaking: speaking indicator color
 */

.lk-container {
  --lk-bg: #1a1a2e;
  --lk-surface: #16213e;
  --lk-text: #ffffff;
  --lk-text-muted: #a0a0b8;
  --lk-accent: #4361ee;
  --lk-danger: #e63946;
  --lk-radius: 8px;
  --lk-speaking: #06d6a0;
  --lk-grid-cols: 1;

  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--lk-bg);
  color: var(--lk-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

/* ─── Overlay ──────────────────────────────────────────────────── */

.lk-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: var(--lk-text-muted);
  font-size: 16px;
  z-index: 5;
}

/* ─── CAMERA MODE — Video Grid ─────────────────────────────────── */

.lk-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--lk-grid-cols), 1fr);
  gap: 6px;
  padding: 6px;
  overflow: auto;
}

.lk-grid--spotlight .lk-tile:first-child {
  grid-column: 1 / -1;
  min-height: 60%;
}

/* ─── Participant Tile ─────────────────────────────────────────── */

.lk-tile {
  position: relative;
  background: var(--lk-surface);
  border-radius: var(--lk-radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  transition: box-shadow 0.2s;
}

.lk-tile--speaking {
  box-shadow: 0 0 0 3px var(--lk-speaking);
}

.lk-tile-video {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lk-video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--lk-radius);
}

.lk-tile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--lk-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  z-index: 1;
}

.lk-tile--has-video .lk-tile-avatar {
  display: none;
}

.lk-tile-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  font-size: 12px;
  color: #fff;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lk-tile-status {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.lk-status-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.lk-status-mic-off::after {
  content: '🔇';
  font-size: 12px;
}

.lk-status-cam-off::after {
  content: '📷';
  font-size: 12px;
  opacity: 0.5;
}

/* ─── SCREEN MODE — Presenter Layout ──────────────────────────── */

.lk-screen-mode {
  flex-direction: row;
}

.lk-screen-main {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 200px;
}

.lk-screen-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lk-screen-thumbs {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  background: var(--lk-surface);
  overflow-y: auto;
}

.lk-screen-thumb {
  min-height: 90px;
  max-height: 120px;
}

/* ─── AUDIO MODE — Participant List ────────────────────────────── */

.lk-audio-mode {
  padding: 0;
}

.lk-audio-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.lk-audio-participant {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--lk-radius);
  transition: background 0.15s;
}

.lk-audio-participant:hover {
  background: var(--lk-surface);
}

.lk-audio-participant--speaking {
  background: var(--lk-surface);
}

.lk-audio-participant--speaking .lk-audio-avatar {
  box-shadow: 0 0 0 3px var(--lk-speaking);
}

.lk-audio-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lk-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  transition: box-shadow 0.2s;
}

.lk-audio-name {
  flex: 1;
  font-size: 14px;
  color: var(--lk-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lk-audio-mic {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--lk-speaking);
  flex-shrink: 0;
  transition: background 0.15s;
}

.lk-audio-mic--muted {
  background: var(--lk-danger);
}

/* ─── LIVE MODE — Status Bar ───────────────────────────────────── */

.lk-live-status {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--lk-text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lk-live-status--connected {
  color: var(--lk-speaking);
}

/* Reactions overlay */
.lk-reactions-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.lk-reaction-float {
  position: absolute;
  bottom: 60px;
  font-size: 28px;
  animation: lk-float-up 2s ease-out forwards;
  pointer-events: none;
}

@keyframes lk-float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-200px) scale(1.3);
  }
}

/* ─── Control Bar ──────────────────────────────────────────────── */

.lk-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--lk-surface);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.lk-ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--lk-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.lk-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lk-ctrl-btn:active {
  transform: scale(0.95);
}

.lk-ctrl-btn--active {
  background: var(--lk-danger);
  color: #fff;
}

.lk-ctrl-btn--danger {
  background: var(--lk-danger);
  color: #fff;
}

.lk-ctrl-btn--danger:hover {
  background: #c1121f;
}

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

/* ─── Responsive ───────────────────────────────────────────────── */

@media (max-width: 640px) {
  .lk-screen-mode {
    flex-direction: column;
  }

  .lk-screen-thumbs {
    width: 100%;
    flex-direction: row;
    height: 100px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .lk-screen-thumb {
    min-width: 120px;
    min-height: unset;
    max-height: unset;
  }

  .lk-tile-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .lk-ctrl-btn {
    width: 40px;
    height: 40px;
  }
}
