/* style.css - v2.0 (增加拖拽排序样式) */
:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #06d6a0;
    --danger: #ef233c;
    --warning: #ffd166;
    --purple: #7209b7;
    --dark: #2b2d42;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #dee2e6;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    color: #333;
    padding-bottom: 30px;
    /* 禁止手机上长按出现菜单，方便长按拖拽 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
/* 恢复输入框的可选状态 */
input, textarea { -webkit-user-select: text; user-select: text; }

.container { max-width: 1200px; margin: 0 auto; padding: 10px; }

/* 头部样式 */
.header {
    display: flex; justify-content: space-between; align-items: center;
    background: white; padding: 10px 15px; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 10px;
}
.header h1 { font-size: 1.3em; color: var(--primary); margin: 0; display: flex; align-items: center; gap: 10px; }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

/* 统计卡片 */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 15px;
}
.stat-card {
    background: white; padding: 15px; border-radius: 12px; text-align: center;
    cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: all 0.3s;
    border: 1px solid white; display: flex; flex-direction: column; justify-content: center;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.stat-card h3 { color: var(--primary); font-size: 1.8em; margin-bottom: 2px; font-weight: 700; line-height: 1; }
.stat-card p { font-size: 0.85em; color: #666; margin: 0; }

/* 导航栏 */
.nav-tabs {
    display: flex; gap: 10px; margin-bottom: 15px;
    background: white; padding: 8px; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.nav-tab {
    flex: 1; padding: 8px; border: none; background: transparent;
    border-radius: 8px; cursor: pointer; font-weight: 600; color: #666; font-size: 14px;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.nav-tab:hover { background: #f8f9fa; color: var(--primary); }
.nav-tab.active { background: var(--primary); color: white; }

/* 搜索框吸顶 */
.sticky-search {
    position: sticky; top: 0; z-index: 100;
    background: #f0f2f5; padding-bottom: 5px; padding-top: 5px;
}
.search-box { position: relative; width: 100%; margin-bottom: 10px;}
.search-box input {
    width: 100%; padding: 10px 10px 10px 40px;
    border-radius: 20px; border: 2px solid #eef2f7;
    background: white; font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03); transition: all 0.3s;
}
.search-box input:focus { border-color: var(--primary); outline: none; }
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--primary); font-size: 16px; }

/* 横向滚动分类条 */
.category-filter-bar {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-filter-bar::-webkit-scrollbar { display: none; }

.cat-chip {
    background: white; border: 1px solid #e0e0e0; border-radius: 20px;
    padding: 6px 14px; font-size: 13px; color: #666; cursor: pointer; white-space: nowrap;
    transition: all 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.cat-chip.active {
    background: var(--primary); color: white; border-color: var(--primary);
    box-shadow: 3px 8px rgba(67, 97, 238, 0.3);
}
.cat-chip:hover:not(.active) { background: #f8f9fa; border-color: #ccc; }

/* 网站卡片 */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.site-card {
    background: white; border-radius: 10px; padding: 15px; border: 1px solid #f0f0f0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02); transition: all 0.3s;
    display: flex; flex-direction: column; justify-content: space-between;
    /* 允许触摸拖动 */
    touch-action: none; 
}
.site-info { cursor: pointer; margin-bottom: 8px; }

/* 拖拽时的样式 (SortableJS 自动添加的类) */
.sortable-ghost {
    opacity: 0.4;
    background-color: #f0f2f5;
    border: 2px dashed var(--primary);
}
.sortable-drag {
    cursor: grabbing;
}

/* 网站Logo样式 */
.site-favicon {
    width: 20px; height: 20px; 
    border-radius: 4px; 
    vertical-align: middle; 
    margin-right: 6px;
    object-fit: contain; 
    background-color: #f9f9f9; 
}

.site-info h3 { font-size: 1.1em; margin-bottom: 4px; color: var(--dark); display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.site-info p { font-size: 0.8em; color: #888; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}
.site-actions { display: flex; gap: 5px; border-top: 1px solid #f5f5f5; padding-top: 8px; }
.site-actions button { flex: 1; border-radius: 4px; padding: 5px 0; font-size: 12px; }

/* 分页控件 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 20px; }
.page-btn { padding: 6px 15px; background: white; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px; }

/* 手机适配优化 */
@media (max-width: 600px) {
    .container { padding: 5px; }
    .header { padding: 8px 12px; margin-bottom: 8px; }
    .header h1 { font-size: 1.1em; }
    
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px; }
    .stat-card { padding: 5px; border-radius: 8px; min-height: 60px; }
    .stat-card h3 { font-size: 1.2em; margin-bottom: 2px; }
    .stat-card p { font-size: 10px; line-height: 1.1; transform: scale(0.9); }
    
    .nav-tabs { padding: 5px; gap: 5px; margin-bottom: 10px; }
    .nav-tab { padding: 6px; font-size: 12px; }
    
    .sticky-search { padding-bottom: 2px; }
    .category-filter-bar { padding-bottom: 8px; }
    .cat-chip { padding: 4px 10px; font-size: 12px; }

    .site-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .site-card { padding: 10px; }
    .site-info h3 { font-size: 0.95em; }
    .site-actions button span { display: none; }
    .site-actions button i { margin: 0; }
}

/* 通用组件 */
.hidden { display: none !important; }
.card { background: white; border-radius: 12px; padding: 20px; margin-bottom: 15px; }
.btn { padding: 8px 16px; border-radius: 6px; border:none; color:white; cursor:pointer; font-size:14px; }
.btn-primary { background: var(--primary); }
.btn-secondary { background: #6c757d; color: white; }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #333; }
.btn-success { background: var(--success); }
.btn-purple { background: var(--purple); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9em; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.modal-content { background: white; margin: 10vh auto; padding: 20px; border-radius: 12px; width: 90%; max-width: 450px; position: relative; }
.close { position: absolute; right: 15px; top: 15px; font-size: 20px; cursor: pointer; color: #999; }

.category-list { max-height: 350px; overflow-y: auto; border: 1px solid #eef2f7; border-radius: 6px; padding: 5px; margin-top:10px;}
.category-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid #f0f0f0; background: #fff;
}
.category-item:last-child { border-bottom: none; }
.category-item:hover { background-color: #f8f9fa; }
.category-controls { display: flex; gap: 5px; }