:root {
    /* Light theme (default) */
    --bg-color: #ffffff;
    --text-color: #333333;
    --accent-color: #2196f3;
    --card-bg: #f5f5f5;
    --hover-color: #e3f2fd;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --accent-color: #64b5f6;
    --card-bg: #2d2d2d;
    --hover-color: #3d3d3d;
}

/* System preference based theme */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="custom"]) {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --accent-color: #64b5f6;
        --card-bg: #2d2d2d;
        --hover-color: #3d3d3d;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 1rem;
    width: 100%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    width: 100%;
}

.controls-container {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.theme-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Search Bar Styles */
.search-bar-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
    padding: 0 1rem;
}

.search-bar {
    position: relative;
    width: 300px;
    transition: width 0.3s ease;
    margin: 0 auto;
}

.search-bar:hover {
    width: 80%;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    text-align: center;
}

.search-bar input:focus {
    outline: none;
    box-shadow: 0 0 5px var(--accent-color);
}

.search-bar button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

.search-bar button:hover {
    color: var(--accent-color);
}

.search-bar-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 1rem 0 2rem;
    padding: 0 1rem;
}

.search-bar {
    position: relative;
    width: 300px;
    transition: width 0.3s ease;
    margin: 0 auto;
}

.search-bar:hover {
    width: 80%;
}

.search-bar input {
    text-align: center;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.search-bar input:focus {
    outline: none;
    box-shadow: 0 0 5px var(--accent-color);
}

.search-bar button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

.search-bar button:hover {
    color: var(--accent-color);
}

h1 {
    color: var(--accent-color);
    font-size: 2.5rem;
}

.controls-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.theme-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#resetTheme {
    padding: 0.5rem 1rem;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}

#resetTheme:hover {
    opacity: 0.9;
}

/* Switch styling */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Links container styling */
.links-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.link-item {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.link-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background-color: var(--hover-color);
}

.link-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.favicon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.favicon-hidden .favicon {
    display: none;
}

.link-item h2 {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.description {
    margin: 0.5rem 0;
    color: var(--text-color);
}

.url {
    display: block;
    color: var(--accent-color);
    text-decoration: none;
    margin-top: 1rem;
    word-break: break-all;
}

.url:hover {
    text-decoration: underline;
}

/* Custom Theme Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-color);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    max-width: 800px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

/* Theme Select Styles */
.theme-select-container {
    margin: 1.5rem 0;
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 10px;
}

.theme-select-container h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.theme-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background-color: var(--bg-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-card.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.theme-preview {
    height: 80px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    gap: 0.5rem;
}

.theme-preview .accent-line {
    width: 60%;
    height: 4px;
    border-radius: 2px;
}

.theme-name {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.9rem;
    background-color: rgba(0, 0, 0, 0.05);
    color: inherit;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    width: 100%;
}

.color-picker-container {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0;
}

.color-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.preset-theme {
    padding: 1rem;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    border: 2px solid transparent;
}

.preset-theme:hover {
    border-color: var(--accent-color);
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    opacity: 0.9;
}

/* Category Button Styles */
.category-btn {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 2px solid var(--accent-color);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
}

.category-btn:hover {
    background-color: var(--hover-color);
    transform: translateY(-1px);
}

.category-btn.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Search and Filter Styles */
.search-and-filter {
    display: flex;
    gap: 1rem;
    margin: 1rem 0 2rem;
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    min-width: 250px;
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 0.8rem 2.5rem 0.8rem 1rem;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}

.clear-search {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
}

.category-filter select {
    padding: 0.8rem;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
}

/* Categories Navigation */
.categories-nav {
    margin-bottom: 2rem;
}

#categoryList {
    list-style: none;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0;
}

.category-tag {
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-tag:hover,
.category-tag.active {
    background-color: var(--accent-color);
    color: white;
}

/* Category Containers */
.category-section {
    margin-bottom: 3rem;
}

.category-section h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.8rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.links-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

/* Hide Elements */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .theme-controls {
        width: 100%;
        justify-content: space-between;
    }

    .search-and-filter {
        flex-direction: column;
    }

    .category-filter {
        width: 100%;
    }

    .category-filter select {
        width: 100%;
    }

    .links-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10% 1rem;
    }
}