/* =============================================
   1. 基础重置与全局变量（统一风格，方便修改）
   ============================================= */
:root {
    /* 主色调 */
    --primary-color: #165DFF;
    --primary-hover: #0d47a1;
    /* 危险色 */
    --danger-color: #F87272;
    --danger-hover: #d63031;
    /* 成功色 */
    --success-color: #52c41a;
    --success-hover: #43a817;
    --success-bg: #f6ffed;
    --success-border: #b7eb8f;
    /* 错误色 */
    --error-color: #f5222d;
    --error-bg: #fff2f0;
    --error-border: #ffccc7;
    /* 中性色 */
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #e8e8e8;
    --bg-light: #f5f5f5;
    --bg-white: #fff;
    /* 字体 */
    --font-family: "Microsoft Yahei", sans-serif;
    --line-height: 1.6;
    /* 新增：z-index 层级规范 */
    --z-header: 100;
    --z-footer: 100;
    --z-add-btn: 90;
    --z-modal: 1000;
}

/* 修复：基础重置更严谨 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 防止文本溢出 */
    word-wrap: break-word;
}

html, body {
    height: 100%;
    overflow-x: hidden; /* 防止横向滚动 */
}

body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: var(--line-height);
    /* 修复：底部留白，防止内容被footer遮挡 */
    padding-bottom: 0 !important;
    background: transparent !important;
}

/* =============================================
   2. 布局组件（页面结构复用）
   ============================================= */

/* 顶部导航 - 修复：定位与间距问题 */
.header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-header);
    /* 修复：防止导航内容溢出 */
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.header a {
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 15px;
    /* 优化：增加点击区域 */
    padding: 2px 0;
    display: inline-block;
}

.header a:hover {
    text-decoration: underline;
}

.header .admin-info {
    float: right;
    color: var(--text-secondary);
    /* 修复：防止被挤压 */
    margin-left: 20px;
}

/* 主内容区 - 修复：间距适配 */
.main {
    margin-top: 70px; /* 适配导航高度，避免遮挡 */
    padding: 20px 15px; /* 小屏幕优化 */
    /* 修复：最大宽度限制，防止大屏内容过宽 */
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.section-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--text-primary);
    /* 优化：增加底部边框，视觉更清晰 */
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* 页脚 - 修复：定位与层级 */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    z-index: var(--z-footer);
    /* 修复：防止文本换行错乱 */
    line-height: 1.4;
}

/* =============================================
   3. 表格与列表（数据展示）
   ============================================= */

.table-container {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
    /* 修复：小屏幕横向滚动 */
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* 修复：表格最小宽度，防止挤压 */
    min-width: 600px;
}

th, td {
    padding: 12px 15px; /* 优化：增加内边距，提升可读性 */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    /* 修复：文本溢出处理 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

th {
    background-color: #fafafa;
    font-weight: bold;
    color: var(--text-secondary);
    /* 修复：表头粘滞，滚动时可见 */
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:hover {
    background-color: var(--bg-light);
}

/* 最后一行去除下边框 */
tr:last-child td {
    border-bottom: none;
}

/* =============================================
   4. 按钮与交互元素（统一交互风格）
   ============================================= */

/* 基础按钮 - 修复：交互体验 */
.btn {
    display: inline-flex; /* 优化：居中对齐 */
    align-items: center;
    justify-content: center;
    padding: 6px 14px; /* 优化：内边距 */
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background-color: var(--bg-white);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px; /* 优化：字体大小 */
    cursor: pointer;
    margin-right: 8px; /* 优化：间距 */
    margin-bottom: 8px; /* 新增：换行时间距 */
    transition: all 0.2s ease; /* 优化：过渡效果 */
    /* 修复：最小点击区域 */
    min-height: 32px;
    min-width: 60px;
}

.btn:hover {
    opacity: 0.9; /* 优化：hover 透明度 */
    border-color: #b9b9b9;
}

.btn:active {
    /* 新增：点击反馈 */
    transform: scale(0.98);
}

/* 主要按钮（蓝色） */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* 危险按钮（红色） */
.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* 学习按钮 - 统一格式，修复 hover */
.btn-study {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
}

.btn-study:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
    opacity: 0.9;
}

/* 悬浮添加按钮 - 修复：定位与交互 */
.add-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #fff;
    font-size: 24px;
    text-align: center;
    line-height: 50px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
    z-index: var(--z-add-btn);
    /* 修复：防止点击穿透 */
    pointer-events: auto;
}

.add-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

/* =============================================
   5. 表单控件（输入、文本域等）
   ============================================= */

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    /* 修复：小屏幕换行 */
    flex-wrap: wrap;
}

.form-item {
    flex: 1;
    /* 修复：最小宽度，防止挤压 */
    min-width: 200px;
}

.form-item label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    /* 优化：加粗标签，提升可读性 */
    font-weight: 500;
}

.form-item input,
.form-item textarea {
    width: 100%;
    padding: 10px 12px; /* 优化：内边距 */
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
    /* 修复：最小高度 */
    min-height: 38px;
}

.form-item input:focus,
.form-item textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    /* 优化：焦点阴影 */
    box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1);
}

/* 文本域单独处理 */
.form-item textarea {
    min-height: 100px;
    resize: vertical; /* 仅允许垂直调整 */
    line-height: 1.6;
}

/* 仅用于是否启用复选框同行紧挨着显示 */
.enable-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 4px; /* 优化：间距，提升点击体验 */
    cursor: pointer;
    /* 修复：对齐方式 */
    vertical-align: middle;
}

.enable-checkbox input {
    margin: 0 !important;
    padding: 0;
    /* 修复：复选框大小 */
    width: 16px;
    height: 16px;
    min-height: auto;
}

/* =============================================
   6. 弹窗与模态框（交互弹窗）
   ============================================= */

/* 模态背景层 - 修复：显示逻辑 */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* 修复：防止点击穿透 */
    pointer-events: none;
}

.modal-backdrop.show {
    display: flex;
    pointer-events: auto;
}

/* 弹窗容器 - 优化：响应式 */
.modal {
    background-color: var(--bg-white);
    border-radius: 4px;
    width: 100%;
    max-width: 600px;
    overflow: hidden;
    /* 优化：动画 */
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-backdrop.show .modal {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 修复：防止标题溢出 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-title {
    font-size: 16px;
    font-weight: bold;
}

.modal-close {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s;
    /* 优化：点击区域 */
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    /* 修复：内容溢出 */
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    /* 修复：按钮换行 */
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

/* =============================================
   7. 提示信息（成功/错误反馈）
   ============================================= */

.message {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    /* 优化：边框圆角，增加图标空间 */
    display: flex;
    align-items: center;
    gap: 8px;
    /* 修复：最大宽度 */
    max-width: 100%;
}

.message-success {
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-color);
}

.message-error {
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-color);
}

/* =============================================
   8. 工具类（辅助复用）
   ============================================= */

/* 弹窗打开时，页面禁止滚动 */
body.modal-open {
    overflow: hidden;
    /* 修复：iOS 滚动问题 */
    position: fixed;
    width: 100%;
}

/* 文本居中 */
.text-center {
    text-align: center !important;
}

/* 隐藏元素 */
.hidden {
    display: none !important;
}

/* 3. 通用间距工具类 */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-10 { margin-top: 2.5rem; }
.mr-4 { margin-right: 1rem; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-10 { margin-bottom: 2.5rem; }
.ml-0 { margin-left: 0; }
.pt-16 { padding-top: 4rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-12 { padding: 3rem 0 !important; }
.p-6 { padding: 1.5rem; }

/* 4. 通用文字样式 */
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.text-white { color: var(--color-white); }
.text-white\/90 { color: var(--color-white-90); }
.text-gray-500 { color: var(--color-gray-500); }
.text-gray-900 { color: var(--color-gray-900); }
.text-yellow-200 { color: var(--color-yellow-200); }
.text-primary { color: var(--color-primary); }
.leading-relaxed { line-height: 1.625; }


.font-medium { 
    font-weight: 500 !important; 
}
.text-lg { 
    font-size: 1.125rem !important; 
}


/* 新增：清除浮动 */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* 新增：适配小屏幕 */
@media (max-width: 768px) {
    .header .admin-info {
        float: none;
        display: block;
        margin-top: 8px;
        margin-left: 0;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .add-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
        line-height: 44px;
        bottom: 70px;
        right: 15px;
    }
    
    .modal {
        max-width: 95%;
    }
}

/* =============================================
   9. 首页专属样式
   ============================================= */
.main-index {
    max-width: 1200px;
    margin: 70px auto 20px; /* 修复：顶部间距 */
    padding: 20px 15px; /* 优化：小屏幕 */
    text-align: center;
}

.index-title {
    font-size: 28px; /* 优化：响应式 */
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
    /* 修复：换行 */
    white-space: normal;
}

.index-desc {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: var(--line-height);
    /* 优化：最大宽度，提升可读性 */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.btn-group {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 60px;
    /* 修复：小屏幕换行 */
    flex-wrap: wrap;
}

/* 复用基础按钮样式，仅调整尺寸 */
.index-btn {
    padding: 12px 30px;
    font-size: 16px;
    min-width: 120px; /* 优化：最小宽度 */
}


