:root {
    --bg: #fff;
    --fg: #000;
    --border: #ddd;
    --link: #0366d6;
    --link-visited: #8250df;
    --subtle: #666;
    --code-bg: #f6f8fa;
    --sidebar-bg: #fafbfc;
    --active-bg: #e1f5fe;
    --hover-bg: #f0f0f0;
    --sidebar-width: 220px;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --fg: #c9d1d9;
    --border: #30363d;
    --link: #58a6ff;
    --link-visited: #bc8cff;
    --subtle: #8b949e;
    --code-bg: #161b22;
    --sidebar-bg: #161b22;
    --active-bg: #1f3a1f;
    --hover-bg: #21262d;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    font-size: 13px;
}

/* Three-column layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    padding: 15px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-left {
    left: 0;
    border-right: 1px solid var(--border);
}

.sidebar-right {
    right: 0;
    border-left: 1px solid var(--border);
}

.sidebar-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.theme-btn {
    width: 100%;
    padding: 5px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg);
    cursor: pointer;
    font-size: 12px;
}

.theme-btn:hover {
    background: var(--hover-bg);
}

.nav-section {
    margin-bottom: 18px;
}

.nav-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--subtle);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

/* Collapsible sections */
.collapsible-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 0;
    transition: color 0.2s ease;
}

.collapsible-header:hover {
    color: var(--fg);
}

.collapse-icon {
    font-size: 9px;
    transition: transform 0.2s ease;
    color: var(--subtle);
}

.collapsible-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

/* Scrollable filter lists */
#category-list,
#language-list,
#type-list,
#quality-list,
#tag-list {
    max-height: 250px;
    overflow-y: auto;
}

#category-list::-webkit-scrollbar,
#language-list::-webkit-scrollbar,
#type-list::-webkit-scrollbar,
#quality-list::-webkit-scrollbar,
#tag-list::-webkit-scrollbar {
    width: 5px;
}

#category-list::-webkit-scrollbar-thumb,
#language-list::-webkit-scrollbar-thumb,
#type-list::-webkit-scrollbar-thumb,
#quality-list::-webkit-scrollbar-thumb,
#tag-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.filter-btn {
    display: block;
    width: 100%;
    padding: 4px 8px;
    margin-bottom: 2px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg);
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-btn:hover {
    background: var(--hover-bg);
}

.filter-btn.active {
    background: var(--active-bg);
    border-color: var(--link);
    font-weight: 600;
}

.reset-btn {
    width: 100%;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg);
    cursor: pointer;
    font-size: 12px;
}

.reset-btn:hover {
    background: var(--hover-bg);
}

.date-filter {
    padding: 4px 0;
}

#date-slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

#date-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--link);
    cursor: pointer;
}

#date-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--link);
    cursor: pointer;
    border: none;
}

.date-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

#days-input {
    width: 50px;
    padding: 3px 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 12px;
    text-align: center;
}

#days-input::-webkit-outer-spin-button,
#days-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.days-label {
    font-size: 11px;
    color: var(--subtle);
}

.date-label {
    margin-top: 6px;
    font-size: 11px;
    color: var(--subtle);
    text-align: center;
}

/* Main content - centered between sidebars */
.main-content {
    margin-left: var(--sidebar-width);
    margin-right: var(--sidebar-width);
    flex: 1;
    padding: 15px 25px;
    min-width: 0;
}

.header {
    margin-bottom: 15px;
}

/* Search with autocomplete */
.search-container {
    position: relative;
    max-width: 100%;
}

#search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 13px;
    border-radius: 4px;
}

#search:focus {
    outline: none;
    border-color: var(--link);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--hover-bg);
}

.suggestion-type {
    color: var(--subtle);
    font-size: 10px;
    text-transform: uppercase;
    margin-right: 8px;
}

.suggestion-value {
    color: var(--fg);
}

.search-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.search-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--active-bg);
    border: 1px solid var(--link);
    border-radius: 3px;
    font-size: 11px;
}

.search-tag-remove {
    cursor: pointer;
    color: var(--subtle);
    font-weight: bold;
}

.search-tag-remove:hover {
    color: var(--fg);
}

.stats {
    color: var(--subtle);
    font-size: 12px;
    margin-top: 8px;
}

.stats span {
    margin-right: 12px;
}

.resources {
    list-style: none;
}

.resource-item {
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
}

.resource-item:last-child {
    border-bottom: none;
}

.resource-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.resource-title a {
    color: var(--link);
    text-decoration: none;
}

.resource-title a:visited {
    color: var(--link-visited);
}

.resource-title a:hover {
    text-decoration: underline;
}

.quality-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin: 6px 0;
}

.quality-tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--link);
    background: transparent;
    padding: 1px 5px;
    border: 1px solid var(--link);
    border-radius: 3px;
}

.resource-why {
    color: var(--fg);
    font-size: 12px;
    line-height: 1.4;
    margin: 6px 0;
    padding: 6px 10px;
    background: var(--code-bg);
    border-left: 3px solid var(--link);
}

.resource-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 11px;
    color: var(--subtle);
    margin: 6px 0;
}

.badge {
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
}

.badge-category {
    background: var(--code-bg);
    color: var(--fg);
}

.badge-difficulty {
    border: 1px solid var(--border);
}

.badge-type {
    border: 1px solid;
}

.resource-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.tag {
    font-size: 10px;
    color: var(--subtle);
    background: var(--code-bg);
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
}

.tag:hover {
    background: var(--hover-bg);
}

.footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--subtle);
    font-size: 11px;
}

/* Responsive - stack on smaller screens */
@media (max-width: 1200px) {
    .sidebar-right {
        display: none;
    }
    .main-content {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }
    .main-content {
        margin-left: 0;
        margin-right: 0;
        padding: 15px;
    }
}

/* Favorite button */
.favorite-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    margin-right: 6px;
    color: var(--muted);
    transition: all 0.2s ease;
    vertical-align: middle;
}

.favorite-btn:hover {
    transform: scale(1.15);
    color: #fbbf24;
}

.favorite-btn.active {
    color: #fbbf24;
}

/* Sync buttons */
.sync-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 4px 8px;
    margin: 2px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.sync-btn:hover {
    background: var(--hover-bg);
}

/* Activity badges */
.badge-activity {
    font-weight: bold;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 6px;
}

.badge-activity.hot {
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    color: white;
    box-shadow: 0 1px 4px rgba(255, 75, 87, 0.3);
}

.badge-activity.recent {
    background: linear-gradient(135deg, #48cae4, #0077b6);
    color: white;
}

.badge-activity.warm {
    background: linear-gradient(135deg, #ffd23f, #ff9500);
    color: white;
}

.badge-activity.cool {
    background: linear-gradient(135deg, #a8dadc, #457b9d);
    color: white;
}

/* Dark theme adjustments */
[data-theme="dark"] .badge-activity.hot {
    background: linear-gradient(135deg, #ff5252, #d32f2f);
}

[data-theme="dark"] .badge-activity.recent {
    background: linear-gradient(135deg, #42a5f5, #1565c0);
}

[data-theme="dark"] .badge-activity.warm {
    background: linear-gradient(135deg, #ffca28, #f57c00);
}

[data-theme="dark"] .badge-activity.cool {
    background: linear-gradient(135deg, #90a4ae, #546e7a);
}
