/* Custom Dropdown Container */
.custom-dropdown {
    position: relative;
    margin: 0 auto;
    width: max-content;
}

/* Custom Dropdown Menu: Default (Hidden) State */
.custom-dropdown-menu {
    display: none; /* MUST be explicitly hidden by default */
    position: absolute;
    top: 100%; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    
    /* Layout and Appearance */
    min-width: 250px;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
    padding: 0;
    margin: 0.125rem 0 0;
    list-style: none;
    flex-direction: column; /* Good for vertical stacking */
}

/* Dropdown Item Styling (Applies to all links within the menu) */
.custom-dropdown-menu a.dropdown-item {
    display: block; /* Makes the link fill the full width */
    padding: 0.5rem 1rem; 
    clear: both;
    
    /* Inherited link styles */
    font-weight: 600;
    color: #702779;
    text-decoration: none; 
    
    /* Layout */
    background-color: transparent; /* Fix: merged from the erroneous a:link rule */
    text-align: left; 
    white-space: nowrap; 
    border: 0;
}

/* Dropdown link Hover State */
.custom-dropdown-menu a.dropdown-item:hover {
    text-decoration: underline; 
    color: #616365; /* Darker color on hover */
    background-color: #f8f9fa; /* Light grey background on hover */
}

/* Ensure any wrapper div for items also behaves as a block and uses flex for horizontal flow */
.custom-dropdown-menu div {
    display: flex; 
    align-items: center; /* Vertically align text/badge */
    padding: 0;
    margin: 0;
}

/* Styling for the generation badge and number */
.gen-number-dropdown {
    display: inline-block;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    font-weight: bold;
    color: #f9f9f9;
    background-color: #337ab7;
    border-radius: 0.25rem;
    
    /* Positioning */
    flex-shrink: 0;
}

/* Utility to ensure specific badge padding */
.badge.gen-number-dropdown {
    padding-left: 8px;
}

/* Custom Dropdown Menu: Visible State (Activated by JS) */
.custom-dropdown-menu.is-open {
    display: block; 
}

/* Custom Collapsible Styling: Hidden State */
.collapsible-content.is-collapsed, .js-modal-gallery.is-hidden, .modal-overlay.is-hidden {
    display: none;
}
    
/* Custom Collapsible Styling: Visible State */
.collapsible-content:not(.is-collapsed) {
    display: block; 
}

/* Utility to center elements */
.h-text-center {
    text-align: center;
}

/* Container to organize the details and the photo side-by-side */
.l-record--photo-layout {
    display: flex;
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    align-items: flex-start;
    gap: 20px; /* Space between the text details and the photo */
}

/* Styling for the details column (takes up more space) */
.l-record__details {
    flex: 2; /* Takes up 2/3 of the space */
    min-width: 250px; /* Ensures it doesn't get too narrow */
}

/* --- 1. Reusable Layout for Photo Records (Issue 1) --- */
.photo-record-group {
    display: flex; /* Enable side-by-side layout */
    flex-wrap: wrap; /* Allows wrapping on small screens */
    gap: 20px;
    align-items: flex-start;
}

.photo-text-column {
    flex: 2; /* Takes 2/3 space for details */
    min-width: 300px;
}

.photo-viewer-column {
    flex: 1; /* Takes 1/3 space for the photo */
    min-width: 150px;
    max-width: 200px; /* Control the size of the photo column */
    text-align: center;
}

/* --- 2. Thumbnail Styling --- */
.thumbnail-image {
    width: 100%;
    height: auto;
    /* Cursor is set in JS, but keeping it here as a fallback */
    cursor: pointer; 
    border: 3px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
}

.thumbnail-image:hover {
    border-color: #007bff; /* Visual feedback on hover */
    opacity: 0.95;
}


/* --- 3. Modal Overlay Styling (Issue 2) --- */
.modal-overlay {
    position: fixed; /* Fixed position relative to the viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.70); /* Darker, semi-transparent background */
    z-index: 9999; /* Ensure it's on top of everything (higher than your quick-list) */
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay.is-hidden {
    display: none; /* Hidden by default, controlled by JS */
}

.modal-content {
    background: #fff;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    overflow: auto; /* Allows scrolling if the image is too big */
}

.modal-full-image {
    display: block;
    max-width: 100%; /* Image stays within the width of the modal content box */
    max-height: 80vh; /* NEW: Limits the height to 80% of the viewport height */
    width: auto;      /* Ensures the width scales proportionally to the height change */
    height: auto;     /* Maintains aspect ratio */
}

.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 15px;
    font-size: 30px;
    font-weight: bold;
    line-height: 30px;
    color: #fff; /* White close button for visibility over the dark overlay */
    background-color: #000000;
    border: none;
    cursor: pointer;
    z-index: 10000;
    padding: 10px;
}

.modal-close-btn:hover {
    color: #ccc;
}

/* Styling for navigation buttons inside the modal */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 15px 10px;
    font-size: 20px;
    cursor: pointer;
    z-index: 10; /* Ensure buttons are above the image */
    user-select: none; /* Prevent text selection */
}

.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.prev-btn {
    left: 10px; /* Position on the left */
    border-radius: 0 3px 3px 0;
}

.next-btn {
    right: 10px; /* Position on the right */
    border-radius: 3px 0 0 3px;
}

/* Ensure the modal content container has relative position for absolute buttons */
.modal-content {
    /* ... (keep existing styles) ... */
    position: relative; /* This is crucial for positioning children */
}