/* style.css - Co-Editor 样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.container {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

/* Header */
.header {
  background: #fff;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header h1 {
  font-size: 20px;
  color: #333;
}

.status-bar {
  display: flex;
  gap: 15px;
  align-items: center;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}

.btn:hover {
  opacity: 0.8;
}

.btn-primary {
  background: #2196f3;
  color: white;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

/* Status */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 14px;
}

.status.online {
  background: #e8f5e9;
  color: #2e7d32;
}

.status.offline {
  background: #ffebee;
  color: #c62828;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.users {
  font-size: 14px;
  color: #666;
}

/* Main */
.main {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* Documents List */
.documents-list {
  max-width: 900px;
  margin: 0 auto;
}

.document-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.document-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.document-info h3 {
  margin-bottom: 8px;
  color: #333;
  font-size: 16px;
}

.document-meta {
  display: flex;
  gap: 15px;
  align-items: center;
  font-size: 13px;
  color: #666;
}

.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.badge-public {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-private {
  background: #ffebee;
  color: #c62828;
}

.empty,
.error,
.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.error {
  color: #dc3545;
}

/* Editor */
.editor-container {
  flex: 1;
  padding: 30px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 30px;
  flex: 1;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.8;
  color: #333;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  resize: none;
  min-height: 400px;
}

.editor:focus {
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

.editor::placeholder {
  color: #aaa;
}

.editor.active {
  display: block;
}

/* Footer */
.footer {
  background: #fff;
  padding: 10px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #999;
}

.last-saved {
  color: #666;
}

.contact {
  color: #666;
  text-decoration: none;
}

.contact:hover {
  color: #2196f3;
}

/* Scrollbar */
.editor::-webkit-scrollbar {
  width: 12px;
}

.editor::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.editor::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.editor::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Password Overlay */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  max-width: 520px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.modal-content h2 {
  margin-bottom: 20px;
  color: #333;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: #fafafa;
}

.form-group input[type="text"]:hover,
.form-group input[type="password"]:hover {
  border-color: #c0c0c0;
  background: #fff;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  outline: none;
  border-color: #2196f3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group small {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: #666;
}

.form-group .error {
  color: #dc3545;
  font-size: 12px;
  margin-top: 5px;
}

/* 密码设置复选框样式 */
.form-group label.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid #dee2e6;
  border-radius: 10px;
  transition: all 0.3s ease;
  margin-bottom: 0;
}

.form-group label.checkbox-label:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-group input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #adb5bd;
  border-radius: 5px;
  margin-right: 12px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  background: white;
  flex-shrink: 0;
}

.form-group input[type="checkbox"]:hover {
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group input[type="checkbox"]:checked {
  background: #2196f3;
  border-color: #2196f3;
}

.form-group input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.form-group label.checkbox-label span {
  font-size: 14px;
  color: #495057;
  font-weight: 500;
}

/* 密码输入框组动画 */
#password-group {
  animation: slideDown 0.3s ease;
  overflow: hidden;
}

#password-group.hiding {
  animation: slideUp 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 200px;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    max-height: 200px;
  }
  to {
    opacity: 0;
    max-height: 0;
  }
}

/* 密码输入框特殊样式 */
#password-group input[type="password"] {
  border-color: #ffc107;
  background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

#password-group input[type="password"]:focus {
  border-color: #ff9800;
  box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

#password-group label::before {
  content: '🔒 ';
  margin-right: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.form-actions button:last-child {
  margin-left: auto;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 20px;
  color: #333;
}

/* File Share (WebRTC) */
.file-share {
  max-width: 1200px;
  margin: 16px auto 0;
  width: 100%;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 14px;
}

.file-share__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.file-share__title {
  font-size: 16px;
  color: #333;
}

.file-share__info {
  padding: 10px 14px;
  margin: 10px 0;
  background: linear-gradient(135deg, #e3f2fd 0%, #f1f8ff 100%);
  border-left: 3px solid #2196f3;
  border-radius: 6px;
}

.file-share__dropzone {
  border: 2px dashed #cfd8dc;
  border-radius: 10px;
  padding: 14px;
  color: #666;
  background: #fafafa;
  transition: all 0.15s ease;
}

.file-share__dropzone.dragover {
  border-color: #2196f3;
  background: #eef6ff;
  color: #1b5fa8;
}

.file-share__list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-item {
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.file-item__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.file-item__name {
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item__sub {
  font-size: 12px;
  color: #777;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-item__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress {
  height: 8px;
  background: #eee;
  border-radius: 8px;
  overflow: hidden;
}

.progress > div {
  height: 100%;
  width: 0%;
  background: #4caf50;
  transition: width 0.1s linear;
}

/* 续传缓存管理 */
.resume-cache-section {
  margin-top: 14px;
  border: 1px solid #fff3cd;
  border-radius: 10px;
  padding: 12px;
  background: #fffdf5;
}

.resume-cache-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #856404;
}

.resume-cache-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resume-cache-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
}

.resume-cache-item__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.resume-cache-item__name {
  font-weight: 500;
  color: #333;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resume-cache-item__detail {
  font-size: 11px;
  color: #999;
}

.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 10px;
  }

  .document-card {
    flex-direction: column;
    gap: 15px;
  }

  .document-meta {
    flex-direction: column;
    gap: 5px;
  }

  .footer {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

/* File Tree Styles */
.file-tree-folder {
  border-radius: 6px;
  margin-bottom: 4px;
}

.file-tree-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.file-tree-folder-header:hover {
  background: #f5f5f5;
}

.file-tree-folder-header:active {
  background: #e8f5e9;
}

.folder-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.folder-name {
  flex: 1;
  font-weight: 500;
  color: #495057;
  font-size: 14px;
}

.folder-arrow {
  font-size: 10px;
  color: #999;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.file-tree-folder-header:hover .folder-arrow {
  color: #666;
}

.file-tree-children {
  animation: fadeIn 0.2s ease;
}

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

/* 嵌套的文件需要调整间距 */
.file-tree-children .file-item {
  border-left: 1px solid #e0e0e0;
  margin-left: 8px;
  padding-left: 8px;
}
