/* ============================================================
   admin.css — 管理后台样式
   侧边栏 + 内容区的经典布局。
   被 templates/admin/base.html 引用。
   ============================================================ */

:root {
    --sidebar-width: 240px;
    --admin-header-height: 56px;
    --color-admin-bg: #f1f5f9;
    --color-sidebar-bg: #1e293b;
    --color-sidebar-text: #94a3b8;
    --color-sidebar-active: #fff;
    --color-sidebar-hover: #334155;
}

/* ---- 后台布局 ---- */
.admin-body {
    display: flex;
    min-height: 100vh;
    background: var(--color-admin-bg);
}

/* ---- 侧边栏 ---- */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid #334155;
}
.sidebar-header a {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}
.sidebar-header a:hover {
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--color-sidebar-text);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-active);
    text-decoration: none;
}
.sidebar-nav a.active {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-active);
    border-right: 3px solid var(--color-primary);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
    font-size: 0.85rem;
}
.sidebar-footer a {
    color: var(--color-sidebar-text);
}

/* ---- 主内容区 ---- */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 100%;
}

.admin-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ---- 统计卡片 ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
}
.stat-card-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-card-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

/* ---- 表格 ---- */
.admin-table {
    width: 100%;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}

.admin-table th {
    background: var(--color-bg-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table .actions {
    display: flex;
    gap: 0.5rem;
}

/* ---- 按钮 ---- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-border);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ---- 表单 ---- */
.admin-form {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 2rem;
    max-width: 800px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    min-height: 300px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* ---- 状态标签 ---- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-published {
    background: #dcfce7;
    color: #166534;
}
.badge-draft {
    background: #fef9c3;
    color: #854d0e;
}

/* ---- 登录页 ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-admin-bg);
}

.login-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-error {
    background: #fef2f2;
    color: var(--color-danger);
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.login-card .form-actions {
    border-top: none;
    padding-top: 0;
    margin-top: 0.5rem;
}
.login-card .form-actions .btn {
    width: 100%;
}

/* ---- Markdown 预览 ---- */
.md-preview {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1rem;
    min-height: 200px;
    background: var(--color-bg);
    line-height: 1.7;
}
.md-preview h2 { font-size: 1.3rem; margin: 1.5rem 0 0.75rem; }
.md-preview p { margin-bottom: 0.75rem; }
.md-preview pre {
    background: var(--color-bg-secondary);
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}
.md-preview code {
    background: var(--color-bg-secondary);
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ---- 版本列表（包编辑页） ---- */
.version-list-admin {
    margin: 1rem 0;
}
.version-item-admin {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}
.version-item-admin .version-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ---- 上传进度条 ---- */
.upload-progress {
    display: none;
    margin-top: 0.75rem;
}
.upload-progress.active {
    display: block;
}
.upload-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.upload-progress-text {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-align: center;
    margin-top: 0.25rem;
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 60px;
    }
    .sidebar-nav a span,
    .sidebar-header .site-name,
    .sidebar-footer span {
        display: none;
    }
    .admin-main {
        margin-left: 60px;
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
