/* --- Base & Body --- */
body {
    margin: 0;
    font-family: 'Roboto', Arial, sans-serif;
    /* display: flex; /* Keep for desktop */
    height: 100vh;
    overflow: hidden; /* Prevent body scrollbars usually */
    background-color: #f8f9fa;
    color: #333;
    position: relative; /* Needed for positioning context of children */
    transition: padding-left 0.3s ease-in-out; /* Smooth map transition */
}

body.logged-in {
    display: flex; /* Only use flex when logged in */
}

/* --- Layout: Sidebar + Map (Desktop Default) --- */
#sidebar {
    width: 350px;
    padding: 25px;
    background: #ffffff;
    border-right: 1px solid #dee2e6;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 1001; /* Above map, below button */
    position: fixed; /* Changed to fixed for easier mobile handling */
    left: 0;
    top: 0;
    height: 100%;
    transition: transform 0.3s ease-in-out; /* For smooth sliding */
    transform: translateX(0); /* Default state */
}

#map {
    /* flex: 1; /* Let padding handle the offset */
    height: 100%;
    background-color: #e9ecef;
    /* position: relative; /* Removed, let body handle context */
    z-index: 1; /* Below sidebar */
    margin-left: 350px; /* Default offset matching sidebar width */
    width: calc(100% - 350px); /* Fill remaining space */
    transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out; /* Smooth transition */
}

/* --- Hamburger Menu Button --- */
#hamburger-menu-button {
    display: none; /* Hidden by default (on desktop) */
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1002; /* Highest */
    font-size: 1.8rem; /* Adjust size */
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    line-height: 1; /* Prevent extra spacing */
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
#hamburger-menu-button:hover {
    background-color: #eee;
}

/* --- Menu Overlay --- */
#menu-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    z-index: 1000; /* Below sidebar, above map */
    cursor: pointer; /* Indicate it's clickable */
}

/* --- Sidebar Content (Existing Styles) --- */
/* ... your existing #sidebar h2, h3, hr, .form-group, input, textarea styles ... */
#sidebar h2, #sidebar h3 {
    color: #0056b3;
    margin-top: 0;
    margin-bottom: 15px;
}
#sidebar h3 {
    margin-top: 20px;
    font-size: 1.1em;
}
#sidebar hr {
    border: 0;
    height: 1px;
    background-color: #dee2e6;
    margin: 20px 0;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
}
.form-group input[type="text"],
.form-group input[type="date"], /* Added date */
.form-group input[type="file"], /* Added file */
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1rem;
}
.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus,
.form-group textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}


/* --- Tag Filters (Existing Styles) --- */
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}
.tag-filter-button {
    padding: 6px 12px;
    border: 1px solid #007bff;
    background-color: #fff;
    color: #007bff;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.tag-filter-button:hover {
    background-color: #e7f3ff;
}
.tag-filter-button.active {
    background-color: #007bff;
    color: #fff;
    font-weight: 500;
}

/* --- Buttons (Existing Styles) --- */
/* ... your existing button, .button-logout, .button-secondary styles ... */
button, .button-upload /* Style the upload link like a button */ {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #007bff; /* Default blue */
    color: white;
    text-align: center; /* For link acting as button */
    text-decoration: none; /* For link acting as button */
    display: inline-block; /* For link acting as button */
}
button:hover, .button-upload:hover {
    background-color: #0056b3;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.button-logout {
    background-color: #dc3545;
    width: 100%;
}
.button-logout:hover {
    background-color: #c82333;
}
.button-secondary {
    background-color: #6c757d;
    color: white;
}
.button-secondary:hover {
    background-color: #5a6268;
}
/* Explicit style for Upload link in sidebar */
#sidebar .button-upload {
     display: block;
     background: #28a745;
     margin-top: 15px;
     margin-bottom: 15px;
}
#sidebar .button-upload:hover {
    background: #218838;
}

/* --- Status Message (Inside Sidebar) --- */
.status-message {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 5px;
    min-height: 1.2em; /* Prevent layout jump */
}

/* --- Authentication Page Styles --- */
/* ... (Keep your existing .auth-container styles) ... */
.auth-container {
    max-width: 450px;
    margin: 40px auto;
    padding: 30px;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
/* ... rest of auth styles ... */
/* --- Survey Button Styling --- */
#survey-link { /* Target the anchor tag wrapping the button */
    text-decoration: none; /* Remove underline from link */
    display: block;        /* Ensures the link takes up the full width for the button */
    /* REMOVE fixed positioning properties:
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    */
}

#survey-button {
  padding: 10px 20px;
    background-color: #ffc107; /* A distinct color, e.g., warning yellow/orange */
    color: #212529; /* Dark text for good contrast on yellow */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s ease, transform 0.1s ease;
    width: 100%; /* Ensures the button itself takes full width of its container (the <a> tag) */
                 /* This makes the inline style="width: 100%;" in index.php redundant but harmless */
}

#survey-button:hover {
    background-color: #e0a800; /* Darker shade on hover */
    transform: translateY(-1px); /* Slight lift effect */
}

#survey-button:active {
    transform: translateY(0px); /* Press down effect */
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}


/* --- RESPONSIVE STYLES (Mobile) --- */
@media (max-width: 767px) {
    body.logged-in {
        display: block;
        overflow-x: hidden;
    }

    /* Sidebar behavior when LOGGED IN on mobile */
    body.logged-in #sidebar {
        transform: translateX(-100%); /* Start hidden off-screen */
        width: 280px;
        box-shadow: 2px 0 5px rgba(0,0,0,0.2);
    }
    body.logged-in.sidebar-visible #sidebar {
        transform: translateX(0); /* Slide in */
    }

    /* Sidebar behavior when LOGGED OUT on mobile */
    body:not(.logged-in) #sidebar {
        transform: translateX(0); /* Always visible */
        width: 100%; /* Take full width */
        height: 100vh; /* Take full height */
        border-right: none; /* No border needed if full width */
        padding: 25px; /* Or your preferred padding for full screen form */
        overflow-y: auto; /* Allow scrolling if content is too long */
    }
    body:not(.logged-in) #map { /* Ensure map is not accidentally displayed */
        display: none;
    }


    /* Hamburger Button: Only display if LOGGED IN on mobile */
    /* The user's CSS had multiple rules for #hamburger-menu-button.
       This rule ensures it's only shown when logged in on mobile.
       It should override other general #hamburger-menu-button display:none rules for desktop.
    */
    #hamburger-menu-button { /* General rule from user CSS makes it hidden on desktop */
        /* display: none; by default from user general style */
    }
    body.logged-in #hamburger-menu-button {
        display: block !important; /* Show only if logged in on mobile. Use !important if necessary to override other rules. */
    }


    /* Menu Overlay: Only display if LOGGED IN and sidebar is visible on mobile */
    #menu-overlay {
        display: none; /* Hidden by default */
    }
    body.logged-in.sidebar-visible #menu-overlay {
        display: block; /* Show overlay */
    }


    /* Map adjustments for logged-in mobile view */
    body.logged-in #map { /* This rule was already present and correct */
        margin-left: 0;
        width: 100%;
        height: 100vh;
    }

    /* Adjust Status and other fixed elements if necessary for logged-out view */
    body:not(.logged-in) #status {
        display: none; /* Hide map status message if not logged in */
    }
    
    /* Keep existing mobile styles for #status, Leaflet controls etc. */
    #status {
        position: fixed;
        top: auto;
        bottom: 10px;
        left: 10px;
        max-width: calc(100% - 90px);
        z-index: 990;
    }
    .leaflet-control-container {
        z-index: 900 !important;
    }
    .leaflet-top.leaflet-right {
         top: 10px;
    }
     .leaflet-popup-content-wrapper {
         max-width: calc(100vw - 40px);
         box-sizing: border-box;
     }
     .leaflet-popup-content {
         max-width: 100%;
         box-sizing: border-box;
     }
     .leaflet-popup-content img {
         max-width: 100% !important;
         height: auto !important;
     }
}


/* --- Leaflet Popup Customizations --- */
.leaflet-popup-content { /* Main content area of the popup */
    margin: 13px 20px 13px 20px; /* Default is 13px 19px */
    line-height: 1.4;
    font-size: 0.9rem; /* Base font for popup content */
}

.leaflet-popup-content-inner { /* Optional: if you want an inner wrapper */
    /* Add any specific styles for the inner content if needed */
}

.popup-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.leaflet-popup-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #333;
}

.popup-caption {
    margin-top: 0;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.9em;
}
.popup-caption strong {
    color: #333;
}


.popup-tags {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 0.85em;
    color: #666;
}
.popup-tags strong {
    color: #444;
}

.popup-meta {
    font-size: 0.8em;
    color: #777;
    margin-top: 5px;
    margin-bottom: 0;
}

/* Styles for the scrollable image gallery within a popup */
.popup-image-scroller {
    max-height: 250px; /* Adjust as needed */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px; /* Space for scrollbar */
    margin-top: 10px;
    border-top: 1px solid #f0f0f0; /* Optional separator */
    padding-top: 10px; /* Space above first item in scroller */
}

.popup-image-item {
    margin-bottom: 15px;
}
.popup-image-item:last-child {
    margin-bottom: 0;
}

.popup-item-separator {
    border: 0;
    height: 1px;
    background-color: #e0e0e0;
    margin: 15px 0;
}

/* Responsive adjustments for popups if needed */
@media (max-width: 767px) {
    .leaflet-popup-content {
        max-width: calc(100vw - 60px); /* Ensure popup isn't too wide on mobile */
    }
    .popup-image-scroller {
        max-height: 200px; /* Smaller scroll area on mobile */
    }
}


/* --- Style to hide the rogue blue hamburger button --- */
.hamburger-menu-button { /* Or use #rogue-id if it's an ID */
    display: none !important; /* Hide it on all screen sizes */
}
#hamburger-menu-button {
    display: none; /* Hidden by default (on desktop) */
    position: fixed;
    top: 12px; /* Slightly adjusted for better spacing */
    left: 12px;
    z-index: 1002; /* Highest */
    font-size: 1.6rem; /* Adjust size if needed */
    background-color: rgba(255, 255, 255, 0.95); /* Slightly more opaque */
    color: #333;
    border: 1px solid #bbb; /* Slightly darker border */
    border-radius: 4px;
    padding: 4px 9px; /* Adjust padding for the icon */
    cursor: pointer;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: auto; /* Ensure it's clickable */
}

  #hamburger-menu-button {
        display: block; /* Show the button on mobile */
    }
/* Add styles for the sidebar-visible class on the body */


/* --- Comment Section Styles --- */
.image-comments-container {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.comments-title { /* Renamed from h5 for specificity */
    font-size: 1em;
    margin-bottom: 8px;
    color: #444;
    font-weight: bold;
}

.comments-list {
    max-height: 150px; /* Limit height and make scrollable */
    overflow-y: auto;
    margin-bottom: 10px;
    padding-right: 5px; /* For scrollbar */
}

.comment-item {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dotted #f0f0f0;
    font-size: 0.9em;
}
.comment-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.comment-text {
    margin: 0 0 4px 0;
    word-wrap: break-word; /* Prevent long words from breaking layout */
    white-space: pre-wrap; /* Respect newlines in comments */
}

.comment-meta {
    font-size: 0.8em;
    color: #777;
}
.comment-meta strong {
    color: #555;
}
.comment-meta.error-text {
    color: #dc3545;
}

.add-comment-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 0.9em;
    margin-bottom: 5px;
    resize: vertical;
    min-height: 40px;
}

.add-comment-form .comment-submit-btn { /* Renamed from button[type="submit"] for specificity */
    padding: 5px 10px;
    font-size: 0.85em;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}
.add-comment-form .comment-submit-btn:hover {
    background-color: #0056b3;
}
.add-comment-form .comment-submit-btn:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

.no-comments-yet {
    font-style: italic;
    color: #888;
}

/* --- Sidebar Auth Message --- */
.sidebar-auth-message {
    padding: 10px 15px; /* Matched button padding */
    margin-bottom: 20px; /* Matched form-group margin */
    border-radius: 4px;
    font-size: 0.9em;
    text-align: center;
    border: 1px solid transparent; /* Base border */
}
.sidebar-auth-message.auth-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.sidebar-auth-message.auth-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}