/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    text-align: left;
    font: 14px/1.5 "微软雅黑", "宋体", "Verdana", sans-serif;
    background: #EDEDED url("body-bg.png") repeat 0 0;
    color: #888;
    min-width: 1000px;
    overflow-x: auto;
}

a {
    cursor: pointer;
    color: #000;
    text-decoration: none;
    outline: 0 none;
    transition: all .2s linear;
}

a:hover {
    text-decoration: none;
    color: #2783e0;
}

/* 头部导航 */
.header {
    height: 50px;
    background: #2783e0;
    color: #FFF;
    text-shadow: 1px 1px 1px #000;
    padding: 0;
}

.header h1 {
    width: 980px;
    margin: 0 auto;
    padding: 0 10px;
    font: normal 25px/50px "microsoft yahei", "微软雅黑", "宋体";
}

/* 主容器 */
.container {
    width: 980px;
    margin: 0 auto;
    padding: 10px 0;
    position: relative;
}

/* 导航分类样式 */
.nav-section {
    position: relative;
    display: flex;
    align-items: flex-end;  /* 改为底部对齐 */
    margin-bottom: 10px;
}

.section-title-wrapper {
    display: flex;
    align-items: flex-end;  /* 改为底部对齐 */
    margin-bottom: 0;  /* 移除底部间距 */
    position: relative;
}

.section-title {
    background: var(--theme-color);
    color: white;
    padding: 0 15px;
    font-size: 16px;
    display: inline-block;
    min-width: 124px;
    text-align: center;
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    margin-bottom: 1px;
    text-shadow: 1px 1px 1px #000;
    cursor: pointer;
    position: relative;
}

/* 链接网格基础样式 */
.links-grid,
.parent-links {
    position: absolute;
    left: 0;
    top: 45px;
    width: 100%;  /* 确保宽度是100% */
    background: white;
    border: 1px solid #e6e6e6;
    z-index: 1;
    padding: 0;
    margin: 0;
}

/* 一级分类链接样式 - 默认显示并横排 */
.parent-links {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    min-width: 972px;  /* 6个链接的总宽度 = 162px * 6 */
}

/* 二级分类链接样式 */
.links-grid {
    display: none;
    min-width: 972px;  /* 确保容器足够宽 */
}

.links-grid.active {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

/* 当有子分类被激活时，隐藏一级分类的链接 */
.has-active-subcategory .parent-links {
    display: none !important;
}

/* 子分类容器 */
.subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
    align-items: flex-end;  /* 改为底部对齐 */
    padding-bottom: 2px;  /* 添加小的底部间距，与一级分类对齐 */
}

/* 移除固定间距的样式 */
.nav-section:has(.parent-links:not(:empty)),
.nav-section:has(.links-grid.active) {
    margin-bottom: 0;
}

.nav-section:has(.parent-links:not(:empty)) + .nav-section,
.nav-section:has(.links-grid.active) + .nav-section {
    margin-top: 0;
}

/* 没有链接时的默认间距 */
.nav-section:not(:has(.parent-links:not(:empty))):not(:has(.links-grid.active)) {
    margin-bottom: 10px;
}

/* 删除按钮基础样式 */
.delete-button {
    position: absolute;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    text-align: center;
    z-index: 100;  /* 提高层级 */
    opacity: 0;  /* 默认隐藏 */
    transition: opacity 0.2s, background-color 0.2s;
    pointer-events: auto;  /* 确保可以点击 */
}

/* 一级分类删除按钮 */
.delete-category {
    display: none;
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    margin: 0;
    z-index: 999;
}

.logged-in .section-title-wrapper:hover .delete-category {
    display: block;
}

/* 二级分类删除按钮 */
.delete-subcategory {
    display: none;
    position: absolute;
    right: -8px;
    top: -8px;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    z-index: 999;
}

.logged-in .subcategory:hover .delete-subcategory {
    display: block;
}

/* 显示删除按钮 */
.logged-in .section-title-wrapper:hover .delete-category,
.logged-in .subcategory:hover .delete-subcategory {
    opacity: 1;
}

/* 删除按钮悬停效果 */
.delete-category:hover,
.delete-subcategory:hover {
    background: #ff6666;
}

/* 确保删除按钮容器可以正确定位 */
.section-title-wrapper,
.subcategory {
    position: relative;
    display: inline-block;
}

/* 防止删除按钮被其他元素遮挡 */
.section-title-wrapper::after,
.subcategory::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* 链接卡片样式 */
.link-card {
    flex: 0 0 162px !important;  /* 固定宽度，不伸缩 */
    width: 162px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-left: 1px solid #e6e6e6;
    border-bottom: 1px solid #e6e6e6;
    position: relative;
    margin: 0;  /* 移除可能的外边距 */
    padding: 0;  /* 移除可能的内边距 */
}

/* 每行第6个卡片添加右边框 */
.link-card:nth-child(6n) {
    border-right: 1px solid #e6e6e6;
}

.link-card:hover {
    background: #000;
}

.link-card:hover a {
    color: #FFF;
    text-shadow: 1px 1px 1px #000;
}

.link-card a {
    color: #000;
    text-decoration: none;
    font-size: 16px;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 5px;
}

/* 管理员控件样式 */
.admin-controls {
    display: none;
}

.admin-controls.show {
    display: block;
    margin-bottom: 10px;
}

.admin-controls button,
.admin-controls a {
    background: #2783e0;
    color: white;
    border: none;
    padding: 0 15px;
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 16px;
    display: inline-block;
    text-shadow: 1px 1px 1px #000;
}

.admin-controls button:hover,
.admin-controls a:hover {
    background: #000;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px 0;
    height: 50px;
    line-height: 50px;
    color: #888;
}

/* 编辑模式样式 */
.logged-in .admin-actions {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    padding: 5px;
    border-radius: 3px;
    display: none;
}

.link-card:hover .admin-actions {
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-actions button {
    background: var(--theme-color);
    color: white;
    border: none;
    padding: 3px 8px;
    margin: 0 2px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 4px;
    width: 90%;
    max-width: 400px;
    margin: 100px auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

.modal-content input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 14px;
}

.modal-content button {
    background: #2783e0;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
}

.modal-content button:hover {
    background: #000;
}

/* 可编辑文本样式 */
.editable {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
}

.editable:hover {
    background: rgba(255,255,255,0.1);
}

/* 页脚管理员登录按钮 */
.admin-login-btn {
    margin-top: 10px;
}

.admin-btn {
    display: inline-block;
    background: #2783e0;
    color: white;
    padding: 5px 15px;
    border-radius: 3px;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.admin-btn:hover {
    background: #000;
    color: white;
}

.error {
    color: #ff0000;
    margin-bottom: 10px;
    padding: 5px;
    border-radius: 3px;
    background-color: rgba(255,0,0,0.1);
}

.modal-content textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 14px;
    min-height: 80px;
    resize: vertical;
}

/* 分类导航浮动窗口 */
.category-nav {
    position: fixed;
    left: calc(50% - 600px); /* 居中对齐，考虑主容器宽度 */
    top: 100px;
    width: 120px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 999;
}

.category-nav-title {
    background: #2783e0;
    color: white;
    padding: 8px 5px;
    font-size: 14px;
    text-align: center;
    border-radius: 4px 4px 0 0;
    text-shadow: 1px 1px 1px #000;
}

.category-nav ul {
    list-style: none;
    padding: 5px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    margin: 0;  /* 添加外边距重置 */
}

.category-nav li {
    margin-bottom: 5px;
    list-style: none;  /* 确保没有列表样式 */
}

.category-nav a {
    display: block;
    padding: 5px 8px;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.2s ease;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-nav a:hover {
    background: #f0f0f0;
    color: #2783e0;
}

.category-nav a.active {
    background: #2783e0;
    color: white;
}

/* 响应式布局调整 */
@media screen and (max-width: 1300px) {
    .category-nav {
        left: 10px; /* 屏幕较窄时固定在左侧 */
    }
}

@media screen and (max-width: 1150px) {
    .category-nav {
        display: none; /* 屏幕更窄时隐藏导航 */
    }
    
    .container {
        margin: 0 auto; /* 重置容器边距 */
        width: 980px;
    }
}

/* 折叠链接样式 */
.links-grid .collapsed {
    display: none;
}

.links-grid.show-all .collapsed {
    display: block;
}

.show-more-btn {
    width: 100%;
    background: #f5f5f5;
    color: #666;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    border-top: 1px solid #e6e6e6;
}

.show-more-btn:hover {
    background: #e9e9e9;
}

/* 提交链接按钮 */
.submit-link-btn {
    position: absolute;
    right: 10px;
    top: 10px;
}

.submit-link-btn button {
    background: #2783e0;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

/* 分类选择下拉框 */
.modal-content select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 14px;
}

/* 管理员视图 */
.links-grid.admin-view .collapsed {
    display: block;
}

/* 待审核链接样式 */
.pending-links {
    margin: 20px 0;
}

.pending-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.pending-info h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.pending-info p {
    margin: 5px 0;
    color: #666;
}

.pending-actions {
    margin-top: 10px;
}

.pending-actions button {
    background: #2783e0;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 10px;
}

.pending-actions button[value="reject"] {
    background: #ff4444;
}

.back-btn {
    display: inline-block;
    background: #2783e0;
    color: white;
    padding: 8px 20px;
    border-radius: 4px;
    margin-top: 20px;
    text-decoration: none;
}

/* 待审核链接编辑样式 */
.pending-field {
    margin-bottom: 10px;
}

.pending-field label {
    display: inline-block;
    width: 80px;
    color: #666;
}

.pending-field input,
.pending-field select,
.pending-field textarea {
    width: calc(100% - 100px);
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.pending-field textarea {
    height: 60px;
    resize: vertical;
}

.visit-link {
    display: inline-block;
    margin-left: 10px;
    color: #2783e0;
    text-decoration: none;
}

.visit-link:hover {
    text-decoration: underline;
}

/* 颜色切换器样式 */
.color-switcher {
    position: absolute;
    right: 120px;  /* 修改位置到右上角，留出提交链接按钮的空间 */
    top: 10px;
    display: flex;
    gap: 5px;  /* 减小颜色框之间的间距 */
}

.color-box {
    width: 15px;     /* 减小宽度为原来的一半 */
    height: 15px;    /* 减小高度为原来的一半 */
    border-radius: 2px;
    cursor: pointer;
    border: 1px solid #fff;  /* 减小边框宽度 */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.color-box:hover {
    transform: scale(1.1);
}

.color-box.active {
    border-color: #000;
}

/* 添加CSS变量用于主题色 */
:root {
    --theme-color: #2783e0;
}

/* 使用CSS变量替换固定颜色 */
.header,
.section-title,
.admin-controls button,
.admin-controls a,
.admin-actions button,
.modal-content button,
.category-nav-title,
.category-nav a.active,
.submit-link-btn button,
.back-btn {
    background: var(--theme-color);
}

a:hover,
.category-nav a:hover {
    color: var(--theme-color);
}

/* 子分类链接样式 */
.subcategory-link {
    display: inline-block;
    padding: 5px 15px;
    background: #f5f5f5;
    border-radius: 3px;
    color: #333;
    text-decoration: none;
    margin-right: 10px;
    position: relative;
    margin-bottom: 0;  /* 移除底部间距 */
}

/* 子分类激活状态使用对比色 */
.subcategory-link.active {
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 子分类激活状态的主题色映射 - 使用突出的颜色 */
:root[style*="--theme-color: #3498db"] .subcategory-link.active {
    background: #2980b9; /* 天空蓝对应的深蓝 */
}

:root[style*="--theme-color: #2c5530"] .subcategory-link.active {
    background: #1e8449; /* 墨绿对应的翠绿 */
}

:root[style*="--theme-color: #4a235a"] .subcategory-link.active {
    background: #8e44ad; /* 深紫对应的亮紫 */
}

:root[style*="--theme-color: #c65d02"] .subcategory-link.active {
    background: #d35400; /* 赤褐对应的橙红 */
}

:root[style*="--theme-color: #34495e"] .subcategory-link.active {
    background: #2c3e50; /* 深邃蓝对应的靛青 */
}

/* 子分类激活状态样式 */
.subcategory-link.active {
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-weight: bold;  /* 保留加粗文字效果 */
}

/* 响应式布局调整 */
@media screen and (max-width: 768px) {
    .nav-section {
        flex-direction: column;
    }
    
    .section-title-wrapper {
        margin-bottom: 10px;
    }
    
    .subcategories {
        width: 100%;
        margin-top: 10px;
    }
}

/* 清除浮动，确保容器高度正确 */
.nav-section::after {
    content: '';
    display: table;
    clear: both;
}

/* 查找并替换所有 -ms-high-contrast 相关的代码 */

/* 旧代码示例 */
@media (-ms-high-contrast: active) {
  /* 某些样式 */
}

/* 替换为新标准 */
@media (forced-colors: active) {
  /* 相同的样式 */
} 