/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    color: #2c3e50;
    background: #f0f2f5;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #3498db;
    text-decoration: none;
}

a:hover {
    color: #2980b9;
}

ul, ol { list-style: none; }

/* ========== 通用按钮 ========== */
.btn {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    vertical-align: middle;
    background: #fff;
    color: #333;
    border-color: #ddd;
    transition: all .15s;
}

.btn:hover { opacity: .85; }

.btn-primary {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}
.btn-success {
    background: #27ae60;
    color: #fff;
    border-color: #27ae60;
}
.btn-danger {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}
.btn-warning {
    background: #f39c12;
    color: #fff;
    border-color: #f39c12;
}
.btn-sm {
    padding: 3px 8px;
    font-size: 12px;
}
.btn-block {
    display: block;
    width: 100%;
}

/* ========== 登录页 ========== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c3e50 0%, #4a6580 100%);
}

.login-card {
    width: 380px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,.18);
    padding: 36px 32px;
}

.login-card .brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-card .brand .logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ff6b00 0%, #ff9244 100%);
    color: #fff;
    font-size: 26px;
    line-height: 56px;
    font-weight: bold;
}

.login-card .brand h1 {
    font-size: 20px;
    color: #2c3e50;
    font-weight: 600;
}

.login-card .brand p {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
}

.login-card .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}

.login-card .form-control:focus {
    border-color: #3498db;
}

.login-card .btn-login {
    width: 100%;
    padding: 11px;
    font-size: 15px;
    margin-top: 6px;
}

/* ========== 布局 ========== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #2c3e50;
    color: #bdc3c7;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar .brand {
    padding: 18px 20px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .brand .logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff6b00 0%, #ff9244 100%);
    color: #fff;
    text-align: center;
    line-height: 32px;
    font-size: 16px;
}

.sidebar .nav { padding: 12px 0; }

.sidebar .nav a {
    display: block;
    padding: 11px 22px;
    color: #bdc3c7;
    font-size: 14px;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.sidebar .nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.05);
}

.sidebar .nav a.active {
    color: #fff;
    background: rgba(52,152,219,.15);
    border-left-color: #3498db;
}

.sidebar .nav .nav-icon {
    display: inline-block;
    width: 18px;
    margin-right: 8px;
    text-align: center;
}

.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .page-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar .user-info .name {
    font-size: 13px;
    color: #555;
}

.topbar .user-info .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3498db;
    color: #fff;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
}

.content {
    padding: 20px 24px;
    flex: 1;
}

/* ========== 卡片 ========== */
.card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid #ebeef5;
    margin-bottom: 18px;
}

.card-header {
    padding: 12px 18px;
    border-bottom: 1px solid #ebeef5;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 18px; }

/* ========== 统计卡片 ========== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 6px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid #ebeef5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-info .label {
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
}

.stat-card .stat-info .value {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
}

.bg-blue { background: linear-gradient(135deg, #3498db, #2980b9); }
.bg-green { background: linear-gradient(135deg, #27ae60, #2ecc71); }
.bg-orange { background: linear-gradient(135deg, #ff6b00, #ff9244); }
.bg-purple { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.bg-red { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.bg-cyan { background: linear-gradient(135deg, #1abc9c, #16a085); }

/* ========== 表格 ========== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}

table.data-table thead th {
    background: #fafafa;
    color: #555;
    font-weight: 600;
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid #ebeef5;
    white-space: nowrap;
}

table.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    vertical-align: middle;
}

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

table.data-table tbody tr:nth-child(even):hover {
    background: #f7fafc;
}

table.data-table .actions a,
table.data-table .actions button {
    margin-right: 4px;
}

.avatar-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ddd;
    object-fit: cover;
}

.cover-thumb {
    width: 60px;
    height: 40px;
    border-radius: 4px;
    background: #ddd;
    object-fit: cover;
}

/* ========== 状态徽章 ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}

.badge-success { background: #e8f8ef; color: #27ae60; }
.badge-danger { background: #fdecea; color: #e74c3c; }
.badge-warning { background: #fef5e7; color: #f39c12; }
.badge-info { background: #e8f4fb; color: #3498db; }
.badge-default { background: #f4f4f5; color: #909399; }
.badge-primary { background: #e8f4fb; color: #3498db; }
.badge-purple { background: #f4ecf7; color: #9b59b6; }

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
}

.form-group .required {
    color: #e74c3c;
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
    background: #fff;
    color: #333;
    font-family: inherit;
}

.form-control:focus {
    border-color: #3498db;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
}

/* ========== 过滤栏 ========== */
.filter-bar {
    background: #fff;
    padding: 14px 18px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    border: 1px solid #ebeef5;
}

.filter-bar .form-control {
    width: auto;
    min-width: 160px;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 200px;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 16px 0 4px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-block;
    min-width: 32px;
    height: 32px;
    line-height: 30px;
    padding: 0 8px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 13px;
    color: #555;
    background: #fff;
    text-align: center;
}

.pagination a:hover {
    border-color: #3498db;
    color: #3498db;
}

.pagination .current {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

.pagination .disabled {
    color: #c0c4cc;
    cursor: not-allowed;
    background: #f4f4f5;
}

.pagination .info {
    border: none;
    background: transparent;
    margin-right: 10px;
}

/* ========== 提示消息 ========== */
.alert {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success { background: #e8f8ef; color: #27ae60; border-color: #c8eecd; }
.alert-error { background: #fdecea; color: #e74c3c; border-color: #f8c8c4; }
.alert-warning { background: #fef5e7; color: #f39c12; border-color: #fae3b3; }
.alert-info { background: #e8f4fb; color: #3498db; border-color: #c8e2f5; }

/* ========== 模态框 ========== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal.show { display: flex; }

.modal-dialog {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}

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

.modal-header h3 {
    font-size: 16px;
    color: #2c3e50;
}

.modal-header .close {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-body { padding: 18px; }
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #ebeef5;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== 章节树 ========== */
.chapter-tree {
    background: #fff;
    border-radius: 6px;
    padding: 10px 18px;
    border: 1px solid #ebeef5;
}

.chapter-item {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chapter-item:last-child { border-bottom: none; }

.chapter-item .title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chapter-children {
    margin-left: 24px;
    border-left: 2px solid #f0f0f0;
    padding-left: 12px;
}

/* ========== 通用工具类 ========== */
.text-muted { color: #999; }
.text-success { color: #27ae60; }
.text-danger { color: #e74c3c; }
.text-warning { color: #f39c12; }
.text-primary { color: #3498db; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 13px;
}

.recent-list {
    background: #fff;
    border-radius: 6px;
    border: 1px solid #ebeef5;
}

.recent-list .item {
    padding: 10px 18px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.recent-list .item:last-child { border-bottom: none; }

.recent-list .item .desc { color: #555; }
.recent-list .item .time { color: #999; font-size: 12px; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    .main {
        margin-left: 0;
    }
    .layout {
        flex-direction: column;
    }
    .topbar { padding: 0 14px; }
    .content { padding: 14px; }
    .form-row { grid-template-columns: 1fr; }
}
