/* University Business Style */

/* Global Styles */
:root {
  --primary-color: #003366; /* 深蓝色，代表专业和信任 */
  --secondary-color: #0066cc; /* 中蓝色，用于强调 */
  --accent-color: #ffcc00; /* 金色，代表卓越和成就 */
  --text-color: #333333; /* 深灰色，用于主要文本 */
  --light-text: #666666; /* 浅灰色，用于次要文本 */
  --background-color: #ffffff; /* 白色背景 */
  --light-background: #f8f9fa; /* 浅灰色背景，用于卡片和容器 */
  --border-color: #e0e0e0; /* 边框颜色 */
  --success-color: #28a745; /* 成功颜色 */
  --error-color: #dc3545; /* 错误颜色 */
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  background-color: var(--light-background);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* 隐藏可能的奇怪符号 */
* {
  box-sizing: border-box;
}

/* 确保没有意外的内容 */
body::before,
body::after {
  content: none !important;
}

/* 隐藏可能的空白字符 */
.container::before,
.container::after {
  content: none !important;
}

/* Container Styles */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  background-color: var(--background-color);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* Header Styles */
.header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-logo img {
  height: 60px;
  margin-right: 1rem;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-links {
  display: flex;
  gap: 1rem;
}

.header-links a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.header-links a:hover,
.header-links a:active,
.header-links a.active {
  color: var(--accent-color);
}

/* Navigation Styles */
.nav {
  background: linear-gradient(to bottom, #fafbfc 0%, #f0f4f8 100%);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 51, 102, 0.06);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
}

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.75rem;
}

.nav-links li {
  position: relative;
}

.nav-links a {
  display: block;
  padding: 0.65rem 1.4rem;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid rgba(0, 51, 102, 0.12);
  box-shadow: 0 1px 3px rgba(0, 51, 102, 0.08);
  transition: all 0.28s ease;
}

.nav-links a:hover,
.nav-links a:active,
.nav-links a.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0, 51, 102, 0.22);
  transform: translateY(-1px);
}

/* Title Styles */
.title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  text-align: center;
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 3px solid var(--accent-color);
  display: inline-block;
}

/* Search Area Styles */
.search-area {
  background-color: var(--light-background);
  padding: 2rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  align-items: center;
}

.search-form input,
.search-form select,
.search-form button {
  padding: 1rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  min-width: 180px;
  box-sizing: border-box;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.search-form input {
  min-width: 300px;
  font-size: 1rem;
}

.search-form select {
  min-width: 180px;
  font-size: 1rem;
  padding-right: 2.5rem;
  background-position: right 1rem center;
  color: var(--text-color);
  background-color: var(--background-color);
}

.search-form select option,
.form-group select option {
  color: var(--text-color);
  background-color: var(--background-color);
}

/* 下拉框默认值/选中值显示修复：用 span 覆盖显示，保证始终可见 */
.select-display-wrap {
  position: relative;
  display: inline-block;
  min-width: 180px;
  flex: 1 1 auto;
}

.search-form .select-display-wrap {
  min-width: 180px;
}

.select-display-wrap select {
  width: 100%;
  position: relative;
  z-index: 1;
  color: transparent; /* 隐藏原生显示，由下方 span 显示选中文案 */
}

.select-display-text {
  position: absolute;
  left: 1rem;
  right: 2.5rem;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
  color: var(--text-color);
  font-size: 1rem;
  z-index: 2; /* 覆盖在 select 上方，始终显示当前选中项 */
}

.form-group .select-display-wrap.form-select-wrap {
  width: 100%;
  min-width: unset;
  flex: none;
}

.form-group .select-display-text {
  left: 1rem;
  right: 2.5rem;
}

.search-form button {
  white-space: nowrap;
  font-size: 1rem;
  padding: 1rem 2rem;
}

.search-form input:focus,
.search-form select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.1);
}

/* Button Styles */
.btn {
  padding: 1rem 2rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

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

.btn-primary:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 51, 102, 0.3);
}

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

.btn-secondary:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

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

.btn-success:hover {
  background-color: #218838;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Advanced Search Panel */
.advanced-search-content {
  padding: 1.5rem;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-color);
}

.form-group select {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  padding-right: 2.5rem;
  background-position: right 1rem center;
  color: var(--text-color);
  background-color: var(--background-color);
}

.form-group label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 500;
  color: var(--text-color);
  white-space: nowrap;
  font-size: 1rem;
}

/* Results Styles */
#resultsCount {
  margin-top: 2rem;
  margin-bottom: 2rem;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--primary-color);
  text-align: center;
}

#results {
  margin-top: 2.5rem;
}

/* Card Styles */
.teacher-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.teacher-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.teacher-card h5 {
  color: var(--primary-color);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.75rem;
}

.teacher-card p {
  margin: 1rem 0;
  color: var(--text-color);
  font-size: 1.1rem;
}

.teacher-card .department {
  font-weight: 500;
  color: var(--secondary-color);
}

/* 公共空闲：老师标签列表 */
.teacher-list {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.teacher-item {
  display: inline-block;
  margin: 4px;
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 999px;
  background: #e3f2fd;
  color: #0b4f9c;
  cursor: pointer;
  transition: all 0.2s ease;
}

.teacher-item:hover {
  background: #bbdefb;
}

.teacher-item.selected {
  background: #0b4f9c;
  color: #ffffff;
}

/* Table Styles */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: normal;
  word-wrap: break-word;
  font-size: 1.1rem;
}

.table th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 1.2rem;
}

.table tr:hover {
  background-color: var(--light-background);
}

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

/* Export Button */
#export-container {
  display: flex;
  justify-content: flex-end;
  padding: 1.5rem 0;
  margin-bottom: 2rem;
}

#exportButton {
  display: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Error Message */
#error-message {
  margin: 2rem 0;
  padding: 1.5rem;
  border-radius: 4px;
  background-color: rgba(220, 53, 69, 0.1);
  border-left: 4px solid var(--error-color);
  color: var(--error-color);
  display: none;
  font-size: 1.1rem;
}

/* Footer Styles */
.footer {
  background-color: var(--primary-color);
  color: white;
  padding: 2rem 0;
  margin-top: 3rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-column {
  flex: 1;
  min-width: 250px;
  margin-bottom: 1.5rem;
}

.footer-column h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.footer-column p,
.footer-column a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  margin-bottom: 0.5rem;
  display: block;
}

.footer-column a:hover {
  color: var(--accent-color);
}

.footer-bottom {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 1rem 0;
  text-align: center;
  margin-top: 1.5rem;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
  }

  .header-content {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
  }

  .header-logo {
    margin-bottom: 1rem;
  }

  /* 顶部蓝色栏右侧链接在手机上横向滑动展示，避免两行竖排 */
  .header-links {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
    padding-bottom: 0.25rem;
  }

  .header-links a {
    white-space: nowrap;
    font-size: 0.85rem;
  }

  .title {
    font-size: 1.75rem;
  }

  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form input,
  .search-form select,
  .search-form button {
    width: 100%;
    min-width: unset;
  }

  .search-form .select-display-wrap {
    width: 100%;
    min-width: unset;
  }

  .teacher-schedule {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: 0.75rem;
    white-space: normal;
    word-wrap: break-word;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .footer-column {
    margin-bottom: 2rem;
  }

  .form-group select {
    width: 100%;
  }
}

/* Extra small phones: 适配更窄的手机屏幕 */
@media (max-width: 576px) {
  .title {
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
  }

  /* 顶部导航在手机上：改为可横向滑动，避免换行挤成竖排文字 */
  .nav-content {
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .nav-links a {
    white-space: nowrap;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
  }

  .search-area {
    padding: 1.25rem 1rem;
  }

  .search-form input,
  .search-form select,
  .search-form button {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }

  /* 课表区域：允许横向滚动，单元格更紧凑，避免“显示不全” */
  .teacher-schedule {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding: 0.5rem 0.5rem 1rem;
  }

  .teacher-schedule table {
    min-width: 640px; /* 保证 1 列时间 + 7 列周一~周日都有足够宽度，通过横向滚动查看 */
  }

  .teacher-schedule th,
  .teacher-schedule td {
    padding: 0.5rem 0.4rem;
    font-size: 0.78rem;
  }

  .footer {
    padding: 1.5rem 0;
  }
}

/* 手机端课表卡片视图（仿课程表 App 风格） */
.teacher-schedule-mobile {
  display: none;
  margin-top: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.teacher-schedule-mobile-header {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--primary-color);
}

.teacher-schedule-mobile .week-label {
  font-size: 0.85rem;
  color: var(--light-text);
  margin-bottom: 0.75rem;
}

.teacher-schedule-mobile-body {
  display: inline-flex;
  align-items: stretch;
  gap: 0.5rem;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.teacher-schedule-mobile .time-axis {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5rem 0;
  margin-right: 0.5rem;
}

.teacher-schedule-mobile .time-axis .time-slot-label {
  font-size: 0.75rem;
  color: var(--text-color);
  text-align: right;
  height: 150px;        /* 行高加宽，容纳更多内容 */
  line-height: 150px;
}

.teacher-schedule-mobile .days-wrapper {
  display: flex;
  flex: 0 0 auto;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.teacher-schedule-mobile .day-column {
  flex: 0 0 84px;
  display: grid;
  grid-auto-rows: 150px;   /* 与时间轴保持一致 */
  row-gap: 0.5rem;
}

.teacher-schedule-mobile .day-header {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.teacher-schedule-mobile .slot-card {
  border-radius: 12px;
  padding: 0.45rem 0.35rem;
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.3;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  min-height: 150px;       /* 与行高一致，避免被截断 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.teacher-schedule-mobile .slot-spacer {
  height: 150px;           /* 空行占位，保证行对齐 */
}

.teacher-schedule-mobile .slot-card .slot-time {
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 0.15rem;
}

.teacher-schedule-mobile .slot-card .slot-content {
  font-weight: 400;
}

.slot-color-0 { background: #4c6fff; }
.slot-color-1 { background: #ff7ab2; }
.slot-color-2 { background: #00b894; }
.slot-color-3 { background: #ffb347; }
.slot-color-4 { background: #9b59b6; }
.slot-color-5 { background: #3498db; }

@media (max-width: 768px) {
  /* 手机端默认使用卡片视图，隐藏表格版 */
  .teacher-schedule {
    display: none;
  }
  .teacher-schedule-mobile {
    display: block;
  }
}


@media (max-width: 992px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .header-logo {
    margin-bottom: 1rem;
  }

  .nav-links {
    justify-content: center;
  }
}

/* Animation Styles */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-area,
.advanced-search-content,
.teacher-card {
  animation: fadeIn 0.5s ease-out;
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 51, 102, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
  margin: 2rem auto;
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000080;
    --secondary-color: #0000ff;
    --accent-color: #ffcc00;
    --text-color: #000000;
    --light-text: #333333;
    --background-color: #ffffff;
    --light-background: #f0f0f0;
    --border-color: #000000;
  }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #1a365d;
    --secondary-color: #2b6cb0;
    --accent-color: #ffd700;
    --text-color: #e2e8f0;
    --light-text: #a0aec0;
    --background-color: #1a202c;
    --light-background: #2d3748;
    --border-color: #4a5568;
  }
  
  body {
    background-color: #171923;
  }
  
  .table {
    background-color: var(--light-background);
  }
  
  .teacher-card {
    background-color: var(--light-background);
  }
  
  .advanced-search-content {
    background-color: var(--light-background);
  }
  
  .search-area {
    background-color: var(--light-background);
  }
}