/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Montserrat:wght@500;700&display=swap');

:root {
  /* Wilderness Center Color Palette */
  --primary-green: #007749; /* dark green */
  --light-green: #52a843;   /* bright green */
  --accent-green: #d0e3c4;  /* pale green */
  --earth-brown: #94795d;   /* earth tone */
  --light-brown: #e8e0d7;   /* light earth tone */
  --text-dark: #333333;
  --text-light: #ffffff;
  --background-light: #f9f9f7;
  /* New: default fade duration (can be overridden by JS) */
  --fade-duration: 250ms;
}

body {
    font-family: 'Open Sans', sans-serif;
    background-color: var(--background-light);
    color: var(--text-dark);
    margin: 0;
    line-height: 1.6;
    display: block;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 90%;
    width: 700px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--primary-green);
}

h1 {
    margin-bottom: 20px;
    font-size: 2.2rem;
}

a {
    color: var(--primary-green);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--light-green);
    text-decoration: underline;
}

/* --- Authentication/Login Styles --- */
html.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-container {
    width: 350px;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.auth-container h2 {
    margin-bottom: 20px;
    color: var(--primary-green);
    font-size: 1.8rem;
}

.auth-container input[type="text"],
.auth-container input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: 'Open Sans', sans-serif;
}

.auth-container button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.2s;
}

.auth-container button:hover {
    background-color: var(--light-green);
}

.auth-container button:disabled {
    background-color: #a8b7ad;
    cursor: not-allowed;
    box-shadow: none;
}

.password-requirements {
    margin: -10px 0 16px;
    text-align: left;
    font-size: 0.9em;
    color: #5f6f65;
}

.requirement,
.password-match-message {
    margin: 4px 0;
}

.requirement::before,
.password-match-message::before {
    content: "• ";
    font-weight: 700;
}

.requirement.met,
.password-match-message.met {
    color: var(--primary-green);
}

.requirement.met::before,
.password-match-message.met::before {
    content: "✓ ";
}

.requirement.missing,
.password-match-message.missing {
    color: #9a3b2f;
}

.requirement.missing::before,
.password-match-message.missing::before {
    content: "• ";
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--accent-green);
    font-size: 0.95em;
}

.header a {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
    margin-left: 10px;
}

.header a:hover {
    color: var(--light-green);
}

/* --- Image and Controls --- */
.image-container {
    margin: 25px 0;
    min-height: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--accent-green);
    border-radius: 8px;
    background-color: var(--background-light);
    padding: 5px;
    position: relative; /* ensure badges can be positioned */
}

#image-display,
#video-display {
    max-width: 100%;
    max-height: 450px;
    height: auto;
    border-radius: 4px;
    transition: opacity var(--fade-duration) ease;
    opacity: 0;
}

/* Hide video by default; JS toggles display */
#video-display {
    display: none;
    background: #000; /* black bars for videos */
    width: 100%;
    min-height: 200px; /* Ensure minimum height so it's visible even if video fails */
    object-fit: contain; /* Maintain aspect ratio */
    position: relative;
}

/* Video error and warning messages */
.video-error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    z-index: 10;
    max-width: 80%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.video-warning-message {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255, 165, 0, 0.95);
    color: black;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    z-index: 10;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.controls {
    margin: 15px 0;  /* Reduced margin */
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;  /* Smaller gap between buttons */
    max-width: 600px; /* Limit maximum width */
    margin-left: auto;
    margin-right: auto;
}

/* --- Button Styles --- */
.btn {
    padding: 8px 12px;  /* Reduced padding */
    font-size: 0.85em;  /* Smaller font */
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: 'Open Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 3px;  /* Add small margin between buttons */
}

.btn:disabled {
    background-color: #d1d1d1 !important;
    cursor: not-allowed;
    box-shadow: none;
    color: #888;
}

.btn-category {
    background-color: var(--primary-green);
    color: var(--text-light);
    flex: 0 0 auto;  /* Don't allow buttons to grow */
    min-width: 100px; /* Set minimum width */
}

.btn-category:hover:not(:disabled) {
    background-color: var(--light-green);
}

.btn-blank {
    background-color: var(--earth-brown);
    color: var(--text-light);
    min-width: 100px; /* Set minimum width */
}

.btn-blank:hover:not(:disabled) {
    background-color: #a78a6d; /* slightly lighter brown */
}

.btn-undo {
    background-color: var(--light-brown);
    color: var(--text-dark);
    padding: 6px 10px;  /* Even smaller padding for undo button */
    font-size: 0.8em;
}

.btn-undo:hover:not(:disabled) {
    background-color: #dfd5ca;
}

.btn-skip {
    background-color: #3498db;
    color: white;
    padding: 6px 10px;
    font-size: 0.8em;
    transition: all 0.3s ease;
}

.btn-skip:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-skip:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-warning {
    background-color: #f39c12;
    color: var(--text-dark);
}

.btn-warning:hover:not(:disabled) {
    background-color: #e67e22;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
    font-weight: bold;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

.status-message {
    margin-top: 15px;
    min-height: 1.2em;
    color: var(--primary-green);
    font-weight: 600;
}

/* Flash Messages */
.message {
    margin: 15px 0;
    padding: 12px;
    border-radius: 4px;
    font-weight: 600;
}

.message.error {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.message.success {
    background: #e8f5e9;
    color: var(--primary-green);
    border: 1px solid #c8e6c9;
}

/* --- Leaderboard Styles --- */
#leaderboard-display {
    display: none;
    text-align: left;
    margin-top: 20px;
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#leaderboard-display h2, #leaderboard-display h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-green);
}

#leaderboard-display table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

#leaderboard-display th, #leaderboard-display td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

#leaderboard-display th {
    background-color: var(--primary-green);
    color: white;
    font-weight: 600;
}

#leaderboard-display tr:nth-child(even) {
    background-color: var(--background-light);
}

#leaderboard-display td:last-child {
    font-weight: 600;
    color: var(--light-green);
}

#leaderboard-display p {
    text-align: center;
}

/* Progress Bar */
#progress-bar-container {
    margin-bottom: 25px;
}

#progress-bar {
    background: var(--primary-green);
    transition: width 0.5s;
}

/* Counter Styles */
#image-counters {
    margin-bottom: 20px;
    line-height: 1.8;
}

#pending-counter {
    color: var(--earth-brown);
    font-weight: 600;
}

#consensus-counter {
    color: var(--light-green);
    font-weight: 600;
}

#unseen-counter, #volunteers-online-counter {
    color: var(--primary-green);
    font-weight: 600;
}

#pending-unclassified-counter {
    color: var(--light-green);
    font-weight: 600;
}

/* Gallery Specific Styles */
.gallery-container {
    max-width: 1200px;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 30px auto;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.gallery-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    background-color: var(--background-light);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.gallery-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    cursor: pointer;
}

.gallery-info {
    padding: 15px;
    font-size: 0.9em;
}

.status-badge {
    background-color: var(--light-green);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 5px;
}

.status-badge.pending {
    background-color: var(--earth-brown);
}

/* Settings Page Styles */
.settings-section {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.settings-section h2 {
    color: var(--primary-green);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--accent-green);
    padding-bottom: 10px;
}

/* Make tables consistent with Wilderness Center style */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

table th, table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

table th {
    background-color: var(--primary-green);
    color: white;
    font-weight: 600;
}

table tr:nth-child(even) {
    background-color: var(--background-light);
}

/* Form elements */
input[type="text"], 
input[type="password"], 
input[type="number"], 
select, 
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: 'Open Sans', sans-serif;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

/* Consistent button styles */
button, .btn {
    padding: 12px 24px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: background-color 0.2s;
}

button:hover, .btn:hover {
    background-color: var(--light-green);
}

.btn-danger {
    background-color: #c62828;
}

.btn-danger:hover {
    background-color: #d32f2f;
}

/* Add new styles for already voted images */
.already-voted {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.already-voted-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    background-color: rgba(255, 59, 48, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9em;
    z-index: 2;
    pointer-events: none;
}

.staff-review-label {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(243, 156, 18, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.donotshow-warning {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(231, 76, 60, 0.92); /* red */
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
    z-index: 12;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.staff-flag {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(243, 156, 18, 0.95); /* orange */
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
    z-index: 12;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Off-image flag bar shown above the image */
#flag-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    min-height: 0;
    margin: 6px 0 8px 0;
}

/* Generic flag chip */
.flag-chip {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Specific chip variants */
.flag-chip--review {
    background-color: rgba(243, 156, 18, 0.95); /* orange */
}

/* Clickable staff review chip (for staff users) */
.flag-chip--review[style*="cursor: pointer"]:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    background-color: rgba(230, 140, 0, 1);
}

.flag-chip--warning {
    background-color: rgba(231, 76, 60, 0.92); /* red */
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container, .auth-container, .gallery-container {
        width: 95%;
        padding: 20px 15px;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .controls {
        flex-direction: row;  /* Keep buttons in rows */
        justify-content: center;
    }
    
    .btn {
        padding: 6px 8px;
        font-size: 0.75em;
        min-width: auto;  /* Allow buttons to be narrower on mobile */
        margin: 2px;
    }
    
    .btn-category, .btn-blank {
        min-width: 70px;  /* Smaller minimum width on mobile */
        flex-basis: calc(33.33% - 8px);  /* Three buttons per row */
        max-width: calc(33.33% - 8px);
    }
    
    .btn-undo {
        flex-basis: 100%;  /* Full width for undo button */
        margin-bottom: 8px;
    }
    
    h1 {
        font-size: 1.8rem;
    }

    .splash-modal { padding: 18px; }
}

/* Splash overlay modal */
.splash-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none; /* shown via JS */
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.splash-modal {
    background: #fff;
    width: 92%;
    max-width: 720px;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    text-align: left;
}
.splash-modal h2 {
    margin-top: 0;
    color: var(--primary-green);
}
.splash-modal p {
    margin: 10px 0;
}
.splash-modal ul {
    margin: 10px 0 16px 20px;
}
.splash-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.splash-actions label {
    margin-right: auto;
    color: #333;
}

/* Fullscreen Lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.lightbox-overlay.visible { display: flex; }
.lightbox-content {
    max-width: 96vw;
    max-height: 96vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content img,
.lightbox-content video {
    max-width: 96vw;
    max-height: 96vh;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    background: #000;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    cursor: pointer;
    line-height: 40px;
    text-align: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* Lightbox edge navigation */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    line-height: 56px;
    text-align: center;
    cursor: pointer;
    z-index: 3001; /* above content */
    user-select: none;
    display: block; /* force visible when enabled */
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-nav:hover { background: rgba(255,255,255,0.3); }

/* Improve hit target on small screens */
@media (max-width: 640px) {
    .lightbox-nav {
        width: 48px;
        height: 48px;
        font-size: 28px;
        line-height: 48px;
    }
}

/* Modal Styles for Leaderboard */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
.lightbox-actionbar {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}
    max-width: 800px;
    position: relative;
}

.modal .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.modal .close:hover,
.modal .close:focus {
    color: #000;
    text-decoration: none;
}

/* Transcode / Loading Spinner */
.transcode-spinner-overlay {
    position: absolute;
    inset: 0; /* top:0; right:0; bottom:0; left:0 */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    z-index: 2500;
    pointer-events: none; /* let clicks through when hidden */
}
.transcode-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 5px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.95);
    animation: spin 900ms linear infinite;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Small helper when the spinner is shown inside the image container */
.image-container .transcode-spinner-overlay { pointer-events: auto; }
