* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: white;
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
}

.auth-box h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 24px;
}

.tab-buttons {
  display: flex;
  margin-bottom: 30px;
  border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  color: #666;
  transition: all 0.3s;
}

.tab-btn.active {
  color: #667eea;
  border-bottom: 2px solid #667eea;
  margin-bottom: -2px;
}

.auth-form {
  display: block;
}

.auth-form.hidden {
  display: none;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.3s;
  -webkit-appearance: none;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.message {
  margin-top: 20px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  display: none;
}

.message.success {
  display: block;
  background: #d4edda;
  color: #155724;
}

.message.error {
  display: block;
  background: #f8d7da;
  color: #721c24;
}

.app-container {
  display: flex;
  height: 100vh;
  background: #f5f5f5;
  overflow: hidden;
}

.sidebar {
  width: 320px;
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.user-info {
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  gap: 15px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.user-details .username {
  color: white;
  font-weight: 600;
  font-size: 16px;
}

.user-details .status {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  margin-top: 4px;
}

.user-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.user-list-container h3 {
  color: #333;
  font-size: 14px;
  margin-bottom: 15px;
  font-weight: 600;
}

.camera-settings {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid #e0e0e0;
}

.camera-settings h3 {
  color: #333;
  font-size: 14px;
  margin-bottom: 15px;
  font-weight: 600;
}

.camera-preview-container {
  width: 100%;
  aspect-ratio: 4/3;
  background: #1a1a1a;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 15px;
  position: relative;
}

.camera-preview-container #camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-preview-container::before {
  content: '摄像头预览';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #666;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.camera-preview-container video[src]::before {
  display: none;
}

.camera-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.camera-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #f8f9fa;
  transition: all 0.2s;
}

.camera-item.active {
  background: #e3f2fd;
  border: 2px solid #667eea;
}

.camera-info {
  flex: 1;
  min-width: 0;
}

.camera-name {
  color: #333;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-status {
  font-size: 11px;
  color: #666;
}

.camera-status.active {
  color: #4caf50;
  font-weight: 500;
}

.camera-status.error {
  color: #f44336;
}

.camera-select-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: #667eea;
  color: white;
  white-space: nowrap;
}

.camera-select-btn:hover {
  background: #5568d3;
  transform: translateY(-1px);
}

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

.camera-item.active .camera-select-btn {
  background: #4caf50;
  cursor: default;
}

.camera-item.active .camera-select-btn:hover {
  background: #4caf50;
  transform: none;
}

.camera-messages {
  margin-top: 15px;
}

.camera-error,
.camera-success {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: none;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.camera-error {
  background: #ffebee;
  color: #c62828;
  border-left: 3px solid #f44336;
}

.camera-success {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 3px solid #4caf50;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-item:hover {
  background: #f0f0f0;
}

.user-item .avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.user-item .user-details {
  flex: 1;
  min-width: 0;
}

.user-item .user-details .username {
  color: #333;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-item .user-details .status {
  font-size: 12px;
}

.user-item .status.online {
  color: #4caf50;
}

.user-item .status.offline {
  color: #999;
}

.user-item .call-btn {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.user-item .call-btn:hover {
  background: #5568d3;
}

.user-item .call-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-logout {
  margin: 20px;
  padding: 12px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: #d32f2f;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  padding: 20px;
}

.welcome-screen h2 {
  font-size: 32px;
  margin-bottom: 10px;
  text-align: center;
}

.welcome-screen p {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.call-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 2000;
  display: none;
  flex-direction: column;
}

.call-screen.show {
  display: flex;
}

.call-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
}

.call-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.call-user-details {
  flex: 1;
  min-width: 0;
}

.call-username {
  color: white;
  font-weight: 600;
  font-size: 18px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-status {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  margin-top: 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.video-container {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #1a1a1a;
}

.video-wrapper.local {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 120px;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: move;
  user-select: none;
}

.video-wrapper.local:active {
  cursor: grabbing;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  transform: scale(1.02);
  transition: transform 0.1s, box-shadow 0.1s;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1a1a1a;
}

.video-wrapper.local video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.video-play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s;
  z-index: 5;
}

.video-play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.video-play-overlay svg {
  width: 64px;
  height: 64px;
  color: white;
  margin-bottom: 10px;
}

.video-play-overlay span {
  color: white;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 20px 60px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.control-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.control-btn svg {
  width: 32px;
  height: 32px;
}

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

.control-btn.active {
  background: rgba(76, 175, 80, 0.9);
}

.control-btn.inactive {
  background: rgba(244, 67, 54, 0.9);
}

.btn-end-call {
  width: 72px;
  height: 72px;
  background: rgba(244, 67, 54, 0.9);
}

.btn-end-call:active {
  background: rgba(211, 47, 47, 0.9);
}

.incoming-call-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.incoming-call-modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 24px;
  padding: 50px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease;
  max-width: 90%;
  width: 320px;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content .caller-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  color: white;
  margin: 0 auto 20px;
}

.modal-content h3 {
  color: #333;
  margin-bottom: 10px;
  font-size: 20px;
}

.modal-content p {
  color: #666;
  margin-bottom: 30px;
  font-size: 16px;
}

.modal-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.btn-answer {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #4caf50;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-answer:active {
  transform: scale(0.95);
  background: #45a049;
}

.btn-answer svg {
  width: 32px;
  height: 32px;
}

.btn-reject {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f44336;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-reject:active {
  transform: scale(0.95);
  background: #d32f2f;
}

.btn-reject svg {
  width: 32px;
  height: 32px;
}

.permission-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 4000;
  padding: 20px;
}

.permission-modal.show {
  display: flex;
}

.permission-modal .modal-content {
  background: white;
  border-radius: 24px;
  padding: 40px 30px;
  text-align: center;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

.permission-modal h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 22px;
}

.permission-modal p {
  color: #666;
  margin-bottom: 25px;
  font-size: 15px;
  line-height: 1.6;
}

.permission-modal .btn-primary {
  margin-top: 10px;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
  }
  
  .user-list-container {
    flex: 0 0 auto;
    max-height: 40vh;
  }
  
  .camera-settings {
    flex: 1;
    border-top: 1px solid #e0e0e0;
  }
  
  .main-content {
    display: none;
  }
  
  .auth-box {
    padding: 30px 20px;
    border-radius: 16px;
  }
  
  .auth-box h1 {
    font-size: 20px;
    margin-bottom: 20px;
  }
  
  .local-video-wrapper {
    width: 100px;
    height: 133px;
    top: 15px;
    right: 15px;
  }
  
  .call-controls {
    padding: 30px 15px 50px;
    gap: 20px;
  }
  
  .control-btn {
    width: 56px;
    height: 56px;
  }
  
  .control-btn svg {
    width: 28px;
    height: 28px;
  }
  
  .btn-end-call {
    width: 64px;
    height: 64px;
  }
  
  .call-info .caller-name {
    font-size: 20px;
  }
  
  .call-info .call-duration {
    font-size: 14px;
  }
  
  .modal-content {
    padding: 40px 30px;
  }
  
  .modal-content .caller-avatar {
    width: 70px;
    height: 70px;
    font-size: 28px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 15px;
  }
  
  .auth-box {
    padding: 25px 20px;
  }
  
  .auth-box h1 {
    font-size: 18px;
  }
  
  .tab-btn {
    font-size: 15px;
    padding: 10px;
  }
  
  .form-group input {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .btn-primary {
    padding: 12px;
    font-size: 15px;
  }
  
  .user-info {
    padding: 15px;
  }
  
  .avatar {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
  
  .user-item {
    padding: 10px;
  }
  
  .user-item .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  .user-item .call-btn {
    padding: 6px 12px;
    font-size: 11px;
  }
  
  .local-video-wrapper {
    width: 90px;
    height: 120px;
    top: 12px;
    right: 12px;
  }
  
  .call-controls {
    padding: 25px 12px 45px;
    gap: 16px;
  }
  
  .control-btn {
    width: 52px;
    height: 52px;
  }
  
  .control-btn svg {
    width: 26px;
    height: 26px;
  }
  
  .btn-end-call {
    width: 60px;
    height: 60px;
  }
  
  .call-info .caller-name {
    font-size: 18px;
  }
  
  .call-info .call-duration {
    font-size: 13px;
  }
  
  .call-status {
    font-size: 16px;
    padding: 15px 30px;
  }
  
  .modal-content {
    padding: 35px 25px;
    width: 280px;
  }
  
  .modal-content .caller-avatar {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  
  .modal-content h3 {
    font-size: 18px;
  }
  
  .modal-content p {
    font-size: 15px;
  }
  
  .modal-buttons {
    gap: 15px;
  }
  
  .btn-answer,
  .btn-reject {
    width: 56px;
    height: 56px;
  }
  
  .btn-answer svg,
  .btn-reject svg {
    width: 28px;
    height: 28px;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .local-video-wrapper {
    width: 160px;
    height: 120px;
    top: 10px;
    right: 10px;
  }
  
  .call-controls {
    padding: 20px 15px 30px;
  }
  
  .control-btn {
    width: 48px;
    height: 48px;
  }
  
  .control-btn svg {
    width: 24px;
    height: 24px;
  }
  
  .btn-end-call {
    width: 56px;
    height: 56px;
  }
}
