/**
 * Tab Gallery Widget Styles
 */

.pravalli-tab-gallery {
  margin-bottom: 30px;
}

/* Tab Navigation */
.pravalli-tab-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
  gap: 10px;
}

.pravalli-tab-btn {
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 20px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.pravalli-tab-btn.active {
  background-color: rgb(26 183 96) !important;
  color: #fff;
  font-weight: 600;
}

.pravalli-tab-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Tab Content */
.pravalli-tab-content {
  position: relative;
}

.pravalli-tab-pane {
  display: none;
}

.pravalli-tab-pane.active {
  display: flex;
}

/* Gallery Grid */
.pravalli-gallery-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(350px, 1fr));
  grid-auto-rows: 400px;
  grid-auto-flow: dense;
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  grid-auto-flow: row dense; /* This helps fill empty spaces */
}

/* Gallery Items */
.pravalli-gallery-item {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  min-height: 150px;
  min-width: 100%;
}

/* Make some items wider or taller to create the uneven grid */
.pravalli-gallery-item-wide {
  grid-column: span 2 !important;
}

.pravalli-gallery-item-tall {
  grid-row: span 2 !important;
}

.pravalli-gallery-item-large {
  grid-column: span 2 !important;
  grid-row: span 2 !important;
}

.pravalli-gallery-item-filler {
  background-color: transparent;
  min-height: 0;
  min-width: 0;
  visibility: hidden;
  margin: 0;
  padding: 0;
}

/* Adjust width and appearance for grid fill */
@media (max-width: 1100px) {
  .pravalli-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.pravalli-gallery-image-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pravalli-gallery-image-container .pravalli-gallery-image {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.pravalli-gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease;
}

.pravalli-gallery-item:hover .pravalli-gallery-image {
  transform: scale(1.05);
}

.pravalli-gallery-item:hover .pravalli-gallery-overlay {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Lightbox Styles */
.pravalli-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.pravalli-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.pravalli-lightbox-content {
  max-width: 90%;
  max-height: 90%;
  position: relative;
}

.pravalli-lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.pravalli-lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
}

.pravalli-lightbox-nav {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  padding: 0 20px;
}

.pravalli-lightbox-prev,
.pravalli-lightbox-next {
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.3);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Admin Form Styles */
.pravalli-tabs-container {
  background: #f7f7f7;
  padding: 15px;
  border: 1px solid #e0e0e0;
  margin-top: 15px;
}

.pravalli-tab-item {
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
}

.pravalli-gallery-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.pravalli-preview-image {
  width: 60px;
  height: 60px;
  position: relative;
  border: 1px solid #ddd;
}

.pravalli-preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pravalli-remove-image {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #e03131;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .pravalli-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: 120px;
    gap: 8px;
  }

  .pravalli-gallery-item {
    min-height: 120px;
  }

  /* Adjust spans for better coverage on tablets */
  .pravalli-gallery-item:nth-child(3n + 1) {
    grid-column: span 2;
  }

  .pravalli-gallery-item:nth-child(5n + 3) {
    grid-row: span 2;
  }
}

@media (max-width: 480px) {
  .pravalli-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    grid-auto-rows: 100px;
    gap: 5px;
  }

  .pravalli-gallery-item {
    min-height: 100px;
  }

  /* Simplify layout on mobile for better coverage */
  .pravalli-gallery-item:nth-child(odd) {
    grid-column: span 1;
  }

  .pravalli-gallery-item:nth-child(even) {
    grid-column: span 1;
  }

  .pravalli-gallery-item:nth-child(3n) {
    grid-row: span 2;
  }

  .pravalli-tab-nav {
    flex-direction: column;
    gap: 5px;
  }

  .pravalli-tab-btn {
    width: 100%;
    text-align: center;
  }
}
