/**
 * Maala Photo Gallery Styles
 */

/* Superman Theme Variables */
:root {
  --superman-red: #D1392B;
  --superman-red-dark: #b32820;
  --superman-yellow: #FFAE11;
  --superman-yellow-light: #FFD166;
  --superman-blue: #3F3D56;
  --superman-blue-dark: #2F2D40;
}

/* Gallery List Page Container */
.views-element-container,
.view-maala-galleries,
.view-id-maala_galleries {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Gallery Cards Grid Layout */
.view-maala-galleries .view-content,
.view-id-maala_galleries .view-content {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 30px !important;
  padding: 20px 0;
}

/* Additional specificity for gallery cards */
.view-id-maala_galleries .views-row {
  height: 100%;
}

/* Gallery Page Title - Superman Theme */
#block-superman-page-title h1 {
  color: var(--superman-red);
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  position: relative;
  padding-bottom: 20px;
}

#block-superman-page-title h1:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(to right, var(--superman-yellow), var(--superman-red));
  border-radius: 2px;
}

/* Gallery Card Styles */
.gallery-card {
  height: 100%;
}

.gallery-card-wrapper {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

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

/* Gallery Header Actions */
.gallery-header-actions {
  text-align: center;
  margin-bottom: 40px;
}

/* Hide gallery header actions for anonymous users */
body.user-anonymous .view-maala-galleries .gallery-header-actions {
  display: none !important;
}

body.user-anonymous .view-maala-galleries header {
  display: none !important;
}

.gallery-header-actions .btn,
.gallery-header-actions .btn-primary {
  display: inline-block;
  padding: 12px 30px;
  background: linear-gradient(135deg, var(--superman-red), var(--superman-red-dark));
  color: white !important;
  text-decoration: none;
  border-radius: 30px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.gallery-header-actions .btn:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.gallery-header-actions .btn:hover {
  background: linear-gradient(135deg, var(--superman-red-dark), var(--superman-red));
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(209, 57, 43, 0.4);
}

.gallery-header-actions .btn:hover:before {
  width: 300px;
  height: 300px;
}

/* Gallery Grid Layout - Full Width */
.gallery-item.views-row {
  display: block;
  width: 100%;
  margin: 0 0 30px 0;
  background: linear-gradient(135deg, #ffffff 0%, #f8f8f8 100%);
  border: 2px solid transparent;
  border-radius: 15px;
  padding: 0;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.4s ease;
  overflow: hidden;
  position: relative;
}

.gallery-item.views-row:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--superman-red);
  background: linear-gradient(135deg, #ffffff 0%, #fff5f5 100%);
}

/* Gallery Card Content Wrapper */
.gallery-item {
  position: relative;
}

/* Gallery Header Section */
.gallery-header-section {
  padding: 20px;
  background: linear-gradient(135deg, var(--superman-red) 0%, var(--superman-red-dark) 100%);
  color: white;
  position: relative;
}

.gallery-header-section .field--name-field-gallery-name {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: white;
}

.gallery-header-section .gallery-year {
  display: inline-block;
  background: var(--superman-yellow);
  color: var(--superman-blue-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 10px;
}

/* Gallery Preview Images Section */
.gallery-preview-section {
  padding: 0;
  background: #f8f8f8;
  position: relative;
  flex: 1;
}

/* Gallery Thumbnail */
.gallery-thumbnail {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  border-radius: 8px;
  position: relative;
  background: #f0f0f0;
}

.gallery-thumbnail img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}

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

.gallery-preview-images {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 15px;
}

.preview-image-wrapper {
  position: relative;
  padding-bottom: 100%; /* 1:1 aspect ratio */
  overflow: hidden;
  border-radius: 10px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.preview-image-wrapper:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.preview-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.preview-image-wrapper:hover img {
  transform: scale(1.1);
}

/* More photos indicator */
.more-photos-indicator {
  position: absolute;
  bottom: 35px;
  right: 35px;
  background: var(--superman-red);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

/* Empty gallery state */
.gallery-preview-section.no-images {
  text-align: center;
  padding: 40px;
}

.empty-gallery-message {
  color: #999;
}

.empty-gallery-message svg {
  margin-bottom: 10px;
  display: block;
  opacity: 0.3;
  margin: 0 auto 10px auto;
}

.empty-gallery-message p {
  margin: 0;
  font-size: 1.1rem;
}

/* Gallery Title Link - Hide default title */
.gallery-item .views-field-title {
  display: none;
}

/* Gallery Name Styling - Card Header */
.gallery-item .views-field-field-gallery-name {
  background: linear-gradient(135deg, var(--superman-blue), var(--superman-blue-dark));
  padding: 30px 40px;
  margin: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-item .views-field-field-gallery-name::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 174, 17, 0.1) 0%, transparent 70%);
  transform: rotate(45deg);
}

.gallery-item .gallery-name,
.gallery-item h3.gallery-name {
  color: white !important;
  font-size: 1.8rem;
  margin: 0;
  font-weight: 600;
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Gallery Year Badge */
.gallery-item .gallery-year {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--superman-yellow);
  color: var(--superman-blue);
  padding: 8px 16px;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(255, 174, 17, 0.4);
  z-index: 10;
}

/* Gallery Link Button Container */
.gallery-item .views-field-nid {
  padding: 30px 40px;
  background: white;
  display: flex;
  justify-content: center;
}

/* Gallery Stats */
.gallery-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: white;
  border-top: 1px solid #f0f0f0;
}

.gallery-stat {
  text-align: center;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-stat .count {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--superman-red);
}

.gallery-stat .label {
  font-size: 0.875rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gallery-stat .count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--superman-red);
  display: block;
  line-height: 1;
}

.gallery-stat .label {
  font-size: 0.9rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 5px;
  display: block;
}

/* Gallery Actions */
.gallery-actions {
  padding: 20px;
  background: white;
  display: flex;
  justify-content: center;
  border-top: 1px solid #f0f0f0;
}

/* Gallery Link Button */
.gallery-link,
.gallery-link.btn,
.gallery-link.btn-primary {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 12px 24px;
  background: var(--superman-red) !important;
  color: white !important;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gallery-link::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.gallery-link:hover {
  background: linear-gradient(135deg, var(--superman-red-dark), var(--superman-red)) !important;
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(209, 57, 43, 0.4);
  text-decoration: none;
  color: white !important;
}

.gallery-link:hover::before {
  width: 300px;
  height: 300px;
}

/* Gallery Photos Single Row Layout - Force Override */
.view-maala-gallery-photos {
  margin-top: 30px;
}

/* Override the grid structure completely */
.view-maala-gallery-photos .views-view-grid {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 20px !important;
  padding-bottom: 20px !important;
  -webkit-overflow-scrolling: touch !important;
  margin-top: 20px !important;
  width: 100% !important;
}

/* Remove all row structure */
.view-maala-gallery-photos .views-view-grid .views-row {
  display: contents !important;
  width: auto !important;
  margin: 0 !important;
  clear: none !important;
}

/* Make all columns inline */
.view-maala-gallery-photos .views-view-grid .views-col {
  flex: 0 0 300px !important;
  max-width: 300px !important;
  width: 300px !important;
  float: none !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  clear: none !important;
}

/* Remove clearfix effects */
.view-maala-gallery-photos .clearfix::before,
.view-maala-gallery-photos .clearfix::after {
  display: none !important;
}

/* Style the scrollbar */
.view-maala-gallery-photos .views-view-grid::-webkit-scrollbar {
  height: 10px;
}

.view-maala-gallery-photos .views-view-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 5px;
}

.view-maala-gallery-photos .views-view-grid::-webkit-scrollbar-thumb {
  background: var(--superman-red);
  border-radius: 5px;
}

.view-maala-gallery-photos .views-view-grid::-webkit-scrollbar-thumb:hover {
  background: var(--superman-red-dark);
}

.view-maala-gallery-photos .gallery-photo-wrapper {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: #f8f8f8;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.view-maala-gallery-photos .gallery-photo-wrapper:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Square Thumbnails */
.gallery-photo-thumbnail {
  width: 100%;
  height: 300px;
  position: relative;
  overflow: hidden;
}

.gallery-photo-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-photo-wrapper:hover .gallery-photo-thumbnail img {
  transform: scale(1.1);
}

/* Photo Title */
.gallery-photo-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  color: white;
  padding: 15px;
  font-size: 0.95rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.gallery-photo-wrapper:hover .gallery-photo-title {
  transform: translateY(0);
}

/* Style the gallery title in view header */
.view-maala-gallery-photos header h2.gallery-title {
  color: var(--superman-red);
  font-size: 2rem;
  margin-bottom: 20px;
  font-weight: 600;
}

/* Colorbox Integration */
.view-maala-gallery-photos a.colorbox {
  display: block;
  text-decoration: none;
}

.view-maala-gallery-photos a.colorbox:hover {
  opacity: 0.9;
}

/* Enhance Colorbox overlay */
#cboxOverlay {
  background: rgba(0, 0, 0, 0.9) !important;
}

/* Style Colorbox content */
#colorbox {
  border-radius: 8px;
  overflow: hidden;
}

#cboxLoadedContent {
  background: #000;
}

/* Style Colorbox controls with Superman theme */
#cboxPrevious,
#cboxNext,
#cboxClose {
  background: var(--superman-red) !important;
  color: white !important;
  border: none !important;
  transition: all 0.3s ease;
}

#cboxPrevious:hover,
#cboxNext:hover,
#cboxClose:hover {
  background: var(--superman-red-dark) !important;
  transform: scale(1.1);
}

/* Style Colorbox title */
#cboxTitle {
  color: white !important;
  background: rgba(0, 0, 0, 0.8) !important;
  padding: 10px 15px !important;
  font-size: 1rem !important;
}

/* Style Colorbox current display */
#cboxCurrent {
  color: var(--superman-yellow) !important;
  font-weight: 600;
}

/* Hide slideshow controls by default */
#cboxSlideshow {
  display: none;
}

/* Body class when Colorbox is open */
body.colorbox-open {
  overflow: hidden;
}

/* Empty State for Galleries */
.view-empty {
  text-align: center;
  padding: 60px 20px;
}

.view-empty h3 {
  color: var(--superman-blue);
  font-size: 1.5rem;
  margin-bottom: 15px;
}

.view-empty p {
  color: #666;
  font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .gallery-item.views-row {
    width: 100%;
  }
  
  .view-maala-gallery-photos .views-view-grid .views-col {
    flex: 0 0 250px !important;
    max-width: 250px !important;
    width: 250px !important;
  }
  
  .gallery-photo-thumbnail {
    height: 250px;
  }
}

@media (max-width: 768px) {
  #block-superman-page-title h1 {
    font-size: 2.5rem;
  }
  
  .gallery-item.views-row {
    width: 100%;
    margin: 0 0 20px 0;
  }
  
  .gallery-preview-images {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .view-maala-gallery-photos .views-view-grid {
    gap: 15px !important;
  }
  
  .view-maala-gallery-photos .views-view-grid .views-col {
    flex: 0 0 200px !important;
    max-width: 200px !important;
    width: 200px !important;
  }
  
  .gallery-photo-thumbnail {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .views-element-container {
    padding: 20px 15px;
  }
  
  #block-superman-page-title h1 {
    font-size: 2rem;
    letter-spacing: 1px;
  }
  
  .gallery-item .views-field-field-gallery-name {
    padding: 20px;
  }
  
  .gallery-item .gallery-name {
    font-size: 1.5rem;
  }
  
  .view-maala-gallery-photos .views-view-grid {
    gap: 10px !important;
  }
  
  .view-maala-gallery-photos .views-view-grid .views-col {
    flex: 0 0 150px !important;
    max-width: 150px !important;
    width: 150px !important;
  }
  
  .gallery-photo-thumbnail {
    height: 150px;
  }
  
  .gallery-photo-title {
    font-size: 0.85rem;
    padding: 10px;
  }
}

/* Loading Animation */
.gallery-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.gallery-loading::after {
  content: '';
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--superman-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Multiple Upload Form */
.maala-photo-gallery-multiple-upload {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.maala-photo-gallery-multiple-upload .form-item {
  margin-bottom: 20px;
}

.maala-photo-gallery-multiple-upload .form-managed-file {
  border: 2px dashed #ddd;
  padding: 20px;
  border-radius: 5px;
  text-align: center;
  transition: border-color 0.3s ease;
}

.maala-photo-gallery-multiple-upload .form-managed-file:hover {
  border-color: var(--superman-red);
}

.maala-photo-gallery-multiple-upload .button--primary {
  background-color: var(--superman-red);
  border-color: var(--superman-red);
  font-size: 1.1rem;
  padding: 12px 30px;
}

.maala-photo-gallery-multiple-upload .button--primary:hover {
  background-color: var(--superman-red-dark);
  border-color: var(--superman-red-dark);
}

/* Responsive design for gallery cards */
@media (max-width: 1200px) {
  .view-maala-galleries .view-content,
  .view-id-maala_galleries .view-content {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 25px !important;
  }
}

@media (max-width: 768px) {
  .view-maala-galleries .view-content,
  .view-id-maala_galleries .view-content {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  
  .gallery-card-wrapper {
    margin-bottom: 0;
  }
  
  .gallery-header-section {
    padding: 15px;
  }
  
  .gallery-header-section .field--name-field-gallery-name {
    font-size: 1.25rem;
  }
  
  #block-superman-page-title h1 {
    font-size: 2rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .gallery-card-wrapper {
    background: #2a2a2a;
    color: #f0f0f0;
  }
  
  .gallery-preview-section {
    background: #1a1a1a;
  }
  
  .gallery-stats,
  .gallery-actions {
    background: #2a2a2a;
    border-top-color: #3a3a3a;
  }
}