/* ==================================
   CSS for Sectioned Image Gallery
   ================================== */

/* --- Basic Reset & Body Style --- */
body {
    font-family: sans-serif;
    margin: 0;
    padding: 0; /* Remove body padding if folder view handles spacing */
    background-color: #f4f4f4;
    min-height: 100vh; /* Ensure body takes full height */
}
body.gallery-open {
    overflow: hidden;
}

/* --- Folder Selection View --- */
#folder-selection-view {
    padding: 40px 20px;
    text-align: center;
    /* Animation placeholder - View fades out */
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}
#folder-selection-view.hidden {
    opacity: 0;
    visibility: hidden;
    position: absolute; /* Remove from layout when hidden */
    pointer-events: none;
}

#folder-selection-view h2 {
    margin-bottom: 30px;
    color: #333;
}

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Responsive grid */
    gap: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.folder-item {
    background-color: #fff;
    padding: 20px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative; /* Needed for potential animation transforms */
    z-index: 1; /* Base level */
}

.folder-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
}

.folder-item h3 {
    margin: 15px 0 5px 0;
    font-size: 1.1em;
    color: #333;
}
.folder-item p {
    margin: 0;
    font-size: 0.85em;
    color: #777;
}

/* --- CSS Folder Icon --- */
.folder-icon {
    width: 80px;
    height: 60px;
    margin: 0 auto;
    position: relative;
}
.folder-icon-tab {
    width: 40%;
    height: 10px;
    background-color: #f0ad4e; /* Folder color */
    border-radius: 4px 4px 0 0;
    position: absolute;
    top: 0;
    left: 5px;
}
.folder-icon-body {
    width: 100%;
    height: calc(100% - 5px); /* Leave space below tab */
    background-color: #f0ad4e; /* Folder color */
    border-radius: 0 5px 5px 5px;
    position: absolute;
    bottom: 0;
    left: 0;
    /* Optional: Add Font Awesome icon inside */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    color: rgba(0, 0, 0, 0.5);
}


/* --- Folder Animation --- */
.folder-item.animating {
    /* Ensure it's above others during animation */
    z-index: 10;
    /* Example Animation: Scale up */
    animation: folder-zoom 0.5s ease-out forwards;
}

@keyframes folder-zoom {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
         transform: scale(1.3);
         opacity: 0.8;
         box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    }
    100% {
        transform: scale(1.1); /* Slightly shrink back */
        opacity: 0; /* Fade out at the end */
        visibility: hidden;
    }
}


/* --- Gallery Container Styling - FULL SCREEN --- */
#image-gallery {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000; background-color: rgba(0, 0, 0, 0.95); /* Darker? */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to top */
    align-items: center;
    padding: 0; /* Remove padding, controls handle spacing */

    opacity: 0; visibility: hidden;
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
    overflow: hidden;
}
#image-gallery.visible { opacity: 1; visibility: visible; }

/* --- Top Gallery Controls --- */
.gallery-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 20px;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.3); /* Subtle background */
    flex-shrink: 0; /* Prevent shrinking */
    z-index: 1010; /* Above arrows */
}
.gallery-controls button {
    background: none;
    border: none;
    color: #eee;
    font-size: 16px; /* Adjust as needed */
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}
.gallery-controls button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
#close-gallery-btn {
    font-size: 28px; /* Larger X */
    font-weight: bold;
    padding: 5px 10px; /* Fine tune padding */
    margin-left: auto; /* Push X to the right */
}
#back-to-folders-btn {
    margin-right: auto; /* Push Back button left */
}
#gallery-section-title {
    color: #fff;
    margin: 0 15px;
    font-size: 1.1em;
    font-weight: normal;
    text-align: center;
    flex-grow: 1; /* Allow title to take space */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Main Image Area (Adjust padding for controls) --- */
.main-image-nav-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-grow: 1; /* Take remaining vertical space */
    min-height: 0;
    padding: 10px 50px 0; /* Reduced top padding, keep side padding */
    box-sizing: border-box;
}
.main-image-container { /* (Remains the same) */ }
#main-image { /* (Remains the same, ensure max-height considers controls+thumbs) */
    max-height: calc(100% - 30px); /* Adjust max height */
     /* Add transitions for smooth image change */
    transition: opacity 0.3s ease-in-out;
}
#main-image.loading { /* Class to fade image during load */
    opacity: 0.5;
}


/* --- Navigation Arrows (Shared Styles) --- */
.nav-arrow { /* (Remains mostly the same) */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.3); color: white; border: none;
    font-size: 24px; padding: 15px 10px; cursor: pointer;
    border-radius: 5px; z-index: 1005;
    transition: background-color 0.3s ease; line-height: 1;
}
.nav-arrow:hover { background-color: rgba(0, 0, 0, 0.6); }
.nav-arrow:disabled { opacity: 0.3; cursor: default; background-color: rgba(0, 0, 0, 0.2); }
/* Main Image Arrows Positioning */
.main-prev { left: 10px; }
.main-next { right: 10px; }

/* --- Thumbnail Scrolling Area (Adjust spacing) --- */
.thumbnail-scroll-container {
    position: relative; width: 90%; max-width: 1000px;
    flex-shrink: 0;
    margin-top: 10px; /* Reduced margin */
    margin-bottom: 10px; /* Added bottom margin */
    padding: 0 40px; box-sizing: border-box;
}
/* Individual section containers */
.thumbnail-container {
    /* Styles moved from here to shared rules or handled by JS display toggle */
     display: none; /* Default state, JS controls visibility */
     /* Keep flex settings for when it *is* visible */
     justify-content: flex-start; /* Align thumbs to start */
     overflow-x: auto; overflow-y: hidden; white-space: nowrap;
     gap: 10px; padding: 10px 0; scrollbar-width: none;
     -ms-overflow-style: none; scroll-behavior: smooth;
}
.thumbnail-container::-webkit-scrollbar { display: none; }
/* Set display flex for the *active* container via JS, but can keep base here */
/* Removed: display: flex; */


/* Thumbnail Image Styling (Remains the same) */
.thumbnail-image { /* ... */ }
.thumbnail-image:hover { /* ... */ }
.thumbnail-image.active-thumb { /* ... */ }

/* Thumbnail Arrows Positioning (Remains the same) */
.thumb-prev { left: 5px; }
.thumb-next { right: 5px; }
.thumbnail-scroll-container .nav-arrow { top: 50%; }

/* --- Helper class --- */
.hidden { display: none !important; } /* Ensure hidden always wins */