/* 现代化紧凑设计 - 支持背景图片 */
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b; 

    /* 图标背景颜色模式 */
    --accent-color: #ffffff;
    --hover-color: #2563eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --header-overlay: rgba(255, 255, 255, 0.95);
    /* 透明度变量由PHP动态设置，不在此处定义默认值 */
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
}

/* 背景图片支持 */
body.has-bg-image {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

body.has-bg-image::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    z-index: -1;
    pointer-events: none;
}

/* 背景颜色模式 */
body.bg-color {
    background: var(--bg-color);
}

body.bg-color::before {
    display: none;
}

/* 头部样式 - 支持透明度 */
.header {
    position: relative;
    border-bottom: 1px solid var(--card-border);
    padding: 1.5rem 0;
    box-shadow: 0 1px 3px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, var(--header-bg-opacity));
    z-index: -1;
}

body.has-bg-image .header::before {
    background: rgba(255, 255, 255, var(--header-bg-opacity));
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.search-bar {
    flex: 1;
    max-width: 400px;
}

/* 搜索输入框样式 */
.search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--card-border);
    border-radius: 0.375rem;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
    opacity: 0.65; /* 设置透明度为80% */
}

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    opacity: 1; /* 聚焦时不透明 */
}

/* 主内容区域 */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* 分类卡片 - 支持背景图片 */
.category-section {
    margin-bottom: 1.5rem;
    position: relative;
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px var(--shadow-color);
    transition: all 0.2s;
}

.category-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, var(--links-area-opacity));
    z-index: -1;
}

body.has-bg-image .category-section::before {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.category-header {
    position: relative;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.125rem;
    transition: all 0.2s;
    color: var(--category-color, var(--accent-color));
    border-left: 4px solid var(--category-color, var(--accent-color));
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.category-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, var(--category-bg-opacity));
    z-index: -1;
}

body.has-bg-image .category-header::before {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.category-section:hover {
    box-shadow: 0 4px 6px var(--shadow-hover);
}

body.has-bg-image .category-section:hover::before,
body.has-bg-image .category-section:active::before,
body.has-bg-image .category-section:focus::before {
    background: rgba(255, 255, 255, calc(var(--links-area-opacity) + 0.1));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.category-header > * {
    position: relative;
    z-index: 2;
}

.category-header .card-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-primary);
}

.category-header .count {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-left: auto;
}

.category-header p {
    display: none; /* 隐藏描述以节省空间 */
}

/* 链接网格 - 更紧凑 */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    position: relative;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    min-height: 60px;
}

.link-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, var(--link-card-opacity));
    border-radius: 0.375rem;
    z-index: -1;
}

body.has-bg-image .link-card::before {
    border-color: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

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

body.has-bg-image .link-card:hover::before,
body.has-bg-image .link-card:active::before,
body.has-bg-image .link-card:focus::before {
    background: rgba(255, 255, 255, calc(var(--link-card-opacity) + 0.1));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
}

.link-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    background: var(--accent-color);
    color: white;
    font-size: 1rem;
}

.link-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

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

.link-content h3 {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-content p {
    font-size: 0.75rem;
    color: #475569; /* 更深的灰色，从#64748b改为#475569 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .search-bar {
        max-width: none;
    }
    
    .links-grid {
        grid-template-columns: 1fr;
    }
    
    .main {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem 0;
    }
    
    .category-header {
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
    }
    
    .link-card {
        padding: 0.625rem;
        min-height: 50px;
    }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.empty-state code {
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* 搜索高亮 */
.highlight {
    background: yellow;
    color: var(--text-primary);
    padding: 0.125rem;
    border-radius: 0.125rem;
}

.search-highlight {
    background-color: var(--accent-color);
    color: var(--card-bg);
    padding: 0 2px;
    border-radius: 2px;
}

/* 动画优化 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-section {
    animation: fadeIn 0.3s ease-out;
}

.link-card {
    animation: fadeIn 0.2s ease-out;
}

/* SVG图标样式 */
.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
}

.category-header .icon {
    font-size: 1.125rem;
    margin-right: 0.5rem;
}

.link-icon .icon {
    font-size: 1rem;
}

/* 页脚样式 - 增强可见度 */
.footer {
    padding: 0.5rem 0;
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    background: rgba(255, 255, 255, var(--footer-bg-opacity, 0.7));
    border-top: 1px solid var(--card-border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

body.has-bg-image .footer {
    background: rgba(255, 255, 255, var(--footer-bg-opacity, 0.7));
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.footer-content {
    margin-bottom: 0.125rem;
    line-height: 1.3;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 800px;
}

.footer-content p {
    margin: 0.0625rem 0;
}

.footer-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.footer-content a:hover {
    text-decoration: underline;
    color: var(--hover-color);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    margin-top: 0.125rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--card-border);
    width: 100%;
    max-width: 600px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.footer-links a:hover {
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.footer-links a i {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .footer {
        padding: 0.375rem 0;
        margin-top: 0.75rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 0.125rem;
        align-items: center;
    }
    
    .footer-links a {
        justify-content: center;
    }
}