/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    display: flex;
    min-height: 100vh;
}

/* Sidebar navigation */
.sidebar {
    width: 200px;
    background: #2c3e50;
    color: #ecf0f1;
    padding: 1rem 0.75rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar h1 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #3498db;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    margin-bottom: 0.25rem;
}

.sidebar a {
    color: #ecf0f1;
    text-decoration: none;
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.sidebar a:hover {
    background: #34495e;
}

/* Main content */
.content {
    margin-left: 200px;
    padding: 2rem;
    flex: 1;
}

.content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.content h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #34495e;
}

.content p {
    margin-bottom: 1rem;
}

.content ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.content a {
    color: #3498db;
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.gallery-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item-info {
    padding: 1rem;
}

.gallery-item-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.gallery-item-prompt {
    font-size: 0.9rem;
    color: #7f8c8d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Model comparison grid */
.model-comparison {
    margin-top: 2rem;
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comparison-table th {
    background: #34495e;
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.comparison-table td {
    padding: 1rem;
    border-bottom: 1px solid #ecf0f1;
}

.comparison-table tr:last-child td {
    border-bottom: none;
}

.comparison-table img {
    max-width: 200px;
    height: auto;
    border-radius: 4px;
    transition: transform 0.2s;
    cursor: pointer;
}

.comparison-table img:hover {
    transform: scale(1.05);
}

/* Code blocks in help pages */
pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

code {
    background: #ecf0f1;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
}

pre code {
    background: none;
    padding: 0;
}

/* Gallery filters */
.gallery-filters {
    margin-bottom: 2rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter {
    padding: 0.5rem 1rem;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 40px;
}

.filter:hover:not(:disabled) {
    background: #ecf0f1;
}

.filter:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #95a5a6;
    color: #95a5a6;
}

.filter.active {
    background: #3498db;
    color: white;
}

/* Gallery comparison grid */
.gallery-comparison {
    overflow-x: auto;
    margin-top: 1rem;
}

.comparison-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comparison-grid th {
    background: #34495e;
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #2c3e50;
    position: sticky;
    top: 0;
    z-index: 10;
    max-width: 220px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.comparison-grid td {
    padding: 1rem;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.comparison-grid tbody tr:last-child td {
    border-bottom: none;
}

.comparison-grid tbody tr:hover {
    background: #f8f9fa;
}

.comparison-grid tbody tr[data-tags] {
    content-visibility: auto;
    contain-intrinsic-height: 220px;
}

.comparison-grid th:first-child,
.comparison-grid td:first-child {
    max-width: 100px;
    min-width: 80px;
}

.model-label {
    font-weight: 600;
    color: #2c3e50;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.model-aliases {
    font-size: 0.75em;
    font-weight: 400;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

.gallery-cell {
    position: relative;
    width: 200px;
    height: auto;
    display: inline-block;
}

.gallery-cell .gallery-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease-in-out;
}

.gallery-cell .gallery-link:first-child {
    position: relative;
}

.gallery-img {
    max-width: 200px;
    height: auto;
    border-radius: 4px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: block;
}

.gallery-img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Image zoom modal */
.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.image-modal-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
}

.image-modal-left {
    flex-shrink: 0;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 90vh;
}

.image-modal-info {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-y: auto;
}

.image-modal-prompt {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-y: auto;
}

.image-modal-prompt h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #ecf0f1;
    font-weight: 600;
}

.image-modal-prompt .prompt-text {
    margin: 0;
    font-size: 0.9rem;
    color: #bdc3c7;
    line-height: 1.5;
    word-wrap: break-word;
}

.image-modal-regen {
    background: #2c3e50;
    padding: 1.5rem;
    border-radius: 8px;
    display: none;
}

.regen-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: 2px solid #e74c3c;
    background: #e74c3c;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.regen-btn:hover:not(:disabled) {
    background: #c0392b;
    border-color: #c0392b;
}

.regen-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.regen-btn.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.regen-status {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    min-height: 1.5rem;
}

.regen-status.info {
    background: #3498db;
    color: white;
}

.regen-status.success {
    background: #27ae60;
    color: white;
}

.regen-status.error {
    background: #e74c3c;
    color: white;
}

.image-modal-info h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: #3498db;
}

.image-modal-info .model-description {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #bdc3c7;
    line-height: 1.5;
}

.image-modal-info .model-specs {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.image-modal-info .spec-group {
    border-top: 1px solid #34495e;
    padding-top: 1rem;
}

.image-modal-info .spec-group:first-child {
    border-top: none;
    padding-top: 0;
}

.image-modal-info .spec-group h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #ecf0f1;
    font-weight: 600;
}

.image-modal-info .spec-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.image-modal-info .spec-label {
    color: #95a5a6;
    margin-right: 1rem;
}

.image-modal-info .spec-value {
    color: #ecf0f1;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.image-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    flex: 1;
    max-height: 90vh;
}

.image-modal-img {
    width: 100%;
    height: auto;
    max-height: 45vh;
    object-fit: contain;
    border-radius: 4px;
}

.image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: opacity 0.2s;
}

.image-modal-close:hover {
    opacity: 0.7;
}

/* Gallery pagination controls */
.gallery-pagination-top,
.gallery-pagination-bottom {
    margin: 1rem 0;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-start;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 40px;
}

.pagination-btn:hover:not(:disabled) {
    background: #ecf0f1;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #95a5a6;
    color: #95a5a6;
}

.pagination-btn.active {
    background: #3498db;
    color: white;
}

.pagination-pages {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.pagination-page {
    min-width: 40px;
}

.pagination-intermediate {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.5rem 0.8rem;
}

.pagination-intermediate:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.pagination-prev,
.pagination-next {
    font-weight: 700;
}

/* Modal navigation buttons */
.image-modal-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.nav-btn {
    width: 50px;
    height: 50px;
    border: 2px solid #3498db;
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(52, 152, 219, 0.2);
    transform: scale(1.1);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #95a5a6;
    color: #95a5a6;
}

.nav-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn-row {
    display: flex;
    gap: 0.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 1rem;
        gap: 1rem;
    }

    .sidebar h1 {
        margin-bottom: 0;
        margin-right: 1rem;
    }

    .sidebar ul {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin: 0;
    }

    .sidebar li {
        margin-bottom: 0;
    }

    .content {
        margin-left: 0;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .gallery-filters {
        gap: 0.25rem;
    }

    .filter {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 35px;
    }

    .gallery-img {
        max-width: 150px;
    }

    .image-modal-close {
        top: 10px;
        right: 10px;
    }

    .image-modal-container {
        flex-direction: column;
        max-width: 95vw;
        max-height: 95vh;
        overflow-y: auto;
    }

    .image-modal-left {
        width: 100%;
        max-height: none;
    }

    .image-modal-info {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }

    .image-modal-prompt {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }

    .image-modal-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        max-height: none;
    }

    .image-modal-img {
        max-height: 40vh;
    }

    .pagination-controls {
        gap: 0.5rem;
    }

    .pagination-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 35px;
    }

    .pagination-pages {
        gap: 0.25rem;
    }

    .image-modal-nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        padding: 0.5rem;
    }

    .nav-btn-group {
        flex-direction: row;
    }
}
