/* ===== 基础样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #333;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }

/* ===== 顶部导航 ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left { display: flex; align-items: center; gap: 20px; }

.title { font-size: 18px; font-weight: 600; }

.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3f4f6;
  padding: 6px 12px;
  border-radius: 8px;
}

.nav-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.nav-btn:hover { background: #e5e7eb; }

#currentMonth { font-weight: 500; min-width: 100px; text-align: center; }

.admin-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* ===== 管理员工具栏 ===== */
.admin-toolbar {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  flex-wrap: wrap;
}

/* ===== 排课表容器 ===== */
.schedule-container {
  padding: 16px;
  padding-bottom: 80px;
}

.schedule-wrapper {
  overflow: auto;
  max-height: calc(100vh - 200px);
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #fff;
}

/* ===== Excel 风格表格 ===== */
.schedule-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid #e5e7eb;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

/* 表头 - 日期 */
.schedule-table thead th {
  background: #f6f8fa;
  padding: 10px 8px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 100px;
  border-bottom: 2px solid #d0d7de;
}

.schedule-table thead th.today {
  background: #dbeafe;
  color: #1d4ed8;
}

.schedule-table thead th.weekend {
  background: #fef3c7;
}

/* 行号列 */
.schedule-table .row-header {
  background: #f6f8fa;
  font-weight: 500;
  color: #6b7280;
  width: 50px;
  min-width: 50px;
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 2px solid #d0d7de;
}

.schedule-table thead th.corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  background: #f0f2f5;
  width: 50px;
  min-width: 50px;
}

/* 课程单元格 */
.course-cell {
  min-height: 60px;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  min-width: 100px;
}

.course-cell:hover {
  background: #eff6ff;
}

.course-cell.available { background: #fff; }
.course-cell.selected {
  background: #2563eb;
  color: #fff;
}
.course-cell.selected .course-time,
.course-cell.selected .course-price { color: #fff; }

.course-cell.full {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

.course-cell.full:hover { background: #f3f4f6; }

.course-cell.closed {
  background: #fef2f2;
  color: #fca5a5;
  cursor: not-allowed;
}

.course-cell.admin-selected {
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}

.course-time {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
  margin-bottom: 4px;
}

.course-price {
  font-size: 12px;
  color: #6b7280;
}

.course-status {
  font-size: 11px;
  margin-top: 2px;
}

.course-cell.full .course-status { color: #9ca3af; }

/* 隐藏列 */
.hidden-col { display: none; }

/* ===== 底部已选栏 ===== */
.selected-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 100;
}

.selected-info {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 15px;
}

.selected-info strong { color: #2563eb; font-size: 18px; }

.total-price { color: #6b7280; }
.total-price strong { color: #dc2626; font-size: 20px; }

.selected-actions { display: flex; gap: 10px; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  animation: modalIn 0.2s ease;
}

.modal-lg .modal-content { max-width: 800px; }

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #6b7280;
}

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: #374151;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group { flex: 1; }

.weekday-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.weekday-checks label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: normal;
  cursor: pointer;
}

/* ===== 右键菜单 ===== */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 6px 0;
  min-width: 180px;
  z-index: 2000;
}

.context-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
}

.context-item:hover { background: #f3f4f6; }

/* ===== 登录页 ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 20px;
}

.error-msg {
  color: #dc2626;
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}

/* ===== 订单页 ===== */
.order-page {
  background: #f5f6f8;
  min-height: 100vh;
}

.order-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

.order-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.order-status {
  text-align: center;
  padding: 20px 0;
}

.order-status .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.order-status h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.order-status .countdown {
  color: #dc2626;
  font-size: 18px;
  font-weight: 600;
}

.order-info { margin-top: 16px; }

.order-info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.order-info-row:last-child { border-bottom: none; }

.order-info-row .label { color: #6b7280; }
.order-info-row .value { font-weight: 500; }

.order-courses { margin-top: 16px; }

.order-course-item {
  padding: 10px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.pay-section {
  text-align: center;
  padding: 20px 0;
}

.pay-btn {
  padding: 14px 40px;
  font-size: 16px;
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.pay-btn:hover { background: #06ad56; }

.debug-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-left: 6px;
}

/* 老师联系方式卡片 */
.teacher-contact {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-top: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 2px solid #2563eb;
}

.teacher-contact h3 {
  color: #2563eb;
  font-size: 20px;
  margin-bottom: 16px;
}

.teacher-contact .teacher-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.teacher-contact .contact-item {
  padding: 10px;
  background: #f0f9ff;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 15px;
}

.teacher-contact .contact-item .label {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 4px;
}

.teacher-contact .contact-item .value {
  font-weight: 600;
  color: #1d4ed8;
  font-size: 16px;
}

.teacher-tip {
  margin-top: 16px;
  padding: 12px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.6;
}

/* ===== 老师管理 ===== */
.teacher-list {
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
}

.teacher-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
}

.teacher-item-info { flex: 1; }
.teacher-item-name { font-weight: 500; margin-bottom: 4px; }
.teacher-item-contact { font-size: 12px; color: #6b7280; }

.teacher-item-actions { display: flex; gap: 8px; }

.teacher-form {
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.teacher-form h4 { margin-bottom: 16px; }

/* ===== 订单表格 ===== */
.order-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.order-filters select,
.order-filters input {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}

.order-table-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.order-table th,
.order-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.order-table th {
  background: #f6f8fa;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.status-paid { color: #059669; font-weight: 500; }
.status-pending { color: #d97706; font-weight: 500; }
.status-expired { color: #6b7280; }
.status-cancelled { color: #dc2626; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .top-bar { padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
  .title { font-size: 16px; }
  .month-nav { padding: 4px 8px; }
  #currentMonth { min-width: 80px; font-size: 13px; }
  
  .schedule-container { padding: 8px; padding-bottom: 100px; }
  .course-cell { min-width: 80px; padding: 6px 4px; min-height: 50px; }
  .course-time { font-size: 12px; }
  .course-price { font-size: 11px; }
  .schedule-table thead th { min-width: 80px; padding: 8px 4px; font-size: 12px; }
  
  .selected-bar { padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
  .selected-info { font-size: 13px; gap: 12px; }
  .selected-info strong { font-size: 16px; }
  .total-price strong { font-size: 18px; }
  
  .admin-toolbar { padding: 8px 12px; gap: 6px; }
  .admin-toolbar .btn { padding: 6px 10px; font-size: 12px; }
  
  .modal-content { width: 95%; }
  .form-row { flex-direction: column; gap: 0; }
}

@media (max-width: 480px) {
  .course-cell { min-width: 70px; }
  .schedule-table thead th { min-width: 70px; }
  .schedule-table .row-header { width: 40px; min-width: 40px; }
}
