/* 极简风格 */
:root {
    --bg: #f5f5f5;
    --card: #fff;
    --text: #333;
    --sub: #666;
    --muted: #999;
    --accent: #2563eb;
    --border: #e5e5e5;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 全屏布局 */
html, body {
    height: 100%;
    overflow: hidden;
}

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

a { color: var(--accent); text-decoration: none; }

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    flex-shrink: 0;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo { font-size: 16px; font-weight: 700; }

/* 搜索框 */
.search-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper input {
    width: 100%;
    padding: 6px 28px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-clear {
    position: absolute;
    right: 6px;
    width: 18px;
    height: 18px;
    border: none;
    background: #ccc;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    background: #999;
}

.header-actions { display: flex; gap: 6px; }

.btn {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

.btn:hover { background: #1d4ed8; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

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

/* Toast 通知 */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 8px 16px;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    min-width: 160px;
}

.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.warning { background: #f59e0b; }
.toast.info { background: #3b82f6; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateX(100%); }
}

.toast.fade-out { animation: fadeOut 0.3s ease forwards; }

/* 主容器 */
.main-container {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* 左侧分类栏 */
.home-sidebar {
    width: 200px;
    padding: 12px 10px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--bg);
}

.home-sidebar::-webkit-scrollbar {
    width: 3px;
}

.home-sidebar::-webkit-scrollbar-track {
    background: var(--bg);
}

.home-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.home-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 6px;
}

.sidebar-title {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.btn-add-cat {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-cat:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 分类项统一样式 */
.cat-item {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    background: transparent;
    color: var(--text);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-item:hover {
    background: var(--border);
}

/* 选中状态统一蓝色背景白色文字 */
.cat-item.active {
    background: var(--accent);
    color: #fff;
}

.cat-item.active .cat-actions button {
    color: #fff;
    opacity: 0.8;
}

.cat-item.active .cat-actions button:hover {
    opacity: 1;
}

.cat-item .cat-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cat-item .cat-name img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.cat-item .cat-actions {
    display: none;
    gap: 3px;
    margin-left: 6px;
}

.cat-item:hover .cat-actions {
    display: flex;
}

.cat-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 3px;
    border-radius: 3px;
    opacity: 0.6;
    color: inherit;
}

.cat-actions button:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

.cat-item.active .cat-actions button:hover {
    background: rgba(255,255,255,0.2);
}

/* 子分类缩进 */
.subcat-list {
    margin-left: 16px;
    padding-left: 6px;
    border-left: 1px dashed var(--border);
}

.subcat-list .cat-item {
    background: transparent;
}

/* 右侧主内容区 */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 12px 16px;
}

/* 网址网格容器 */
.tool-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 2px;
}

/* 网址网格 - 卡片缩小 */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

/* 网址卡片 - 缩小 */
.site-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    transition: all 0.2s;
    position: relative;
    cursor: pointer;
}

.site-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.site-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.site-icon img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.site-info {
    margin-top: 6px;
}

.site-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-desc {
    font-size: 10px;
    color: var(--sub);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-fav {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.4;
    padding: 2px;
}

.site-fav:hover, .site-fav.active { opacity: 1; }

/* 网址卡片上的管理按钮 */
.site-admin-actions {
    position: absolute;
    bottom: 4px;
    right: 4px;
    display: none;
    gap: 4px;
}

.site-card:hover .site-admin-actions {
    display: flex;
}

.site-admin-actions button {
    background: rgba(0,0,0,0.6);
    border: none;
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 9px;
    cursor: pointer;
    color: #fff;
}

.site-admin-actions button:hover {
    background: var(--accent);
}

/* 空状态 */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 12px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    flex-shrink: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.page-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--card);
    cursor: pointer;
    font-size: 12px;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
.footer {
    text-align: center;
    padding: 6px 20px;
    color: var(--muted);
    font-size: 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--card);
    border-radius: 10px;
    max-width: 420px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    padding: 20px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--bg);
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--border);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--sub);
    margin-bottom: 5px;
    font-weight: 500;
}

.form-input, select.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

.form-input:focus, select.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* 图标类型选择器 */
.icon-type-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.icon-type-selector label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-weight: normal;
    font-size: 12px;
}

.icon-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: var(--bg);
    border-radius: 5px;
    margin-top: 8px;
}

/* 响应式 */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; }
    .search-wrapper { order: 3; width: 100%; }
    .home-sidebar { width: 160px; }
    .tool-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (max-width: 480px) {
    .home-sidebar { width: 130px; }
    .tool-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}