/* files/admin_style.css - Refined Admin Theme (v19 - Final Polish) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 12px; /* 稍微增大圆角 */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    --header-height: 60px;
    --navbar-height: 60px;
}

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    margin: 0; 
    line-height: 1.5;
    height: 100vh; 
    overflow: hidden; 
    display: flex;
    flex-direction: column;
}

* { box-sizing: border-box; }

/* --- 1. Navbar --- */
.admin-navbar { 
    background: #ffffff; 
    border-bottom: 1px solid var(--border); 
    padding: 0 24px; 
    height: var(--navbar-height); 
    flex-shrink: 0; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
    z-index: 100; 
}
.brand { font-weight: 700; font-size: 1.2rem; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.user-menu { display: flex; align-items: center; gap: 16px; }
.nav-btn { text-decoration: none; font-size: 0.9rem; font-weight: 500; color: var(--text-main); padding: 6px 12px; border-radius: 6px; transition: background 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.nav-btn:hover { background: #f3f4f6; }
.nav-btn.danger { color: var(--danger); } .nav-btn.danger:hover { background: #fef2f2; }
.welcome-text { font-size: 0.9rem; color: var(--text-muted); display: none; }
@media(min-width: 768px) { .welcome-text { display: inline; } }

/* --- 2. 核心布局 (修复底部被切问题) --- */
.admin-wrapper { 
    width: 100%;
    max-width: 1600px;
    margin: 0 auto; 
    /* 核心修复：使用 box-sizing 确保 padding 包含在高度内，避免撑破屏幕 */
    height: calc(100vh - var(--navbar-height)); 
    padding: 24px; 
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 确保 wrapper 内部不产生双滚动条 */
}

.admin-layout { 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
    height: 100%; 
    min-height: 0; /* Flexbox 嵌套滚动的关键 */
}

@media (min-width: 1024px) { 
    .admin-layout { 
        flex-direction: row; 
        align-items: stretch; 
    } 
}

/* --- 3. 左侧边栏 --- */
.admin-sidebar { 
    width: 100%; 
    flex-shrink: 0;
    max-height: 40vh; 
    overflow-y: auto;
}
@media (min-width: 1024px) { 
    .admin-sidebar { 
        width: 360px; 
        max-height: 100%; 
        overflow-y: visible; /* 桌面端由内部卡片滚动，外部不滚 */
        display: flex;
        flex-direction: column;
    } 
}

/* --- 4. 右侧内容区 --- */
.admin-content { 
    flex-grow: 1; 
    width: 100%; 
    min-width: 0; 
    height: 100%; 
    display: flex;
    flex-direction: column;
}

/* --- 5. 卡片通用 --- */
.card { 
    background: var(--bg-card); 
    border-radius: var(--radius); 
    box-shadow: var(--shadow); 
    border: 1px solid var(--border); 
    display: flex;
    flex-direction: column;
    /* 确保卡片不会溢出 wrapper */
    max-height: 100%;
}

/* 右侧大列表卡片 */
.list-card {
    height: 100%; 
    flex: 1;
    overflow: hidden;
}
/* 左侧 Tab 卡片：也需要占满高度或自适应，但不能超出一屏 */
.tab-card {
    max-height: 100%;
    overflow: hidden; /* 让内部的 card-body 滚动 */
}

/* 标头样式 */
.card-header, .tabs-header { 
    height: var(--header-height); 
    padding: 0 20px; 
    background: #ffffff;
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0; 
}

/* --- 6. 左侧标签页美化 --- */
.tabs-header {
    background: #f8fafc;
    padding: 8px 12px;
    gap: 8px;
    justify-content: flex-start;
    /* [修复1] 顶部圆角：防止 header 背景遮挡 card 的圆角 */
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn:hover { color: var(--text-main); background: rgba(0,0,0,0.03); }
.tab-btn.active { background: #ffffff; color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

/* 左侧卡片内容区 (滚动核心) */
.tab-card .card-body {
    padding: 24px;
    overflow-y: auto; /* [修复] 让表单区域独立滚动 */
    height: 100%;     /* 占满剩余高度 */
}
/* 隐藏左侧卡片默认滚动条，美观 */
.tab-card .card-body::-webkit-scrollbar { width: 4px; }
.tab-card .card-body::-webkit-scrollbar-thumb { background-color: transparent; }
.tab-card .card-body:hover::-webkit-scrollbar-thumb { background-color: #e5e7eb; border-radius: 4px; }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
.tab-title { margin-top: 0; margin-bottom: 24px; font-size: 1.15rem; color: var(--text-main); font-weight: 700; border-left: 4px solid var(--primary); padding-left: 12px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* --- 7. 表单与按钮 --- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-main); margin-bottom: 8px; }
input[type="text"], input[type="url"], input[type="password"], select, input[type="file"] { 
    width: 100%; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.95rem; 
    transition: all 0.2s; background-color: #fff; 
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

.btn { border: none; padding: 10px 18px; border-radius: 8px; font-size: 0.95rem; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: opacity 0.2s; }
.btn:hover { opacity: 0.9; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.btn.block { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn.primary { background: var(--primary); color: white; }
.btn.secondary { background: #f3f4f6; color: var(--text-main); border: 1px solid #d1d5db; }
.btn.danger { background: var(--danger); color: white; }
.btn.info { background: var(--info); color: white; }
.btn.warning { background: var(--warning); color: white; }

.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.form-actions .btn-save { flex: 2; }
.form-actions .btn-cancel { flex: 1; text-align: center; }

/* 快速管理列表 (左侧) */
.mini-cat-list { 
    /* [修复2] 增高列表高度，充分利用左侧空间 */
    max-height: 450px; 
    overflow-y: auto; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    margin-top: 16px; 
    background: #f9fafb; 
}
.category-item-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 0; border-bottom: 1px solid #e5e7eb; font-size: 0.9rem; }
.category-item-row:last-child { border-bottom: none; }
.row-actions { display: flex; gap: 6px; opacity: 0.4; transition: opacity 0.2s; }
.category-item-row:hover .row-actions { opacity: 1; }
.mini-btn { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; border: none; cursor: pointer; color: var(--text-muted); background: transparent; transition: all 0.2s; text-decoration: none; font-size: 0.9rem; }
.mini-btn:hover { background: #e5e7eb; color: var(--text-main); }
.mini-btn.edit:hover { color: var(--primary); background: #e0e7ff; }
.mini-btn.delete:hover { color: var(--danger); background: #fee2e2; }

/* --- 8. 内容列表 (右侧) --- */
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; color: #374151; display: flex; align-items: center; gap: 8px; }
.header-controls { display: flex; gap: 10px; }
.ctrl-btn { background: white; border: 1px solid #d1d5db; padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; cursor: pointer; color: var(--text-muted); transition: all 0.2s; }
.ctrl-btn:hover { background: #f3f4f6; color: var(--primary); border-color: var(--primary); }

/* 右侧滚动区域 */
.scrollable-body { 
    flex: 1; 
    overflow-y: auto; 
    padding: 0; 
    /* [修复3] 确保有底部圆角，且不会因为 padding 导致底部内容被切 */
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}
.scrollable-body::-webkit-scrollbar { width: 6px; }
.scrollable-body::-webkit-scrollbar-track { background: transparent; }
.scrollable-body::-webkit-scrollbar-thumb { background-color: #d1d5db; border-radius: 20px; }
.scrollable-body::-webkit-scrollbar-thumb:hover { background-color: #9ca3af; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 4rem; margin-bottom: 20px; color: #e5e7eb; display: block; }

/* 列表项 */
.collapsible-list { padding-bottom: 20px; } /* 底部留一点空隙 */
.tree-group { border-bottom: 1px solid #f3f4f6; }
.tree-group summary { padding: 14px 24px; cursor: pointer; font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; transition: background 0.1s; list-style: none; user-select: none; }
.tree-group summary::-webkit-details-marker { display: none; }
.tree-group summary:hover { background: #f9fafb; }
.folder-icon { width: 24px; color: #fbbf24; margin-right: 12px; text-align: center; }
.count-tag { margin-left: auto; background: #e5e7eb; color: var(--text-muted); font-size: 0.75rem; padding: 3px 10px; border-radius: 99px; font-weight: bold; }
.tree-content { border-top: 1px solid #f3f4f6; background: #ffffff; }

.bookmark-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 24px 10px 50px; border-bottom: 1px solid #f9fafb; transition: background 0.1s; }
.bookmark-row:hover { background: #f0f9ff; }
.bm-info { display: flex; align-items: center; gap: 12px; overflow: hidden; flex: 1; }
.bm-icon { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; }
.bm-info a { text-decoration: none; color: var(--text-main); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-actions { display: flex; gap: 8px; align-items: center; opacity: 0; transition: opacity 0.2s; }
.bookmark-row:hover .bm-actions { opacity: 1; }
.sort-group { display: flex; flex-direction: column; gap: 2px; margin-right: 6px; }
.sort-group .mini-btn { height: 12px; width: 20px; font-size: 0.65rem; line-height: 1; }

/* 其他组件 */
.sub-section { margin-bottom: 24px; }
.divider { border: 0; border-top: 1px solid #e5e7eb; margin: 24px 0; }
.separator { display: flex; align-items: center; text-align: center; margin: 20px 0 10px; }
.separator::before, .separator::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.separator span { padding: 0 10px; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.radio-group { display: flex; gap: 16px; margin: 10px 0; font-size: 0.9rem; }
.switch-label { display: flex; align-items: center; justify-content: space-between; font-size: 0.95rem; color: var(--text-main); cursor: pointer; background: #f9fafb; padding: 14px; border-radius: 8px; border: 1px solid var(--border); transition: border-color 0.2s; }
.switch-label:hover { border-color: #d1d5db; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Login Page & Toast (Keep as is) */
.login-container { height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; } 
.login-form { background: var(--bg-card); padding: 32px; border-radius: 12px; box-shadow: var(--shadow); width: 100%; max-width: 380px; text-align: center; border: 1px solid var(--border); }
.login-form h2 { margin: 0 0 24px 0; font-size: 1.5rem; color: var(--text-main); }
.login-form input { width: 100%; padding: 12px; margin-bottom: 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 1rem; }
.login-form button { width: 100%; padding: 12px; background-color: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 1rem; font-weight: 500; }
.login-form .error { color: var(--danger); margin-bottom: 16px; font-size: 0.9rem; }
.form-footer { margin-top: 20px; font-size: 0.9rem; color: var(--text-muted); }
.form-footer a { color: var(--primary); text-decoration: none; }

#toast-container { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; align-items: flex-end; }
.toast { background: white; border-left: 4px solid var(--primary); padding: 15px 20px; border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); margin-bottom: 10px; font-size: 0.95rem; display: flex; align-items: center; gap: 10px; min-width: 280px; animation: slideIn 0.3s ease; }
.toast-success { border-color: var(--success); } .toast-error { border-color: var(--danger); }
.toast-close { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #9ca3af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { transform: translateX(100%); opacity: 0; } }
.toast.hiding { animation: fadeOut 0.3s forwards; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-backdrop.hidden { display: none; }
.modal { background: white; padding: 28px; border-radius: 12px; width: 90%; max-width: 400px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.modal h3 { margin-top: 0; color: #111827; margin-bottom: 12px; font-size: 1.3rem; }
.modal p { color: #4b5563; line-height: 1.6; margin-bottom: 24px; font-size: 1rem; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 12px; }
.modal-btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; font-weight: 500; font-size: 0.95rem; transition: background 0.2s; }
.modal-btn-cancel { background: white; border: 1px solid #d1d5db; color: #374151; }
.modal-btn-confirm { background: var(--primary); color: white; }
.confirm-dangerous { background: var(--danger); }