/* ============================================================
   LiteLog 后台样式
   ============================================================ */

:root {
    --sidebar-bg:       #1e293b;
    --sidebar-hover:    #334155;
    --sidebar-text:     #94a3b8;
    --sidebar-section:  #64748b;
    --primary:          #2563eb;
    --primary-hover:    #1d4ed8;
    --danger:           #dc2626;
    --danger-hover:     #b91c1c;
    --success:          #059669;

    --main-bg:          #f6f8fb;
    --card-bg:          #ffffff;
    --border:           #e5e9f0;

    --text:             #1e293b;
    --text-muted:       #64748b;
    --text-dim:         #94a3b8;

    --radius:           10px;
    --radius-sm:        6px;

    --shadow-sm:        0 1px 2px rgba(15,23,42,.04);
    --shadow:           0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-lg:        0 10px 30px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--main-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ============================================================
   骨架
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.brand-text span {
    color: var(--sidebar-section);
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section {
    padding: 14px 12px 6px;
    font-size: 11px;
    color: var(--sidebar-section);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 14px;
    margin-bottom: 2px;
    position: relative;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(37,99,235,.18); color: #fff; }
.nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 9px; bottom: 9px;
    width: 3px;
    background: #3b82f6;
    border-radius: 0 3px 3px 0;
}
.nav-icon {
    display: flex; width: 18px; height: 18px;
    flex-shrink: 0;
    align-items: center; justify-content: center;
    opacity: .9;
}
.nav-link.active .nav-icon { opacity: 1; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 13px;
    margin-bottom: 2px;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-btn:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-header {
    padding: 28px 40px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.main-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.01em;
}
.header-actions { display: flex; gap: 8px; }
.main-body { padding: 20px 40px 56px; flex: 1; }

/* ============================================================
   卡片
   ============================================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}
.card + .card { margin-top: 18px; }
.card-title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title::before {
    content: '';
    width: 3px; height: 14px;
    background: var(--primary);
    border-radius: 2px;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    transition: background .15s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled, .btn[disabled] {
    opacity: .6;
    cursor: not-allowed;
    background: #94a3b8;
}
.btn:disabled:hover { background: #94a3b8; }

.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: #f8fafc; color: var(--text); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-sm svg { width: 14px; height: 14px; }

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 14px 20px;
    text-align: left;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }

.row-actions a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 13px;
    margin-right: 14px;
    transition: color .15s;
}
.row-actions a:hover { color: var(--primary); text-decoration: none; }
.row-actions a.danger:hover { color: var(--danger); }

/* ★ 新增：POST 按钮（替代 GET 写操作） */
.row-actions form { display: inline; }
.row-actions form button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 0;
    padding: 0;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    margin-right: 14px;
    cursor: pointer;
    transition: color .15s;
}
.row-actions form button:hover { color: var(--primary); }
.row-actions form button.danger { color: var(--text-muted); }
.row-actions form button.danger:hover { color: var(--danger); }

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}
.tag-published { background: #ecfdf5; color: #059669; }
.tag-hidden    { background: #f1f5f9; color: #64748b; }

/* ============================================================
   表单
   ============================================================ */
.form label, .field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}
.form .field,
.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="number"],
.form input[type="url"],
.form select,
.form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    margin-bottom: 16px;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form input::placeholder, .form textarea::placeholder { color: #cbd5e1; }

/* ============================================================
   提示 / 空状态
   ============================================================ */
.error {
    color: #b91c1c;
    background: #fef2f2;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    border-left: 3px solid var(--danger);
}
.empty {
    text-align: center;
    padding: 70px 20px;
    color: var(--text-muted);
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    line-height: 1.9;
}
.empty a { font-weight: 500; }

/* ============================================================
   分页
   ============================================================ */
.pagination {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13.5px;
    text-decoration: none;
    transition: all .15s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   概览统计
   ============================================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat {
    background: var(--card-bg);
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity .2s;
}
.stat:hover::after { opacity: 1; }
.stat-value {
    font-size: 30px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    letter-spacing: -.02em;
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 10px; }

.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list li a { color: var(--text); }
.recent-list li a:hover { color: var(--primary); text-decoration: none; }
.recent-list .recent-meta {
    display: flex; gap: 14px;
    font-size: 12.5px;
    color: var(--text-dim);
    align-items: center;
}

/* ============================================================
   登录页
   ============================================================ */
body.login-page {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh; padding: 20px;
}
.login-box {
    width: 100%; max-width: 380px;
    background: #fff;
    padding: 40px 36px 34px;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login-logo {
    width: 52px; height: 52px;
    border-radius: 13px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 24px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 22px rgba(37,99,235,.35);
}
.login-box h2 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
}
.login-box .login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 26px;
}
.login-box input {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.login-box input:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 500;
    font-family: inherit;
    transition: background .15s;
    margin-top: 4px;
}
.login-box button:hover { background: var(--primary-hover); }
.login-box .error { text-align: center; font-size: 13px; padding: 9px 14px; }

/* ============================================================
   写文章页
   ============================================================ */
.edit-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
    align-items: start;
}
.edit-main { min-width: 0; }
.edit-side {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 24px;
}
.title-input {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    padding: 12px 4px 14px;
    border-bottom: 2px solid transparent;
    outline: 0;
    margin-bottom: 18px;
    letter-spacing: -.01em;
    transition: border-color .15s;
}
.title-input::placeholder { color: #cbd5e1; font-weight: 500; }
.title-input:focus { border-bottom-color: var(--primary); }

.side-field { margin-bottom: 4px; }
.side-field label {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}
.side-field input, .side-field select, .side-field textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
}
.side-field input:focus, .side-field select:focus, .side-field textarea:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.side-field + .side-field { margin-top: 12px; }
.side-actions { margin-top: 16px; display: flex; gap: 8px; }
.side-actions .btn { flex: 1; }

/* ============================================================
   插件管理
   ============================================================ */
.plugin-list { display: flex; flex-direction: column; gap: 14px; }
.plugin-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    transition: box-shadow .2s, transform .2s;
    border: 1px solid transparent;
}
.plugin-card:hover { box-shadow: var(--shadow-lg); }
.plugin-card.active { border-color: rgba(37,99,235,.35); }

.plugin-icon {
    width: 52px; height: 52px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1d4ed8;
    display: flex; align-items: center; justify-content: center;
}
.plugin-card.active .plugin-icon {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    box-shadow: 0 6px 16px rgba(37,99,235,.35);
}

.plugin-info { flex: 1; min-width: 0; }
.plugin-title {
    display: flex; align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.plugin-title strong { font-size: 15px; color: var(--text); }
.plugin-title .ver {
    color: var(--text-dim);
    font-size: 12px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.7;
}
.badge-on  { background: #ecfdf5; color: var(--success); }
.badge-off { background: #f1f5f9; color: #64748b; }

.plugin-desc {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 6px 0 6px;
    line-height: 1.6;
}
.plugin-meta {
    display: flex; gap: 16px;
    color: var(--text-dim);
    font-size: 12.5px;
    flex-wrap: wrap;
}
.plugin-actions { flex-shrink: 0; }

/* ============================================================
   主题管理
   ============================================================ */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.theme-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .25s, transform .25s;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
}
.theme-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.theme-card.active { border-color: rgba(37,99,235,.4); }

.theme-preview {
    position: relative;
    aspect-ratio: 3 / 2;
    background: #f1f5f9;
    overflow: hidden;
}
.theme-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
    transition: transform .35s;
}
.theme-card:hover .theme-preview img { transform: scale(1.03); }

.theme-preview-placeholder {
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 12.5px;
}

.theme-active-badge {
    position: absolute;
    top: 10px; right: 10px;
    background: var(--primary);
    color: #fff;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(37,99,235,.4);
}
.theme-active-badge svg { width: 13px; height: 13px; }

.theme-info { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.theme-title {
    display: flex; align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.theme-title strong { font-size: 15px; color: var(--text); }
.theme-title .ver {
    color: var(--text-dim);
    font-size: 12px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.theme-desc {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
    min-height: 40px;
    margin-bottom: 12px;
}
.theme-meta {
    display: flex; gap: 14px;
    color: var(--text-dim);
    font-size: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.theme-actions {
    display: flex; gap: 8px;
    margin-top: auto;
    align-items: center;
    flex-wrap: wrap;
}
.theme-actions .btn { flex: 1; }
.theme-actions form { display: inline; flex: 1; }
.theme-actions form button { width: 100%; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1100px) {
    .edit-grid { grid-template-columns: 1fr; }
    .edit-side { position: static; }
}
@media (max-width: 900px) {
    .sidebar { width: 200px; }
    .main-header { padding: 22px 22px 0; }
    .main-body { padding: 16px 22px 40px; }
    .plugin-card { flex-direction: column; align-items: flex-start; gap: 14px; }
    .plugin-actions { width: 100%; }
    .plugin-actions .btn { width: 100%; }
}
@media (max-width: 680px) {
    .sidebar {
        position: fixed; left: 0; z-index: 100;
        transform: translateX(-100%);
        transition: transform .25s;
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
    }
    .sidebar.open { transform: translateX(0); }
    .title-input { font-size: 21px; }
    .table th, .table td { padding: 11px 14px; font-size: 13px; }
    .theme-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   App 式独立滚动布局 (桌面端)
   ============================================================ */
@media (min-width: 900px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }
    .admin-shell {
        height: 100vh;
        overflow: hidden;
    }
    .sidebar {
        height: 100%;
    }
    .main {
        height: 100%;
        overflow-y: auto;
    }
    /* 美化主内容区滚动条 */
    .main::-webkit-scrollbar {
        width: 8px;
    }
    .main::-webkit-scrollbar-track {
        background: transparent;
    }
    .main::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
    .main::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}