/* Type Selection Modal Styles */
.type-selection-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85); /* Darker overlay */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.type-selection-modal .modal-content {
  background: #000000; /* True black background */
  padding: 25px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--accent-color); /* Purple border */
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4); /* White box shadow */
}

.type-selection-modal h3 {
  margin-bottom: 20px;
  color: var(--accent-color); /* Purple title */
  text-align: center;
}

.type-selection {
  margin-bottom: 20px;
}

.type-select, .new-type-input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #444; /* Darker border */
  border-radius: 4px;
  background-color: #111; /* Very dark grey input background */
  color: #f0f0f0; /* Light text */
  font-size: 1rem;
  text-align: center; /* Center align text in select */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px; /* Add some space above buttons */
}

.modal-buttons button {
  padding: 10px 18px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s ease;
  display: inline-flex; /* Use inline-flex */
  align-items: center;
  justify-content: center;
  gap: 8px; /* Space between icon and text */
}

#saveTypeBtn {
  background: var(--accent-color); /* Purple save button */
  color: #000000; /* Black text on purple */
}
#saveTypeBtn:hover {
  background: var(--accent-hover-color); 
}

#cancelTypeBtn {
  background: #333; /* Dark grey cancel button */
  color: #ccc; /* Light grey text */
}
#cancelTypeBtn:hover {
  background: #444; 
}

/* Styling for the EDIT modal buttons */
.type-selection-modal #edit-saveBtn {
    background: var(--accent-color); /* Purple save button */
    color: #000000; /* Black text on purple */
}
.type-selection-modal #edit-saveBtn:hover {
  background: var(--accent-hover-color); 
}

.type-selection-modal #edit-cancelBtn {
  background: #333; /* Dark grey cancel button */
  color: #ccc; /* Light grey text */
}
.type-selection-modal #edit-cancelBtn:hover {
  background: #444; 
}

/* Basic Reset & Root Variables */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #000000;
    --accent-color: #a142d1; 
    --accent-hover-color: #8a36b8; 
    --text-color: #f0f0f0;
    --text-muted-color: #a0a0a0;
    --border-color: #333;
    --modal-bg: rgba(0, 0, 0, 0.8);
    --modal-content-bg: #1a1a1a;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --info-color: #2196F3;
    --like-color: #e91e63; 
    --input-bg: #222;
    --input-border: #444;
    --button-bg: var(--accent-color);
    --button-text: var(--bg-color); 
    --button-hover-bg: var(--accent-hover-color);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Navigation */
header {
    background-color: var(--bg-color);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.site-title {
    color: var(--accent-color);
    font-size: 1.8rem;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
    margin: 0 1rem;
}

.header-controls {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: center;
}

.refresh-button {
    background: none;
    border: none;
    color: #a142d1;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px;
    flex-shrink: 0;
}

.refresh-button:hover {
    color: #c471f5;
}

nav {
    display: flex;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s ease;
    padding: 4px 8px;
}

nav ul li {
    display: flex;
    align-items: center;
    gap: 4px;
}

nav ul li i {
    font-size: 0.85rem;
}

nav a:hover,
nav a:focus {
    color: var(--accent-color);
}

.settings-button {
    background: none;
    border: none;
    color: #a142d1;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 1.3rem; 
    flex-shrink: 0;
}

.settings-button:hover,
.settings-button:focus {
    color: var(--accent-color);
    background-color: rgba(161, 66, 209, 0.1); 
    outline: none;
}

/* Main Content & Sections */
main {
    flex-grow: 1;
    padding: 2rem;
    max-width: 1200px; /* Limit max width for better readability */
    margin: 0 auto; /* Center content */
    width: 100%;
}

section {
    padding: 2rem 0;
    animation: fadeIn 0.5s ease-in-out;
}

/* Utility class to hide elements */
.hidden {
    display: none !important; 
}

#upload-section {
    display: none;
}

section[style*="display: block;"] {
     display: block; 
     animation: fadeIn 0.5s ease-in-out;
}

/* NEW Gallery Header Layout */
.gallery-header {
    display: flex;
    justify-content: space-between; /* Space out View Toggle, H2, Download All */
    align-items: center;
    margin-bottom: 1rem; /* Space below heading line */
    margin-top: 1rem; /* Space above heading line */
}

section h2 {
    /* Remove margin if it exists, handled by gallery-header */
    margin: 0;
    /* Allow H2 to grow but not push buttons too far */
    flex-grow: 1;
    text-align: center; /* Keep text centered */
}

/* Loading/Error/Info Messages */
.loading-message, .error-message, .info-message, .no-results, .upload-message {
    text-align: center;
    padding: 1rem;
    margin: 1rem auto;
    border-radius: 4px;
    max-width: 600px;
}

.loading-message {
    color: var(--text-muted-color);
}

.error-message {
    background-color: black;
    color: var(--error-color);
    border: 1px solid var(--error-color);
    width: 70vw;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 0 20px rgb(255, 255, 255, 0.9);
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); /* Adjust minmax as needed */
    gap: 15px;
    padding: 15px;
}

.image-column {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items in the column */
    gap: 40px; /* Increased gap between elements */
    padding: 15px;
}

/* Target the card/item within the column view specifically */
.image-column .image-card, /* If you use image-card */
.image-column .grid-item { /* If you reuse grid-item */
    width: 80%; /* Make items large but not full width */
    max-width: 800px; /* Increase max width slightly */
    margin-bottom: 0; /* Remove margin as gap handles spacing */
    height: auto; /* Override any fixed height/aspect ratio */
    aspect-ratio: unset; /* Remove aspect ratio constraint */
}

/* Target the image itself within the column view */
.image-column .image-card img,
.image-column .grid-item img {
    width: 100%;      /* Make image fill its container width */
    height: auto;       /* Maintain aspect ratio */
    max-height: none;   /* Remove any max-height constraint */
    object-fit: contain; /* Ensure the whole image is visible */
    display: block;     /* Ensure it behaves as a block element */
}

/* Adjust View Toggle Button for new context */
.view-toggle {
    /* background-color: #555; */ /* Keep or change? */
    /* color: white; */
    /* border: none; */
    padding: 5px 8px; /* Make it smaller */
    /* border-radius: 5px; */
    /* cursor: pointer; */
    font-size: 1.1rem; /* Make icon slightly larger */
    margin: 0; /* Remove margin */
    line-height: 1; /* Align icon better */
    flex-shrink: 0;
}

/* Adjust Download All Button for new context */
.download-all-btn {
    background: none;
    border: 1px solid var(--accent-color); /* Purple border */
    color: var(--accent-color); /* Purple text */
    padding: 5px 8px; /* Keep smaller padding */
    border-radius: 4px;
    cursor: pointer; /* Add cursor */
    font-size: 0.8rem; /* Keep smaller text */
    margin: 0; /* Keep margin removed */
    line-height: 1.4; /* Keep line height */
    flex-shrink: 0;
    display: inline-flex; 
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
}

.download-all-btn:hover {
    background-color: rgba(161, 66, 209, 0.1); /* Light purple background */
    color: var(--accent-hover-color); /* Darker purple text */
}

.download-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: transparent; /* Ensure no background when disabled */
    color: var(--accent-color); /* Keep color but dimmed by opacity */
    border-color: var(--accent-color); /* Keep border color */
}

/* Hide text on smaller screens if needed */
@media (max-width: 600px) {
    .download-all-btn .button-text {
        display: none; 
    }
     .download-all-btn {
        padding: 5px 8px; /* Adjust padding for icon only */
    }
}

/* Adjust Filter Bar Margin */
.filter-search-bar {
    /* display: flex; */
    /* gap: 1rem; */
    margin-bottom: 1rem; 
    /* align-items: center; */
    /* flex-wrap: wrap; */
    margin-top: 0; /* Reduced top margin */
}

.view-toggle:hover {
    /* background-color: #777; */
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.8rem;
    margin-top: 2rem;
    width: 100%;
}

.grid-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    background-color: var(--input-bg);
    border: 1px solid #666;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.grid-item:hover {
    transform: scale(1.03);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

.grid-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the area */
    transition: opacity 0.3s ease;
}

.grid-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    color: var(--text-color);
    padding: 0.5rem;
    opacity: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 50%;
}

.grid-item-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.edit-button, .delete-button {
    background: transparent;
    border: none;
    color: white;
    padding: 0.3rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.edit-button:hover {
    color: #4CAF50;
}

.delete-button:hover {
    color: #f44336;
}

/* Base styles for icon columns */
.grid-item .icon-column {
    position: absolute;
    top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduce base gap, margin will create larger space */
    z-index: 10; 
}

/* Positioning for the LEFT icon column */
.grid-item .icon-column-left {
    left: 10px;
}

/* Positioning for the RIGHT icon column */
.grid-item .icon-column-right {
    right: 10px;
    align-items: flex-end; 
}

/* Specific styles for icons remain the same, applied via icon class */
.grid-item .icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    transition: background-color 0.3s ease;
    background-color: rgba(0, 0, 0, 0.5); 
}

.grid-item .download-icon {
     background: rgba(98, 0, 234, 0.7); /* Purple background */
}

.grid-item .delete-icon {
     background: rgba(255, 0, 0, 0.7); /* Red background */
}

.grid-item .share-icon {
    background: rgba(0, 150, 255, 0.7); /* Blue background */
    margin-top: 20px; /* Push share icon down - Adjusted */
}

.grid-item .plus-icon {
    background: rgba(0, 100, 0, 0.7); /* Green background */
    margin-top: 20px; /* Push edit (plus) icon down - Adjusted */
}

/* Hover effects - apply to all icons */
.grid-item .icon:hover {
     filter: brightness(1.2); /* General hover effect */
}

/* Specific hover for plus-icon */
.grid-item .plus-icon:hover {
    background: rgba(0, 130, 0, 0.9);
}

.grid-item-overlay h3 {
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #a142d1;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 4px 6px;
    border-radius: 4px;
    width: fit-content;
    max-width: calc(100% - 20px);
    margin-left: 0;
}

.editable-title:hover .edit-title-icon {
    opacity: 1;
}

.title-edit-input,
.description-edit-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--accent-color);
    color: var(--text-color);
    width: 100%;
    outline: none;
    padding: 2px 4px;
}

.title-edit-input {
    font-size: 1rem;
}

.description-edit-input {
    font-size: 0.8rem;
    font-style: italic;
}

.grid-item-overlay p {
    font-size: clamp(0.5rem, 1.2vw, 0.65rem);
    color: var(--text-muted-color);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: fit-content;
    max-width: calc(100% - 20px);
    margin-left: 0;
}

.grid-item-description {
    font-style: italic;
    opacity: 0.8;
    font-size: clamp(0.45rem, 1vw, 0.6rem) !important;
}

/* Like button inside grid item */
.like-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-color);
    padding: 0.4rem 0.6rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    display: inline-flex; /* Use inline-flex */
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.3s ease, color 0.3s ease;
    align-self: flex-start; /* Align button to the start */
    position: absolute; /* Position independently within overlay */
    top: 10px; /* Adjust position from top */
    right: 10px; /* Adjust position from right */
    opacity: 0; /* Hidden by default */
    pointer-events: none; /* Not clickable by default */
}

.grid-item:hover .like-button {
    opacity: 1; /* Show on hover */
    pointer-events: auto; /* Make clickable on hover */
}

.like-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.like-button i.fas { /* Liked state */
    color: var(--like-color);
}
.like-button i.far { /* Not liked state */
    color: var(--text-muted-color);
}

/* Filter/Search Bar */
.filter-search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

/* Wrapper for the two select dropdowns */
.select-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 800px;
    margin: 0.5rem auto;
    background: #121212;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid #ba4df5;
    box-shadow: 0 0 20px rgba(186, 77, 245, 0.2);
}

@media (max-width: 768px) {
    .select-wrapper {
        flex-direction: column;
        padding: 0.6rem;
    }

    .select-wrapper select {
        width: 100%;
        min-width: unset;
    }
}

/* Make select elements take full width */
.select-wrapper select {
    flex: 1;
    width: 100%;
    background: #1a1a1a;
    border: 1px solid rgba(186, 77, 245, 0.3);
    padding: 0.8rem;
    flex-shrink: 0; 
    height: 50px; /* Increased height */
    min-height: 50px;
    min-width: 150px; 
    cursor: pointer; 
    background-color: black;
    color: var(--text-color);
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

/* Ensure selects don't grow too much */
#filter-select,
#type-filter-select {

}

#search-input {
    flex-grow: 1; /* Take available space */
    min-width: 200px; /* Minimum width */
}

.view-toggle {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    padding: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-toggle:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

.image-grid.list-view {
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 800px;
    margin: 2rem auto;
}

.image-grid.list-view .grid-item {
    display: flex;
    flex-direction: column;
    aspect-ratio: unset;
    height: auto;
}

.image-grid.list-view .grid-item img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.view-toggle {
    display: block;
    margin: 1rem auto;
    padding: 0.8rem 2rem;
}

.image-grid.list-view .grid-item-overlay {
    position: relative;
    background: none;
    padding: 1rem;
    opacity: 1;
    height: 100%;
    width: 100%;
}

#search-input, #filter-select {
    padding: 0.8rem 1rem;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

#search-input {
    flex-grow: 1; /* Take available space */
    min-width: 200px; /* Minimum width */
}

#filter-select {
    min-width: 150px; /* Minimum width */
    cursor: pointer;
}

/* Modal Styling */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: none; /* Ensure base display is none */
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 1rem;
    /* Remove any visibility or opacity rules if they exist */
    /* visibility: hidden; */ 
    /* opacity: 0; */
}

/* Rule to make modal visible */
.modal.visible {
    display: flex !important; /* Ensure display is flex when visible */
    /* Remove any visibility or opacity rules if they exist */
    /* visibility: visible; */
    /* opacity: 1; */
}

.modal-content {
    background-color: var(--modal-content-bg);
    padding: 2rem;
    border-radius: 8px;
    position: relative;
    max-width: 90vw; /* Max width relative to viewport */
    max-height: 90vh; /* Max height relative to viewport */
    overflow-y: auto; /* Allow scrolling if content overflows */
    width: 600px; /* Default width for larger screens */
    color: var(--text-color);
    transform: scale(0.95);
    transition: transform 0.3s ease-in-out;
}

.modal.visible .modal-content {
    transform: scale(1);
}

/* Image Detail Modal Specifics */
#image-detail-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    text-align: center;
    gap: 1rem;
    width: auto; /* Let content determine width */
    max-width: 800px; /* Limit max width for image modal */
}

.edit-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.edit-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    transition: background 0.3s;
}

.edit-option:hover {
    background: #3a3a3a;
}

.edit-option i {
    font-size: 1.2em;
    color: #a142d1;
}

#modal-image {
    max-width: 100%;
    max-height: 60vh; /* Limit image height */
    height: auto;
    display: block;
    border-radius: 4px;
    margin-bottom: 1rem;
}

#modal-title {
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

#image-detail-modal-content p {
    font-size: 0.95rem;
    color: var(--text-muted-color);
    line-height: 1.5;
}

#image-detail-modal-content p strong {
    color: var(--text-color);
}

.modal-like-button {
    margin-top: 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    padding: 0.7rem 1.2rem;
    border-radius: 25px;
    font-size: 1rem;
    transition: background-color 0.3s, color 0.3s;
}

.modal-like-button.liked {
    background-color: rgba(233, 30, 99, 0.1); /* Pink tint for liked */
    border-color: var(--like-color);
}
.modal-like-button.liked i.fas {
    color: var(--like-color);
}
.modal-like-button:hover {
     background-color: #333;
}

/* Edit Options Modal */
.edit-options-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    z-index: 9999;   
}

.edit-modal-content {
    background: #121212;
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    width: 800px;
    border: 1px solid #ba4df5;
    position: relative;
    box-shadow: 0 0 20px rgba(186, 77, 245, 0.2);
    margin: 2rem auto;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
}

.edit-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.edit-option-card {
    background: rgba(186, 77, 245, 0.05);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(186, 77, 245, 0.2);
    overflow: hidden;
}

.edit-option-card:hover {
    background: rgba(186, 77, 245, 0.1);
    transform: translateY(-4px);
    border-color: #ba4df5;
    text-decoration: none;
}

.edit-option-card .card-content {
    padding: 1.5rem;
}

.edit-option-card h3 {
    color: #ba4df5;
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-option-card p {
    color: #aaa;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}

.edit-options-modal .edit-modal-content {
    background: #121212;
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    width: 800px;
    border: 1px solid #ba4df5;
    position: relative;
    box-shadow: 0 0 20px rgba(186, 77, 245, 0.2);
}

.edit-options-modal .edit-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.edit-options-modal .close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.edit-options-modal .close-button:hover {
    color: #fff;
}

.edit-options-modal h2 {
    color: #ba4df5;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.edit-options-modal h2 i {
    margin-right: 0.5rem;
}

.edit-options-modal .page-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.edit-options-modal .edit-option-card {
    background: rgba(186, 77, 245, 0.05);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(186, 77, 245, 0.2);
    overflow: hidden;
}

.edit-options-modal .edit-option-card .card-content {
    padding: 1.5rem;
}

.edit-options-modal .edit-option-card:hover {
    background: rgba(186, 77, 245, 0.1);
    transform: translateY(-4px);
    border-color: #ba4df5;
    box-shadow: 0 4px 15px rgba(186, 77, 245, 0.2);
}

.edit-options-modal .edit-option-card h3 {
    color: #ba4df5;
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-options-modal .edit-option-card p {
    color: #aaa;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}

.edit-options-modal .page-link-card h3 i {
    margin-right: 0.5rem;
}

.edit-options-modal .page-link-card p {
    color: #aaa;
    font-size: 0.9rem;
    margin: 0;
}

/* Settings Modal Specifics */
.settings-modal .modal-content {
    max-width: 500px; /* Smaller max-width for settings */
    width: 90%; /* Adjust width for settings */
}

.settings-modal h3 {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
}

.settings-form .form-group {
    margin-bottom: 1.5rem;
}

.settings-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted-color);
    font-size: 0.9rem;
}

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
#search-input,
#filter-select,
.password-container,
input {
    width: 100%;
    height: 40px;
    background-color: #000;
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 0 10px;
}

.password-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* Style for the password input itself inside the container */
.password-container input[type="password"] {
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 1rem;
    padding-right: 40px; /* Make space for the toggle button */
    /* Inherit width/height from general input rules or set explicitly */
    width: 100%; 
    height: 40px;
    padding-left: 10px; /* Add left padding similar to other inputs */
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted-color);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--text-color);
}

#save-settings-btn {
    display: block;
    width: 100%;
    padding: 0.9rem;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s ease;
    margin-top: 1rem;
}

#save-settings-btn:hover,
#save-settings-btn:focus {
    background-color: var(--button-hover-bg);
}

.settings-modal .info-message {
    font-size: 0.85rem;
    color: var(--text-muted-color);
    margin-top: 1rem;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    border-radius: 50%;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
    outline: none;
}

/* Floating Action Button */
.upload-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #9d46ff;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-fab:hover {
    transform: scale(1.1);
    background: #8a3ee0;
}

/* Upload Modal */
#upload-modal {
    display: none;
}

#imagePreview {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Upload Form Styling */
.upload-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    background-color: var(--modal-content-bg); /* Use similar bg for consistency */
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--text-muted-color);
}

.form-group input[type="file"],
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: 4px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted-color);
}

#upload-submit-btn {
    display: flex; /* Use flex to align text and spinner */
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.9rem;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s ease;
    position: relative; /* Needed for absolute spinner */
    min-height: 45px; /* Ensure button has height */
}

#upload-submit-btn:disabled {
    background-color: var(--text-muted-color);
    cursor: not-allowed;
}

#upload-submit-btn:hover:not(:disabled) {
    background-color: var(--button-hover-bg);
}

#upload-spinner {
    font-size: 0.9em;
    /* Spinner animation would go here if needed, for now just text */
}

.upload-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}
.upload-message.hidden {
    display: none;
}

.upload-success {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}
.upload-error {
     background-color: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.info-message {
    background-color: rgba(33, 150, 243, 0.1);
    color: var(--info-color);
    border: 1px solid var(--info-color);
}
.info-message.hidden {
    display: none;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted-color);
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    nav {
        width: 100%;
        overflow-x: auto;
        margin: 0 -10px;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    nav::-webkit-scrollbar {
        height: 4px;
    }
    nav::-webkit-scrollbar-thumb {
                background: var(--accent-color);
        border-radius: 4px;
    }
    nav ul {
        gap: 1rem;
        white-space: nowrap;
        padding: 4px 10px;
        margin: 0;
        width: max-content;
    }
    nav a {
        font-size: 0.9rem;
    }
    main {
        padding: 1rem;
    }
    section h2 {
        font-size: 1.8rem;
    }
    .filter-search-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
    .upload-form {
        padding: 1.5rem;
    }
    .modal-content {
        padding: 1.5rem;
        width: 90%; /* Take more width on smaller screens */
    }
    #image-detail-modal-content {
         gap: 0.8rem;
    }
     #modal-title {
        font-size: 1.3rem;
    }
    #image-detail-modal-content p {
        font-size: 0.9rem;
    }
    .settings-modal h3 {
        font-size: 1.4rem;
    }

}

@media (max-width: 480px) {
     .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.8rem;
    }
    .grid-item-overlay h3 {
        font-size: 0.9rem;
    }
     .grid-item-overlay p {
        font-size: 0.75rem;
    }
    .like-button {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
        gap: 0.3rem;
        top: 5px;
        right: 5px;
    }
}

/* Video Converter Link Styles */
.video-converter-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.7rem 1.2rem;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

.video-converter-link:hover {
    background-color: var(--accent-hover-color);
}



/* FAB Image Details Modal */
.fab-details-modal .modal-content {
    margin-right: 5px;
}

/* Result image */
#result {
  display: block; /* Initially hidden */
  margin-top: 20px;
  width: auto; /* Allow width to adjust */
  max-width: 90%; /* Max width relative to its container/page */
  max-height: 60vh; /* Limit height to leave space for controls */
  object-fit: contain; /* Scale down while preserving aspect ratio */
  border: none; /* No border */
  box-shadow: none; /* No shadow */
  object-position: center; /* Center the image */
}

#container {
  position: relative;
  display: block; /* Initially hidden */
  width: 90vw; 
  max-width: 100%; 
  margin: 20px auto; 
  height: 80vh; /* Use height instead of aspect ratio */
  overflow: hidden; 
  background-color: #111; /* Dark background for letterboxing visibility */
}

#result {
  width: 100%;
  height: 100%;
  object-fit: contain;
}