/* Global Styles & Variables */
:root {
    --primary-color: #5B6AFF; /* 主色 */
    --secondary-color: #8C54FF; /* 辅助色 */
    --background-color-light: #FFFFFF; /* 白色背景 */
    --background-color-medium: #F5F7FA; /* 浅灰色背景 */
    --text-color-dark: #333333; /* 深灰色文字 */
    --text-color-medium: #666666; /* 中灰色文字 */
    --text-color-light: #FFFFFF; /* 白色文字 */
    --gradient-primary: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --shadow-main: 0 4px 12px rgba(0,0,0,0.08); /* 主要阴影 */
    --border-radius-main: 12px; /* 主要圆角 */
    --spacing-unit: 8px; /* 间距单位 */
}

/* Dark Theme Variables */
body.dark-theme {
    --primary-color: #6A7BFF; /* 暗模式下主色可微调以保证对比度 */
    --secondary-color: #9D6CFF;
    --background-color-light: #1E2124; /* 暗色背景 */
    --background-color-medium: #16181A; /* 更暗的背景 */
    --text-color-dark: #E0E0E0; /* 亮色文字 */
    --text-color-medium: #A0A0A0;
    --shadow-main: 0 6px 18px rgba(0,0,0,0.25); /* 暗模式下阴影可更明显 */
}


body {
    font-family: 'Inter', '思源黑体', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color-medium);
    color: var(--text-color-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease; /* 平滑主题切换 */
}

.app-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Top Navigation */
#top-nav {
    background: var(--primary-color);
    color: var(--text-color-light);
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 4); /* 调整padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); /* 稍微调整阴影 */
    height: 64px; /* 固定高度 */
}

#top-nav .logo {
    display: flex;
    align-items: center;
}

#top-nav .logo i {
    font-size: calc(var(--spacing-unit) * 3); /* 24px */
    margin-right: var(--spacing-unit);
}

#top-nav .logo h1 {
    font-size: calc(var(--spacing-unit) * 2.5); /* 20px */
    margin: 0;
    font-weight: 700; /* 加粗 */
}

#top-nav .search-bar {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.15); /* 调整透明度 */
    border-radius: var(--border-radius-main); /* 使用主要圆角 */
    padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.5);
    transition: background-color 0.3s ease;
}
body.dark-theme #top-nav .search-bar {
    background-color: rgba(0, 0, 0, 0.2);
}


#top-nav .search-bar input {
    background: transparent;
    border: none;
    color: var(--text-color-light);
    padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit);
    outline: none;
    width: 280px;
    font-size: 14px;
}

#top-nav .search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}
body.dark-theme #top-nav .search-bar input::placeholder {
    color: rgba(224, 224, 224, 0.5);
}

#top-nav .search-bar button {
    background: transparent;
    border: none;
    color: var(--text-color-light);
    cursor: pointer;
    font-size: 18px; /* 增大图标 */
    padding: calc(var(--spacing-unit) * 0.5);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}
#top-nav .search-bar button:hover {
    opacity: 1;
}

#top-nav .top-nav-actions {
    display: flex;
    align-items: center;
}

/* Default hide mobile only buttons */
.mobile-only-button {
    display: none;
}

#top-nav .top-nav-actions button {
    background: transparent;
    border: none;
    color: var(--text-color-light);
    font-size: calc(var(--spacing-unit) * 2.5); /* 20px */
    margin-left: calc(var(--spacing-unit) * 2); /* Adjusted margin slightly */
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    padding: var(--spacing-unit); /* 增加点击区域 */
    border-radius: 50%; /* 圆形背景效果（悬停时） */
}
#top-nav .top-nav-actions button#mobile-search-toggler {
    margin-left: var(--spacing-unit); /* Specific margin for this button */
}


#top-nav .top-nav-actions button:hover {
    opacity: 1;
    transform: scale(1.1);
    background-color: rgba(255,255,255,0.1);
}
body.dark-theme #top-nav .top-nav-actions button:hover {
    background-color: rgba(0,0,0,0.2);
}


#top-nav .user-profile {
    display: flex;
    align-items: center;
    margin-left: calc(var(--spacing-unit) * 2.5); /* 20px */
    cursor: pointer;
    padding: var(--spacing-unit);
    border-radius: var(--border-radius-main);
    transition: background-color 0.2s ease;
}
#top-nav .user-profile:hover {
    background-color: rgba(255,255,255,0.1);
}
body.dark-theme #top-nav .user-profile:hover {
    background-color: rgba(0,0,0,0.2);
}

#top-nav .user-profile i {
    font-size: calc(var(--spacing-unit) * 3); /* 24px */
    margin-right: var(--spacing-unit);
}
#top-nav .user-profile span {
    font-size: 14px;
}


/* Main Layout (Sidebar + Content) */
.main-layout {
    display: flex;
    flex-grow: 1;
    padding-top: 64px; /* Height of top-nav */
}

/* Left Sidebar */
#left-sidebar {
    width: 260px; /* 固定宽度 */
    background-color: var(--background-color-light);
    padding: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 1.5); /* 调整padding */
    box-shadow: 3px 0 10px rgba(0,0,0,0.03); /* 微调阴影 */
    height: calc(100vh - 64px); /* Full height minus top-nav */
    position: fixed;
    top: 64px; /* Below top-nav */
    left: 0;
    overflow-y: auto;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
body.dark-theme #left-sidebar {
    box-shadow: 3px 0 10px rgba(0,0,0,0.15);
}


#left-sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#left-sidebar .category-item {
    display: flex;
    align-items: center;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2); /* 12px 16px */
    margin-bottom: var(--spacing-unit); /* 8px */
    border-radius: var(--border-radius-main);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    color: var(--text-color-medium);
    font-weight: 500;
}

#left-sidebar .category-item i {
    font-size: 18px;
    margin-right: calc(var(--spacing-unit) * 1.5); /* 12px */
    width: calc(var(--spacing-unit) * 2.5); /* 20px For alignment */
    text-align: center;
    transition: color 0.2s ease;
}

#left-sidebar .category-item:hover {
    background-color: var(--background-color-medium);
    color: var(--primary-color);
    transform: translateX(4px); /* 轻微右移 */
}
#left-sidebar .category-item:hover i {
    color: var(--primary-color);
}
body.dark-theme #left-sidebar .category-item:hover {
    background-color: #2A2D30; /* 暗模式下的悬停背景 */
}


#left-sidebar .category-item.active {
    background: var(--gradient-primary); /* 使用渐变作为激活背景 */
    color: var(--text-color-light);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 91, 106, 255), 0.3); /* 基于主色的阴影 */
}
/* Helper for box-shadow with primary color RGB */
:root { --primary-color-rgb: 91, 106, 255; }
body.dark-theme { --primary-color-rgb: 106, 123, 255; }


#left-sidebar .category-item.active i {
    color: var(--text-color-light);
}

/* Main Content Area */
#main-content {
    flex-grow: 1;
    padding: calc(var(--spacing-unit) * 4); /* 32px */
    margin-left: 260px; /* Width of left-sidebar */
    background-color: var(--background-color-medium);
    transition: background-color 0.3s ease;
}

.category-header {
    margin-bottom: calc(var(--spacing-unit) * 4); /* 32px */
}

.category-header h2 {
    font-size: calc(var(--spacing-unit) * 3.5); /* 28px */
    color: var(--text-color-dark);
    margin-bottom: var(--spacing-unit);
    font-weight: 700;
}

.category-header p {
    font-size: calc(var(--spacing-unit) * 2); /* 16px */
    color: var(--text-color-medium);
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* 增大最小宽度 */
    gap: calc(var(--spacing-unit) * 3); /* 24px */
}

.tool-card {
    background-color: var(--background-color-light);
    border-radius: var(--border-radius-main);
    box-shadow: var(--shadow-main);
    padding: calc(var(--spacing-unit) * 3); /* 24px */
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.tool-card:hover {
    transform: translateY(-6px); /* 悬停上浮效果 */
    box-shadow: 0 10px 20px rgba(0,0,0,0.12); /* 悬停阴影增强 */
}
body.dark-theme .tool-card:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.tool-card-icon {
    font-size: calc(var(--spacing-unit) * 4.5); /* 36px */
    color: var(--primary-color);
    margin-bottom: calc(var(--spacing-unit) * 2); /* 16px */
    height: calc(var(--spacing-unit) * 5); /* 40px Ensure consistent height */
    display: flex;
    align-items: center;
}

.tool-card-title {
    font-size: calc(var(--spacing-unit) * 2.25); /* 18px */
    font-weight: 600;
    color: var(--text-color-dark);
    margin-bottom: var(--spacing-unit); /* 8px */
}

.tool-card-description {
    font-size: 14px;
    color: var(--text-color-medium);
    flex-grow: 1;
    margin-bottom: calc(var(--spacing-unit) * 2.5); /* 20px */
    line-height: 1.5;
}

.tool-card-button {
    background: var(--gradient-primary);
    color: var(--text-color-light);
    border: none;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 3); /* 12px 24px */
    border-radius: var(--border-radius-main); /* 使用主要圆角 */
    cursor: pointer;
    font-weight: 600; /* 加粗 */
    text-align: center;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(var(--primary-color-rgb, 91, 106, 255), 0.2);
}

.tool-card-button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(var(--primary-color-rgb, 91, 106, 255), 0.3);
}


/* Responsive Design */
@media (max-width: 1024px) { /* 调整断点 */
    #left-sidebar {
        width: 240px;
    }
    #main-content {
        margin-left: 240px;
    }
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) { /* Mobile devices */
    .main-layout {
        flex-direction: column;
        padding-top: 64px; /* 确保与top-nav高度一致 */
    }

    #top-nav {
        padding: 0 calc(var(--spacing-unit) * 2); /* 调整padding */
        height: 60px; /* 移动端可略小 */
    }
    .main-layout { padding-top: 60px; }
    #left-sidebar { top: 60px; height: calc(100vh - 60px); }


    #top-nav .logo h1 {
        font-size: calc(var(--spacing-unit) * 2.25); /* 18px */
    }
    /* Hide the main desktop search bar on mobile initially */
    #top-nav > .search-bar { /* Direct child to target the one in the nav flow */
        display: none;
    }

    /* Styles for the search bar when it's toggled active on mobile */
    #top-nav .search-bar.active-mobile {
        display: flex; /* Make it visible */
        position: absolute;
        left: calc(var(--spacing-unit) * 2);
        right: calc(var(--spacing-unit) * 2);
        top: calc(60px + var(--spacing-unit)); /* Position below nav */
        background-color: var(--background-color-light);
        padding: calc(var(--spacing-unit) * 1.5);
        box-shadow: var(--shadow-main);
        border-radius: var(--border-radius-main);
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
        z-index: 999;
    }
     /* Initial state for transition (when not active) for the mobile version */
    #top-nav .search-bar { /* This targets the general search-bar for its initial hidden state for mobile transition */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        /* other styles like position absolute, left, right, top, etc. should be in .active-mobile if they only apply when active */
    }


    body.dark-theme #top-nav .search-bar.active-mobile { /* Dark theme for active mobile search */
        background-color: var(--background-color-light);
    }
    #top-nav .search-bar.active-mobile input {
        color: var(--text-color-dark);
        width: 100%;
    }
    #top-nav .search-bar.active-mobile input::placeholder {
        color: var(--text-color-medium);
    }
    #top-nav .search-bar.active-mobile button {
        color: var(--primary-color);
    }

    /* Show mobile search toggler button */
    #top-nav .mobile-only-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    #left-sidebar {
        width: 100%;
        height: auto;
        position: static;
        box-shadow: none;
        border-bottom: 1px solid var(--background-color-medium); /* 使用变量 */
        padding: var(--spacing-unit);
        overflow-y: visible;
    }
    body.dark-theme #left-sidebar {
        border-bottom-color: #2A2D30;
    }

    #left-sidebar nav ul {
        display: flex;
        overflow-x: auto;
        padding-bottom: var(--spacing-unit);
        scrollbar-width: thin; /* Firefox */
        scrollbar-color: var(--primary-color) var(--background-color-medium); /* Firefox */
    }
    #left-sidebar nav ul::-webkit-scrollbar {
        height: 6px;
    }
    #left-sidebar nav ul::-webkit-scrollbar-thumb {
        background-color: var(--primary-color);
        border-radius: var(--border-radius-main);
    }
    #left-sidebar nav ul::-webkit-scrollbar-track {
        background-color: var(--background-color-medium);
    }


    #left-sidebar .category-item {
        flex-shrink: 0;
        margin-right: var(--spacing-unit);
        margin-bottom: 0;
        padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5); /* 调整移动端padding */
    }

    #main-content {
        margin-left: 0;
        padding: calc(var(--spacing-unit) * 2.5); /* 20px */
    }

    .tools-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: calc(var(--spacing-unit) * 2.5); /* 20px */
    }
    .tool-card {
        padding: calc(var(--spacing-unit) * 2.5); /* 20px */
    }
}

/* Dark Theme Specifics (already partially integrated above) */
body.dark-theme #top-nav {
    box-shadow: 0 2px 10px rgba(0,0,0,0.3); /* 暗模式下阴影 */
}

body.dark-theme #left-sidebar .category-item.active {
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 106, 123, 255), 0.4);
}

body.dark-theme .tool-card-icon {
    color: var(--primary-color); /* 确保暗模式下图标颜色依然鲜明 */
}