/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-left h1 i {
    color: var(--primary-color);
}

.tagline {
    color: var(--text-light);
    font-size: 0.875rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.search-box i {
    position: absolute;
    left: 1rem;
    color: var(--text-light);
}

.search-box input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    width: 300px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* 按钮 */
.btn, .admin-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.admin-btn {
    background: var(--primary-color);
    color: white;
}

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

/* 菜单切换按钮 */
.menu-toggle {
    display: none;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-toggle:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

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

.btn-danger:hover {
    background: #dc2626;
}

/* 分类导航 */
/* 主布局 */
.main-wrapper {
    display: flex;
    min-height: calc(100vh - 73px - 60px); /* 减去头部和底部高度 */
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 73px - 60px);
    position: sticky;
    top: 73px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

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

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

.sidebar-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

/* 分类列表 */
.category-list {
    list-style: none;
    padding: 0.5rem 0;
}

.category-item {
    margin: 0;
}

.category-item a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.category-item a:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.category-item.active a {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.category-item.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.category-item a i {
    width: 20px;
    text-align: center;
    margin-right: 0.75rem;
}

.category-item a span {
    flex: 1;
}

.category-item a .count {
    background: var(--bg-color);
    color: var(--text-light);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-weight: 500;
}

.category-item.active a .count {
    background: var(--primary-color);
    color: white;
}

/* 分类展开/收起图标 */
.category-toggle {
    width: 16px;
    text-align: center;
    margin-right: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.category-spacer {
    display: inline-block;
    width: 16px;
    margin-right: 8px;
}

/* 子分类列表 */
.category-children {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.02);
}

.category-children .category-item {
    border-left: 2px solid var(--border-color);
}

.category-children .category-item:hover {
    border-left-color: var(--primary-color);
}

/* 不同级别的缩进 */
.category-item[data-level="1"] > a {
    font-size: 0.9rem;
}

.category-item[data-level="2"] > a {
    font-size: 0.85rem;
}

.category-item[data-level="3"] > a {
    font-size: 0.8rem;
}

/* 主内容区 */
.content {
    flex: 1;
    padding: 2rem;
    background: var(--bg-color);
    min-width: 0;
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* 网站网格 */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* 网站卡片 */
.site-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    position: relative;
}

.site-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.site-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-color);
    color: var(--primary-color);
}

.site-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.site-name {
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.2;
}

.site-description {
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-light);
}

.loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* 页脚 */
footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
}

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

footer a:hover {
    text-decoration: underline;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.close:hover {
    color: var(--text-color);
}

/* 表单 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

/* 拖拽模式容器 */
.drag-mode-container {
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* 拖拽模式按钮 */
.drag-mode-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    color: white;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.drag-mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.drag-mode-btn.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

.drag-mode-btn i {
    font-size: 16px;
}

.drag-mode-btn span {
    font-size: 14px;
}


/* 拖拽模式样式 */
body.drag-mode #categoryList > .category-item {
    position: relative;
}

body.drag-mode #categoryList > .category-item > a {
    position: relative;
    padding-left: 40px !important;
}

body.drag-mode #categoryList > .category-item > a::before {
    content: '⋮⋮';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
    cursor: move;
    font-weight: bold;
}

body.drag-mode #categoryList > .category-item[data-category="all"] {
    opacity: 0.5;
    pointer-events: none;
}

body.drag-mode #categoryList > .category-item[data-category="all"] > a::before {
    display: none;
}

/* 拖拽模式下的悬停效果 */
body.drag-mode #categoryList > .category-item:not([data-category="all"]):hover {
    background-color: rgba(33, 150, 243, 0.05);
}

body.drag-mode #categoryList > .category-item:not([data-category="all"]):hover > a::before {
    color: #2196F3;
}

/* 分类拖拽样式 */
.category-item[draggable="true"] {
    cursor: move;
    transition: all 0.3s ease;
}

.category-item.dragging {
    opacity: 0.4;
}

.category-item.drag-over {
    background-color: rgba(33, 150, 243, 0.1);
}

.category-item.drag-over-top {
    border-top: 2px solid #2196F3;
}

.category-item.drag-over-bottom {
    border-bottom: 2px solid #2196F3;
}

.drag-handle {
    cursor: move;
    color: #999;
    transition: color 0.2s;
}

.drag-handle:hover {
    color: #2196F3;
}

.category-item a:hover .drag-handle {
    color: #2196F3;
}

/* 通知样式 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification {
    animation: slideIn 0.3s ease;
}

/* 响应式 */
@media (max-width: 768px) {
    .header-left h1 {
        font-size: 1.25rem;
    }
    
    .tagline {
        display: none;
    }
    
    .search-box input {
        width: 200px;
    }
    
    /* 显示菜单按钮 */
    .menu-toggle {
        display: block;
    }
    
    /* 移动端侧边栏隐藏 */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 73px;
        height: calc(100vh - 73px);
        transition: left 0.3s;
        z-index: 100;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* 显示遮罩层 */
    .sidebar.active ~ .sidebar-overlay {
        display: block;
    }
    
    .content {
        padding: 1rem;
    }
    
    .site-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .search-box {
        display: none;
    }
    
    .site-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* 拖动排序样式 */
.site-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.site-card.drag-over {
    border: 2px dashed var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.02);
}

.site-card[draggable="true"] {
    cursor: move;
    user-select: none;
}

.site-card[draggable="true"]::before {
    content: '⋮⋮';
    position: absolute;
    top: 5px;
    right: 5px;
    color: var(--text-light);
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.site-card[draggable="true"]:hover::before {
    opacity: 1;
}