/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    min-height: 100vh;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 确保 hidden 类优先级最高，覆盖所有其他显示规则 */
.hidden.superadmin-only,
.hidden.admin-only,
.hidden.teacher-only,
body.is-superadmin .hidden.superadmin-only,
body.is-admin .hidden.admin-only,
body.is-teacher .hidden.teacher-only,
body.is-superadmin .content-page.hidden.superadmin-only,
body.is-admin .content-page.hidden.admin-only,
body.is-teacher .content-page.hidden.teacher-only {
    display: none !important;
}

/* 确保用户管理页面只在显示时才可见 */
#userManage.hidden {
    display: none !important;
}

/* 登录页面 */
#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ff3838;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* 主页面布局 */
#mainPage {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    min-height: 100vh;
}

/* 顶部导航 */
.header {
    grid-area: header;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    color: #666;
    font-size: 14px;
    transition: background-color 0.2s;
}

.user-dropdown-trigger:hover {
    background-color: #f0f0f0;
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.user-dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 140px;
    z-index: 200;
    overflow: hidden;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    transition: background-color 0.15s;
}

.user-dropdown-menu a:hover {
    background-color: #f5f7fa;
    color: #333;
}

.user-dropdown-menu hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 4px 0;
}

.user-dropdown-menu .logout-link {
    color: #e74c3c;
}

.user-dropdown-menu .logout-link:hover {
    background-color: #fef0ef;
}

/* 侧边栏 */
.sidebar {
    grid-area: sidebar;
    background: white;
    border-right: 1px solid #e8e8e8;
    padding: 20px 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
}

.nav-item {
    padding: 14px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #666;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #f5f7fa;
    color: #667eea;
}

.nav-item.active {
    background: #f0f3ff;
    color: #667eea;
    border-left-color: #667eea;
}

.nav-item .icon {
    font-size: 18px;
}

/* 主内容区 */
.main-content {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}

.content-page {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    color: #333;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* 表格样式 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.data-table .actions {
    display: flex;
    gap: 8px;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.filter-bar select {
    min-width: 150px;
}

/* 签到表样式 */
.attendance-sheet {
    overflow-x: auto;
}

.attendance-sheet table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

.attendance-sheet th,
.attendance-sheet td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.attendance-sheet th {
    background: #f8f9fa;
    font-weight: 600;
}

.attendance-sheet .student-name {
    text-align: left;
    font-weight: 500;
}

.attendance-sheet .status-check {
    color: #52c41a;
    font-size: 18px;
}

.attendance-sheet .status-absent {
    color: #ff4d4f;
    font-size: 14px;
}

.attendance-sheet .status-leave {
    color: #faad14;
    font-size: 14px;
}

/* 学员课时登记表样式 */
.student-attendance-sheet {
    margin-top: 20px;
}

.student-info-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    margin: -24px -24px 20px -24px;
}

.student-info-header h3 {
    margin-bottom: 8px;
}

.student-info-header p {
    opacity: 0.9;
    font-size: 14px;
}

/* 课时统计卡片 */
.hours-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-item {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-item .value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.stat-item .label {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* 签到状态选择 */
.attendance-status {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.attendance-status label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.3s;
}

.attendance-status label:hover {
    background: #f0f0f0;
}

.attendance-status input[type="radio"] {
    cursor: pointer;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 900px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 18px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e8e8e8;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* 学员列表（签到用） */
.student-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    margin-bottom: 8px;
}

.student-list-item span {
    font-weight: 500;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    font-size: 16px;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 36px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.stat-card .stat-label {
    color: #666;
    font-size: 14px;
}

/* 课时不足警告 */
.low-hours {
    color: #ff4d4f;
    font-weight: bold;
}

.warning-badge {
    background: #fff2f0;
    color: #ff4d4f;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid #ffccc7;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #mainPage {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "header"
            "main";
    }
    
    .sidebar {
        display: none;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-bar select,
    .filter-bar input {
        width: 100%;
    }
}

/* 班级多选复选框组 */
.checkbox-group {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 14px;
    color: #333;
    user-select: none;
}

.checkbox-item:hover {
    background-color: #f0f3ff;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #667eea;
    flex-shrink: 0;
}

.checkbox-group-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* 打印样式 */
@media print {
    .header,
    .sidebar,
    .btn,
    .filter-bar {
        display: none !important;
    }
    
    #mainPage {
        display: block;
    }
    
    .content-page {
        display: block !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* 管理员专用 */
.admin-only {
    display: none;
}

body.is-admin .admin-only {
    display: block;
}

body.is-admin .nav-item.admin-only {
    display: flex;
}

/* 上课老师专用（教务老师不可见） */
.teacher-only {
    display: none;
}

body:not(.is-admin) .teacher-only,
body.is-teacher .teacher-only {
    display: inline-block;
}

body.is-teacher .nav-item.teacher-only {
    display: flex;
}

/* 管理员专用（仅superadmin可见） */
.superadmin-only {
    display: none !important;
}

.nav-item.superadmin-only {
    display: none !important;
}

body.is-superadmin .superadmin-only {
    display: block !important;
}

body.is-superadmin .nav-item.superadmin-only {
    display: flex !important;
}

/* 签到表头部信息 */
.attendance-header-info {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
}

.attendance-header-info div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attendance-header-info label {
    font-weight: 600;
    color: #666;
}

.attendance-header-info span {
    color: #333;
}

/* 课程内容显示 */
.course-content-display {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.course-content-display label {
    font-weight: 600;
    color: #096dd9;
    margin-right: 8px;
}

/* 备注区域 */
.remarks-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e8e8e8;
}

.remarks-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #666;
}

.remarks-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}