:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-hover-bg: rgba(51, 65, 85, 0.8);
    --primary-color: #3b82f6;
    --accent-color: #8b5cf6;
    --font-family: 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --card-bg: rgba(255, 255, 255, 0.15);
    /* Extremely transparent */
    --card-border: rgba(0, 0, 0, 0.05);
    --card-hover-bg: rgba(255, 255, 255, 0.25);
    --primary-color: #2563eb;
}

/* Light mode background override */
[data-theme="light"] body {
    /* Very subtle gradient overlay so the image pops through */
    background-image: linear-gradient(135deg, rgba(224, 242, 254, 0.4) 0%, rgba(240, 249, 255, 0.4) 100%), url('bg-light.png');
    background-color: var(--bg-color);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-blend-mode: normal;
}

[data-theme="light"] .category-sidebar {
    background: rgba(255, 255, 255, 0.15);
    /* More transparent */
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .tool-icon {
    background: rgba(0, 0, 0, 0.1);
    /* Darker background for icons in light mode */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

/* ... (body styles remain same) ... */

/* Header Layout */
.top-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding-top: 1rem;
}

.header-actions {
    position: absolute;
    top: 1rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

/* Mobile adjustment for header actions */
@media (max-width: 768px) {
    .header-actions {
        top: 1rem;
        right: 1rem;
    }
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.icon-btn:hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

body {
    font-family: var(--font-family);
    background-color: #0f172a;
    /* Very subtle dark gradient overlay */
    background-image: linear-gradient(135deg, rgba(15, 23, 42, 0.5) 0%, rgba(30, 41, 59, 0.5) 100%), url('bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-blend-mode: normal;
    /* Removed overlay blend mode */
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.category-sidebar {
    width: 240px;
    background: rgba(30, 41, 59, 0.25);
    /* More transparent for sidebar */
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    /* Increased blur for better readability */
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform 0.3s ease;
    /* Smooth transition */
}

.category-sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space between logo and collapse button */
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--card-border);
}

.icon-btn-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-text:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.sidebar-header .logo i {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.category-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), transparent);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--card-border);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
    min-width: 0;
    /* Fix for sticky footer */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    /* Smooth transition */
}

.main-content.expanded {
    margin-left: 0;
}

.top-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.search-box {
    width: 100%;
    max-width: 600px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
}

/* Tool Card */
.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.tool-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    background: var(--card-hover-bg);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
}

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

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.tool-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.nav-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.tool-tag {
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
}

.tool-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.visit-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    transition: var(--transition);
}

.tool-card:hover .visit-btn {
    color: var(--primary-color);
    transform: translateX(4px);
}

/* Footer */
.site-footer {
    width: 100%;
    padding: 1rem 0;
    /* Reduced padding */
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    /* Slightly smaller font */
    position: relative;
    z-index: 60;
    margin-top: -1px;
}

.author-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.author-link:hover {
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Loading */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Responsive */
/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    /* Below sidebar (50) but above content */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    .category-sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Slightly wider on mobile for better touch */
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    /* Mobile: Sidebar Open State */
    .category-sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        /* Always 0 on mobile */
        padding: 1rem;
        width: 100%;
    }

    /* Ensure expand button is visible on mobile */
    #sidebarExpand {
        display: flex !important;
        margin-right: 0.5rem;
        /* Reduced margin */
    }

    /* Show collapse button on mobile */
    #sidebarCollapse {
        display: flex;
    }

    /* Mobile Header Layout */
    .top-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding-top: 0;
        /* Reset padding */
        margin-bottom: 1.5rem;
        flex-wrap: nowrap;
        /* Prevent wrapping */
    }

    .search-box {
        flex: 1;
        /* Take remaining space */
        max-width: none;
        /* Reset max-width */
        min-width: 0;
        /* Allow shrinking */
    }

    .search-box input {
        width: 100%;
        padding: 0.6rem 0.6rem 0.6rem 2.2rem;
        /* Smaller padding */
        font-size: 0.9rem;
    }

    .search-box i {
        left: 0.8rem;
        font-size: 0.9rem;
    }

    .header-actions {
        position: static;
        /* Reset absolute positioning */
        margin-left: 0.5rem;
        gap: 0.5rem;
        /* Smaller gap */
    }

    .icon-btn {
        width: 36px;
        /* Smaller buttons on mobile */
        height: 36px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }
}

/* Admin Panel Styles (Simplified for now, can be expanded if needed) */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-color);
}