/* START OF FILE styles.css */

/* Reset default styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #f8f9fa; /* Lighter, cleaner background */
    --text-color: #343a40; /* Darker gray for text */
    --header-bg: #2c3e50; /* Dark desaturated blue */
    --header-text: #ecf0f1; /* Light gray */
    --footer-bg: #34495e; /* Slightly lighter dark blue */
    --footer-text: #bdc3c7; /* Lighter gray for footer */
    --primary-accent: #3498db; /* Peter River blue */
    --secondary-accent: #f1c40f; /* Sun Flower yellow */
    --danger-color: #e74c3c; /* Alizarin red */
    --success-color: #2ecc71; /* Emerald green */
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --border-color: #dee2e6;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Roboto', sans-serif;
    --border-radius: 8px;
    --transition-speed: 0.3s;
    /* Define popup colors for easier management if needed later */
    --popup-bg: #333;
    --popup-text: #bbb;
    --popup-border: #444;
    --popup-hover-bg: #444;
    --popup-hover-text: #fff;
    --popup-padding-top: 5px;
    --popup-padding-bottom: 5px;
    --warning-color: #f39c12;
}

/* General styling */
body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    width: 100%; /* Ensure main takes full width */
}

section {
    padding: 3rem 1.5rem;
    max-width: 100%; /* Allow full width */
    margin: 0 auto;
    overflow-x: hidden; /* Prevent horizontal overflow */
    width: 100%; /* Ensure section takes full width */
}

/* Header */
.main-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 1.5rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.main-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--header-text);
    margin: 0;
    flex-shrink: 0;
}

.mobile-menu-toggle {
    display: none; /* Hidden by default for desktop */
    background: none;
    border: 1px solid var(--header-text);
    border-radius: var(--border-radius);
    color: var(--header-text);
    font-size: 1.5rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    line-height: 1;
}

/* Headings and Links */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--header-bg);
    margin-bottom: 0.75em;
}

a {
    color: var(--primary-accent);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Buttons */
button, .button-link {
    font-family: var(--font-body);
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    text-align: center;
    display: inline-block;
    line-height: 1.5;
}

.primary-btn, .button-link.primary {
    background-color: var(--primary-accent);
    color: white;
}

.primary-btn:hover, .button-link.primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.secondary-btn, .button-link.secondary {
    background-color: var(--secondary-accent);
    color: var(--text-color);
}

.secondary-btn:hover, .button-link.secondary:hover {
    background-color: #f39c12;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.danger-btn, .button-link.danger {
    background-color: var(--danger-color);
    color: white;
}

.danger-btn:hover, .button-link.danger:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Navigation */
.main-nav {
    margin-left: auto;
    display: block; /* Visible on desktop by default */
}

.main-nav ul {
    display: flex; /* Horizontal menu on desktop */
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 0;
}

.main-nav ul li {
    margin: 0 0.8rem;
    position: relative;
}

.main-nav ul li a,
.category-button {
    color: var(--header-text);
    text-decoration: none;
    font-size: 1rem;
    padding: 0.5rem 0.2rem;
    transition: color var(--transition-speed) ease;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
}

.main-nav ul li a::after,
.category-button::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-accent);
    transition: width var(--transition-speed) ease;
}

.category-button::after {
    content: '▼';
    font-size: 10px;
    margin-left: 5px;
    vertical-align: middle;
    display: inline-block;
    width: auto;
    height: auto;
    background-color: transparent;
    position: static;
    transform: none;
    transition: transform var(--transition-speed) ease;
}

.main-nav ul li a:hover,
.category-button:hover {
    color: #fff;
}

.main-nav ul li a:hover::after {
    width: 100%;
}

li.gallery-categories:hover .category-button::after,
li.video-categories:hover .category-button::after {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.popup-menu {
    display: block;
    position: absolute;
    top: 100%;
    margin-top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--popup-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 110;
    min-width: 180px;
    padding-top: var(--popup-padding-top, 5px);
    padding-bottom: var(--popup-padding-bottom, 10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s 0.25s linear, margin-top 0.25s ease;
    pointer-events: none;
    overflow: hidden;
}

.popup-menu::before {
    content: '';
    position: absolute;
    bottom: 100%;
    margin-bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent var(--popup-bg) transparent;
}

li.gallery-categories:hover .popup-menu,
li.video-categories:hover .popup-menu {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    margin-top: 0px;
    pointer-events: auto;
}

.popup-menu a {
    display: flex; /* Use flexbox for centering */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    padding: 12px 20px;
    text-decoration: none;
    color: var(--popup-text);
    white-space: nowrap;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--popup-border);
    text-align: center !important; /* Enforce centering with high specificity */
    width: 100%; /* Ensure it spans the full width */
}

.popup-menu a:last-child {
    border-bottom: none;
}

.popup-menu a:hover {
    background-color: var(--popup-hover-bg);
    color: var(--popup-hover-text);
}

.gallery-container,
.video-container {
    display: grid !important; /* Increase specificity */
    gap: 1.5rem;
    padding: 1rem 0;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    overflow-x: hidden;
    /* background-color: rgba(255, 0, 0, 0.1); /* Temporary background for debugging */ */
}

.video-container {
    display: grid !important; /* Ensure grid layout */
    gap: 1.5rem;
    padding: 1rem 0;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)) !important; /* Increase specificity */
    overflow-x: hidden;
    /* background-color: rgba(0, 255, 0, 0.1); /* Temporary background for debugging */ */
}

/* Grid Items */
.gallery-item,
.video-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden; /* Keep hidden to clip potential button overflow */
    box-shadow: 0 4px 10px var(--card-shadow);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    position: relative; /* MODIFIED: Ensure this is relative for absolute positioning inside */
    display: flex;
    flex-direction: column;
    aspect-ratio: 4 / 3;
    width: 100%;
    max-width: 100%;
    /* --- START: Added Border for Picked State --- */
    border: 3px solid transparent; /* Add space for picked border */
    transition: border-color 0.3s ease; /* Animate border change */
    /* --- END: Added Border --- */
}

/* --- START: Style for Picked Items --- */
.gallery-item.picked,
.video-item.picked {
    border-color: var(--success-color, #2ecc71); /* Green border */
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4); /* Optional glow */
}
/* --- END: Style for Picked Items --- */


.gallery-item img,
.video-item .video-thumbnail,
.gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* border-bottom: 1px solid var(--border-color); /* REMOVED: Border interferes with picked border */ */
    cursor: pointer;
    flex-grow: 1;
    max-width: 100%;
}

.video-item::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.8);
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.video-item:hover::after {
    opacity: 1;
}

/* --- START: Play Icon for VIDEO thumbnails in SHARE GALLERY --- */
section#gallery .video-item::after { /* Targeting video items within share gallery */
    content: '▶';
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem; /* Adjusted size for share gallery thumbnails */
    color: rgba(255, 255, 255, 0.9);
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 50px; /* Adjusted size */
    height: 50px; /* Adjusted size */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7; /* Default visibility for immediate distinction */
    transition: opacity var(--transition-speed) ease;
    pointer-events: none; /* So it doesn't interfere with clicks on the thumbnail */
    z-index: 5; /* Ensure it's above the thumbnail image, but below other buttons if any */
}

section#gallery .video-item:hover::after {
    opacity: 1; /* Full opacity on hover */
}

.gallery-item .save-btn,
.video-item .save-btn {
    /* These styles might need adjustment based on where you want the save button */
    margin: 0.8rem auto; /* Center horizontally, margin top/bottom */
    padding: 0.6rem 1rem;
    background: var(--primary-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-speed);
    font-weight: 500;
    text-align: center;
    display: block; /* Make it block to center with margin auto */
    width: fit-content; /* Adjust width to content */
    flex-shrink: 0; /* Prevent shrinking */
}

.gallery-item .save-btn:hover,
.video-item .save-btn:hover {
    background: #2980b9;
}

/* --- START: Pick/Unpick Button Styles --- */
.pick-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 5px 10px;
    font-size: 0.8rem;
    border: none;
    border-radius: var(--border-radius-sm, 4px);
    cursor: pointer;
    z-index: 10; /* Above image/video */
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    transition: background-color 0.2s ease;
    opacity: 0.8;
}

.pick-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
    opacity: 1;
}

/* Style when item is picked */
.gallery-item.picked .pick-btn,
.video-item.picked .pick-btn {
    background-color: var(--success-color, #2ecc71);
    opacity: 1;
}

.gallery-item.picked .pick-btn:hover {
    background-color: #27ae60; /* Darker green */
}
/* --- END: Pick/Unpick Button Styles --- */


/* --- Styles for share.html (section#gallery) --- */
section#gallery .gallery-item,
section#gallery .video-item {
    /* Override base styles for share page */
    aspect-ratio: unset; /* REMOVE fixed aspect ratio */
    background-color: transparent; /* Use page background */
    align-items: center; /* Center content */
    box-shadow: none; /* Optional: remove shadow if background is transparent */
    border: 3px solid transparent; /* Keep border for consistency */
}

/* Re-apply picked border style specifically for share page if needed */
section#gallery .gallery-item.picked,
section#gallery .video-item.picked {
     border-color: var(--success-color, #2ecc71);
}


section#gallery .gallery-item img,
section#gallery .video-item .video-thumbnail,
section#gallery .gallery-item video {
    /* Override media styles for share page */
    object-fit: contain; /* Fit content without cropping */
    height: auto; /* Let height be determined by content */
    flex-grow: 0; /* Don't need flex-grow with height: auto */
    max-width: 100%; /* Ensure it doesn't overflow */
    margin-bottom: 5px; /* Add a little space below media */
}

/* Save button specific to share.html */
section#gallery .gallery-item .save-btn,
section#gallery .video-item .save-btn {
    display: block; /* Ensure it's visible */
    margin: 5px auto 8px auto; /* Adjusted margins */
    padding: 0.6rem 2rem; /* Wide padding */
    font-size: 0.95rem;
    background: var(--primary-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-speed);
    font-weight: 500;
    text-align: center;
    flex-shrink: 0;
    width: auto;
}
section#gallery .gallery-item .save-btn:hover,
section#gallery .video-item .save-btn:hover {
     background: #2980b9;
}


/* --- Styles for Nunta/Botez IMAGE Galleries --- */
section#nunta-gallery .gallery-item,
section#botez-gallery .gallery-item,
section#portrete-gallery .gallery-item {
    /* 1. Sets the fixed shape for the grid box */
    aspect-ratio: 4 / 3;

    /* 3. Sets the background color for the box (shows in empty areas) */
		background-color: #e9ecef; /* Uses the light gray page background */
}

/* Rule for the image (img) inside the container box */
section#nunta-gallery .gallery-item img,
section#botez-gallery .gallery-item img,
section#portrete-gallery .gallery-item img {
    /* 2. Makes the entire image fit inside the box without cropping */
    object-fit: contain;

    /* Ensures the image tries to fill the container's height, respecting 'contain' */
    height: 100%;

    /* Inherits width: 100% and other base styles */
}

/* Optional: Rule to hide the save button in these specific galleries */
section#nunta-gallery .save-btn,
section#botez-gallery .save-btn,
section#portrete-gallery .save-btn {
    display: none;
}


/* --- Styles for Nunta/Botez VIDEO Galleries (section#video) --- */
/* Keep video galleries using object-fit: cover for now unless specified otherwise */
section#video .video-item {
    aspect-ratio: 16 / 9;
    background-color: var(--card-bg);
}

section#video .video-item .video-thumbnail {
    object-fit: cover; /* Keep cover for video thumbnails */
    height: 100%;
}

/* Play icon for video items (applies only to video sections) */
section#video .video-item::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.8);
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

section#video .video-item:hover::after {
    opacity: 1;
}


/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    overflow: hidden;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    transition: opacity 0.4s ease;
    cursor: pointer;
}

.lightbox-backdrop.fade-in {
    opacity: 1;
}

.lightbox-content-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 95vh;
    opacity: 0;
    padding: 20px;
}

.lightbox-content-wrapper.active {
    opacity: 1;
}

.lightbox-content {
    display: block;
    max-width: 100%;
    max-height: calc(95vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox-content.slide-in-right {
    animation: lightboxSlideInRight 0.4s ease-out forwards;
}

.lightbox-content.slide-in-left {
    animation: lightboxSlideInLeft 0.4s ease-out forwards;
}

@keyframes lightboxSlideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes lightboxSlideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.caption {
    color: #fff;
    margin-top: 10px;
    font-size: 0.9rem;
    text-align: center;
    opacity: 0; /* This will become irrelevant */
    transition: opacity 0.3s ease 0.2s; /* This will become irrelevant */
    max-width: 80%;
    word-wrap: break-word;
    display: none !important; /* Hide the caption element - added !important for emphasis */
}

/* This rule below will now have no visual effect because of display: none */
.lightbox-content-wrapper.active .caption {
    opacity: 1;
}

/* Lightbox Controls */
.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    width: 50px;
    height: 50px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s ease;
    opacity: 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-align: center;
}

.prev-arrow {
    left: -65px;
}

.next-arrow {
    right: -65px;
}

.arrow:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.close {
    position: absolute;
    top: -45px;
    right: -15px;
    font-size: 1.8rem;
    width: 40px;
    height: 40px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s ease;
    opacity: 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.lightbox-content-wrapper:hover .arrow,
.lightbox-content-wrapper:hover .close,
.lightbox-content-wrapper.active .arrow,
.lightbox-content-wrapper.active .close {
    opacity: 1;
}

.arrow.show, .close.show {
    opacity: 1 !important;
}

/* Lightbox Buttons */
.lightbox-buttons {
    margin-top: 20px; /* Space below image on desktop */
    display: flex;
    gap: 10px;
    opacity: 0; /* For fade-in effect */
    transition: opacity 0.3s ease 0.2s;
    flex-wrap: wrap;
    justify-content: center;
    position: relative; /* IMPORTANT: For normal flow on desktop */
    width: auto; 
    z-index: 1003;
}

.lightbox-content-wrapper.active .lightbox-buttons {
    opacity: 1;
}

.lightbox-buttons button {
    padding: 8px 18px; /* Default button padding */
    font-size: 0.9rem; /* Default button font size */
    background-color: var(--primary-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed), opacity 0.2s;
}

.lightbox-buttons button:hover {
    background-color: #2980b9;
    opacity: 0.9;
}

.lightbox-buttons .download-btn {
    background-color: var(--success-color);
}
.lightbox-buttons .download-btn:hover {
    background-color: #27ae60;
}

/* Lightbox Pick Button Styles */
.lightbox-buttons .lightbox-pick-btn {
    background-color: rgba(80, 80, 80, 0.8); /* Neutral default */
}
.lightbox-buttons .lightbox-pick-btn:hover {
    background-color: rgba(50, 50, 50, 0.9);
}
.lightbox-buttons .lightbox-pick-btn.picked {
    background-color: var(--success-color);
}
.lightbox-buttons .lightbox-pick-btn.picked:hover {
    background-color: #27ae60; /* Darker green */
}

/* Footer */
footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: auto;
    width: 100%;
}

/* Utility Classes */
.no-content {
    padding: 2rem;
    text-align: center;
    color: #777;
    background: #f1f3f5;
    border-radius: var(--border-radius);
    width: 100%;
    margin-top: 1rem;
}

/* Notification Styling */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--success-color);
    color: white;
    padding: 12px 25px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-weight: 500;
}

.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* Save All Button */
#save-all-button {
    /* display: block; /* REMOVED - Let it be inline-block with sort button */
    /* margin: 2rem auto; /* REMOVED - Handled by parent div now */
    padding: 12px 30px;
    background-color: var(--success-color);
    color: white !important;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 150px;
    text-align: center;
    vertical-align: middle; /* Align with sort button */
}

/* --- START: Sort Button Styles --- */
#sort-button {
    /* Inherits .secondary-btn styles by default */
    margin-right: 10px; /* Space between buttons */
    vertical-align: middle; /* Align with save all button */
    padding: 12px 25px; /* Match padding roughly */
    font-size: 1.1rem; /* Match font size */
    font-weight: 600;
    text-transform: uppercase;
}
#sort-button.active {
    background-color: var(--primary-accent); /* Indicate active sort */
    color: white;
    border-color: var(--primary-accent); /* Match border if using border */
}
/* --- END: Sort Button Styles --- */


#save-all-button:hover {
    background-color: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

#save-all-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#save-all-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.8;
    color: #ecf0f1 !important;
}

#save-all-button.loading {
    color: transparent !important;
}

#save-all-button.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    top: 50%;
    left: 50%;
    margin-top: -12px;
    margin-left: -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design Adjustments */
@media (max-width: 768px) {
    .main-header {
        padding: 0.8rem 1rem;
        justify-content: space-between;
        align-items: center;
    }

    .main-header h1 {
        font-size: 1.5rem;
        margin: 0;
    }

    .mobile-menu-toggle {
        display: block; /* Show toggle on mobile */
        border: 1px solid var(--header-text);
        border-radius: var(--border-radius);
        color: var(--header-text);
        font-size: 1.5rem;
        padding: 0.2rem 0.5rem;
        cursor: pointer;
        z-index: 101;
        line-height: 1;
    }

    .main-nav {
        display: none; /* Hidden by default on mobile */
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--header-bg);
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
        padding: 0.5rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .main-nav.active {
        display: block; /* Show when toggled */
    }

    .main-nav ul {
        flex-direction: column;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .main-nav ul li {
        margin: 0;
        width: 100%;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .main-nav ul li:last-child {
        border-bottom: none;
    }

    .main-nav ul li a,
    .category-button {
        display: flex; /* Use flexbox to center content */
        justify-content: center; /* Center horizontally */
        align-items: center; /* Center vertically */
        padding: 0.9rem 1rem;
        font-size: 1rem;
        color: var(--header-text);
        width: 100%; /* Ensure it spans the full width */
        text-align: center; /* Fallback for centering */
    }

    .category-button::after {
        margin-left: 5px; /* Keep spacing consistent */
        vertical-align: middle;
    }

    /* Fix for popup-menu positioning glitch on mobile */
    .popup-menu {
        margin-top: 0; /* Remove margin-top transition */
        transition: opacity 0.25s ease, visibility 0s 0.25s linear; /* Remove margin-top from transition */
    }

    li.gallery-categories:hover .popup-menu,
    li.video-categories:hover .popup-menu {
        margin-top: 0; /* Ensure no movement */
    }

    .gallery-container,
    .video-container {
        max-width: 100%;
        width: 100%;
        padding: 0 1rem;
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
        gap: 1rem;
        overflow-x: hidden;
        background-color: transparent; /* Reset debugging background */
    }

    .gallery-item,
    .video-item {
        width: 100%;
        aspect-ratio: 4 / 3;
        max-width: 100%;
    }

    .gallery-item img,
    .video-item .video-thumbnail,
    .gallery-item video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        max-width: 100%;
    }

    .gallery-item .save-btn,
    .video-item .save-btn {
        margin: 0.6rem;
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    .video-item::after {
        font-size: 2.5rem;
        width: 50px;
        height: 50px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    section {
        max-width: 100%;
        padding: 2rem 1rem;
        overflow-x: hidden;
    }

    footer {
        padding: 1rem;
    }

    /* Lightbox adjustments for mobile */
    .lightbox { /* Base lightbox style, ensure it's fixed for mobile context */
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important; height: 100% !important;
        z-index: 1000 !important;
    }


    .lightbox-content-wrapper {
        /* Mobile: Full viewport, no card styles */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* This centers children like .lightbox-content and .lightbox-buttons horizontally */
        justify-content: center !important; /* Vertically centers the (image + buttons) block if shorter than viewport. If taller, content scrolls starting from top. */
        overflow-y: auto !important;
        box-sizing: border-box !important;
        transform: none !important;
        opacity: 1 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background-color: transparent !important;
        z-index: 1001 !important;
    }

    .lightbox-content { /* Image/Video on Mobile */
        width: auto; /* Let width be intrinsic up to max-width */
        max-width: calc(100% - 20px); /* Side padding for the image itself */
        height: auto; /* Let height be intrinsic up to max-height */
        object-fit: contain;
        flex-shrink: 0; /* Prevent shrinking in flex layout */
        border-radius: 0 !important;
        box-shadow: none !important;
        /* margin-top is removed; justify-content:center on wrapper + max-height handles positioning */
        background-color: #000; /* For transparent images */
        display: block; /* Crucial for centering via parent's align-items:center */

        /*
           Max height calculation:
           Viewport height (100vh)
           - Space for fixed top close button (e.g., button height 40px + 10px margin = 50px)
           - Space for buttons block below image (its margin-top 25px + est. height 50px + margin-bottom 15px = 90px)
           Total reserved vertical space = 50px + 90px = 140px.
           Image max-height = 100vh - 140px.
        */
        max-height: calc(100vh - 140px) !important;
    }

    /* Higher specificity for image/video on mobile to remove card styles */
    .lightbox-content-wrapper .lightbox-content,
    .lightbox-content-wrapper #lightbox-img,
    .lightbox-content-wrapper #lightbox-video {
        width: 100% !important; /* Span full width of the scrollable area within wrapper */
        max-width: 100% !important; /* No extra side margins if wrapper handles it */
        height: auto !important;
        object-fit: contain !important;
        flex-shrink: 0 !important;
        border-radius: 0 !important; /* NO rounded corners */
        box-shadow: none !important; /* NO shadow */
        margin-top: 50px !important; /* Space from top of viewport for fixed close button */
        margin-left: auto !important; /* Center if width is less than 100% (e.g. due to max-width on wrapper) */
        margin-right: auto !important;
        background-color: #000 !important; /* Keep for transparent images */
        /* Max height calculation remains same: (100vh - 140px) */
        max-height: calc(100vh - 140px) !important;
    }

    .caption {
        /* ... (caption styles remain the same, may need to be re-evaluated if buttons cover it) ... */
        /* If caption is an issue, consider placing it between image and buttons or hiding on very small screens */
        /* For now, let's assume it's okay or will be handled later if it conflicts with buttons. */
        display: none !important; /* Let's hide it for now to simplify layout */
    }

    .lightbox-buttons {
        position: relative !important; /* Normal flow inside wrapper */
        width: 100% !important; /* Span full width available in wrapper */
        max-width: 100% !important; /* Ensure it doesn't overflow if parent is constrained */
        padding-left: 10px !important; /* Inner padding for button group */
        padding-right: 10px !important;
        box-sizing: border-box !important;
        margin-top: 25px !important;
        margin-bottom: 15px !important; /* Space at the bottom of scrollable content */
        display: flex !important;
        justify-content: center !important; /* Center buttons within this bar */
        flex-wrap: nowrap !important;
        overflow-x: auto !important; /* Horizontal scroll for buttons if they overflow */
        gap: 10px !important;
        padding-bottom: 5px !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: 1002 !important; /* Ensure buttons are clickable */
    }
    .lightbox-buttons button {
        padding: 10px 15px;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Fixed Controls (Close, Arrows) - Higher Specificity & z-index */
    .close, .arrow {
        position: fixed !important;
        z-index: 1002 !important;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    .close.show, .arrow.show { opacity: 1 !important; }

    .close {
        top: 15px; /* ADJUSTED from 10px */
        right: 15px; /* ADJUSTED from 10px */
        font-size: 1.8rem; width: 40px; height: 40px;
        color: rgba(255, 255, 255, 0.8); background: rgba(0, 0, 0, 0.4);
        border: none; border-radius: 50%; cursor: pointer;
        font-weight: bold; display: flex; align-items: center; justify-content: center; line-height: 1;
    }
    .arrow {
        top: 50%;
        transform: translateY(-50%);
        font-size: 1.3rem; width: 30px; height: 30px;
        color: rgba(255, 255, 255, 0.8); background: rgba(0, 0, 0, 0.4);
        border: none; border-radius: 50%; cursor: pointer; font-weight: bold;
        display: flex; align-items: center; justify-content: center; padding: 0; text-align: center;
    }
    .prev-arrow { left: 8px; }
    .next-arrow { right: 8px; }
}
}
	.pick-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
        top: 5px;
        right: 5px;
    }
    /* --- END: Responsive Pick Button --- */

    /* Adjust save button margin if needed */
    section#gallery .gallery-item .save-btn,
    section#gallery .video-item .save-btn {
        margin-top: 5px;
        margin-bottom: 5px; /* Reduce bottom margin slightly */
    }

    /* Adjust sort/save all buttons */
     #sort-button, #save-all-button {
        padding: 10px 20px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .main-header h1 {
        font-size: 1.3rem;
    }

    .mobile-menu-toggle {
        font-size: 1.3rem;
        padding: 0.1rem 0.4rem;
    }

    .main-nav ul li a,
    .category-button {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }

    .gallery-container,
    .video-container {
        max-width: 100%;
        width: 100%;
        padding: 0 0.8rem;
        grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
        gap: 0.8rem;
        overflow-x: hidden;
    }

    .gallery-item,
    .video-item {
        width: 100%;
        aspect-ratio: 4 / 3;
        max-width: 100%;
    }

    .gallery-item img,
    .video-item .video-thumbnail,
    .gallery-item video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        max-width: 100%;
    }

    .gallery-item .save-btn,
    .video-item .save-btn {
        margin: 0.5rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .video-item::after {
        font-size: 2rem;
        width: 40px;
        height: 40px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    section {
        max-width: 100%;
        padding: 1.5rem 0.8rem;
        overflow-x: hidden;
    }

    /* Further lightbox adjustments for smaller screens */
    .lightbox-content-wrapper {
        padding: 40px 5px 60px 5px; /* Adjust padding for smaller screens */
    }

    .lightbox-content {
        max-height: calc(100vh - 100px); /* Adjust for smaller padding */
    }

    .caption {
        font-size: 0.8rem;
        padding: 4px 8px;
        bottom: 50px;
    }

    .lightbox-buttons {
        bottom: 5px;
        gap: 8px;
    }

    .lightbox-buttons button {
        padding: 5px 12px;
        font-size: 0.8rem;
    }

    .prev-arrow {
        left: 5px;
    }

    .next-arrow {
        right: 5px;
    }

    .close {
        top: 5px;
        right: 5px;
    }

    .arrow {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .close {
        width: 30px;
        height: 30px;
        font-size: 1.5rem;
    }
}
/* Lightbox Buttons */
.lightbox-buttons {
    margin-top: 25px; /* <<< Increased value */
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease 0.2s;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    width: auto;
    z-index: 1003;
}

.lightbox-content-wrapper.active .lightbox-buttons {
    opacity: 1;
}

.lightbox-buttons button {
    padding: 8px 15px; /* Adjusted padding slightly */
    font-size: 0.85rem; /* Slightly smaller font */
    background-color: var(--primary-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed), opacity 0.2s; /* Added opacity transition */
}

.lightbox-buttons button:hover {
    background-color: #2980b9;
    opacity: 0.9;
}

.lightbox-buttons .download-btn {
    background-color: var(--success-color);
}

.lightbox-buttons .download-btn:hover {
    background-color: #27ae60;
}

/* --- START: ADD LIGHTBOX PICK BUTTON STYLES HERE --- */
.lightbox-buttons .lightbox-pick-btn {
    background-color: rgba(80, 80, 80, 0.8); /* Neutral default */
}
.lightbox-buttons .lightbox-pick-btn:hover {
    background-color: rgba(50, 50, 50, 0.9);
}

/* Style when the item IS picked */
.lightbox-buttons .lightbox-pick-btn.picked {
    background-color: var(--success-color);
}
.lightbox-buttons .lightbox-pick-btn.picked:hover {
    background-color: #27ae60; /* Darker green */
}
/* --- END: ADD LIGHTBOX PICK BUTTON STYLES HERE --- */
@media (max-width: 320px) {
    .gallery-container,
    .video-container {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .gallery-item,
    .video-item {
        width: 100%;
        aspect-ratio: 4 / 3;
        max-width: 100%;
    }

    .gallery-item img,
    .video-item .video-thumbnail,
    .gallery-item video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        max-width: 100%;
    }
}

/* Desktop Reinforcement */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important; /* Ensure hidden on desktop */
    }

    .main-nav {
        display: block !important; /* Ensure visible on desktop */
        position: static;
        width: auto;
        background: none;
        box-shadow: none;
        padding: 0;
        border-top: none;
    }

    .main-nav ul {
        flex-direction: row;
        width: auto;
    }

    .main-nav ul li {
        margin: 0 0.8rem;
        width: auto;
        text-align: left;
        border-bottom: none;
    }

    .main-nav ul li a,
    .category-button {
        padding: 0.5rem 0.2rem;
    }

    /* Ensure grid layout for both gallery and video on desktop */
    section .gallery-container {
        display: grid !important;
        gap: 1.5rem;
        padding: 1rem 0;
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
        overflow-x: hidden;
        background-color: transparent; /* Reset debugging background */
    }

    section .video-container {
        display: grid !important;
        gap: 1.5rem;
        padding: 1rem 0;
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)) !important;
        overflow-x: hidden;
        background-color: transparent; /* Reset debugging background */
    }
}
	.lightbox-buttons {
        gap: 8px; /* Adjust gap */
        bottom: -20px; /* Ensure position */
        position: absolute; /* Position explicitly */
        left: 50%;
        transform: translateX(-50%);
        width: auto; /* Allow container to size based on buttons */
    }
    .lightbox-buttons button {
        padding: 6px 12px; /* Adjust padding */
        font-size: 0.8rem;
    }
/* --- START: Folder Item Styling for Share Gallery --- */
.gallery-item.folder-item {
    /* Override some gallery-item styles for folders */
    background-color: var(--card-bg); /* Give folders a background */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
    border: 1px solid var(--border-color);
    aspect-ratio: 1 / 1; /* Make folders square-ish */
    display: flex !important; /* Use !important temporarily for debugging */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    cursor: default !important; /* Override pointer cursor */
    border-color: transparent; /* Reset picked border */
    /* Add temporary visibility aids */
    /* outline: 2px solid red; */
    /* min-height: 100px; */
}
.folder-file-count-display {
    font-size: 0.8rem;
    color: #555;
    margin-top: 0.3rem;
}

.gallery-item.folder-item:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
	display: flex !important;
}
#current-view-info {
    display: table; /* Treat like a table for shrink-wrapping */
    margin-left: auto; /* Center the element */
    margin-right: auto; /* Center the element */
    text-align: center; /* Center the text INSIDE */

    background-color: #e9ecef; /* Light gray background */
    padding: 0.4rem 0.8rem; /* Padding inside the badge */
    border-radius: var(--border-radius-sm, 4px); /* Rounded corners */
    font-size: 0.9rem; /* Text size */
    color: #495057; /* Text color */
    margin-bottom: 1rem; /* Space below the badge */
    line-height: 1.3;
}
.folder-icon-display {
    font-size: 3.5rem;
    color: var(--secondary-accent, #f1c40f);
    margin-bottom: 0.5rem;
    line-height: 1;
    display: block !important; /* Use !important temporarily for debugging */
}

.folder-name-display {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
    word-break: break-word;
    line-height: 1.3;
    display: block !important; /* Use !important temporarily for debugging */
}

/* Hide save/pick buttons specifically on folder items */
.gallery-item.folder-item .save-btn,
.gallery-item.folder-item .pick-btn {
    display: none;
}
/* --- END: Folder Item Styling --- */

/* Ensure the main container is displayed */
section#gallery .gallery-container {
    display: grid !important; /* Make sure grid is applied */
    /* Add temporary visibility aids */
    /* outline: 2px solid blue; */
    /* min-height: 200px; */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Ensure columns are defined */
    gap: 1.5rem; /* Ensure gap is applied */
}
/* --- END: Folder Item Styling --- */
/* --- START: Document Item Styling for Share Gallery --- */
.gallery-item.document-item {
    /* Similar to folder items, but maybe different icon/background */
    background-color: var(--card-bg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
    border: 1px solid var(--border-color);
    aspect-ratio: 1 / 1; /* Keep square-ish */
    display: flex !important; /* Debugging */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    cursor: default !important;
    border-color: transparent; /* Reset picked border */
}

.gallery-item.document-item:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
}

.document-icon-display {
    font-size: 3.5rem;
    color: #6c757d; /* Gray color for document icon */
    margin-bottom: 0.5rem;
    line-height: 1;
     display: block !important; /* Debugging */
}

.document-name-display {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
    word-break: break-word;
    line-height: 1.3;
    display: block !important; /* Debugging */
    /* Limit lines if needed */
    /* max-height: 2.6em; */ /* approx 2 lines */
    /* overflow: hidden; */
}

/* Hide pick button specifically on document items */
.gallery-item.document-item .pick-btn {
    display: none;
}

/* Ensure save button is visible on document items */
.gallery-item.document-item .save-btn {
    display: block; /* Or inline-block if preferred */
    margin-top: 0.8rem; /* Add some space above */
}
/* --- END: Document Item Styling --- */
/* Adjust grid layout if needed to better accommodate folders */
section#gallery .gallery-container {
    /* You might adjust minmax size if folders look too small/large */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Example adjustment */
}	
/* --- START: Share Breadcrumbs Styling (Revised) --- */
.share-breadcrumbs {
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    background-color: #e9ecef;
    border-radius: var(--border-radius-sm, 4px);
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    /* Remove gap, let separators handle spacing */
    /* gap: 0.3rem 0.5rem; */
}

/* Style for both spans and links within breadcrumbs */
.share-breadcrumbs span,
.share-breadcrumbs a {
    color: #495057;
    text-decoration: none;
    padding: 0.2rem 0; /* Vertical padding only */
    margin: 0; /* Remove default margins */
    line-height: 1.2; /* Ensure consistent vertical alignment */
}

/* Style specifically for links */
.share-breadcrumbs a {
    color: var(--primary-accent);
    font-weight: 500;
    padding: 0.2rem 0.3rem; /* Add horizontal padding to links */
}
.share-breadcrumbs a:hover {
    text-decoration: underline;
}

/* Style for the separator span */
.share-breadcrumbs .breadcrumb-separator {
    color: #adb5bd; /* Separator color */
    margin: 0 0.2rem; /* Add small horizontal margin around separator */
    /* No padding needed for separator itself */
    padding: 0;
    user-select: none; /* Prevent selecting the separator */
}

/* Style for the final (non-link) segment span */
.share-breadcrumbs .breadcrumb-current {
     font-weight: bold; /* Make the current folder bold */
     padding: 0.2rem 0.3rem; /* Add horizontal padding */
     color: var(--text-color); /* Use standard text color */
}
/* --- END: Share Breadcrumbs Styling --- */
.tertiary-btn {
    padding: 0.6rem 1rem;
    background-color: #f0f0f0; /* Light gray or similar */
    color: #555;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s;
}
.tertiary-btn:hover {
    background-color: #e0e0e0;
    color: #333;
}
/* END OF FILE styles.css */
/* --- START: Admin Shares Table Styles --- */

#shares-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px var(--card-shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
}

#shares-table th,
#shares-table td {
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}

#shares-table th {
    background: #f1f3f5;
    font-weight: 600;
    color: var(--header-bg);
}

#shares-table td {
    word-break: break-word;
    background-color: var(--card-bg);
}

#shares-table tr:nth-child(even) td {
    background-color: #f8f9fa;
}

/* Style for expired rows */
#shares-table tr.expired-share {
    color: #999;
    background-color: #fcfcfc !important; /* Override zebra-striping */
}

#shares-table tr.expired-share a {
    color: #999;
    text-decoration: line-through;
}

#shares-table .status-expired {
    color: var(--danger-color);
    font-weight: bold;
}

#shares-table .status-active {
    color: var(--success-color);
}
/* --- END: Admin Shares Table Styles --- */