/* Cheatsheet Layout */
.cheatsheet-wrapper {
    display: flex;
    gap: 40px;
    padding: 40px 0 80px;
    align-items: flex-start;
}

/* Sidebar */
.category-sidebar {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.category-btn {
    width: 100%;
    text-align: left;
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn:last-child {
    border-bottom: none;
}

.category-btn:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.category-btn.active {
    background: var(--bg-main);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: 17px;
    /* Compensate for border */
}

/* Main Content */
.cheatsheet-main {
    flex-grow: 1;
}

/* Search Bar */
.cs-search-container {
    margin-bottom: 30px;
    position: relative;
}

.cs-search-input {
    width: 100%;
    padding: 16px 20px 16px 48px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cs-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.cs-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Grid Layout */
.cheatsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Card Styling */
.cs-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.cs-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.cs-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.cs-category-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 500;
}

.cs-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.4;
}

.cs-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
}

/* Tags */
.cs-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.cs-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Footer of Card */
.cs-card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cs-status-badge {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    font-weight: 500;
}

.cs-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.cs-btn.disabled {
    background: var(--bg-main);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.cs-btn.primary {
    background: var(--primary);
    color: white;
}

.cs-btn.primary:hover {
    background: var(--primary-dark);
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .cheatsheet-wrapper {
        flex-direction: column;
        gap: 20px;
        padding: 20px 20px;
        /* Added side padding and restored top padding */
    }

    .category-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        /* Remove scroll from here */
    }

    .category-list {
        display: flex;
        border-radius: var(--radius-md);
        white-space: nowrap;
        /* Enable scroll here */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    /* Hide scrollbar for Chrome/Safari */
    .category-list::-webkit-scrollbar {
        display: none;
    }

    .category-btn {
        width: auto;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding: 12px 16px;
        flex-shrink: 0;
        /* Prevent shrinking */
    }

    .category-btn:last-child {
        border-right: none;
    }

    .category-btn.active {
        border-left: none;
        border-bottom: 3px solid var(--primary);
        padding-left: 16px;
    }
}

/* Cheatsheet Viewer Styles */
.cheatsheet-content-container {
    max-width: 900px;
    margin: 0 auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 30px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.cs-viewer-body h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.cs-intro {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2rem;
}

.cs-viewer-body h3 {
    font-size: 1.4rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.cs-viewer-body h3::before {
    content: "#";
    color: var(--primary);
    margin-right: 10px;
    opacity: 0.5;
}

.cs-viewer-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.cs-viewer-body hr {
    margin: 3rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Dark Theme Code Blocks */
pre {
    background: #1e293b;
    /* Dark slate */
    color: #e2e8f0;
    /* Light gray */
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    border: 1px solid #334155;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

code {
    font-family: inherit;
}

/* Syntax Highlighting (Simulated) */
.cs-comment {
    color: #94a3b8;
    /* Muted Blue-Gray */
    font-style: italic;
}

.cs-note {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--primary);
    padding: 12px 16px;
    border-radius: 0 4px 4px 0;
    color: var(--text-main);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.cs-note::before {
    content: "💡";
    margin-right: 8px;
}

/* Button Hover: Slight lift and shadow instead of color change */
.cs-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cs-btn.primary:hover {
    background: var(--primary);
    /* Keep same color */
    filter: brightness(1.1);
    /* Slight lightening */
}

/* Copy Button Styles */
.code-block-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.code-block-wrapper pre {
    margin-bottom: 0;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #e2e8f0;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

.code-block-wrapper:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

@media (max-width: 768px) {
    .copy-btn {
        opacity: 1;
        background: rgba(255, 255, 255, 0.15);
        padding: 6px 10px;
    }
}