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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
}

/* 侧边栏样式 */
.sidebar {
    width: 250px;
    background: white;
    height: 100vh;
    position: fixed;
    left: -250px;
    top: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 1000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: white;
}

.sidebar-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-header .sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.sidebar-nav {
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    background: #f8f9fa;
    border-left-color: #2c3e50;
    padding-left: 25px;
}

.sidebar-footer {
    padding: 10px;
    border-top: 2px solid #f0f0f0;
    flex-shrink: 0;
}

.sidebar-apply-btn {
    display: block;
    width: 100%;
    padding: 8px 15px;
    background: #2c3e50;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sidebar-apply-btn:hover {
    background: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3);
}

.link-count {
    background: #2c3e50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* 二级菜单样式 */
.sidebar-menu-item {
    overflow: hidden;
}

.sidebar-parent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-parent:hover {
    background: #f8f9fa;
    border-left-color: #2c3e50;
    padding-left: 25px;
}

.submenu-arrow {
    margin-left: 8px;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    color: #666;
}

.sidebar-menu-item.active .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f8f9fa;
}

.sidebar-menu-item.active .sidebar-submenu {
    max-height: 500px;
}

.sidebar-sublink {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 12px 35px;
    color: #555;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-sublink:hover {
    background: #e9ecef;
    border-left-color: #667eea;
    padding-left: 40px;
}

.sidebar-sublink .link-count {
    background: #667eea;
    font-size: 0.8rem;
}

/* 主内容区 */
.main-wrapper {
    flex: 1;
    margin-left: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 固定顶部导航栏 */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.sidebar-toggle-btn {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: #34495e;
}

.site-title {
    flex: 1;
    text-align: center;
}

.site-title h1 {
    font-size: 2rem;
    color: #333;
    margin: 0;
    font-weight: 600;
}

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

/* 搜索框卡片 */
.search-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.search-box {
    max-width: 800px;
    margin: 0 auto;
}

.search-box form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.search-btn {
    padding: 12px 30px;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.search-btn:hover {
    background: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.search-clear {
    padding: 12px 20px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.search-clear:hover {
    color: #5568d3;
}

.search-info {
    background: white;
    padding: 15px 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #667eea;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 分类容器 */
.categories-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 分类样式 */
.category {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    scroll-margin-top: 20px;
}

.category-title {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2c3e50;
}

/* 二级分类标签页样式 */
.subcategory-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 15px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.subcategory-tab {
    padding: 6px 16px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 6px;
    color: #666;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.subcategory-tab:hover {
    background: #e9ecef;
    color: #2c3e50;
}

.subcategory-tab.active {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

.subcategory-contents {
    position: relative;
}

.subcategory-content {
    display: none;
}

.subcategory-content.active {
    display: block;
}

/* 链接网格 */
.links-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.link-item:hover {
    background: #2c3e50;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.link-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 4px;
}

.link-content {
    flex: 1;
    min-width: 0;
}

.link-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-description {
    font-size: 0.85rem;
    opacity: 0.8;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 隐藏链接项 */
.link-item.hidden-item {
    display: none;
}

/* "显示更多"链接项样式 */
.link-item.show-more-item {
    background: #2c3e50 !important;
    color: white !important;
}

.link-item.show-more-item:hover {
    background: #34495e !important;
}

.link-item.show-more-item .link-icon {
    display: none;
}

.link-item.show-more-item .link-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.link-item.show-more-item .link-title {
    color: white !important;
    white-space: normal;
    text-align: center;
}

.link-item.show-more-item .link-description {
    display: none;
}

/* 无结果提示 */
.no-results {
    background: white;
    padding: 60px 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.no-results p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 20px;
}

/* Footer样式 */
.main-footer {
    margin-top: 40px;
    padding: 30px 20px;
    text-align: center;
    color: #666;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.main-footer p {
    margin: 8px 0;
    font-size: 0.95rem;
}

.main-footer a {
    color: #2c3e50;
    text-decoration: underline;
}

.main-footer a:hover {
    opacity: 0.8;
}

/* 登录页面样式 */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* 登录页面body样式 */
body.login-page {
    background: #f5f5f5;
    display: block;
}

.login-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    /* 禁用所有浏览器的原生样式 */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    -ms-appearance: none;
    -o-appearance: none;
    /* 添加自定义箭头 */
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23667eea" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

/* 强制Chrome移动端使用自定义样式 */
@supports (-webkit-touch-callout: none) {
    .form-group select {
        -webkit-appearance: none !important;
    }
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-full {
    width: 100%;
}

.btn-danger {
    background: #dc3545;
}

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

.btn-success {
    background: #28a745;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* 管理后台样式 */
.admin-header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-header h1 {
    color: #333;
    font-size: 1.8rem;
}

.admin-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e9ecef;
}

.tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab:hover {
    color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

table th {
    background: #f8f9fa;
    color: #333;
    font-weight: 600;
}

table tr:hover {
    background: #f8f9fa;
}

.actions {
    display: flex;
    gap: 8px;
}

/* 模态框样式 */
.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: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    color: #333;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
}

.close:hover {
    color: #333;
}

.alert {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 自定义分类选择器样式 */
.custom-select-wrapper {
    position: relative;
}

.custom-select-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23667eea" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

.custom-select-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.category-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow: hidden;
}

.category-dropdown.active {
    display: block;
}

.category-search {
    width: 100%;
    padding: 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.95rem;
    outline: none;
}

.category-search:focus {
    border-bottom-color: #667eea;
}

.category-options {
    max-height: 250px;
    overflow-y: auto;
}

.category-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.category-option:hover {
    background: #f8f9fa;
}

.category-option.selected {
    background: #667eea;
    color: white;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .links-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1024px) {
    .links-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        display: block;
    }

    .sidebar {
        z-index: 1001;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .nav-container {
        padding: 12px 15px;
    }

    .sidebar-toggle-btn {
        font-size: 1rem;
        padding: 8px 12px;
    }

    .site-title h1 {
        font-size: 1.5rem;
    }

    .search-card {
        padding: 15px;
    }

    .search-box form {
        gap: 8px;
    }

    .search-input {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .search-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .search-clear {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    /* 手机端二级分类标签 */
    .subcategory-tabs {
        gap: 4px;
        margin-bottom: 12px;
    }

    .subcategory-tab {
        padding: 4px 12px;
        font-size: 0.8rem;
        border-radius: 4px;
    }

    .links-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .link-item {
        padding: 8px;
        flex-direction: row;
        text-align: left;
        gap: 8px;
        align-items: center;
    }

    .link-icon {
        margin: 0;
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .link-content {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .link-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.85rem;
        text-align: center;
    }

    .link-description {
        display: none;
    }

    .sidebar {
        width: 250px;
        overflow-y: auto;
    }

    .sidebar-nav {
        flex: 0 1 auto;
        overflow-y: visible;
    }

    .sidebar-footer {
        padding: 10px;
        flex-shrink: 0;
    }

    .sidebar-apply-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .admin-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .admin-header .btn-sm {
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 5px;
    }

    .tab {
        padding: 10px 15px;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .actions .btn-sm {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .modal-content .btn {
        font-size: 0.85rem;
        padding: 10px 20px;
    }

    table {
        font-size: 0.9rem;
        display: block;
        overflow-x: auto;
    }

    table th,
    table td {
        padding: 8px;
        white-space: nowrap;
    }

    .category {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .nav-container {
        padding: 10px;
        gap: 10px;
    }

    .sidebar-toggle-btn {
        font-size: 0.9rem;
        padding: 6px 10px;
    }

    .site-title h1 {
        font-size: 1.3rem;
    }

    .search-card {
        padding: 12px;
    }

    .search-box form {
        gap: 6px;
    }

    .search-input {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .search-btn {
        font-size: 0.85rem;
        padding: 8px 15px;
    }

    .search-clear {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    /* 小屏手机端二级分类标签 */
    .subcategory-tabs {
        gap: 3px;
        margin-bottom: 10px;
    }

    .subcategory-tab {
        padding: 3px 10px;
        font-size: 0.75rem;
        border-radius: 4px;
        border-width: 1px;
    }

    .links-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .link-item {
        padding: 6px;
        gap: 6px;
    }

    .link-icon {
        width: 20px;
        height: 20px;
    }

    .link-content {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .link-title {
        font-size: 0.75rem;
        text-align: center;
    }

    .login-container {
        margin: 30px auto;
        padding: 20px 15px;
        max-width: 90%;
    }

    .category-title {
        font-size: 1.2rem;
    }

    .category {
        padding: 12px 10px;
    }
}

