/* ============================================
   个人博客 - 后台管理样式
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #1f2328;
    line-height: 1.6;
    font-size: 14px;
}

a { color: #0969da; text-decoration: none; }
a:hover { color: #0860c4; }

/* ===== 登录页 ===== */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-title { text-align: center; font-size: 24px; margin-bottom: 4px; color: #1f2328; }
.login-subtitle { text-align: center; color: #8b949e; margin-bottom: 24px; font-size: 14px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; color: #57606a; margin-bottom: 6px; font-weight: 500; }
.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.login-form input:focus { outline: none; border-color: #0969da; box-shadow: 0 0 0 3px rgba(9,105,218,0.1); }
.btn-block { width: 100%; }
.login-tip { text-align: center; margin-top: 16px; font-size: 12px; color: #8b949e; }

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

/* 侧边栏 */
.admin-sidebar {
    width: 220px;
    background: #1f2937;
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}
.admin-logo {
    padding: 20px;
    border-bottom: 1px solid #374151;
    text-align: center;
}
.admin-logo a { color: #fff; font-size: 18px; font-weight: 700; }
.admin-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.admin-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #d1d5db;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.admin-nav .nav-item:hover { background: #374151; color: #fff; }
.admin-nav .nav-item.active {
    background: #374151;
    color: #fff;
    border-left-color: #0969da;
}
.badge-dot {
    background: #cf222e;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
}
.admin-sidebar-footer { border-top: 1px solid #374151; padding: 8px 0; }

/* 主内容区 */
.admin-main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.admin-page-title { font-size: 18px; font-weight: 600; }
.admin-user { font-size: 14px; color: #57606a; }
.admin-content { padding: 24px; flex: 1; }

/* ===== 通用组件 ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    overflow: hidden;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.panel-header h3 { font-size: 16px; font-weight: 600; }

/* 按钮 */
.btn {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
    color: #1f2328;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.5;
}
.btn:hover { border-color: #0969da; color: #0969da; }
.btn-primary { background: #0969da; color: #fff; border-color: #0969da; }
.btn-primary:hover { background: #0860c4; color: #fff; }
.btn-success { background: #1a7f37; color: #fff; border-color: #1a7f37; }
.btn-success:hover { background: #156b2e; color: #fff; }
.btn-warning { background: #9a6700; color: #fff; border-color: #9a6700; }
.btn-warning:hover { background: #805600; color: #fff; }
.btn-danger { background: #cf222e; color: #fff; border-color: #cf222e; }
.btn-danger:hover { background: #a40e26; color: #fff; }
.btn-secondary { background: #f6f8fa; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; margin-bottom: 8px; }
.btn.active { background: #0969da; color: #fff; border-color: #0969da; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: #57606a; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9,105,218,0.1);
}
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 20px;
}
.form-inline .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }
.form-check-group { display: flex; gap: 20px; flex-wrap: wrap; }
.check-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    color: #1f2328;
}
.check-label input { width: auto; }
.form-actions { padding: 16px 0 0; display: flex; gap: 10px; }

/* 数据表格 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: #f6f8fa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #57606a;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}
.data-table tr:hover { background: #f9fafb; }
.data-table .text-center { text-align: center; }
.data-table .actions { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }
.data-table .actions form { display: inline; }
.comment-content-cell { max-width: 300px; word-break: break-word; }

/* 徽章 */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-top { background: #fff3cd; color: #856404; }
.badge-admin { background: #ddf4ff; color: #0969da; }

/* 筛选栏 */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.filter-form select, .filter-form input {
    padding: 6px 10px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 13px;
}

/* ===== 仪表盘 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 32px; }
.stat-value { font-size: 24px; font-weight: 700; color: #1f2328; }
.stat-label { font-size: 13px; color: #8b949e; }
.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== 文章编辑 ===== */
.form-grid { display: flex; gap: 24px; padding: 20px; }
.form-main { flex: 1; min-width: 0; }
.form-side { width: 280px; flex-shrink: 0; }
.input-title { font-size: 18px; padding: 10px 14px; }
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px;
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}
.md-btn {
    padding: 4px 10px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    color: #57606a;
    font-weight: 600;
}
.md-btn:hover { background: #fff; border-color: #d0d7de; color: #0969da; }
#content-editor {
    border-radius: 0 0 6px 6px;
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    min-height: 400px;
}
.editor-hint { font-size: 12px; color: #8b949e; margin-top: 6px; }
.tag-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}
.tag-checkbox:hover { background: #f6f8fa; }
.tag-checkbox input { width: auto; }
.cover-preview { width: 100%; margin-top: 8px; border-radius: 6px; max-height: 160px; object-fit: cover; }
.cover-file-input { font-size: 12px; margin-top: 6px; }

/* ===== 设置页 ===== */
.settings-form { padding: 20px; }
.settings-section { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid #f0f2f5; }
.settings-section:last-child { border-bottom: none; }
.settings-section h4 {
    font-size: 15px;
    margin-bottom: 16px;
    color: #1f2328;
    padding-left: 10px;
    border-left: 3px solid #0969da;
}

/* 回复表单行 */
.reply-form-row td { background: #f9fafb; }
.reply-form-inline { display: flex; gap: 8px; align-items: flex-start; }
.reply-form-inline textarea { flex: 1; padding: 6px 10px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 16px 20px;
    flex-wrap: wrap;
}
.page-link {
    padding: 5px 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    color: #57606a;
    font-size: 13px;
    cursor: pointer;
}
.page-link:hover { border-color: #0969da; color: #0969da; }
.page-link.active { background: #0969da; color: #fff; border-color: #0969da; }
.page-ellipsis { padding: 5px 4px; color: #8b949e; }

.text-muted { color: #8b949e; }
.status-display { display: flex; align-items: center; }

/* ===== 响应式 ===== */
@media (max-width: 960px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .dashboard-panels { grid-template-columns: 1fr; }
    .form-grid { flex-direction: column; }
    .form-side { width: 100%; }
}

@media (max-width: 640px) {
    .admin-content { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 6px 8px; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline .form-group { min-width: 100%; }
}

/* ===== v2.0 移动端侧边栏切换 ===== */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    color: #57606a;
    margin-right: 8px;
}
.sidebar-toggle:hover { background: #f6f8fa; color: #0969da; border-color: #0969da; }
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}
.admin-sidebar-overlay.show { display: block; opacity: 1; }
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1px;
}
.table-responsive .data-table { min-width: 600px; }

/* ===== v2.0 改进响应式 (覆盖旧规则) ===== */
@media (max-width: 960px) {
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .dashboard-panels { grid-template-columns: 1fr; }
    .form-grid { flex-direction: column; }
    .form-side { width: 100%; }
    .topbar-right .admin-user { display: none; }
}

@media (max-width: 640px) {
    .admin-content { padding: 12px; }
    .admin-topbar { padding: 0 12px; height: 50px; }
    .admin-page-title { font-size: 15px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-icon { font-size: 24px; }
    .stat-value { font-size: 20px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .form-inline { flex-direction: column; align-items: stretch; padding: 12px; }
    .form-inline .form-group { min-width: 100%; }
    .panel-header { padding: 12px 14px; }
    .panel-header h3 { font-size: 14px; }
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { flex: 1; min-width: 100px; }
    .filter-form { padding: 12px; }
    .settings-form { padding: 14px; }
    .settings-section h4 { font-size: 14px; }
    .admin-logo { padding: 14px; }
    .admin-logo a { font-size: 16px; }
    .admin-nav .nav-item { padding: 10px 16px; font-size: 13px; }
    .nav-section { font-size: 11px; padding: 8px 16px 4px; }
    .pagination { padding: 12px; }
    .reply-form-inline { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .admin-page-title { font-size: 14px; }
    .user-group-badge { display: none; }
    .data-table .actions { flex-direction: column; }
    .data-table .actions .btn { width: 100%; text-align: center; }
    .form-row { flex-direction: column; gap: 0; }
    .btn { padding: 6px 12px; font-size: 12px; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .admin-sidebar { overflow-y: auto; }
    .admin-nav { padding: 6px 0; }
    .admin-nav .nav-item { padding: 6px 16px; }
    .admin-logo { padding: 10px; }
    .admin-sidebar-footer { display: none; }
}

/* 顶部栏左侧布局 */
.topbar-left { display: flex; align-items: center; min-width: 0; }
.topbar-left .admin-page-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ===== AJAX保存结果提示 ===== */
.ajax-result {
    margin: 12px 0;
    padding: 0;
    border-radius: 6px;
    font-size: 14px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s;
}
.ajax-result.ajax-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 10px 14px;
    max-height: 100px;
}
.ajax-result.ajax-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    max-height: 100px;
}
.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== Toast 弹窗通知 ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 14px 18px;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
}
.toast.toast-hide {
    animation: toastSlideOut 0.3s ease-in forwards;
}
.toast-success { background: linear-gradient(135deg, #16a34a, #15803d); }
.toast-error { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.toast-warning { background: linear-gradient(135deg, #d97706, #b45309); }
.toast-info { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.toast i { font-size: 18px; margin-top: 1px; flex-shrink: 0; }
.toast .toast-content { flex: 1; }
.toast .toast-close {
    background: none; border: none; color: #fff; opacity: 0.7;
    cursor: pointer; font-size: 16px; padding: 0; margin-left: 8px; flex-shrink: 0;
}
.toast .toast-close:hover { opacity: 1; }
.toast .toast-progress {
    position: absolute; bottom: 0; left: 0; height: 3px;
    background: rgba(255,255,255,0.5); animation: toastProgress 3s linear;
}
@keyframes toastSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; max-height: 100px; margin-bottom: 10px; }
    to { transform: translateX(120%); opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; }
}
@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}
