:root {
  /* Dark theme variables - these are now default */
  --primary-color: #333;
  --secondary-color: #A4A4A4;
  /* Dark grey color for buttons */
  --background-color: #121212;
  --text-color: #A4A4A4;
  --title-color: #A4A4A4;
  --spacing: 5px;
  /* Reduced spacing by 50% */
  --font-family: 'Helvetica Neue', sans-serif;
}

body.light-theme {
  /* Light theme variables - override dark theme defaults */
  --primary-color: #f0f0f0;
  --secondary-color: #A4A4A4;
  --background-color: #ffffff;
  --text-color: #A4A4A4;
  --title-color: #A4A4A4;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.5s, color 0.5s;
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  flex: 0 0 auto;
  z-index: 1000;
  background-color: var(--primary-color);
  color: var(--title-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background-color 0.5s, color 0.5s, border-color 0.5s;
  text-align: center;
}

nav {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  max-width: 900px;
  /* Constraints width for a cleaner look */
}

button {
  padding: 6px 14px;
  background-color: transparent;
  color: var(--secondary-color);
  border: 1px solid var(--secondary-color);
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover {
  background-color: var(--secondary-color);
  color: var(--background-color);
}

main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 2rem;
  -webkit-overflow-scrolling: touch;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  /* Default to 5 columns */
  gap: calc(var(--spacing) * 2);
  padding: 0;
}

.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Square thumbnails for a more premium, organized look */
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.05);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, opacity 0.5s ease;
  opacity: 0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gallery-item.visible {
  opacity: 1;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-item.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  transition: transform 0.5s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.gallery-item:hover img {
  transform: scale(1.1);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  padding: 20px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal img {
  max-width: 95%;
  max-height: 95vh;
  object-fit: contain;
  cursor: default;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.1s ease-out;
  /* Smooth zoom/pan */
}

@keyframes modalZoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--primary-color);
  min-width: 100px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 5px;
  margin-top: 5px;
}

.dropdown-content.show {
  display: block;
}

.dropdown-content a {
  color: #A4A4A4;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-size: 0.9rem;
  transition: background-color 0.3s;
}

.dropdown-content a:hover {
  background-color: var(--secondary-color);
  color: var(--background-color);
}

.dropdown button {
  margin: 0;
}

@keyframes resizeAnimation {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

.resizing {
  animation: resizeAnimation 0.3s ease-in-out;
}

/* Progress Bar Styles */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.progress-container.active {
  opacity: 1;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--secondary-color), #9c27b0, #e91e63);
  background-size: 200% 100%;
  animation: gradientShift 2s linear infinite;
  position: relative;
  transition: width 0.3s ease-out;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes gradientShift {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* Drop overlay */
.drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1500;
  pointer-events: none;
}

.drop-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.drop-message {
  border: 3px dashed var(--secondary-color);
  border-radius: 16px;
  padding: 3rem 5rem;
  color: var(--secondary-color);
  font-size: 1.4rem;
  text-align: center;
  background: rgba(164, 164, 164, 0.05);
  letter-spacing: 0.03em;
}

/* Empty gallery placeholder */
.gallery:empty::after {
  content: 'Load images or drop files & folders here';
  display: block;
  text-align: center;
  color: rgba(164, 164, 164, 0.3);
  font-size: 1rem;
  padding: 5rem 2rem;
  grid-column: 1 / -1;
  pointer-events: none;
}

@media (max-width: 2000px) {
  .gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1200px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

@media (max-width: 600px) {
  header {
    padding: 1rem 0.5rem;
  }

  h1#galleryTitle {
    font-size: 1.5rem;
  }

  nav {
    gap: 0.5rem;
    margin-top: 1rem;
  }

  button {
    padding: 10px 12px;
    font-size: 0.8rem;
    flex: 1 1 calc(50% - 1rem);
    min-width: 120px;
    text-align: center;
  }

  #themeToggle {
    flex: 0 0 auto;
    min-width: 34px;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

#themeToggle {
  background: none;
  border: 1px solid var(--secondary-color);
  padding: 6px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

#themeToggle:hover {
  background-color: var(--secondary-color);
}

#themeToggle:hover svg {
  stroke: var(--background-color);
}

#themeToggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--text-color);
  stroke-width: 2;
  transition: stroke 0.3s;
}

/* Dark theme (default): show moon, hide sun */
.sun-icon {
  display: none;
}

.moon-icon {
  display: inline-block;
}

/* Light theme: show sun, hide moon */
body.light-theme .sun-icon {
  display: inline-block;
}

body.light-theme .moon-icon {
  display: none;
}
