* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background-color: #000;
  color: #333;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.container {
  max-width: 100%;
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #000;
}

#room-join {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  margin: auto;
  text-align: center;
  width: 90%;
  max-width: 400px;
}

#room-join input,
#room-join button {
  padding: 12px 20px;
  margin: 10px;
  border-radius: 5px;
  border: 1px solid #ddd;
  font-size: 1rem;
}

#room-join input {
  width: 200px;
}

#room-join button {
  background-color: #667eea;
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
}

#room-join button:hover {
  background-color: #5a67d8;
}

/* 视频容器 - 支持动态布局 */
#video-container {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  margin: 10px;
  flex-grow: 1;
  min-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* 视频包装器基础样式 */
.video-wrapper {
  position: relative;
  background-color: #222;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
  min-height: 200px;
}

/* 横屏视频样式 */
.video-wrapper.video-landscape {
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 350px;
}

.video-wrapper.video-landscape video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 竖屏视频样式 */
.video-wrapper.video-portrait {
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 450px;
}

.video-wrapper.video-portrait video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 方形视频样式 */
.video-wrapper.video-square {
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 300px;
}

.video-wrapper.video-square video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.video-wrapper video {
  width: 100%;
  height: auto;
  object-fit: contain;
  transition: all 0.3s ease;
  /* 保持视频本身的宽高比，同时适应容器 */
}

/* 视频信息显示 */
.video-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

/* 视频窗口悬停效果 */
.video-wrapper:hover {
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transform: translateY(-2px);
}

/* 根据参会人数动态调整布局 */
.video-container-1 .video-wrapper {
  grid-column: 1 / -1;
  /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
}

.video-container-2 .video-wrapper {
  grid-column: span 1;
  /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
}

.video-container-3-4 .video-wrapper {
  grid-column: span 2;
  /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
}

.video-container-5-6 .video-wrapper {
  grid-column: span 3;
  /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
}

.video-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  font-size: 0.9rem;
}

#controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 15px 10px;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 16px;
  margin: 20px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.control-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.control-btn:active::before {
  width: 100px;
  height: 100px;
}

.control-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 状态变化样式 */
.active {
  animation: pulse 0.5s ease-in-out;
}

/* 通用伪元素图标样式 */
.control-btn::before {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* 麦克风按钮图标 */
#mic-btn {
  width: 50px;
  height: 50px;
  background-image: url("/images/mic_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg");
  border-radius: 50%;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
    border: none;
}

/* 麦克风禁用状态 */
.mic-muted {
  background: #ccc;
  opacity: 0.7;
   border: none;
  background-image: url("/images/mic_off_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg") !important;
}

/* 摄像头按钮图标 */
#camera-btn {
  width: 50px;
  height: 50px;
  background-image: url("/images/video_camera_front_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg");

  border-radius: 50%;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
    border: none;
}

/* 摄像头禁用状态 */
.camera-muted {
  background: #ccc;
  opacity: 0.7;
  background-image: url("/images/video_camera_front_off_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg") !important;
}

/* 扬声器按钮图标 */
.speaker-muted {
  width: 50px;
  height: 50px;
  background-image: url("/images/volume_off_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg");

  border-radius: 50%;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
    border: none;
}

.speaker-active {
  width: 50px;
  height: 50px;
  background-image: url("/images/volume_up_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg");
  border-radius: 50%;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
    border: none;
}

/* 切换摄像头按钮图标 */
#switch-camera-btn {
  width: 50px;
  height: 50px;
  background-image: url("/images/cameraswitch_24dp_5F6368_FILL0_wght400_GRAD0_opsz24.svg");
  border-radius: 50%;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
    border: none;
}

/* 离开房间按钮图标 */
#leave-btn {
}

.leave {
  background: #f44336;

  width: 50px;
  height: 50px;
  background-image: url("/images/logout_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24.svg");
  border-radius: 50%;
  border: none;
  background-size: 75%; /* 图标占据按钮的一半 */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 75%; /* 将按钮改为圆形 */
  color: white;
}

/* 状态变化动画 */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}



/* 占位图标样式 */
.video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #444;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  z-index: 10;
}

.video-placeholder-icon {
  font-size: 4rem;
  margin-bottom: 10px;
}

/* 全屏模式样式 */
.video-wrapper.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  margin: 0;
  background-color: black;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrapper.fullscreen video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.video-wrapper.fullscreen .video-info {
  font-size: 1.2rem;
  padding: 10px 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    background-color: #000;
    touch-action: manipulation;
  }

  .container {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #000;
    max-width: 100%;
  }

  #room-join {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  #room-join input {
    width: 80%;
    max-width: 300px;
    margin-bottom: 15px;
    padding: 15px;
    font-size: 1.1rem;
    border-radius: 8px;
  }

  #room-join button {
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 8px;
    min-width: 150px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  }

  /* 移动端视频容器 */
  #video-container {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 10px;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    background-color: #000;
  }

  .video-wrapper {
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
  }

  .video-wrapper video {
    height: auto;
    object-fit: contain;
  }

  /* 移动端控制面板 */
  #controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 15px 10px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    margin: 0;
    gap: 10px;
    backdrop-filter: blur(10px);
  }

  .control-btn {
    width: 60px;
    height: 60px;
    min-width: 60px;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }

  /* 触摸设备优化 */
  button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* 防止文本选择 */
  * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  input {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }

  /* 移动端横屏模式优化 */
  @media (orientation: landscape) {
    /* 强制全屏显示，隐藏地址栏 */
    body {
      height: 100vh;
      overflow: hidden;
    }

    .container {
      height: 100vh;
    }

    #video-container {
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      margin: 5px;
      gap: 5px;
    }

    .video-wrapper {
      /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
    }

    .video-wrapper video {
      height: auto;
    }

    /* 横屏时控制按钮缩小 */
    #controls {
      padding: 10px;
    }

    .control-btn {
      width: 50px;
      height: 50px;
      min-width: 50px;
      font-size: 1.1rem;
    }
  }

  /* 移动端竖屏模式优化 */
  @media (orientation: portrait) {
    /* 强制全屏显示，隐藏地址栏 */
    html {
      height: 100vh;
      overflow: hidden;
    }

    body {
      height: 100vh;
      overflow: hidden;
    }

    /* 竖屏时单视频最大化显示 */
    .video-container-1 .video-wrapper {
      grid-column: 1 / -1;
      /* 移除固定的aspect-ratio，让视频根据自身宽高比显示 */
    }
  }

  /* 小屏幕设备额外优化 */
  @media (max-width: 360px) {
    #controls {
      gap: 5px;
      padding: 10px 5px;
    }

    .control-btn {
      width: 55px;
      height: 55px;
      min-width: 55px;
      font-size: 1.2rem;
    }

    .leave {
      width: 60px;
      height: 60px;
      min-width: 60px;
      font-size: 1.4rem;
    }
  }
}
