/* 全局样式 */
:root {
    --primary-color: #409eff;
    --secondary-color: #6c757d;
    --success-color: #67c23a;
    --warning-color: #e6a23c;
    --danger-color: #f56c6c;
    --info-color: #909399;
    --light-bg: #f8f9fa;
    --dark-bg: #1a1a1a;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-color: #dee2e6;
    --navbar-link-color: #e9ecef;
    --sidebar-text-color: #333333;
    --sidebar-text-color-dark: #f5f5f5;
    --sidebar-link-color: #000000;
    --sidebar-link-color-dark: #ffffff;
    --sidebar-bg-light: #dee2e6;
    --sidebar-bg-dark: #212529;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
    padding: 0;
    height: 100vh; /* 固定为视口高度 */
    overflow: hidden; /* 防止整个页面出现滚动条 */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

body.dark-theme {
    --light-bg: #121212;
    --card-bg: #1e1e1e;
    --text-color: #f5f5f5;
    --border-color: #333333;
    --navbar-link-color: #adb5bd;
    --sidebar-text-color: #f5f5f5;
    --sidebar-link-color: #ffffff;
    background-color: var(--light-bg);
    color: var(--text-color);
}

/* 主要内容区域 */
.container-fluid {
    flex: 1;
    overflow-y: auto; /* 让主要内容区域可以滚动 */
    height: calc(100vh - 56px); /* 减去顶部导航栏的高度 */
    padding: 0;
    overflow-x: hidden; /* 防止水平滚动 */
}

/* 顶部导航栏 */
.navbar-brand, .nav-link {
    color: var(--navbar-link-color) !important;
}

.navbar-brand:hover, .nav-link:hover {
    color: #ffffff !important;
}

/* 侧边栏 */
.sidebar {
    height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
    overflow-y: auto;
    transition: background-color 0.3s;
    color: var(--sidebar-text-color);
    background-color: var(--sidebar-bg-light);
}

.sidebar.dark-theme {
    background-color: var(--sidebar-bg-dark);
    color: var(--sidebar-text-color-dark);
}

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

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,.2);
    border-radius: 3px;
}

.accordion-button {
    background-color: transparent;
    color: var(--sidebar-text-color);
    font-weight: 500;
}

body.dark-theme .accordion-button {
    color: var(--sidebar-text-color-dark);
}

.accordion-button:not(.collapsed) {
    color: var(--primary-color);
    background-color: rgba(64, 158, 255, 0.1);
}

.accordion-button::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-button.collapsed::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

body.dark-theme .accordion-button::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23f5f5f5'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

body.dark-theme .accordion-button.collapsed::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23f5f5f5'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-item {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
}

.accordion-body {
    padding: 0.5rem 1rem;
}

.nav-link {
    color: var(--sidebar-link-color) !important;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    padding: 0.375rem 1rem;
    display: block;
    text-decoration: none;
}

body.dark-theme .nav-link {
    color: var(--sidebar-link-color-dark) !important;
}

.nav-link:hover {
    background-color: rgba(64, 158, 255, 0.1);
    color: var(--sidebar-link-color) !important;
}

body.dark-theme .nav-link:hover {
    color: var(--sidebar-link-color-dark) !important;
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* 工具卡片 */
.tool-card {
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    color: var(--text-color);
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: #e9f5ff;
}

body.dark-theme .tool-card:hover {
    background-color: #2a3d55;
}

.tool-card.dark-theme {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

.tool-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    background-color: rgba(64, 158, 255, 0.1);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.card-text {
    font-size: 0.8125rem;
    color: var(--text-color);
    height: 2.5rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 紧凑列表视图 */
.table th, .table td {
    padding: 0.5rem;
    vertical-align: middle;
    color: inherit;
}

body.dark-theme #tools-list-view,
body.dark-theme #tools-list-view .table-responsive,
body.dark-theme #tools-list-view .table,
body.dark-theme #tools-list-view table,
body.dark-theme #tools-list-view thead,
body.dark-theme #tools-list-view tbody,
body.dark-theme #tools-list-view tfoot,
body.dark-theme #tools-list-view tr,
body.dark-theme #tools-list-view th,
body.dark-theme #tools-list-view td {
    background-color: #1e1e1e !important;
    color: white !important;
}

body.dark-theme #tools-list-view .table-hover > tbody > tr:hover td,
body.dark-theme #tools-list-view .table-hover > tbody > tr:hover th {
    background-color: #2a3d55 !important;
    color: white !important;
    transition: background-color 0.3s;
}

body.dark-theme .table > thead,
body.dark-theme .table > tbody,
body.dark-theme .table > tfoot,
body.dark-theme .table > thead > tr > th,
body.dark-theme .table > tbody > tr > td {
    color: white;
    background-color: #1e1e1e;
}

body.dark-theme .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--text-color);
    --bs-table-accent-bg: #2a2a2a;
}

body.dark-theme .table-hover > tbody > tr:hover {
    color: var(--text-color);
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th,
.table-hover tbody tr:hover > td,
.table-hover tbody tr:hover > th {
    background-color: #e9f5ff;
    transition: background-color 0.3s;
}

.table-hover tbody tr:hover {
    background-color: #e9f5ff;
    transition: background-color 0.3s;
}

body.dark-theme .table-hover > tbody > tr:hover td,
body.dark-theme .table-hover > tbody > tr:hover th,
body.dark-theme .table-hover > tbody > tr:hover > td,
body.dark-theme .table-hover > tbody > tr:hover > th,
body.dark-theme #tools-list-view .table-hover > tbody > tr:hover td,
body.dark-theme #tools-list-view .table-hover > tbody > tr:hover th {
    background-color: #2a3d55 !important;
    color: white !important;
    transition: background-color 0.3s;
}

body.dark-theme .table-hover > tbody > tr:hover,
body.dark-theme #tools-list-view .table-hover > tbody > tr:hover {
    background-color: #2a3d55 !important;
    color: white !important;
    transition: background-color 0.3s;
}

/* 分类标题 */
.category-header {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 767.98px) {
    .sidebar {
        height: auto;
        position: static;
        margin-bottom: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
    
    /* 紧凑网格视图 */
    .row-cols-1 > * {
        flex: 0 0 auto;
        width: 100%;
    }
    
    .row-cols-2 > * {
        flex: 0 0 auto;
        width: 50%;
    }
}

/* 加载动画 */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading-pulse {
    animation: pulse 1.5s infinite;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0,0,0,.4);
}

/* iframe容器 */
#tool-iframe {
    border: none;
    width: 100%;
    min-height: 300px;
    height: 100%;
}

#tool-detail-container {
    display: flex;
    flex-direction: column;
}

/* 搜索框按钮样式调整 */
.input-group .btn-outline-secondary:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-left: none;
}

.input-group .btn-outline-secondary:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* 页脚样式 */
footer {
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    padding: 5px 0;
    font-size: 0.7rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    margin-top: auto; /* 推页脚到页面底部 */
    flex-shrink: 0; /* 防止页脚被压缩 */
}

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

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

body.dark-theme footer {
    background-color: var(--dark-bg);
    border-top: 1px solid #333333;
}

body.dark-theme footer a {
    color: var(--text-color);
}

/* 页脚内容样式 */
.footer-content {
    width: 100%;
    box-sizing: border-box;
}

.footer-text {
    word-wrap: break-word;
    overflow-x: hidden;
    text-align: center;
}
