/* Base styles */
/* LightGallery custom transitions */
.lg-backdrop {
  transition: opacity 0.2s ease !important;
}

.lg-outer .lg-item {
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease !important;
}

.lg-outer .lg-item.lg-current {
  opacity: 1;
  transform: scale(1);
}

.lg-outer .lg-img-wrap {
  transition: transform 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lg-outer .lg-img-wrap .lg-image {
  max-height: calc(100vh - 120px);
  max-width: 90vw;
  object-fit: contain;
  transition: opacity 0.25s ease-in-out;
  border-radius: 4px;
}

/* Add a subtle shadow to the modal */
.lg-outer .lg-item {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

/* Mobile-optimized gallery styles */
.lg-outer.lg-mobile-optimized .lg-img-wrap {
  padding: 12px;
}

.lg-outer.lg-mobile-optimized .lg-item {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.lg-outer.lg-mobile-optimized .lg-img-wrap .lg-image {
  max-height: calc(100vh - 24px);
  max-width: calc(100vw - 24px);
  border-radius: 8px;
}

/* Improved controls for touch devices */
.lg-outer.lg-mobile-optimized .lg-toolbar {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}

.lg-outer.lg-mobile-optimized .lg-counter {
  font-size: 14px;
  padding: 12px;
}

.lg-outer.lg-mobile-optimized .lg-toolbar .lg-icon {
  padding: 12px;
  width: 40px;
  height: 40px;
}

/* Custom screensaver button in lightGallery toolbar */
.lg-screensaver {
  font-size: 18px !important;
  cursor: pointer;
}

.lg-screensaver:hover {
  background: rgba(255, 255, 255, 0.15) !important;
}

/* Swipe hint animation */
@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(10px); }
}

.lg-outer.lg-mobile-optimized .lg-item.lg-current:after {
  content: '';
  position: absolute;
  right: 20px;
  top: 50%;
  width: 30px;
  height: 30px;
  border-right: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid rgba(255, 255, 255, 0.3);
  transform: rotate(45deg) translateY(-50%);
  animation: swipeHint 1.5s infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.lg-outer.lg-mobile-optimized .lg-item.lg-current:first-child:after {
  opacity: 1;
}

/* Prevent initial flash */
.lg-outer .lg-item:not(.lg-current) {
  position: fixed;
  visibility: hidden;
}

/* Smooth loading transition */
.lg-outer.lg-css3.lg-zoom-dragging .lg-item.lg-complete.lg-zoomable .lg-img-wrap,
.lg-outer.lg-css3.lg-zoom-dragging .lg-item.lg-complete.lg-zoomable .lg-image {
  transition: none !important;
}

/* Preload optimization */
.gallery-item img {
  transition: transform 0.2s ease;
  will-change: transform;
}

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

/* Base styles */
:root {
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  width: 100%;
}

body {
  background-color: #f8f9fa;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  height: auto;
  padding: calc(1rem + var(--safe-area-inset-top)) 1rem calc(2rem + var(--safe-area-inset-bottom));
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #f8f9fa;
}

.content-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  min-height: 100%;
}

.app-header {
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  text-align: center;
  width: 100%;
}

.app-title {
  font-size: 2rem;
  margin: 0 0 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.header-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s ease;
  gap: 0.5rem;
  min-height: 48px;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.action-button:active {
  transform: scale(0.97);
}

.action-button.screensaver-btn {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  box-shadow: 0 2px 10px rgba(52, 211, 153, 0.2);
}

.button-icon {
  font-size: 1.2em;
  line-height: 1;
}

@media (hover: hover) {
  .action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  }

  .action-button.screensaver-btn:hover {
    box-shadow: 0 4px 15px rgba(52, 211, 153, 0.3);
  }
}

/* Pagination Styles */
.pagination {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
  margin: 1rem auto 2rem;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 1;
}

.page-item {
  list-style: none;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0.5rem;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #1f2937;
  font-weight: 600;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

.page-item.disabled .page-link {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(229, 231, 235, 0.9);
}

@media (hover: hover) {
  .page-link:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: rgba(243, 244, 246, 0.95);
  }

  .page-item.active .page-link:hover {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  }
}

@media (max-width: 768px) {
  .pagination {
    gap: 0.25rem;
  }

  .page-link {
    min-width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
}

.button-icon {
  font-size: 1.1em;
}

.app-content {
  width: 100%;
  padding-bottom: 2rem;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-flex: 0;
  -webkit-flex: 0 1 auto;
  flex: 0 1 auto;
}

/* Gallery Grid Layout */
.gallery-container {
  width: 100%;
  padding: 0 0.5rem;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 0.5rem;
  margin: 0 auto;
  max-width: 1200px;
}

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

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.card-img-top {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease;
}
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.gallery-card {
  position: relative;
  overflow: hidden;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Highlight animation for navigated cards */
.gallery-card.highlight-card {
  animation: highlightPulse 2s ease-in-out;
  box-shadow: 0 0 0 4px #0d6efd, 0 4px 12px rgba(0,0,0,0.3);
  border-radius: 8px;
}

@keyframes highlightPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 4px #0d6efd, 0 4px 12px rgba(0,0,0,0.3);
  }
  25% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(13, 110, 253, 0.6), 0 8px 20px rgba(0,0,0,0.4);
  }
  50% {
    transform: scale(1);
    box-shadow: 0 0 0 4px #0d6efd, 0 4px 12px rgba(0,0,0,0.3);
  }
  75% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(13, 110, 253, 0.6), 0 8px 20px rgba(0,0,0,0.4);
  }
}

.gallery-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 8px;
}

.gallery-card-icon {
  color: white;
  font-size: 2rem;
  transform: scale(0.8);
  transition: transform 0.3s ease;
}

.gallery-card:hover .gallery-card-overlay {
  opacity: 1;
}

.gallery-card:hover .gallery-card-icon {
  transform: scale(1);
}

.gallery-card:hover .card-img-top {
  transform: scale(1.05);
}

/* Mobile optimizations */
@media (max-width: 576px) {
  .card-img-top {
    height: 120px;
  }
  
  .gallery-card {
    margin-bottom: 0.5rem;
  }
  
  .gallery-card-overlay {
    display: none;
  }
  
  .col-12 {
    padding-left: 8px;
    padding-right: 8px;
  }
  
  .row {
    margin-left: -8px;
    margin-right: -8px;
  }
}
  object-fit: cover;
}

#screensaver {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 9999;
}

#screensaver img {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Gallery styles */
#gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

#gallery > div {
  flex: 1 1 100%;
  max-width: 100%;
}

@media (min-width: 600px) {
  #gallery > div {
    flex: 1 1 48%;
    max-width: 48%;
  }
}

@media (min-width: 992px) {
  #gallery > div {
    flex: 1 1 23%;
    max-width: 23%;
  }
}

/* Small devices (phones, less than 600px) */
@media (max-width: 599px) {
  .card-img-top {
    height: 100px;
  }
  #screensaver img {
    width: 100vw;
    height: 100vh;
  }
}

/* Medium devices (tablets, 600px and up) */
@media (min-width: 600px) and (max-width: 991px) {
  .card-img-top {
    height: 130px;
  }
  #screensaver img {
    width: 100vw;
    height: 100vh;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  .card-img-top {
    height: 150px;
  }
  #screensaver img {
    width: 100vw;
    height: 100vh;
  }
}

/* Beautiful pagination styles */
#pagination {
  margin-top: 30px;
  margin-bottom: 30px;
  padding-bottom: 20px;
}

.pagination .page-item .page-link {
  color: #007bff;
  border: none;
  margin: 0 2px;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.pagination .page-item.active .page-link {
  background: #007bff;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.pagination .page-item.disabled .page-link {
  color: #ccc;
  background: #f8f9fa;
}

.pagination .page-link:hover:not(:disabled):not(.active) {
  background: #e9ecef;
  color: #0056b3;
}

/* Responsive: center pagination on mobile */
@media (max-width: 600px) {
  #pagination {
    margin-top: 20px;
  }
  .pagination .page-link {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
}

/* Make lightGallery modal background semi-transparent */
.lg-backdrop {
  background-color: rgba(0, 0, 0, 0.7) !important; /* 0.7 = 70% opacity, adjust as needed */
}

/* Search Component Styles */
.search-container {
  margin-bottom: 1.5rem;
  width: 100%;
  position: relative;
  z-index: 10;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.clear-btn {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.clear-btn:hover {
  background-color: #f1f5f9;
  transform: translateY(-1px);
}

.filter-btn {
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.filter-btn.active {
  background-color: #6366f1;
  color: white;
  border-color: #6366f1;
}

.filter-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.filter-label {
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.filter-panel .form-select {
  max-width: 200px;
  border-radius: 8px;
}

@media (max-width: 768px) {
  .search-bar {
    flex-wrap: wrap;
  }
  
  .search-input {
    width: 100%;
    flex: 1 1 100%;
  }
  
  .filter-panel {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-panel .form-select {
    max-width: 100%;
  }
  
  .filter-btn .button-text {
    display: none;
  }
  
  .filter-btn .button-icon {
    margin: 0;
  }
}
