/* ============================================================
   美世教育管理系统 - 全局样式
   ============================================================ */

/* CSS 变量 - 颜色和字体 */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --sidebar-width: 220px;
  --header-height: 56px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 30px;
}
.login-logo h1 {
  font-size: 24px;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-logo p {
  color: var(--gray-500);
  font-size: 13px;
}

/* ========== 布局 ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo h2 {
  font-size: 16px;
  color: #fff;
}
.sidebar-logo p {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}
.sidebar-nav {
  padding: 12px 0;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.sidebar-nav a.active {
  background: rgba(59,130,246,0.15);
  color: var(--primary-light);
  border-left-color: var(--primary-light);
}
.sidebar-nav .nav-icon {
  width: 20px;
  margin-right: 10px;
  text-align: center;
  font-size: 16px;
}
.sidebar-nav .nav-group-title {
  padding: 12px 20px 6px;
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}
.top-header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-header .page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}
.top-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-header .user-name {
  font-size: 14px;
  color: var(--gray-600);
}
.top-header .logout-btn {
  background: none;
  border: 1px solid var(--gray-300);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  transition: all 0.2s;
}
.top-header .logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-700);
}

.page-body {
  padding: 24px;
}

/* ========== 卡片 ========== */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}
.card-body {
  padding: 20px;
}

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-control.error {
  border-color: var(--danger);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* 单选/复选组 */
.radio-group, .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.radio-group label, .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  transition: all 0.2s;
  margin-bottom: 0;
}
.radio-group label:hover, .checkbox-group label:hover {
  border-color: var(--primary-light);
}
.radio-group input:checked + span,
.checkbox-group input:checked + span {
  color: var(--primary);
  font-weight: 500;
}
.radio-group label:has(input:checked),
.checkbox-group label:has(input:checked) {
  border-color: var(--primary-light);
  background: rgba(59,130,246,0.05);
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #059669; }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 表格 ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.data-table tr:hover td {
  background: var(--gray-50);
}
.data-table .actions {
  display: flex;
  gap: 6px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--gray-200);
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ========== 搜索栏 ========== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}
.search-box input {
  flex: 1;
}

/* ========== 合同预览页 ========== */
.contract-preview-wrapper {
  max-width: 800px;
  margin: 0 auto;
}
.contract-toolbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.contract-paper {
  background: #fff;
  padding: 50px 60px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  min-height: 1000px;
  font-size: 14px;
  line-height: 1.8;
  color: #000;
}
.contract-paper .contract-header {
  text-align: center;
  margin-bottom: 12px;
  border-bottom: none;
  padding-bottom: 10px;
}
.contract-paper .contract-company-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
}
.contract-paper .contract-no {
  font-size: 13px;
  margin-top: 8px;
  color: #333;
}
.contract-paper .contract-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 24px 0;
  letter-spacing: 4px;
}
.contract-paper .contract-section {
  margin-bottom: 20px;
}
.contract-paper .contract-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}
.contract-paper .contract-preamble {
  margin: 16px 0;
  text-indent: 2em;
  text-align: justify;
}
.contract-paper .contract-section p {
  margin-bottom: 6px;
  text-align: justify;
}
.contract-paper .contract-section .indent {
  text-indent: 2em;
}
.contract-paper .contract-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}
.contract-paper .contract-table td {
  border: 1px solid #333;
  padding: 6px 10px;
  font-size: 13px;
}
.contract-paper .contract-table .label {
  background: #f5f5f5;
  font-weight: 600;
  width: 100px;
}
.contract-paper .contract-fee {
  margin-top: 12px;
  padding: 12px;
  background: #fafafa;
  border: 1px solid #ddd;
}
.contract-paper .contract-fee p {
  margin-bottom: 4px;
}
.contract-paper .contract-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 50px;
  gap: 40px;
}
.contract-paper .sign-block {
  flex: 1;
}
.contract-paper .sign-block p {
  margin-bottom: 12px;
}
.contract-paper .sign-line {
  border-bottom: 1px solid #333;
  padding-bottom: 20px;
  margin-bottom: 12px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 14px;
}

/* ========== 模态框 ========== */
.modal-overlay {
  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;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-400);
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: block;
  }
  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }
  .page-body {
    padding: 16px;
  }
  .contract-paper {
    padding: 20px;
    font-size: 13px;
  }
  .contract-paper .contract-signatures {
    flex-direction: row;
    gap: 20px;
  }
  .data-table {
    font-size: 12px;
  }
  .data-table th, .data-table td {
    padding: 8px 6px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .login-card {
    padding: 24px;
  }
}

/* ========== 打印样式 ========== */
@media print {
  body {
    background: #fff;
  }
  .sidebar, .top-header, .contract-toolbar, .no-print {
    display: none !important;
  }
  .main-content {
    margin-left: 0;
  }
  .page-body {
    padding: 0;
  }
  .contract-preview-wrapper {
    max-width: 100%;
  }
  .contract-paper {
    border: none;
    box-shadow: none;
    padding: 0;
    min-height: auto;
  }
  @page {
    size: A4;
    margin: 0;
  }
  body {
    margin: 0;
    padding: 0;
  }
  .contract-preview-wrapper {
    margin: 0 !important;
    padding: 0 !important;
  }
  .contract-paper {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  .contract-page {
    padding: 15mm 18mm !important;
    min-height: auto !important;
    box-shadow: none !important;
  }
}


/* ========== 新合同模板样式 ========== */
.contract-paper {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.contract-page {
  font-family: "Avenir", "PingFang SC", "苹方-简", "Helvetica Neue", sans-serif !important;
  color: #1a1a1a !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  position: relative;
  background: #fff;
  padding: 1cm !important;
  padding-bottom: 3.2cm !important;
  box-sizing: border-box;
  min-height: 29.7cm;
}
.contract-header {
  position: relative;
  text-align: center;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.header-left { position: absolute; left: 0; top: -5mm; }
.contract-logo { height: 35px !important; width: auto !important; max-width: 180px !important; object-fit: contain; display: block; }
.header-right { position: absolute; right: 0; top: -5mm; }
.contract-no-top { font-size: 9px; color: #333; font-family: "Avenir", sans-serif; }
.header-center { padding-top: 2px; }
.company-title { font-size: 22px !important; color: #c00000 !important; margin: 0 0 1px 0 !important; font-weight: 700 !important; letter-spacing: 1px; }
.contract-title { font-size: 20px !important; color: #000 !important; margin: 0 !important; font-weight: 600 !important; }
.parties-row { display: flex; gap: 8px; margin-bottom: 6px; }
.party-box { flex: 1; border: 1px solid #333; padding: 4px 6px; }
.party-label { font-weight: 700; margin-bottom: 2px; font-size: 13px; }
.info-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.info-table tr { height: 24px !important; }
.info-table td { padding: 2px 6px; vertical-align: middle; line-height: 1.5 !important; }
.info-label { white-space: nowrap; color: #333; }
.legal-basis { font-size: 11.5px; text-align: justify; margin-bottom: 6px; padding: 4px 6px; border: 1px solid #999; line-height: 1.5; }
.contract-page .contract-section { margin-bottom: 6px; }
.contract-page .contract-section h3 { font-size: 14px; font-weight: 700; margin: 0 0 3px 0; }
.contract-page .contract-section p { margin: 2px 0; font-size: 12px; text-align: justify; line-height: 1.5; }
.contract-page .indent { padding-left: 16px; }
.contract-page .indent2 { padding-left: 32px; }
.service-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 4px; table-layout: fixed; line-height: 1.5; }
.service-table th, .service-table td { border: 1px solid #333; padding: 5px 2px; text-align: center; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-table th { background: #f0f0f0; font-weight: 600; font-size: 10px; }
.service-table .grade-cell { white-space: nowrap; font-size: 11px; }
.service-table col.col-year { width: 6%; }
.service-table col.col-semester { width: 6%; }
.service-table col.col-grade { width: 7%; }
.service-table col.col-subject { width: 6%; }
.service-table col.col-classtype { width: 13%; }
.service-table col.col-hours { width: 5%; }
.service-table col.col-unit { width: 8%; }
.service-table col.col-total { width: 9%; }
.service-table col.col-start { width: 10%; }
.service-table col.col-end { width: 10%; }
.service-table col.col-absence { width: 11%; }
.fee-section { margin-bottom: 6px; font-size: 13px; }
.fee-section p { margin: 2px 0; }
.fee-row { display: flex; gap: 24px; }
.fee-row p { flex: 1; margin: 2px 0; }
.fee-amount { color: #c00000; font-size: 14px; }
.fee-discount { color: #d97706; }
.fee-deduction { color: #dc2626; }
.fee-actual { color: #c00000; font-size: 14px; font-weight: 700; }
.terms-reference { border: 1px solid #999; padding: 6px 10px; margin-bottom: 6px; text-align: center; font-size: 13px; font-weight: 600; }
.terms-reference p { margin: 0; }
.remark-section { border: 1px solid #999; padding: 6px 10px; margin-bottom: 6px; font-size: 12px; }
.remark-section p { margin: 0; }
.contract-signatures { display: flex; justify-content: space-between; position: absolute; bottom: 1.7cm; left: 1cm; right: 1cm; }
.sign-block { width: 48%; font-size: 13px; position: relative; }
.seal-area { position: relative; height: 34px; display: flex; align-items: center; font-size: 13px; }
.contract-seal { position: absolute; top: -6mm; left: 25mm; width: 38mm; height: 38mm; object-fit: contain; opacity: 0.85; pointer-events: none; }
.sign-item { height: 34px; display: flex; align-items: center; font-size: 13px; }
.sign-item-empty { height: 34px; }
.sign-label { white-space: nowrap; }
.sign-ul { flex: 1; border-bottom: 1px solid #333; min-height: 14px; margin-left: 4px; text-align: center; }
.parent-signature-img { max-height: 28px; width: auto; vertical-align: middle; }
.contract-no-top { font-size: 11px; color: #333; font-family: "Avenir", sans-serif; }
.contract-no-bottom { position: absolute; left: 1cm; bottom: 0.5cm; font-size: 11px; color: #666; font-family: "Avenir", sans-serif; }
.contract-page.page-2 { font-size: 8px !important; line-height: 1.35 !important; padding-top: 0.6cm !important; padding-bottom: 1cm !important; min-height: auto !important; }
.page-2 .contract-section { margin-bottom: 3px; }
.page-2 .contract-section h3 { font-size: 9.5px; margin-bottom: 1px; }
.page-2 .contract-section p { font-size: 8px; margin: 1px 0; line-height: 1.4; }
.page-2 .indent { padding-left: 12px; }
.page-2 .indent2 { padding-left: 24px; }
.supplementary-intro { font-size: 8px; margin-bottom: 4px; text-align: justify; line-height: 1.4; }
.supplementary-header { text-align: center; margin-bottom: 8px; padding-bottom: 5px; }
.company-title-small { font-size: 13px; color: #c00000; margin: 0 0 1px 0; font-weight: 700; }
.supplementary-title { font-size: 12px; margin: 0 0 1px 0; font-weight: 600; }
.supplementary-subtitle { font-size: 10px; margin: 0; color: #333; }
@media print {
  @page { size: A4; margin: 0; }
  body { margin: 0; padding: 0; }
  .contract-preview-wrapper { margin: 0 !important; padding: 0 !important; }
  .contract-page { padding: 1cm !important; padding-bottom: 3.2cm !important; min-height: 29.7cm !important; box-shadow: none !important; }
  .contract-page.page-2 { page-break-before: always; padding-top: 0.6cm !important; padding-bottom: 1cm !important; min-height: auto !important; }
  .contract-signatures { position: absolute !important; bottom: 1.7cm !important; left: 1cm !important; right: 1cm !important; }
  .contract-no-bottom { position: fixed; bottom: 0.5cm; left: 1cm; }
}

/* 强制移除合同标题边框 */
.contract-header { border-bottom: none !important; }
.supplementary-header { border-bottom: none !important; }

