/**
 * 多人视频组件样式
 */

/* ========== 多人视频面板 ========== */
.multi-video-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #111827;
}

.multi-video-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-left .room-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left .room-id {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.header-left .participant-count {
  color: #9ca3af;
  font-size: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

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

.multi-video-panel__content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.video-section {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-section--with-list {
  flex: 1;
}

.participant-sidebar {
  width: 240px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
}

.multi-video-panel__controls {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.connecting-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  gap: 16px;
}

/* ========== 视频网格 ========== */
.video-grid {
  display: grid;
  width: 100%;
  height: 100%;
  background: #000;
  gap: 4px;
  padding: 4px;
}

.video-grid--empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 1 人：全屏 */
.video-grid--1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

/* 2 人：左右分屏 */
.video-grid--2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

/* 3-4 人：2x2 网格 */
.video-grid--4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* 5+ 人：3列网格 */
.video-grid--many {
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
}

/* ========== 视频瓦片 ========== */
.video-tile {
  position: relative;
  background: #1f2937;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  aspect-ratio: 16 / 9;
}

.video-tile--local {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5);
}

.video-tile--no-stream {
  background: linear-gradient(135deg, #1f2937, #111827);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile__video--mirrored {
  transform: scaleX(-1);
}

.video-tile__placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6b7280;
}

.video-tile__info {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
}

.video-tile__name {
  font-weight: 500;
}

.video-tile__status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  color: #9ca3af;
  font-size: 14px;
}

.video-tile__state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

/* ========== 网络质量指示器 ========== */
.indicator--network-good {
  color: #10b981;
}

.indicator--network-fair {
  color: #f59e0b;
}

.indicator--network-poor {
  color: #ef4444;
}

.indicator--network-bad {
  color: #991b1b;
}

/* ========== 参与者列表 ========== */
.participant-list {
  position: absolute;
  top: 60px;
  right: 16px;
  width: 200px;
  max-height: 400px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.participant-list--collapsed {
  transform: translateX(calc(100% + 16px));
}

.participant-list__toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
}

.participant-count {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-size: 12px;
}

.participant-list__content {
  max-height: 300px;
  overflow-y: auto;
}

.participant-list__header {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.participant-list__header h3 {
  margin: 0;
  color: #fff;
  font-size: 14px;
}

.participant-list__items {
  padding: 8px;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.participant-item--local {
  background: rgba(16, 185, 129, 0.2);
}

.participant-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.participant-item__avatar video {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.participant-item__info {
  flex: 1;
  min-width: 0;
}

.participant-item__name {
  color: #fff;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  color: #9ca3af;
  font-size: 11px;
}

.participant-item__status {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.status-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.status-badge--connected {
  background: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.status-badge--connecting {
  background: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

.status-badge--failed {
  background: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.participant-item__actions {
  display: flex;
  gap: 4px;
}

.action-btn {
  padding: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.action-btn--danger {
  background: rgba(239, 68, 68, 0.3);
}

.action-btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.5);
}

/* ========== 网络指示器 ========== */
.network-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.network-indicator__bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 16px;
}

.network-indicator__bar {
  width: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
}

.network-indicator__bar--active {
  background: #10b981;
}

.network-indicator--good .network-indicator__bar--active {
  background: #10b981;
}

.network-indicator--fair .network-indicator__bar--active {
  background: #f59e0b;
}

.network-indicator--poor .network-indicator__bar--active {
  background: #ef4444;
}

.network-indicator--bad .network-indicator__bar--active {
  background: #991b1b;
}

.network-indicator__text {
  color: #9ca3af;
  font-size: 11px;
}

.network-indicator__tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}

.network-indicator:hover .network-indicator__tooltip {
  visibility: visible;
  opacity: 1;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  color: #9ca3af;
}

/* ========== 移动端优化 ========== */
@media (max-width: 768px) {
  .participant-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .participant-sidebar.show {
    transform: translateX(0);
  }

  .video-section--with-list {
    flex: 1;
  }

  .multi-video-panel__header {
    padding: 8px 12px;
  }
}
