:root {
    --sidebar-bg: #1e293b;
    --sidebar-width: 240px;
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --topbar-height: 60px;
    --content-bg: #f1f5f9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    background: var(--content-bg);
    color: #334155;
    font-size: 14px;
}

a {
    text-decoration: none;
}

/* ============ 整体布局 ============ */
.app {
    display: flex;
    min-height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand i {
    font-size: 24px;
    color: var(--primary-light);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #cbd5e1;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: background .2s, color .2s;
}

.sidebar-nav .nav-item i {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-nav .nav-item.active {
    background: rgba(79, 70, 229, .28);
    color: #fff;
    border-left-color: var(--primary-light);
}

.sidebar-footer {
    padding: 14px 20px;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ============ 主区域 ============ */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-title {
    font-size: 17px;
    font-weight: 600;
    color: #0f172a;
}

.btn-user {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 14px;
    color: #334155;
    font-size: 14px;
}

.btn-user:hover {
    background: #f8fafc;
    color: #0f172a;
}

.content {
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

/* ============ 卡片 ============ */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 20px;
    font-weight: 600;
    color: #0f172a;
    border-radius: 12px 12px 0 0 !important;
}

.card-body {
    padding: 20px;
}

/* ============ 统计卡片 ============ */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .12);
}

.stat-card .stat-icon {
    font-size: 34px;
    opacity: .85;
}

.stat-card .stat-num {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: .9;
    margin-top: 4px;
}

.bg-stat-primary { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.bg-stat-success { background: linear-gradient(135deg, #059669, #10b981); }
.bg-stat-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.bg-stat-danger  { background: linear-gradient(135deg, #dc2626, #f43f5e); }
.bg-stat-info    { background: linear-gradient(135deg, #0891b2, #22d3ee); }
.bg-stat-dark    { background: linear-gradient(135deg, #334155, #64748b); }

/* ============ 表格 ============ */
.table th {
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    white-space: nowrap;
    border-bottom: 1px solid #e2e8f0;
}

.table td {
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ============ 徽章 ============ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-published { background: #dcfce7; color: #166534; }
.badge-draft     { background: #f1f5f9; color: #475569; }
.badge-approved  { background: #dcfce7; color: #166534; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-active    { background: #dcfce7; color: #166534; }
.badge-disabled  { background: #fee2e2; color: #b91c1c; }
.badge-role      { background: #e0e7ff; color: #3730a3; }

/* ============ 按钮 ============ */
.btn {
    border-radius: 8px;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ============ 表单 ============ */
.form-control, .form-select {
    border-radius: 8px;
    font-size: 14px;
    border-color: #e2e8f0;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15);
}

.form-label {
    font-weight: 500;
    color: #334155;
}

/* ============ 分页 ============ */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 3px;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ============ 空状态 ============ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}

.empty-state i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    color: #cbd5e1;
}

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #312e81 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    padding: 40px 36px;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin: 0 auto 16px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    color: #0f172a;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 28px;
    font-size: 13px;
}

/* ============ 分类统计条形图 ============ */
.category-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.category-bar .bar-label {
    width: 90px;
    font-size: 13px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-bar .bar-track {
    flex: 1;
    height: 22px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.category-bar .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #818cf8);
    border-radius: 6px;
    transition: width .5s ease;
}

.category-bar .bar-value {
    width: 40px;
    text-align: right;
    font-weight: 600;
    color: #0f172a;
}

/* ============ Markdown 预览 ============ */
.markdown-preview {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
    background: #fcfcfd;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
    color: #0f172a;
}

.markdown-preview code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #be185d;
}

.markdown-preview pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 14px;
    border-radius: 8px;
}

.markdown-preview pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--primary-light);
    padding-left: 14px;
    color: #64748b;
    margin: 12px 0;
}

/* ============ 徒步路线：列表卡片 ============ */
.trail-card {
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}

.trail-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}

.trail-cover {
    position: relative;
    display: block;
    height: 170px;
    overflow: hidden;
    background: #e2e8f0;
}

.trail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.trail-card:hover .trail-cover img {
    transform: scale(1.06);
}

.trail-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #94a3b8;
    font-size: 40px;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
}

.trail-status {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    color: #fff;
}

.trail-status-pub { background: rgba(5, 150, 105, .9); }
.trail-status-draft { background: rgba(100, 116, 139, .9); }

.trail-difficulty {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    color: #fff;
}

.diff-relax { background: #10b981; }
.diff-medium { background: #f59e0b; }
.diff-challenge { background: #ef4444; }

.diff-badge {
    color: #fff;
    padding: 4px 12px;
}

.trail-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trail-title a:hover {
    color: var(--primary) !important;
}

.trail-meta {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

.trail-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.trail-facilities {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.facility {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.facility.yes { background: #dcfce7; color: #166534; }
.facility.no { background: #fee2e2; color: #b91c1c; }

/* ============ 徒步路线：详情页 ============ */
.trail-detail-cover {
    height: 320px;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
}

.trail-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.trail-data-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    padding: 12px;
}

.data-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.data-label {
    font-size: 11px;
    color: #94a3b8;
}

.data-value {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.data-value small {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
}

.facility-big {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.facility-big.yes { background: #dcfce7; color: #16a34a; }
.facility-big.no { background: #fee2e2; color: #dc2626; }

.trail-carousel {
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    max-height: 480px;
}

.trail-carousel .carousel-item img {
    height: 460px;
    object-fit: cover;
}

.trail-thumb {
    width: 88px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color .2s;
}

.trail-thumb:hover {
    border-color: var(--primary-light);
}

.trail-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============ 徒步路线：队员评论 ============ */
.review-item {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 16px;
}

.review-pending {
    background: #fffbeb;
    border-color: #fde68a;
}

.review-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.review-content {
    margin-top: 10px;
    color: #334155;
    white-space: pre-line;
}

/* ============ 响应式 ============ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .content {
        padding: 16px;
    }

    .stat-card .stat-num {
        font-size: 24px;
    }
}
