/* General Styles */
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;
}

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

h1 {
    font-size: 1.8em;
    font-weight: 600;
    color: #333;
    padding: 0;
    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 Switch */
.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;
    transition: .3s;
    border-radius: 24px;
}

.dark-mode .slider {
    background-color: #333;
}

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

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

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

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

.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 Styles */
.filters-section {
    background-color: #fff;
    padding: 20px 25px;
    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: row;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto 20px;
    box-sizing: border-box;
}

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

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    width: auto;
    min-width: 180px;
}

.filter-group select {
    width: 150px;
}

.filter-group.tags-group {
    flex: 1 1 auto;
    margin-left: 10px;
    max-width: none;
    min-width: 250px;
}

.filter-group label {
    color: #444;
    font-size: 0.95em;
    white-space: nowrap;
    transition: color 0.3s ease;
    font-weight: 500;
}

.dark-mode .filter-group label {
    color: #ddd;
}

.filter-group select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #fff;
    color: #333;
    height: 38px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    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;
    transition: all 0.3s ease;
    min-width: 120px;
}

.dark-mode .filter-group select {
    background-color: #333;
    color: #eee;
    border-color: #444;
    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;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    min-height: 38px;
    height: auto;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    overflow-y: auto;
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 400px;
    color: #333;
    line-height: 1.5;
    gap: 4px;
}

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

#clear-filters {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    background-color: #dc3545;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    margin-left: auto;
    height: 38px;
    min-width: 120px;
    font-size: 0.95em;
    font-weight: 500;
}

.input-tag {
    background-color: #e9ecef;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 4px;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
}

.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:hover {
    background-color: #c82333;
}

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

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

/* Model Cards */
#models-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

.model-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    border: 1px solid #ddd;
    height: 100%;
}

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

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

.model-image {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    display: block;
}

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

.model-username {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
    line-height: 1.3;
}

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

.model-info {
    color: #666;
    font-size: 0.9em;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

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

.model-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
    padding: 0;
}

.tag {
    background-color: #f0f0f0;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    line-height: 1.2;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dark-mode .tag {
    background-color: #333;
    color: #ddd;
}

.chat-link {
    background-color: #28a745;
    color: white;
    text-decoration: none;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
    line-height: 1.2;
    transition: all 0.2s ease;
    margin-top: auto;
    display: block;
    cursor: pointer;
}

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

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

.dark-mode .chat-link:hover {
    background-color: #145a23;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .filters-section {
        flex-wrap: wrap;
        gap: 12px;
        padding: 15px 20px;
    }

    .filter-group.tags-group {
        flex: 1 1 100%;
        margin-left: 0;
        margin-top: 8px;
    }

    #tag-input-container {
        max-width: none;
        min-width: 0;
    }

    #models-list {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    #models-list {
        padding: 15px;
        gap: 12px;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .filters-section {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 10px;
        width: 90%;
        margin: 0 auto 20px;
        border-radius: 12px;
    }

    .filter-group {
        width: 100%;
        padding: 0;
        gap: 12px;
        flex-direction: row;
        align-items: center;
        min-width: 0;
        margin: 0;
    }

    .filter-group label {
        font-size: 0.95em;
        width: 70px;
        flex: 0 0 70px;
        margin: 0;
    }

    .filter-group select {
        width: calc(100% - 82px);
        height: 38px;
        font-size: 1em;
        padding: 8px 12px;
        margin: 0;
    }

    .filter-group.tags-group {
        flex-direction: row;
        margin-top: 5px;
    }

    .filter-group.tags-group #tag-input-container {
        width: calc(100% - 82px);
        min-height: 38px;
        max-height: 38px;
        font-size: 1em;
        margin: 0;
        padding: 8px 12px;
        overflow: hidden;
        display: flex;
        align-items: center;
    }

    .filter-group.tags-group #tag-input-container .tag-placeholder {
        line-height: 1;
    }

    .model-image {
        border-radius: 6px 6px 0 0;
    }

    .model-info-container {
        padding: 12px;
    }

    .model-username {
        font-size: 1em;
        margin-bottom: 6px;
    }

    .model-tags {
        gap: 4px;
        margin-bottom: 12px;
    }

    .tag {
        padding: 3px 6px;
        font-size: 0.8em;
    }

    .chat-link {
        padding: 10px;
        font-size: 0.95em;
    }
}

@media (max-width: 480px) {
    .filters-section {
        width: 95%;
        padding: 15px;
    }

    #models-list {
        grid-template-columns: repeat(2, 1fr);
        padding: 10px;
        gap: 12px;
    }
}