* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #9b59b6;
  --primary-dark: #8e44ad;
  --primary-light: #a569bd;
  --secondary: #3498db;
  --accent: #e74c3c;
  --magic-gold: #f1c40f;
  --magic-cyan: #1abc9c;
  --magic-pink: #ff6b9d;
  --dark: #1a1a2e;
  --dark-secondary: #16213e;
  --dark-tertiary: #0f3460;
  --light: #ecf0f1;
  --white: #ffffff;
  --glass: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
}

body {
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--dark);
  color: var(--light);
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ==================== 登录页魔法背景 ==================== */
.magic-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #16213e 75%, #1a1a2e 100%);
  z-index: -2;
  overflow: hidden;
}

.magic-bg::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(155, 89, 182, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(52, 152, 219, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(241, 196, 15, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(255, 107, 157, 0.2) 0%, transparent 40%);
  animation: magicPulse 8s ease-in-out infinite;
}

.magic-bg::after {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='1' fill='rgba(255,255,255,0.1)'/%3E%3C/svg%3E");
  background-size: 50px 50px;
  animation: starsMove 60s linear infinite;
  opacity: 0.5;
}

@keyframes magicPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

@keyframes starsMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-25%, -25%); }
}

/* ==================== 登录容器 ==================== */
.login-container {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 40px;
  text-align: center;
}

.login-logo {
  font-size: 100px;
  margin-bottom: 20px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(241, 196, 15, 0.5));
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(5deg); }
  75% { transform: translateY(-10px) rotate(-5deg); }
}

.login-title {
  font-size: 32px;
  color: var(--white);
  margin-bottom: 10px;
  text-shadow: 0 0 30px rgba(155, 89, 182, 0.8);
  font-weight: 300;
  letter-spacing: 5px;
}

.login-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 40px;
  letter-spacing: 2px;
}

/* ==================== 表单 ==================== */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group input {
  width: 100%;
  padding: 18px 20px;
  border: 2px solid var(--glass-border);
  border-radius: 16px;
  background: var(--glass);
  color: var(--white);
  font-size: 16px;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(10px);
}

.form-group input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.form-group input:focus {
  outline: none;
  border-color: var(--magic-gold);
  background: rgba(241, 196, 15, 0.1);
  box-shadow: 0 0 30px rgba(241, 196, 15, 0.3), inset 0 0 20px rgba(241, 196, 15, 0.1);
  transform: scale(1.02);
}

.btn-magic {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, var(--magic-pink) 100%);
  color: var(--white);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 40px rgba(155, 89, 182, 0.4);
  letter-spacing: 3px;
  position: relative;
  overflow: hidden;
}

.btn-magic::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: rotate(45deg);
  transition: all 0.5s;
  opacity: 0;
}

.btn-magic:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 20px 60px rgba(155, 89, 182, 0.6);
}

.btn-magic:hover::before {
  opacity: 1;
  left: 100%;
}

.btn-magic:active {
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.15);
  border-color: var(--primary);
}

.links {
  margin-top: 30px;
}

.links a {
  color: var(--magic-gold);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s;
  letter-spacing: 1px;
}

.links a:hover {
  color: var(--white);
  text-shadow: 0 0 20px var(--magic-gold);
}

/* ==================== 主页面布局 ==================== */
#main-page {
  display: flex;
  min-height: 100vh;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, var(--dark-secondary) 0%, var(--dark) 100%);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--glass-border);
  box-shadow: 10px 0 40px rgba(0,0,0,0.3);
}

.sidebar-header {
  padding: 30px 20px;
  text-align: center;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-logo {
  font-size: 60px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 20px rgba(241, 196, 15, 0.5));
}

.sidebar-title {
  font-size: 18px;
  color: var(--white);
  letter-spacing: 3px;
  font-weight: 300;
}

.sidebar-user {
  padding: 20px;
  background: var(--glass);
  margin: 15px;
  border-radius: 16px;
  text-align: center;
  border: 1px solid var(--glass-border);
}

.sidebar-user .name {
  font-size: 16px;
  color: var(--white);
  margin-bottom: 8px;
}

.sidebar-user .role {
  display: inline-block;
  padding: 5px 15px;
  background: linear-gradient(135deg, var(--primary), var(--magic-pink));
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 1px;
}

.nav-menu {
  flex: 1;
  list-style: none;
  padding: 10px 15px;
  overflow-y: auto;
}

.nav-item {
  margin-bottom: 5px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s;
  border: 1px solid transparent;
}

.nav-item a:hover,
.nav-item a.active {
  background: linear-gradient(135deg, rgba(155, 89, 182, 0.3), rgba(255, 107, 157, 0.2));
  color: var(--white);
  border-color: var(--glass-border);
}

.nav-item a .icon {
  font-size: 24px;
}

.nav-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 15px 0;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--glass-border);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--accent);
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s;
}

.sidebar-footer a:hover {
  background: rgba(231, 76, 60, 0.2);
}

/* ==================== 主内容区 ==================== */
.main-content {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
  background: transparent;
}

.top-bar {
  background: rgba(22, 33, 62, 0.9);
  backdrop-filter: blur(20px);
  padding: 20px 30px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--glass-border);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 28px;
  cursor: pointer;
}

.top-bar h2 {
  font-size: 24px;
  color: var(--white);
  font-weight: 300;
  letter-spacing: 2px;
}

.top-bar-breadcrumb {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
}

.content-area {
  padding: 30px;
}

/* ==================== 卡片 ==================== */
.card {
  background: linear-gradient(135deg, rgba(22, 33, 62, 0.9), rgba(15, 52, 96, 0.8));
  border-radius: 24px;
  padding: 30px;
  margin-bottom: 25px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--magic-gold), var(--magic-pink));
}

.card-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}

.card-header .icon {
  font-size: 36px;
  filter: drop-shadow(0 0 10px rgba(241, 196, 15, 0.5));
}

.card-header h3 {
  font-size: 20px;
  color: var(--white);
  font-weight: 400;
  letter-spacing: 2px;
}

/* ==================== 模块网格 ==================== */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  margin-top: 25px;
}

.module-card {
  background: linear-gradient(135deg, rgba(155, 89, 182, 0.2), rgba(255, 107, 157, 0.1));
  border-radius: 20px;
  padding: 35px 25px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.module-card:hover {
  transform: translateY(-10px) scale(1.02);
  border-color: var(--magic-gold);
  box-shadow: 0 30px 80px rgba(155, 89, 182, 0.4);
}

.module-card:hover::before {
  opacity: 1;
}

.module-card .icon {
  font-size: 60px;
  margin-bottom: 20px;
  display: block;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
}

.module-card h4 {
  color: var(--white);
  font-size: 18px;
  margin-bottom: 10px;
  font-weight: 400;
}

.module-card p {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
}

/* 数据库选择器 */
.workspace-selector {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 15px 20px;
  color: var(--white);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
}

/* ==================== 数据列表 ==================== */
.data-list {
  margin-top: 20px;
}

.data-item {
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--glass-border);
  transition: all 0.3s;
}

.data-item:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--primary);
}

.data-item .info h4 {
  color: var(--white);
  margin-bottom: 8px;
  font-size: 16px;
}

.data-item .info p {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  line-height: 1.6;
}

.data-item .info .meta {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-top: 10px;
}

.data-item .actions {
  display: flex;
  gap: 10px;
}

.btn-sm {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
}

.btn-edit {
  background: var(--secondary);
  color: var(--white);
}

.btn-edit:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

.btn-delete {
  background: var(--accent);
  color: var(--white);
}

.btn-delete:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

/* 表单 */
.card form {
  display: grid;
  gap: 20px;
}

.card form input,
.card form textarea,
.card form select {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--white);
  font-size: 15px;
  transition: all 0.3s;
}

.card form textarea {
  min-height: 150px;
  resize: vertical;
}

.card form input:focus,
.card form textarea:focus,
.card form select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(155, 89, 182, 0.1);
}

/* ==================== 表格 ==================== */
.table-container {
  overflow-x: auto;
  margin-top: 20px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

th, td {
  padding: 18px 20px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

th {
  background: rgba(155, 89, 182, 0.2);
  color: var(--white);
  font-weight: 500;
  letter-spacing: 1px;
  font-size: 13px;
  text-transform: uppercase;
}

td {
  color: rgba(255,255,255,0.8);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ==================== 管理面板 ==================== */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 25px;
}

.admin-card {
  background: linear-gradient(135deg, rgba(22, 33, 62, 0.9), rgba(15, 52, 96, 0.8));
  border-radius: 20px;
  padding: 25px;
  border: 1px solid var(--glass-border);
}

.admin-card h4 {
  color: var(--white);
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.invite-code-box {
  background: linear-gradient(135deg, var(--primary), var(--magic-pink));
  border-radius: 16px;
  padding: 25px;
  text-align: center;
  margin: 20px 0;
}

.invite-code-box .code {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 5px;
  color: var(--white);
  font-family: monospace;
}

/* 复选框 */
.module-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 15px;
}

.module-checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.05);
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid transparent;
  font-size: 14px;
}

.module-checkboxes label:hover {
  background: rgba(155, 89, 182, 0.2);
  border-color: var(--primary);
}

.module-checkboxes input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--magic-gold);
}

/* 用户头像 */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--magic-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* ==================== Toast通知 ==================== */
.toast {
  position: fixed;
  bottom: 40px;
  right: 40px;
  padding: 18px 35px;
  border-radius: 16px;
  color: var(--white);
  font-size: 15px;
  z-index: 1000;
  animation: slideInRight 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.toast.success {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.toast.error {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==================== 空状态 ==================== */
.empty-state {
  text-align: center;
  padding: 80px 40px;
  color: rgba(255,255,255,0.5);
}

.empty-state .icon {
  font-size: 80px;
  margin-bottom: 25px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
  letter-spacing: 1px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 100%;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .menu-toggle {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .login-container {
    padding: 40px 25px;
  }
  
  .login-logo {
    font-size: 80px;
  }
  
  .login-title {
    font-size: 24px;
  }
  
  .module-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-grid {
    grid-template-columns: 1fr;
  }
  
  .data-item {
    flex-direction: column;
    gap: 15px;
  }
  
  .data-item .actions {
    width: 100%;
  }
  
  .data-item .actions button {
    flex: 1;
  }
  
  .top-bar {
    padding: 15px 20px;
  }

  .content-area {
    padding: 20px;
  }

  /* 手机端抖动修复：100dvh 动态视口高度 */
  @supports (height: 100dvh) {
    body, .sidebar, .main-content, .content-area {
      height: 100dvh;
      min-height: 100dvh;
    }
    .magic-bg {
      height: 100dvh;
    }
  }
  body {
    min-height: -webkit-fill-available;
  }

/* ==================== 手机端学生卡片布局（一行横排） ==================== */
  .student-list-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .student-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .student-card-top {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
  }

  .student-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .student-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .student-card-info {
    display: flex;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    flex-shrink: 0;
  }

  .student-card-info span {
    white-space: nowrap;
  }

  .student-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .student-card-actions .btn-sm {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
  }

  /* 手机端显示卡片隐藏表格；桌面端显示表格 */
  .student-list-table { display: none; }
  .student-list-cards { display: flex; }


  /* 手机端显示卡片隐藏表格；桌面端显示表格 */
  .student-list-table { display: none; }
  .student-list-cards { display: flex; }

}
/* ==================== 桌面端学生表格布局 ==================== */
.student-list-wrap {
  width: 100%;
}

.student-list-table {
  display: table;
}

.student-list-cards {
  display: none;
}

/* ==================== 弹窗样式 ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  
}

.modal-box {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 25px 30px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 20px 0;
  text-align: center;
}

.modal-message {
  color: rgba(255,255,255,0.7);
  text-align: center;
  margin: 15px 0;
}

.modal-icon {
  text-align: center;
  font-size: 40px;
  margin-bottom: 10px;
}

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

.modal-btn {
  padding: 10px 25px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.modal-btn-cancel {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}

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

.modal-btn-primary {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
}

.modal-btn-primary:hover {
  opacity: 0.9;
}

.modal-btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}

.modal-btn-danger:hover {
  opacity: 0.9;
}

.modal-input {
  width: 100%;
  padding: 10px 15px;
  border-radius: 10px;
  border: 2px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 14px;
  box-sizing: border-box;
}

.modal-input:focus {
  outline: none;
  border-color: #9b59b6;
}

.modal-input::placeholder {
  color: rgba(255,255,255,0.3);
}


/* ==================== 修复下拉列表样式 ==================== */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(30, 30, 50, 0.9) !important;
  color: #ffffff !important;
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 10px;
  padding: 10px 15px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

select:focus {
  border-color: #9b59b6 !important;
  outline: none;
}

select option {
  background-color: #1a1a2e !important;
  color: #ffffff !important;
  padding: 8px;
}
