/* ==================== 基础样式 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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;
  color: var(--gray-800);
  line-height: 1.6;
}

/* ==================== 学生端容器 ==================== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 20px;
}

.header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

.header h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
  font-size: 1rem;
  opacity: 0.9;
}

/* ==================== 表单卡片 ==================== */
.form-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
}

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

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-700);
  font-size: 0.95rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--gray-50);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

/* ==================== 学生验证状态 ==================== */
.student-status {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.student-status .status-icon {
  font-size: 1.1rem;
}

.student-status.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.student-status.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.student-status strong {
  font-weight: 600;
}

/* ==================== 信息框 ==================== */
.info-box {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.info-box h3 {
  color: var(--primary-dark);
  margin-bottom: 8px;
  font-size: 1rem;
}

.info-box #assignmentDesc {
  margin-bottom: 12px;
  color: var(--gray-700);
}

.requirements {
  background: white;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.requirements p {
  margin: 4px 0;
}

/* ==================== 拖拽上传区域 ==================== */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--gray-50);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-content .upload-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

.drop-zone-content p {
  color: var(--gray-500);
  margin: 4px 0;
}

.file-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* ==================== 文件预览 ==================== */
.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
}

.file-preview span {
  color: var(--success);
  font-weight: 600;
}

.btn-remove {
  background: var(--danger);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== 按钮 ==================== */
.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.btn-submit:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-submit:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--gray-200);
  color: var(--gray-700);
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-small {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-small:hover {
  background: var(--primary-dark);
}

.btn-small.view-btn {
  background: #7c3aed;
}

.btn-small.view-btn:hover {
  background: #6d28d9;
}

.btn-danger {
  padding: 8px 16px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-archive {
  padding: 4px 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-archive:hover {
  background: #b91c1c;
  transform: scale(1.1);
}

/* ==================== 消息提示 ==================== */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-top: 16px;
  text-align: center;
  font-weight: 500;
}

.message.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.message.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ==================== 页脚 ==================== */
.footer {
  text-align: center;
  margin-top: 20px;
}

.footer a {
  color: white;
  opacity: 0.8;
  text-decoration: none;
  font-size: 0.9rem;
}

.footer a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ==================== 管理员页面 ==================== */
.admin-body {
  background: var(--gray-100);
}

/* 登录页面 */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--gray-800);
}

.back-link {
  text-align: center;
  margin-top: 20px;
}

.back-link a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link a:hover {
  text-decoration: underline;
}

/* 管理面板 */
.dashboard {
  max-width: 1000px;
  margin: 0 auto;
  padding: 30px 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 16px;
}

.dashboard-header h1 {
  color: var(--gray-800);
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* 课程列表 */
.course-list {
  display: grid;
  gap: 16px;
}

.course-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.course-card:hover {
  box-shadow: var(--shadow-lg);
}

.course-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.course-card-header h3 {
  color: var(--gray-800);
  font-size: 1.2rem;
}

.course-card-actions {
  display: flex;
  gap: 8px;
}

.course-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  font-size: 0.9rem;
}

.course-info p {
  color: var(--gray-600);
}

.course-info strong {
  color: var(--gray-700);
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-small {
  max-width: 420px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
  color: var(--gray-800);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
}

.btn-close:hover {
  color: var(--gray-600);
}

.modal-content form {
  padding: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* 学生表区域 */
.students-section {
  margin-top: 8px;
}

.students-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.students-import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-xlsx {
  background: #16a34a;
}

.btn-xlsx:hover {
  background: #15803d;
}

.file-name-hint {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.students-batch {
  margin-bottom: 12px;
}

.students-batch textarea {
  min-height: 60px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.students-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.student-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}

.student-item:last-child {
  border-bottom: none;
}

.student-item .remove-student {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
}

.student-item .remove-student:hover {
  color: #b91c1c;
}

/* 作业配置 */
.assignment-config {
  background: var(--gray-50);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.assignments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.assignment-item {
  background: var(--gray-50);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.assignment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.assignment-header .assign-name-input {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
}

.btn-remove-assign {
  background: var(--danger);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-remove-assign:hover {
  background: #b91c1c;
}

.btn-add-assign {
  background: var(--primary);
  color: white;
}

.btn-add-assign:hover {
  background: var(--primary-dark);
}

.sub-label {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--gray-600);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state p {
  font-size: 1.1rem;
}

/* ==================== 提交查看器 ==================== */
.submission-content {
  padding: 24px;
}

.submission-header {
  margin-bottom: 20px;
}

.submission-header h3 {
  margin-bottom: 12px;
  color: var(--gray-800);
}

.submission-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.stat-item {
  font-size: 0.95rem;
  color: var(--gray-600);
}

.stat-item strong {
  color: var(--gray-800);
}

.stat-item.submitted strong {
  color: var(--success);
}

.stat-item.not-submitted strong {
  color: var(--danger);
}

.submission-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.95rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.sub-table thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
}

.sub-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-600);
}

.sub-table tbody tr:hover {
  background: var(--gray-50);
}

.file-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.file-badge.submitted {
  background: var(--success-light);
  color: var(--success);
}

.file-badge.not-submitted {
  background: var(--danger-light);
  color: var(--danger);
}

.empty-row {
  text-align: center;
  color: var(--gray-400);
  padding: 30px !important;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.error-msg {
  text-align: center;
  padding: 20px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 600px) {
  .container {
    padding: 20px 16px;
  }

  .header h1 {
    font-size: 1.6rem;
  }

  .form-card {
    padding: 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button {
    flex: 1;
  }

  .students-input-row {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-height: 95vh;
  }

  .submission-stats {
    flex-direction: column;
    gap: 8px;
  }

  .sub-table {
    font-size: 0.8rem;
  }

  .sub-table thead th,
  .sub-table tbody td {
    padding: 8px;
  }
}
