/* Custom CSS for Image Extractor Application */

/* General Body and Container Adjustments */
body {
    min-height: 100vh; /* Ensure body takes full viewport height */
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa; /* Light background for body */
    color: #333; /* Default text color */
}

main {
    flex: 1; /* Allow main content to grow and push footer down */
}

/* Homepage container - wider and vertically compact */
.homepage-container {
    width: 95%; /* Increased width for homepage */
    max-width: 1200px; /* Increased max-width for very large screens */
    /* Reduced min-height to make it more vertically compact */
    min-height: calc(100vh - 200px); /* Adjusted to fit screen, considering header/footer */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto; /* Center the container */
}
.homepage-container .card {
    width: 100%; /* Ensure card fills the container */
}

/* Results page container - full width */
.results-container {
    max-width: 100%; /* Full width for results */
    padding-left: 15px;
    padding-right: 15px;
    margin: 0 auto; /* Center the container */
}

/* Card Styling */
.card {
    border: none; /* Remove default Bootstrap card border */
    border-radius: 1rem; /* More rounded corners */
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1); /* Softer shadow */
    overflow: hidden; /* Ensures shadow doesn't get cut off */
}

/* File Input Wrapper Styling */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: block; /* Ensure it takes full width */
    border: 2px dashed #007bff; /* Bootstrap primary color */
    border-radius: 0.75rem;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.file-input-wrapper:hover {
    border-color: #0056b3; /* Darker primary on hover */
    background-color: #e9ecef; /* Light gray background on hover */
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 10; /* Ensure it's clickable */
}

/* Loading Overlay Specifics */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 1rem; /* Match card border-radius */
    z-index: 1050; /* Above Bootstrap modals */
    font-size: 1.25rem;
    font-weight: 600;
    color: #343a40; /* Dark text color */
}
.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    color: #007bff; /* Primary color for spinner */
}
.loading-overlay.d-none {
    display: none !important;
}

/* Footer Styling */
.footer {
    background-color: #f8f9fa; /* Light background */
    border-top: 1px solid #e9ecef; /* Light border on top */
    color: #6c757d; /* Muted text color */
}

/* Image List Grid Styling (for results display) */
#imageList {
    display: grid;
    /* Default to 1 column on smallest screens, will be overridden by media queries */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Fallback/default */
    gap: 1.5rem;
}

/* The .col class from Bootstrap's row g-4 will still apply some flexbox behavior,
   but we're overriding the column sizing directly on #imageList with grid-template-columns.
   The .col itself can remain display:flex if its internal content needs it, but it's not
   strictly necessary for the grid layout here. Removed explicit flex on .col for cleaner grid. */
/* #imageList .col {
    display: flex;
} */

#imageList .image-item-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute space between image and controls */
    align-items: center; /* Centers items horizontally in a column */
    background-color: #f8f9fa; /* Lighter background for each item */
    padding: 1rem; /* Padding inside each item */
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.05); /* Softer shadow for items */
    border: 1px solid #dee2e6; /* Light border */
    text-decoration: none;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    height: 220px; /* Fixed height for the container to make grid uniform */
    overflow: hidden; /* Hide overflow if image is larger than container */
    width: 100%; /* Ensure it takes full column width */
    position: relative; /* For absolute positioning of checkbox and download button */
}

#imageList .image-item-wrapper:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

#imageList .image-item-wrapper img {
    cursor: pointer;
    max-width: 100%;
    max-height: 140px; /* Max height for thumbnails */
    object-fit: contain; /* Ensure image fits without cropping */
    border-radius: 0.5rem;
    margin-bottom: 0.75rem; /* Space between image and controls */
}

/* Styling for the download button on image thumbnails */
.download-single-btn {
    /* Removed position: absolute, bottom, right for centering and always visible */
    background-color: #28a745; /* Bootstrap success green */
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s ease; /* Removed opacity transition */
    white-space: nowrap;
    border: none;
    /* Removed opacity: 0; to make it always visible */
    z-index: 10;
}

/* Removed hover opacity change as it's always visible now */
/* .image-item-wrapper:hover .download-single-btn {
    opacity: 1;
} */

.download-single-btn:hover {
    background-color: #218838; /* Darker green on hover */
}

.image-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20; /* Above image and download button */
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Sticky download bar */
.sticky-download-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -0.25rem 1rem rgba(0, 0, 0, 0.1);
    padding: 1rem;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease-in-out;
    transform: translateY(100%); /* Hidden by default */
}

.sticky-download-bar.show {
    transform: translateY(0); /* Show when active */
}

/* Custom download button in GLightbox toolbar */
.gslide-toolbar .gbtn.custom-download-btn {
    order: -1; /* Place it at the beginning (left) */
    margin-right: auto; /* Push it to the left */
    color: #28a745; /* Green color for the icon */
    font-size: 1.5rem; /* Make it a bit bigger */
    /* Ensure it's clickable and visible */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem; /* Add some padding for better touch target */
}
.gslide-toolbar .gbtn.custom-download-btn:hover {
    color: #218838; /* Darker green on hover */
}


/* Responsive adjustments for image grid */
@media (min-width: 1200px) { /* Extra large devices (desktops, 1200px and up) */
    #imageList {
        grid-template-columns: repeat(6, 1fr); /* 6 columns */
    }
    #imageList .image-item-wrapper {
        height: 200px; /* Adjust height for more columns */
    }
    #imageList .image-item-wrapper img {
        max-height: 120px;
    }
}
@media (min-width: 768px) and (max-width: 1199.98px) { /* Medium devices (tablats, 768px to 1199.98px) */
    #imageList {
        grid-template-columns: repeat(3, 1fr); /* 3 columns */
    }
    #imageList .image-item-wrapper {
        height: 200px;
    }
    #imageList .image-item-wrapper img {
        max-height: 120px;
    }
}
@media (min-width: 576px) and (max-width: 767.98px) { /* Small devices (landscape phones, 576px to 767.98px) */
   #imageList {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
    }
    #imageList .image-item-wrapper {
        height: 180px;
    }
    #imageList .image-item-wrapper img {
        max-height: 100px;
    }
}
@media (max-width: 575.98px) { /* Extra small devices (portrait phones, less than 576px) */
    #imageList {
        grid-template-columns: 1fr; /* 1 column */
        gap: 0.75rem;
    }
    .card {
        padding: 1.5rem !important; /* Reduce padding on small screens */
    }
    .file-input-wrapper {
        padding: 1.5rem;
    }
    #imageList .image-item-wrapper {
        height: 180px; /* Slightly smaller height for small screens */
    }
    #imageList .image-item-wrapper img {
        max-height: 100px; /* Adjust image height for small screens */
    }
}
