body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Smooth transition */
}

body.dark-mode {
    background-color: #121212;
    color: #eee;
}

h1 {
    font-size: 1.8em;
    /* Larger font size */
    font-weight: 600;
    /* Semi-bold weight */
    color: #333;
    padding: 0;
    /* Remove padding */
    margin-bottom: 0;
    margin-top: 0;
    transition: color 0.3s ease;
}

.dark-mode h1 {
    color: #eee;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    margin-bottom: 20px;
}

.dark-mode .header {
    background-color: #222;
    border-color: #444;
}

.toggle-container {
    display: flex;
    align-items: center;
}

.toggle-container span {
    margin-right: 10px;
    color: #666;
    transition: color 0.3s ease;
    font-size: 0.9em;
}

.dark-mode .toggle-container span {
    color: #bbb;
}

#filter-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 1px solid #ddd;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    /* Stack filter groups vertically */
    align-items: center;
    /* Center-align items horizontally */
    max-width: 800px;
    /* Limit maximum width */
    margin: 0 auto;
    /* Center the section itself */
}

.dark-mode #filter-section {
    background-color: #222;
    border-color: #444;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#filter-section h2 {
    margin-top: 0;
    color: #555;
    margin-bottom: 15px;
    width: 100%;
    transition: color 0.3s ease;
}

.dark-mode #filter-section h2 {
    color: #ddd;
}

.filter-group {
    margin-bottom: 15px;
    margin-right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.filter-group:last-of-type {
    align-items: flex-start;
}

#filter-section label {
    margin-right: 10px;
    font-weight: bold;
    white-space: nowrap;
    margin-bottom: 5px;
    color: #444;
    transition: color 0.3s ease;
}

.dark-mode #filter-section label {
    color: #bbb;
}

#filter-section select,
#tag-input-container {
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #aaa;
    margin-right: 0px;
    font-size: 1em;
    flex: 1;
    min-width: 100px;
    width: 100%;
    background-color: #fff;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.dark-mode #filter-section select,
.dark-mode #tag-input-container {
    background-color: #333;
    color: #eee;
    border-color: #555;
}

/* Custom dropdown arrow */
#filter-section select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M1.41 0L6 4.58L10.59 0L12 1.41L6 7.41L0 1.41L1.41 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px 8px;
    padding-right: 30px;
    /* Make space for the arrow */
}

.dark-mode #filter-section select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23eee' d='M1.41 0L6 4.58L10.59 0L12 1.41L6 7.41L0 1.41L1.41 0z'/%3E%3C/svg%3E");
}

#tag-input-container {
    cursor: text;
    margin-bottom: 5px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    overflow: hidden;
    width: fit-content;
}

.input-tag {
    background-color: #e0e0e0;
    color: #333;
    border-radius: 4px;
    padding: 2px 5px;
    margin-right: 5px;
    margin-bottom: 2px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dark-mode .input-tag {
    background-color: #444;
    color: #eee;
}

.input-tag-close {
    margin-left: 5px;
    cursor: pointer;
    font-weight: bold;
    color: #888;
    transition: color 0.3s ease;
}

.dark-mode .input-tag-close {
    color: #ccc;
}

.tag-placeholder {
    color: #999;
    transition: color 0.3s ease;
}

.dark-mode .tag-placeholder {
    color: #666
}

#clear-filters {
    padding: 12px 20px;
    /* Larger padding */
    border-radius: 4px;
    border: none;
    background-color: #6c757d;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 1em;
    white-space: nowrap;
    width: 100%;
    /* Full width on small screens */
}

#clear-filters:hover {
    background-color: #5a6268;
}

.dark-mode #clear-filters {
    background-color: #444;
}

.dark-mode #clear-filters:hover {
    background-color: #333;
}

#models-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
}

.model-card {
    border: 1px solid #ddd;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Make cards the same height */
}

.dark-mode .model-card {
    background-color: #252525;
    border-color: #444;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.model-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.dark-mode .model-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.model-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
}

.model-info-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.model-username {
    font-weight: bold;
    margin-top: 0px;
    color: #333;
    font-size: 1.1em;
    transition: color 0.3s ease;
}

.dark-mode .model-username {
    color: #eee;
}

.model-info {
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
    transition: color 0.3s ease;
}

.dark-mode .model-info {
    color: #bbb;
}

.model-tags {
    margin-top: 10px;
    margin-bottom: 15px;
    /* Increased margin */
}

.tag {
    display: inline-block;
    padding: 5px 10px;
    background-color: #eee;
    color: #333;
    border-radius: 4px;
    margin-right: 5px;
    margin-bottom: 5px;
    font-size: 0.8em;
    transition: background-color 0.3s ease, color 0.3s ease;
    cursor: pointer;
    /* Add cursor pointer */
}

.dark-mode .tag {
    background-color: #444;
    color: #eee;
}

.selected-tag {
    background-color: #007bff;
    /* Highlight color */
    color: #fff;
}

.dark-mode .selected-tag {
    background-color: #0056b3;
}

.chat-link {
    display: inline-block;
    padding: 10px 15px;
    background-color: #28a745;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    margin-top: auto;
    transition: background-color 0.3s ease, color 0.3s ease;
    border: none;
    text-align: center;
    cursor: pointer;
}

.dark-mode .chat-link {
    background-color: #1e7e34;
    /* Slightly darker green */
}

.chat-link:hover {
    background-color: #1e7e34;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .filter-group {
        margin-right: 0;
        /* Remove margin on small screens */
    }

    .header {
        flex-direction: column;
        /* Stack header elements vertically */
        align-items: stretch;
        /* Stretch items to full width */
    }

    .toggle-container {
        margin-top: 10px;
    }

    .model-card {
        width: 100%;
    }
}

/* Dark/Light Mode Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .3s;
    transition: .3s;
    border-radius: 24px;
}

.dark-mode .slider {
    background-color: #333;
    /* Darker background in dark mode */
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .3s;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2196F3;
}

input:focus+.slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked+.slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}