/* ==========================================
   高中物理教学演示平台 - 简洁学术风
   主色调：蓝色系 #2563eb
   ========================================== */

/* ---------- 基础重置 ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-sm: 6px;
}

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

/* ---------- 顶部标题栏 ---------- */
.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: white;
  padding: 32px 20px 28px;
  text-align: center;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.title-icon {
  font-size: 1.5rem;
  margin-right: 6px;
}

.title-logo {
  height: 72px;
  width: auto;
  vertical-align: middle;
  margin-right: 10px;
  border-radius: 6px;
}

.site-subtitle {
  font-size: 0.95rem;
  opacity: 0.8;
  font-weight: 400;
}

/* ---------- 分类导航栏 ---------- */
.nav-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.nav-tab:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.nav-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.nav-tab.active .tab-badge {
  background: rgba(255,255,255,0.25);
  color: white;
}

.tab-badge {
  display: inline-block;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* ---------- 主内容区 ---------- */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* 分类标题区 */
.category-header {
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.category-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.category-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex: 1;
}

.program-count {
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 16px;
}

/* ---------- 卡片网格 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ---------- 程序卡片 ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.card-accent {
  height: 4px;
  background: var(--card-accent, var(--primary));
}

.card-link {
  text-decoration: none;
  color: inherit;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-body {
  padding: 18px 20px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 删除按钮 */
.btn-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 2;
  line-height: 1;
}

.btn-delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* 下载按钮 */
.btn-download {
  position: absolute;
  top: 10px;
  right: 44px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 2;
  line-height: 1;
}

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

.card-cat-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.card-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.card-arrow {
  color: var(--primary);
  font-weight: 500;
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.2s ease;
}

.card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

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

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 12px;
}

.empty-hint {
  display: inline-block;
  background: var(--bg);
  border: 1px dashed var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.empty-hint code {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}

/* ---------- 加载错误 ---------- */
.load-error {
  text-align: center;
  padding: 40px;
  color: #dc2626;
  background: #fef2f2;
  border-radius: var(--radius);
  grid-column: 1 / -1;
}

.load-error code {
  background: #fecaca;
  padding: 2px 6px;
  border-radius: 3px;
}

/* ---------- 底部 ---------- */
.footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
}

.footer-updated {
  margin-top: 4px;
  opacity: 0.7;
}

/* ==========================================
   响应式设计
   ========================================== */

/* 平板 */
@media (max-width: 768px) {
  .site-title {
    font-size: 1.35rem;
  }

  .nav-bar {
    padding: 12px 12px 0;
    gap: 6px;
  }

  .nav-tab {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .tab-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }

  .category-header {
    flex-direction: column;
    gap: 6px;
  }

  .main-content {
    padding: 16px 12px 36px;
  }
}

/* 手机 */
@media (max-width: 480px) {
  .header {
    padding: 24px 12px 20px;
  }

  .site-title {
    font-size: 1.15rem;
  }

  .site-subtitle {
    font-size: 0.8rem;
  }

  .nav-bar {
    padding: 10px 8px 0;
    gap: 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-bar::-webkit-scrollbar {
    display: none;
  }

  .nav-tab {
    padding: 5px 10px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card-body {
    padding: 14px 16px;
  }
}

/* ==========================================
   上传按钮（顶部标题栏内）
   ========================================== */
.header-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.header-top > div:first-child {
  text-align: center;
}

.header-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-upload:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-upload-icon {
  font-size: 1.1rem;
}

.btn-approve {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-approve:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-1px);
}

.pending-badge {
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0 5px;
}

/* 审批列表 */
.approve-count {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pending-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.pending-cat {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.pending-info strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-file {
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.btn-approve-item,
.btn-reject-item {
  padding: 6px 12px;
  border: none;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-approve-item {
  background: #dcfce7;
  color: #166534;
}

.btn-approve-item:hover {
  background: #bbf7d0;
}

.btn-reject-item {
  background: #fef2f2;
  color: #991b1b;
}

.btn-reject-item:hover {
  background: #fecaca;
}

.approve-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==========================================
   上传弹窗
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-panel {
  background: var(--bg);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close:hover {
  background: #fee2e2;
  color: #dc2626;
}

.modal-body {
  padding: 20px 24px 24px;
}

/* ==========================================
   表单元素
   ========================================== */
.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  margin-top: 16px;
}

.form-label:first-child {
  margin-top: 0;
}

.form-select,
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  outline: none;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ==========================================
   文件拖拽区
   ========================================== */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

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

.file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.file-drop-icon {
  font-size: 2rem;
}

.file-drop-content span:nth-child(2) {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.file-drop-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}

.text-success {
  color: #10b981 !important;
  font-weight: 600;
}

/* 文件预览条 */
.file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.file-preview-icon {
  font-size: 1.1rem;
}

.file-preview-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ==========================================
   上传状态 & 按钮
   ========================================== */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-submit:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* 状态提示 */
.upload-status {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
}

.status-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.status-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.status-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.upload-note {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ==========================================
   Toast 提示
   ========================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================
   响应式 - 弹窗
   ========================================== */
@media (max-width: 480px) {
  .header-top {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .btn-upload {
    align-self: center;
    padding: 8px 16px;
    font-size: 0.82rem;
  }

  .modal-panel {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    max-height: 95vh;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-header { padding: 16px 18px 12px; }
  .modal-body { padding: 16px 18px 20px; }
}

/* ==========================================
   删除确认弹窗
   ========================================== */
.modal-panel-sm {
  max-width: 400px;
}

.delete-warning {
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.delete-warning strong {
  color: #dc2626;
  word-break: break-all;
}

.delete-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

.delete-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-cancel {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

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

.btn-danger {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: #dc2626;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 打印优化（课堂可能打印） */
@media print {
  .header {
    background: white !important;
    color: black !important;
    padding: 12px 0;
  }
  .nav-bar { display: none; }
  .card-arrow { display: none; }
  .btn-upload { display: none; }
  .modal-overlay { display: none !important; }
}
