header {
    background-color: #212121;
    color: #e0e0e0;
    padding: 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    min-height: 100vh;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

#app {
    padding: 2rem;
    margin: 0 auto;
    background-color: #212121;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

h1, h2, h3 {
    margin-bottom: 0.5rem;
}

.folders-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.folder-card {
    width: 200px;
    background-color: #2c2c2c;
    border-radius: 8px;
    border: 1px solid #3d3d3d;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.folder-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    border-color: #176cea;
}

.folder-card:focus {
    outline: 2px solid #176cea;
    outline-offset: 2px;
}

.thumbs-container {
    padding: 12px;
    cursor: pointer;
}

.folder-cover {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    pointer-events: none;
    background-color: #3d3d3d;
}

.folder-title {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    text-align: center;
    margin-top: 8px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-count {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 4px;
    pointer-events: none;
}

.error-message {
    background-color: #dc3545;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem;
    text-align: center;
}

/* Popup styles */
#popup {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(20, 20, 20, 0.95);
    border-radius: 12px;
    border: 1px solid #3d3d3d;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#popup.fade-active {
    opacity: 1;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.fade-in {
    animation: fade-in 0.3s ease-out;
}

.fade-out-active {
    animation: fade-out 0.3s ease-out;
}

#close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    font-size: 24px;
    color: #ccc;
    user-select: none;
    line-height: 1;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

#close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

#popup-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 60px 80px 20px 80px;
}

#popup-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    transition: opacity 0.15s ease;
}

#popup-image.image-switching {
    opacity: 0.3;
}

/* Navigation buttons */
.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(40, 40, 40, 0.8);
    color: #e0e0e0;
    border: 1px solid #444;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
    z-index: 10;
}

.nav-button:hover {
    background-color: rgba(60, 60, 60, 0.95);
    border-color: #176cea;
    transform: translateY(-50%) scale(1.1);
}

.nav-button:active {
    transform: translateY(-50%) scale(0.95);
}

#prev-btn {
    left: 16px;
}

#next-btn {
    right: 16px;
}

/* Image counter */
#image-counter {
    position: absolute;
    bottom: 125px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(40, 40, 40, 0.8);
    color: #ccc;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    z-index: 10;
}

/* Thumbs navigation */
#thumbs-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 110px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 16px;
    background-color: rgba(30, 30, 30, 0.9);
    border-radius: 0 0 12px 12px;
    border-top: 1px solid #333;
}

#thumbs-nav::-webkit-scrollbar {
    height: 6px;
}

#thumbs-nav::-webkit-scrollbar-track {
    background: transparent;
}

#thumbs-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#thumbs-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.thumb-nav-image {
    height: 80px;
    width: 80px;
    min-width: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.thumb-nav-image:hover {
    transform: scale(1.08);
    border-color: #555;
}

.thumb-nav-image.selected {
    border-color: #176cea;
    box-shadow: 0 0 0 2px rgba(23, 108, 234, 0.3);
    transform: scale(1.05);
}

/* Scrollbar styles for the rest of the page */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Responsive design */
@media (max-width: 768px) {
    #app {
        padding: 1rem;
    }

    .folder-card {
        width: 150px;
    }

    #popup {
        width: 95%;
        height: 90vh;
    }

    #popup-content {
        padding: 50px 50px 10px 50px;
    }

    .nav-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    #prev-btn {
        left: 8px;
    }

    #next-btn {
        right: 8px;
    }

    .thumb-nav-image {
        height: 60px;
        width: 60px;
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .folder-card {
        width: 130px;
    }

    .folder-cover {
        height: 100px;
    }

    #popup-content {
        padding: 45px 40px 10px 40px;
    }
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #3d3d3d;
    border-top-color: #176cea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
