@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {
  /* 核心配色：深蓝科技风 */
  --bg-body: #f0f2f5; /* 浅色背景，更适合管理系统 */
  --bg-sidebar: #001529;
  --bg-card: #ffffff;
  
  --primary: #1890ff;
  --primary-hover: #40a9ff;
  --success: #52c41a;
  --warning: #faad14;
  --error: #f5222d;
  
  --text-main: #262626;
  --text-secondary: #8c8c8c;
  --border-color: #d9d9d9;
  --divider: #f0f0f0;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 8px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
}

/* 布局容器 */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* 侧边导航 (School, Finance, Report) */
.sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all 0.3s;
}

.sidebar .brand {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  gap: 10px;
}
.sidebar .brand i { color: var(--primary); font-size: 24px; }

.nav-menu {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .nav-item {
  padding: 12px 24px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.sidebar .nav-item:hover {
  color: white;
  background: rgba(255,255,255,0.05);
}

.sidebar .nav-item.active {
  color: white;
  background: linear-gradient(90deg, var(--primary), rgba(24, 144, 255, 0.6));
  border-left-color: #fff;
}

.sidebar .logout {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Admin Sidebar User Info */
.sidebar .user-info {
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.1);
}

.sidebar .user-info .avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar .user-info .user-details {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sidebar .user-info .name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
  line-height: 1.2;
}

.sidebar .user-info .role {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  line-height: 1.2;
  margin-top: 2px;
}

.sidebar .user-info .logout-btn {
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.3s;
  padding: 8px;
  border-radius: 4px;
}

.sidebar .user-info .logout-btn:hover {
  color: var(--error);
  background: rgba(255,255,255,0.1);
}

/* 顶部导航 (Index, Parents) */
.app-header {
  background: var(--bg-sidebar);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
}
.app-header .brand i { color: var(--primary); font-size: 24px; }

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-links .nav-item {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-links .nav-item:hover, .nav-links .nav-item.active { color: white; }


/* 主内容区头部 (Breadcrumb & Profile) */
.top-header {
  height: 64px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0,21,41,0.08);
  margin-bottom: 24px;
}

.breadcrumb {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.user-profile img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.notification-badge {
  position: relative;
  margin-right: 16px;
  cursor: pointer;
  color: var(--text-secondary);
}

.notification-badge .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--error);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box; /* Fix padding issue */
}

/* 通用组件：卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--divider);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 12px;
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--primary); }

/* 表单元素 */
input, select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  outline: none;
  transition: all 0.3s;
  font-size: 14px;
  width: 100%; /* Default full width */
  box-sizing: border-box;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-outline { background: white; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { color: var(--primary); border-color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.data-table th {
  background: #fafafa;
  border-bottom: 1px solid var(--divider);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-main);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-main);
}
.data-table tr:hover td { background: #fafafa; }

/* 状态标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid;
}
.tag-green { background: #f6ffed; border-color: #b7eb8f; color: #52c41a; }
.tag-blue { background: #e6f7ff; border-color: #91d5ff; color: #1890ff; }
.tag-red { background: #fff1f0; border-color: #ffa39e; color: #f5222d; }
.tag-gold { background: #fffbe6; border-color: #ffe58f; color: #faad14; }

/* Toast 提示 */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toast {
  background: white;
  padding: 12px 20px;
  border-radius: 4px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  border-left: 4px solid var(--primary);
  animation: slideIn 0.3s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--error); }
.toast.warning i { color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 进度条 */
.progress-bar {
    background: #f5f5f5;
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
    width: 100%;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 100px;
    transition: width 0.5s ease;
}

/* KPI 卡片组 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.kpi-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.kpi-icon {
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 80px;
  opacity: 0.1;
  color: var(--primary);
}
.kpi-label { font-size: 14px; color: var(--text-secondary); }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 8px; color: var(--text-main); }

/* 课程网格（家长端） */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.course-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1px solid var(--divider);
}
.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.course-cover {
  height: 140px;
  background: linear-gradient(135deg, #a5b4fc, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 48px;
}
.course-body { padding: 16px; }
.course-name { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.course-info { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.course-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.price { font-size: 20px; font-weight: 700; color: var(--error); }

/* 实时监控特效 */
.monitor-screen {
  background: #000;
  color: #fff;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  border: 1px solid #333;
}
.monitor-scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  animation: scan 3s linear infinite;
  z-index: 2;
  pointer-events: none;
}
.monitor-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
  background-size: 100% 4px;
  z-index: 1;
  pointer-events: none;
}
@keyframes scan {
  0% { top: -5%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 105%; opacity: 0; }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 500px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-body {
  padding: 24px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* =========================================
   Mobile Responsiveness (手机端适配)
   ========================================= */
@media (max-width: 768px) {
  /* Layout */
  .app-container {
    flex-direction: column;
  }
  
  /* Sidebar -> Bottom Nav */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    flex-direction: row;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
    padding: 0;
    overflow: hidden;
  }
  
  .sidebar .brand {
    display: none;
  }
  
  .nav-menu {
    flex-direction: row;
    padding: 0;
    width: 100%;
    justify-content: space-around;
    gap: 0;
  }
  
  .sidebar .nav-item {
    flex-direction: column;
    padding: 4px;
    font-size: 10px;
    gap: 2px;
    justify-content: center;
    flex: 1;
    border-radius: 0;
    border-left: none;
    border-top: 3px solid transparent;
  }
  
  .sidebar .nav-item.active {
    border-left: none;
    border-top-color: var(--primary);
    background: rgba(255,255,255,0.05);
  }
  
  .sidebar .nav-item i {
    font-size: 20px;
  }
  
  .sidebar .logout,
  .sidebar .user-info {
    display: none;
  }
  
  /* Top Header */
  .app-header {
    padding: 0 16px;
  }
  .app-header .brand span {
    font-size: 16px;
  }
  .nav-links .nav-item span {
      display: none; /* Hide text, show icon only */
  }
  
  .top-header {
    padding: 0 16px;
  }
  
  .user-profile span {
    display: none;
  }
  
  /* Content */
  .main-content {
    margin-bottom: 60px; /* Space for bottom nav */
    padding: 16px;
  }
  
  /* Components */
  .kpi-grid, .course-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .modal-content {
    width: 95%;
    margin: 0 10px;
  }
  
  /* Hide toast on mobile if too many */
  #toast-container {
      top: 10px;
      right: 10px;
      left: 10px;
      width: auto;
  }
  .toast {
      min-width: 0;
      width: 100%;
      box-sizing: border-box;
  }
}
