:root {
    --primary-color: #0d6efd;
    --text-color: #333;
    --light-text-color: #666;
    --background-color: #f8f9fa;
    --white-color: #fff;
    --border-color: #dee2e6;
    --card-shadow: 0 4px 8px rgba(0,0,0,0.05);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

img {
    width: 100%;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    /* 核心修正 2：为 body 应用 Flexbox 布局 */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-container {
    display: flex;
    flex-direction: column;
    width: 100%; /* 确保 site-container 撑满 body */
    flex-grow: 1;
}

.site-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* --- Header --- */
.site-header {
    background-color: var(--white-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%; /* Ensure it spans the full viewport width */
}

.header-container {
    /* 核心修正 1：确保 header-container 与 site-content 具有完全相同的宽度和居中设置 */
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem; /* Match site-content's padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    text-decoration: none;
    /* 核心修正：应用 Flexbox 来对齐图标和文字 */
    display: flex;
    align-items: center;
    gap: 0.75rem; /* 控制图标和文字之间的间距 */
}

.logo-icon {
    height: 48px; /* 设置图标的高度 */
    width: 48px;  /* 设置图标的宽度 */
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    text-decoration: none;
    color: var(--light-text-color);
    font-weight: 500;
    transition: color 0.2s;
    padding: 0.5rem 0;
}

/* 核心修正 2：为激活的菜单项和悬停状态添加统一样式 */
.main-nav li.active a,
.main-nav a:hover {
    color: var(--primary-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}



.search-bar input {
    width: 250px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Footer */
.site-footer {
    background-color: var(--white-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    font-size: 0.9rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-column h4 {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.footer-column ul {
    list-style: none;
}

.footer-column ul li {
    margin-bottom: 0.5rem;
}

.footer-column a {
    color: var(--light-text-color);
    text-decoration: none;
}
.footer-column a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--light-text-color);
}

/* Home Page */
.home-container { padding: 2rem 0; }
.hero { text-align: center; margin-bottom: 4rem; }
.hero h1 { font-size: 3rem; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; color: var(--light-text-color); }
.browse-by-category, .featured-tools { margin-bottom: 4rem; }
h2 { font-size: 2rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;}
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}
.category-card {
    background: var(--white-color);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
}
.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow);
}
.category-icon { font-size: 2.5rem; display: block; margin-bottom: 1rem; }
.category-name { font-weight: bold; display: block; }
.category-count { color: var(--light-text-color); font-size: 0.9rem; }

/* Tool Card */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.tool-card {
    background: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}
.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow);
}
.card-link { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }
.card-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.tool-icon { width: 48px; height: 48px; border-radius: 8px; }
.tool-title-group { flex: 1; }
.tool-title { font-size: 1.1rem; margin-bottom: 0.25rem; }
.tool-rating { font-size: 0.9rem; color: #f59e0b; }
.tool-pricing { font-size: 0.8rem; font-weight: bold; padding: 0.2rem 0.5rem; border-radius: 4px; text-transform: uppercase; }
.tool-pricing.paid { background-color: #fee2e2; color: #b91c1c; }
.tool-pricing.free { background-color: #dcfce7; color: #166534; }
.tool-pricing.freemium { background-color: #e0e7ff; color: #3730a3; }
.tool-description { color: var(--light-text-color); margin-bottom: 1.5rem; flex-grow: 1; }
.card-footer { display: flex; justify-content: space-between; align-items: center; }
.tool-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag, .tag-category { font-size: 0.8rem; background-color: #e5e7eb; padding: 0.2rem 0.5rem; border-radius: 4px; }
.visit-website-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    z-index: 2;
    position: relative;
    transition: background-color 0.2s, color 0.2s;
}
.visit-website-btn:hover { background-color: var(--primary-color); color: var(--white-color); }


/* Responsive */
@media (max-width: 992px) {
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .header-container { padding: 0 1rem; }
    .site-content { padding: 1rem; }
    /* .main-nav { display: none; } Hide for now, can implement drawer menu */
    .mobile-menu-toggle { display: block; }
    #main-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background: var(--white-color);
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    #main-menu.active { display: flex; }
}

@media (max-width: 768px) {
    .tool-grid { grid-template-columns: 1fr; }
    .search-bar { display: none; }
    .footer-container { grid-template-columns: 1fr; }
}

/* --- UI Adjustments for Tool Card --- */

/* 1. Move tags above footer */
.tool-card {
    display: flex;
    flex-direction: column;
}
.tool-description {
    flex-grow: 1; /* Ensures description pushes tags and footer down */
}
.tool-tags {
    margin-bottom: 1.5rem; /* Add space between tags and footer */
}

/* 2. New Footer Layout */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Remove padding if it was there before, as buttons have their own */
    padding: 0; 
}

/* Make the main card link ignore the new buttons */
.card-link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.visit-website-btn, .share-button-container {
    position: relative; /* Ensure buttons are clickable above the overlay */
    z-index: 2;
}

/* 3. Share Button & Popover Styles */
.share-button-container {
    position: relative;
}

.share-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--light-text-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.share-btn:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}
.share-btn svg {
    width: 20px;
    height: 20px;
}

.share-popover {
    position: absolute;
    bottom: calc(100% + 10px); /* Position above the button with a 10px gap */
    right: 0;
    width: auto;
    background-color: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 0.75rem;
    z-index: 10;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none; /* Hidden by default */
}

.share-popover.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Clickable when active */
}

.share-popover.hidden {
    display: none; /* Fallback for JS toggle */
}

.share-popover-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    white-space: nowrap;
}

.social-links-grid {
    display: flex;
    gap: 0.5rem;
}
/* 核心修正 2：只在小屏幕上应用 flex-wrap */
@media (max-width: 420px) { /* Adjust this breakpoint as needed */
    .social-links-grid {
        flex-wrap: wrap;
    }
}

.social-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: #f8f9fa;
    color: var(--light-text-color);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.social-share-btn:hover {
    background-color: #e9ecef;
    color: var(--text-color);
}

.social-share-btn svg {
    width: 16px;
    height: 16px;
}

/* Special style for the Copy Link button */
.social-share-btn[data-platform="copy"] {
    width: auto;
    white-space: nowrap;
    padding: 0 0.75rem;
    border-radius: 18px;
}


/* --- Star Rating Styles (Corrected Version) --- */
.star-rating {
    display: flex;
    align-items: center;
    font-size: 1rem;
}

.star-icon {
    position: relative; /* Required for the pseudo-element to be positioned correctly */
    display: inline-block;
    color: #d1d5db; /* Base empty star color */
    margin-right: 2px;
}

/* The ::before pseudo-element creates the golden filled star overlay */
.full-star::before,
.half-star::before {
    content: '★'; /* The filled star character */
    position: absolute;
    left: 0;
    top: 0;
    overflow: hidden;
    color: #f59e0b; /* Filled star color */
}

/* For a full star, the overlay covers 100% of the base empty star */
.full-star::before {
    width: 100%;
}

/* For a half star, the overlay covers 50% of the base empty star */
.half-star::before {
    width: 50%;
}

.rating-value {
    margin-left: 0.5rem;
    font-size: 0.9rem;
    color: var(--light-text-color);
}


/* --- Footer Social Links (Corrected Position) --- */
.footer-social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem; /* Space above the social links from brand text */
    /* Removed padding-top and border-top as they are no longer needed here */
    flex-wrap: wrap; /* Allow wrapping on very small screens if needed */
}

.social-icon-link {
    color: var(--light-text-color);
    transition: color 0.2s ease-in-out;
}

.social-icon-link:hover {
    color: var(--primary-color);
}

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