* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #ffffff;
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow text selection in specific areas */
header, footer, .pagination, .image-controls, .back-to-gallery {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Header */
header {
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%);
    color: white;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 30px;
}

/* Smaller header on image viewer page */
.image-viewer-main ~ header .header-container,
body:has(.image-viewer-main) header .header-container {
    padding: 10px 30px;
}

header h1 {
    font-size: 2.2em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

header h1 a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s ease;
    display: inline-block;
}

header h1 a:hover {
    opacity: 0.9;
}

.header-logo {
    height: 1.2em;
    width: auto;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    flex: 1;
    width: 100%;
}

.gallery-container {
    margin-bottom: 40px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    content-visibility: auto;
}

.gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background-color: #f8f8f8;
    aspect-ratio: 1;
    pointer-events: auto;
    contain: layout style;
}

.gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.25);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.gallery-item:hover img {
    transform: scale(1.03);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 50px;
    flex-wrap: wrap;
    padding: 20px 0;
}

.pagination button {
    background-color: #ff6b35;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 44px;
}

.pagination button:hover:not(:disabled) {
    background-color: #ff8c42;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3);
}

.pagination button:disabled {
    background-color: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination button.active {
    background-color: #ff4500;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 69, 0, 0.4);
}

.pagination span {
    color: #666;
    padding: 0 5px;
}

/* Image Viewer Page */
.image-viewer-main {
    padding: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(100vh - 60px);
    box-sizing: border-box;
    padding-top: 5px;
}

.image-viewer-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    box-sizing: border-box;
}

.image-wrapper {
    background-color: #f8f8f8;
    border-radius: 8px;
    padding: 1px;
    margin-bottom: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.image-wrapper img {
    max-width: 100%;
    max-height: calc(100vh - 60px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Image Protection */
.image-protection-wrapper {
    position: relative;
    display: inline-block;
}

.image-protection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    background: transparent;
}

.image-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 6px 20px;
    background-color: #f8f8f8;
    border-radius: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-height: 40px;
    margin-top: auto;
}

.image-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.image-info #image-counter {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.back-to-gallery {
    color: #ff6b35;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    font-size: 14px;
}

.back-to-gallery:hover {
    color: #ff4500;
    text-decoration: underline;
}

.nav-btn {
    background-color: #ff6b35;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 120px;
}

.nav-btn:hover:not(:disabled) {
    background-color: #ff8c42;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
}

.nav-btn:disabled {
    background-color: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Footer */
footer {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    color: #fff;
    margin-top: auto;
    padding: 0;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 50px 30px 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 30px;
}

.footer-section h3 {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #ff6b35;
}

.footer-section h4 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #ff8c42;
}

.footer-section p {
    color: #ccc;
    line-height: 1.8;
    font-size: 14px;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section ul li a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 14px;
}

.footer-section ul li a:hover {
    color: #ff6b35;
}

.footer-bottom {
    border-top: 1px solid #444;
    padding-top: 20px;
    text-align: center;
}

.footer-bottom p {
    color: #999;
    font-size: 13px;
}

.footer-bottom a {
    color: #ff6b35;
    text-decoration: none;
}

.footer-bottom a:hover {
    color: #ff8c42;
    text-decoration: underline;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 18px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        padding: 15px 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .header-logo {
        height: 1.2em;
    }

    main {
        padding: 20px 15px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .pagination {
        gap: 5px;
        padding: 15px 0;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 40px;
    }

    .image-viewer-main {
        padding: 0;
        padding-top: 3px;
        min-height: calc(100vh - 80px);
    }

    .image-viewer-container {
        height: calc(100vh - 80px);
    }

    .image-wrapper {
        padding: 1px;
        margin-bottom: 4px;
    }

    .image-wrapper img {
        max-height: calc(100vh - 80px);
    }

    .image-controls {
        padding: 5px 15px;
        min-height: 38px;
    }

    .image-controls {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .nav-btn {
        width: 100%;
        max-width: 100%;
    }

    .footer-container {
        padding: 30px 20px 15px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .pagination button {
        padding: 6px 10px;
        font-size: 13px;
        min-width: 36px;
    }
}
