/* ================================================================
   选课系统 - 全局样式（支持亮色/暗色主题）
   ================================================================ */

/* ---------- CSS 变量（亮色默认） ---------- */
:root {
  --bg-body: #f0f2f5;
  --bg-card: #fff;
  --bg-input: #fff;
  --bg-hover: #fafafa;
  --bg-menu-hover: #f5f5f5;
  --bg-btn-reset-hover: #f0f2ff;

  --text-primary: #333;
  --text-secondary: #666;
  --text-tertiary: #888;
  --text-label: #888;

  --border: #d9d9d9;
  --border-light: #e0e0e0;
  --border-table-head: #e8e8e8;
  --border-table-row: #f0f0f0;

  --primary: #667eea;
  --primary-hover: #5a6fd6;
  --primary-light: rgba(102,126,234,0.10);
  --primary-light2: rgba(102,126,234,0.15);

  --error: #e74c3c;
  --success: #52c41a;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.15);

  --login-grad-1: #667eea;
  --login-grad-2: #764ba2;
}

/* ---------- 暗色主题 ---------- */
html[data-theme="dark"] {
  --bg-body: #16162a;
  --bg-card: #1e1e3a;
  --bg-input: #2a2a48;
  --bg-hover: #282850;
  --bg-menu-hover: #303058;
  --bg-btn-reset-hover: #303058;

  --text-primary: #e0e0e0;
  --text-secondary: #aaa;
  --text-tertiary: #888;
  --text-label: #999;

  --border: #3e3e5c;
  --border-light: #3e3e5c;
  --border-table-head: #3e3e5c;
  --border-table-row: #2a2a48;

  --primary: #8b9cf7;
  --primary-hover: #7b8cf0;
  --primary-light: rgba(139,156,247,0.12);
  --primary-light2: rgba(139,156,247,0.18);

  --error: #f87171;
  --success: #4ade80;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.40);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.50);

  --login-grad-1: #2d2d5e;
  --login-grad-2: #3d2d6e;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
}

/* ================================================================
   Login Page
   ================================================================ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--login-grad-1) 0%, var(--login-grad-2) 100%);
  position: relative;
}

.login-card {
  width: 400px;
  padding: 40px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.login-title {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 30px;
  font-weight: 600;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: left;
}

.login-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light2);
}

.login-error {
  color: var(--error);
  font-size: 13px;
  text-align: left;
}

.login-btn {
  height: 44px;
  background: linear-gradient(135deg, var(--login-grad-1) 0%, var(--login-grad-2) 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- 登录页主题切换 ---------- */
.login-theme-toggle {
  position: absolute;
  top: 20px;
  right: 24px;
}

/* ================================================================
   Main Page
   ================================================================ */
.main-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- 顶部栏 ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
  padding: 0 4px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- 主题切换组件 ---------- */
.theme-switcher {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.theme-btn {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.theme-btn:last-child {
  border-right: none;
}

.theme-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- 检索区 ---------- */
.search-bar {
  background: var(--bg-card);
  padding: 20px 24px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.search-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-item label {
  font-size: 13px;
  color: var(--text-label);
  font-weight: 500;
}

.search-item select,
.search-item input[type="text"] {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  min-width: 140px;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.search-item select:focus,
.search-item input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.search-sort .sort-options {
  display: flex;
  gap: 16px;
  height: 36px;
  align-items: center;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
}

.search-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  min-width: 160px;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.btn-reset {
  height: 36px;
  padding: 0 28px;
  background: var(--bg-card);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-reset:hover {
  background: var(--bg-btn-reset-hover);
}

/* ---------- 表格工具栏 ---------- */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 12px;
}

.toolbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-logout {
  height: 32px;
  padding: 0 14px;
  background: var(--bg-card);
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--error);
  color: #fff;
}

/* 列设置 */
.column-toggle {
  position: relative;
  display: inline-block;
}

.btn-columns {
  height: 32px;
  padding: 0 14px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.col-menu {
  position: absolute;
  right: 0;
  top: 36px;
  min-width: 150px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  padding: 8px 0;
  z-index: 99;
}

.col-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}

.col-menu-item:hover {
  background: var(--bg-menu-hover);
}

.col-menu-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

/* ---------- 表格区 ---------- */
.table-wrapper {
  position: relative;
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 16px 24px;
  min-height: 200px;
}

.table-scroll {
  overflow-x: auto;
}

.course-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 600px;
}

.course-table thead th {
  position: relative;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--border-table-head);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
}

.resize-handle:hover,
.resize-handle:active {
  background: var(--primary);
  opacity: 0.4;
}

.course-table tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-table-row);
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-table tbody tr:hover {
  background: var(--bg-hover);
}

.col-check {
  text-align: center;
}

.col-check input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.empty-state,
.loading-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-tertiary);
  font-size: 15px;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 8px;
}

.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination button:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.page-info {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-right: 8px;
}

.page-size-select {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  margin-right: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
}

/* ---------- 浮动层 ---------- */
.floating-panel {
  position: fixed;
  right: 24px;
  top: 140px;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 1000;
  pointer-events: auto;
}

.floating-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-table-row);
}

.floating-textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 12px;
  font-family: "Consolas", "Monaco", monospace;
  resize: vertical;
  outline: none;
  background: var(--bg-hover);
  color: var(--text-primary);
}

.floating-textarea:focus {
  border-color: var(--primary);
}

.btn-copy {
  width: 100%;
  height: 34px;
  margin-top: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* 统计信息 */
.floating-stats {
  padding: 8px 0;
  border-top: 1px solid var(--border-table-row);
  margin-top: 4px;
}

.stat-row {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  line-height: 1.6;
}

.stat-row b {
  color: var(--text-primary);
  font-weight: 600;
}

/* 复制提示 */
.copy-msg {
  padding: 6px 0 2px;
  font-size: 12px;
  color: var(--success);
  text-align: center;
}

/* 返回顶部 */
.btn-back-top {
  width: 100%;
  height: 30px;
  margin-top: 6px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-back-top:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

