* {
    box-sizing: border-box;
}

:root {
    --background: #ffffff;
    --panel: #324d39;
    --border: #50785b;
    --muted: #64746a;
    --text: #050505;
    --light-green: #d5e5d9;
}

body {
    margin: 0 auto;
    padding: 40px 24px;
    max-width: 900px;
    background: var(--background);
    color: var(--text);
    font-family: "Calibri", Arial, sans-serif;
}

/* headings */

h1 {
    text-align: center;
    color: var(--panel);
    font-size: clamp(32px, 6vw, 54px);
    letter-spacing: -2px;
    margin-bottom: 40px;
}

h2 {
    font-size: 24px;
    color: var(--panel);
}

/* currently exists an empty heading, may need to delete*/
h2:empty {
    display: none;
}

h4 {
    font-size: 20px;
    color: var(--panel);
    margin: 0 0 16px;
}

p {
    color: var(--muted);
    line-height: 1.6;
}

/* Content containers */

body > div {
    background: var(--light-green);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
}

/* empty containers such as image display pre image upload */
body > div:empty,
body > div:has(> img:not([src])) {
    display: none;
}

/* search and delete buttons */

button#search,
button#delete,
input::file-selector-button {
    background: var(--panel);
    color: white;
    border: none;
    border-radius: 9px;
    padding: 14px 32px;
    margin: 5px;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}

/* Hover effect when mouse is over button */

button#search:hover,
button#delete:hover,
input::file-selector-button:hover {
    background: var(--border);
}

/* temporarily reduces button size when clicked */

button#search:active,
button#delete:active,
input::file-selector-button:active {
    transform: scale(0.98);
}

/* File input */

input[type="file"] {
    width: 100%;
    max-width: 100%;
    background: var(--light-green);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 20px;
    text-align: center;
}

input::file-selector-button {
    margin-right: 15px;
}

/* image preview */

img {
    display: block;
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
    margin: 20px auto;
}

/* Navigation bar logo */

.navbar-brand img {
    margin: 0;
    border-radius: 0;
    object-fit: contain;
}

/* metadata table */

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    border-radius: 10px;
    overflow: hidden;
}

th {
    background: var(--panel);
    color: white;
    padding: 14px;
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
}

/* makes first column bold for easier reading */
td:first-child {
    font-weight: bold;
}

/* hides metadata table until metadata is available */

#metadataContainer:not(:has(#metadataTableBody > tr)) {
    display: none;
}

/* metadata list, alternative to table */

#metadataContainer ul {
    text-align: left;
    line-height: 1.8;
}

#metadataContainer li {
    padding: 8px;
}

/* error messages */
 
.error {
    color: #dc2626;
    margin-top: 20px;
}

/* Gallery layout */

.gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-top: 24px;
}

/* Individual gallery items */

.gallery-item {
    background: var(--light-green);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    min-width: 0;
}

/* Gallery images */

.gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    border-radius: 10px;
    margin: 0 0 16px;
}

/* Gallery metadata tables */

.gallery-item table {
    font-size: 14px;
}

.gallery-item th,
.gallery-item td {
    padding: 8px;
}

/* Responsive gallery layout */

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 500px) {
    .gallery {
        grid-template-columns: 1fr;
    }
}

/* Spacing between history and example images */

#galleryContainer {
    margin-bottom: 40px;
}

/* Empty gallery message */

#emptyGallery {
    background: var(--light-green);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

/* Hide message when processed images are available */

body:has(#galleryContainer > .gallery-item) #emptyGallery {
    display: none;
}

/* Prevent filenames from overflowing */

.gallery-filename {
    overflow-wrap: anywhere;
}

/* Prevent large metadata values from stretching tables */

.gallery-item table {
    table-layout: fixed;
}