.school-image-manager {
  max-width: 1200px;
  margin: 20px 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  background: #fafafa;
}

.school-image-manager + .school-image-manager {
  margin-top: 40px;
}

.image-upload-section {
  background: #f9f9f9;
  padding: 20px;
  margin-bottom: 30px;
  border-radius: 5px;
}

.image-upload-section input, .image-upload-section select {
  margin: 5px 10px 5px 0;
  padding: 8px;
}

.debug-btn {
  background: #666 !important;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 3px;
  margin-left: 10px;
}

.category-section {
  margin-bottom: 40px;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  max-width: 100%;
  text-align: center;
  margin: 15px auto;
}

.image-item {
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  background: white;
  cursor: move;
  max-width: 300px;
}

.image-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 3px;
}

.image-controls {
  margin-top: 10px;
}

.caption-input {
  width: 100%;
  padding: 5px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
}

.delete-image {
  background: #dc3545;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 10px;
}

.delete-image:hover {
  background: #c82333;
}

.grant-section {
  margin: 20px 0;
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background: #fafafa;
}

.grant-section h4 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
  font-weight: bold;
}

.grant-id {
  text-transform: uppercase;
}

.ui-sortable-helper {
  opacity: 0.8;
}

p.image-name {
  font-size: 0.8rem;
  margin-top: -15px;
}

.image-info input.image-caption {
  width: 48% !important;
  display: inline-block;
}

.image-info select.image-category {
  display: inline-block;
}

div.category-info {
  float: right;
  width: 48%;
}


/* Force grid layout with higher specificity */
div.school-gallery,
.school-gallery,
.school-images {
  //display: grid !important;
  //grid-gap: 15px !important;
  //gap: 15px !important;
  //margin: 20px 0 !important;
  //width: 100% !important;
  //box-sizing: border-box !important;

  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
  gap: 20px !important;
  max-width: 100% !important;
  text-align: center !important;
  margin: 15px auto !important;
}

/* Column layouts with maximum specificity */
div.school-gallery.gallery-cols-1,
.school-gallery.gallery-cols-1 {
  grid-template-columns: 1fr !important;
}
div.school-gallery.gallery-cols-2,
.school-gallery.gallery-cols-2 {
  grid-template-columns: 1fr 1fr !important;
}
div.school-gallery.gallery-cols-3,
.school-gallery.gallery-cols-3 {
  grid-template-columns: 1fr 1fr 1fr !important;
}
div.school-gallery.gallery-cols-4,
.school-gallery.gallery-cols-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr !important;
}
div.school-gallery.gallery-cols-5,
.school-gallery.gallery-cols-5 {
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr !important;
}
div.school-gallery.gallery-cols-6,
.school-gallery.gallery-cols-6 {
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr !important;
}

/* Gallery items */
.school-gallery .gallery-item,
.school-images .gallery-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative !important;
  overflow: hidden !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  transition: transform 0.2s ease !important;
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.school-gallery .gallery-item a,
.school-images .gallery-item a {
  text-align: center;
  margin: 0 auto;
}
.school-gallery .gallery-item:hover,
.school-images .gallery-item:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important;
}

/* Images with forced sizing */
.school-gallery .gallery-item img,
.school-images .gallery-item img {
  width: 100% !important;
  height: 200px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 8px !important;
  margin: 0 auto !important;
  padding: 8px !important;
  text-align: center;
}

.school-gallery .gallery-lightbox {
  display: block !important;
  text-decoration: none !important;
}

.school-gallery .gallery-caption {
  margin: 8px 0 0 0 !important;
  font-size: 14px !important;
  font-style: italic !important;
  color: #666 !important;
  text-align: center !important;
  line-height: 1.3 !important;
  padding: 0 5px !important;
}

.no-images {
  color: #666 !important;
  font-style: italic !important;
  text-align: center !important;
  padding: 40px !important;
  grid-column: 1 / -1 !important;
}

/* Lightbox with ultra-high z-index */
.gallery-lightbox-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0,0,0,0.9) !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
}

.gallery-lightbox-overlay.active {
  opacity: 1 !important;
}

.gallery-lightbox-content {
  position: relative !important;
  max-width: 90% !important;
  max-height: 90% !important;
  text-align: center !important;
  z-index: 999999 !important;
}

.gallery-lightbox-content img {
  max-width: 100% !important;
  max-height: 80vh !important;
  object-fit: contain !important;
  border-radius: 4px !important;
}

.gallery-lightbox-caption {
  color: white !important;
  font-size: 16px !important;
  margin-top: 15px !important;
  padding: 0 20px !important;
}

.gallery-lightbox-close {
  position: fixed !important;
  top: 20px !important;
  right: 30px !important;
  color: white !important;
  font-size: 40px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  z-index: 9999999 !important;
  background: rgba(0,0,0,0.7) !important;
  border-radius: 50% !important;
  width: 50px !important;
  height: 50px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.2s ease !important;
  border: 2px solid rgba(255,255,255,0.3) !important;
}

.gallery-lightbox-close:hover {
  background: rgba(0,0,0,0.9) !important;
  border-color: rgba(255,255,255,0.6) !important;
}

.gallery-lightbox-nav {
  position: fixed !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: rgba(0,0,0,0.7) !important;
  color: white !important;
  border: 2px solid rgba(255,255,255,0.3) !important;
  font-size: 24px !important;
  padding: 15px 20px !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  transition: all 0.2s ease !important;
  z-index: 9999999 !important;
}

.gallery-lightbox-nav:hover {
  background: rgba(0,0,0,0.9) !important;
  border-color: rgba(255,255,255,0.6) !important;
}

.gallery-lightbox-prev {
  left: 30px !important;
}

.gallery-lightbox-next {
  right: 30px !important;
}

/* Responsive with forced specificity */
@media (max-width: 768px) {
  div.school-gallery.gallery-cols-4,
  div.school-gallery.gallery-cols-5,
  div.school-gallery.gallery-cols-6,
  .school-gallery.gallery-cols-4,
  .school-gallery.gallery-cols-5,
  .school-gallery.gallery-cols-6 {
    grid-template-columns: 1fr 1fr !important;
  }
  div.school-gallery.gallery-cols-3,
  .school-gallery.gallery-cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
  .gallery-lightbox-close {
    top: 10px !important;
    right: 15px !important;
    font-size: 30px !important;
    width: 40px !important;
    height: 40px !important;
  }
  .gallery-lightbox-nav {
    font-size: 20px !important;
    padding: 10px 15px !important;
  }
}

@media (max-width: 480px) {
  div.school-gallery,
  .school-gallery {
    grid-template-columns: 1fr !important;
  }
  .gallery-lightbox-nav {
    display: none !important;
  }
}

/* Override any theme styles that might interfere */
.school-gallery * {
  box-sizing: border-box !important;
}

/* Ensure no float or flexbox interference */
.school-gallery .gallery-item {
  float: none !important;
  flex: none !important;
  position: relative !important;
}

