/* ===== GALLERY THEME VARIABLES ===== */
:root {
  /* Light Theme - Gallery Colors */
  --gallery-bg: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  --gallery-card-bg: #ffffff;
  --gallery-title-color: #2c4964;
  --gallery-text-color: #6c757d;
  --gallery-border: #e9ecef;
  --gallery-shadow: rgba(0, 0, 0, 0.1);
  --gallery-shadow-hover: rgba(0, 0, 0, 0.15);
  --gallery-badge-bg: rgba(255, 255, 255, 0.95);
  --gallery-badge-text: #2c4964;
  --gallery-divider: #ddd;
}

/* Dark Theme - Gallery Colors */
@media (prefers-color-scheme: dark) {
  :root {
    --gallery-bg: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    --gallery-card-bg: #2d3748;
    --gallery-title-color: #f8f9fa;
    --gallery-text-color: #cbd5e1;
    --gallery-border: #4a5568;
    --gallery-shadow: rgba(0, 0, 0, 0.3);
    --gallery-shadow-hover: rgba(0, 0, 0, 0.5);
    --gallery-badge-bg: rgba(45, 55, 72, 0.95);
    --gallery-badge-text: #f8f9fa;
    --gallery-divider: #4a5568;
  }
}

/* Manual Dark Theme Override */
[data-theme="dark"] {
  --gallery-bg: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
  --gallery-card-bg: #2d3748;
  --gallery-title-color: #f8f9fa;
  --gallery-text-color: #cbd5e1;
  --gallery-border: #4a5568;
  --gallery-shadow: rgba(0, 0, 0, 0.3);
  --gallery-shadow-hover: rgba(0, 0, 0, 0.5);
  --gallery-badge-bg: rgba(45, 55, 72, 0.95);
  --gallery-badge-text: #f8f9fa;
  --gallery-divider: #4a5568;
}

/* Manual Light Theme Override */
[data-theme="light"] {
  --gallery-bg: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  --gallery-card-bg: #ffffff;
  --gallery-title-color: #2c4964;
  --gallery-text-color: #6c757d;
  --gallery-border: #e9ecef;
  --gallery-shadow: rgba(0, 0, 0, 0.1);
  --gallery-shadow-hover: rgba(0, 0, 0, 0.15);
  --gallery-badge-bg: rgba(255, 255, 255, 0.95);
  --gallery-badge-text: #2c4964;
  --gallery-divider: #ddd;
}

/* ===== GALLERY SECTION STYLES ===== */
.gallery {
  padding: 80px 0;
  background: var(--gallery-bg);
  overflow: hidden;
  transition: background 0.3s ease;
}

.gallery .section-title {
  text-align: center;
  padding-bottom: 40px;
}

.gallery .section-title h2 {
  font-size: 32px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 20px;
  padding-bottom: 20px;
  position: relative;
  color: var(--gallery-title-color);
  transition: color 0.3s ease;
}

.gallery .section-title h2::before {
  content: "";
  position: absolute;
  display: block;
  width: 120px;
  height: 1px;
  background: var(--gallery-divider);
  bottom: 1px;
  left: calc(50% - 60px);
  transition: background 0.3s ease;
}

.gallery .section-title h2::after {
  content: "";
  position: absolute;
  display: block;
  width: 40px;
  height: 3px;
  background: #0d6efd;
  bottom: 0;
  left: calc(50% - 20px);
}

.gallery .section-title p {
  margin-bottom: 0;
  font-size: 18px;
  color: var(--gallery-text-color);
  max-width: 600px;
  margin: 0 auto;
  transition: color 0.3s ease;
}

/* ===== GALLERY CARD STYLES ===== */
.gallery-box {
  min-width: 320px;
  background: var(--gallery-card-bg);
  border-radius: 15px;
  padding: 0;
  text-align: center;
  box-shadow: 0 10px 30px var(--gallery-shadow);
  transition: all 0.3s ease;
  border: 1px solid var(--gallery-border);
  position: relative;
  overflow: hidden;
  height: 380px;
  display: flex;
  flex-direction: column;
}

.gallery-box:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px var(--gallery-shadow-hover);
}

.gallery-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #0d6efd, #17a2b8);
  z-index: 2;
}

/* ===== GALLERY IMAGE ===== */
.gallery-image {
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: var(--gallery-border);
}

.gallery-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.3s ease;
}

.gallery-box:hover .gallery-image img {
  transform: scale(1.1);
  filter: brightness(1.1);
}

/* Dark mode image adjustments */
@media (prefers-color-scheme: dark) {
  .gallery-image img {
    opacity: 0.95;
  }
  
  .gallery-box:hover .gallery-image img {
    opacity: 1;
    filter: brightness(1.15) contrast(1.05);
  }
}

[data-theme="dark"] .gallery-image img {
  opacity: 0.95;
}

[data-theme="dark"] .gallery-box:hover .gallery-image img {
  opacity: 1;
  filter: brightness(1.15) contrast(1.05);
}

/* ===== GALLERY CONTENT ===== */
.gallery-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--gallery-card-bg);
  transition: background 0.3s ease;
}

.gallery-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gallery-title-color);
  margin-bottom: 10px;
  position: relative;
  padding-bottom: 15px;
  transition: color 0.3s ease;
}

.gallery-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  background: #0d6efd;
}

.gallery-category {
  color: var(--gallery-text-color);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 5px;
  transition: color 0.3s ease;
}

/* ===== CATEGORY BADGE ===== */
.gallery-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--gallery-badge-bg);
  color: var(--gallery-badge-text);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 3;
  box-shadow: 0 2px 10px var(--gallery-shadow);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

/* ===== COLOR VARIANTS FOR CATEGORIES ===== */
.gallery-box.export::before {
  background: linear-gradient(90deg, #17a2b8, #20c997);
}

.gallery-box.facility::before {
  background: linear-gradient(90deg, #fd7e14, #ffc107);
}

.gallery-box.team::before {
  background: linear-gradient(90deg, #20c997, #198754);
}

.gallery-box.event::before {
  background: linear-gradient(90deg, #dc3545, #e83e8c);
}

.gallery-box.achievement::before {
  background: linear-gradient(90deg, #6610f2, #6f42c1);
}

/* Dark mode - Enhanced gradient visibility */
@media (prefers-color-scheme: dark) {
  .gallery-box.export::before {
    background: linear-gradient(90deg, #17a2b8, #20c997);
    opacity: 0.9;
  }

  .gallery-box.facility::before {
    background: linear-gradient(90deg, #fd7e14, #ffc107);
    opacity: 0.9;
  }

  .gallery-box.team::before {
    background: linear-gradient(90deg, #20c997, #198754);
    opacity: 0.9;
  }

  .gallery-box.event::before {
    background: linear-gradient(90deg, #dc3545, #e83e8c);
    opacity: 0.9;
  }

  .gallery-box.achievement::before {
    background: linear-gradient(90deg, #6610f2, #6f42c1);
    opacity: 0.9;
  }
}

/* ===== GALLERY ANIMATION ===== */
#gallery-container {
  display: flex;
  gap: 30px;
  padding: 0 40px;
  min-width: max-content;
  animation: scroll 35s linear infinite;
}

#gallery-container:hover {
  animation-play-state: paused;
}

@keyframes scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ===== LOADING STATE ===== */
.gallery-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  color: var(--gallery-text-color);
  font-size: 18px;
  transition: color 0.3s ease;
}

.gallery-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid var(--gallery-border);
  border-top: 4px solid #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== EMPTY STATE ===== */
.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gallery-text-color);
  transition: color 0.3s ease;
}

.gallery-empty i {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
  color: var(--gallery-text-color);
  transition: all 0.3s ease;
}

.gallery-empty h3 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--gallery-title-color);
  transition: color 0.3s ease;
}

.gallery-empty p {
  font-size: 16px;
  color: var(--gallery-text-color);
  transition: color 0.3s ease;
}

/* ===== HOVER EFFECTS ===== */
.gallery-box:hover {
  border-color: #0d6efd;
}

.gallery-box:hover .gallery-title {
  color: #0d6efd;
}

.gallery-box:hover .gallery-badge {
  transform: scale(1.05);
}

/* Dark mode hover adjustments */
@media (prefers-color-scheme: dark) {
  .gallery-box:hover {
    background: #374151;
    border-color: #0d6efd;
  }
  
  .gallery-box:hover .gallery-content {
    background: #374151;
  }
}

[data-theme="dark"] .gallery-box:hover {
  background: #374151;
  border-color: #0d6efd;
}

[data-theme="dark"] .gallery-box:hover .gallery-content {
  background: #374151;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .gallery {
    padding: 60px 0;
  }

  #gallery-container {
    padding: 0 20px;
    gap: 20px;
  }

  .gallery-box {
    min-width: 280px;
    height: 350px;
  }

  .gallery-image {
    height: 220px;
  }

  .gallery .section-title h2 {
    font-size: 28px;
  }

  .gallery .section-title p {
    font-size: 16px;
    padding: 0 15px;
  }

  .gallery-content {
    padding: 15px;
  }

  .gallery-title {
    font-size: 16px;
  }

  .gallery-category {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .gallery {
    padding: 40px 0;
  }

  #gallery-container {
    padding: 0 15px;
    gap: 15px;
  }

  .gallery-box {
    min-width: 250px;
    height: 320px;
  }

  .gallery-image {
    height: 200px;
  }

  .gallery .section-title h2 {
    font-size: 24px;
    padding-bottom: 15px;
  }

  .gallery .section-title p {
    font-size: 14px;
  }

  .gallery-content {
    padding: 12px;
  }

  .gallery-title {
    font-size: 15px;
    margin-bottom: 8px;
  }

  .gallery-category {
    font-size: 11px;
  }

  .gallery-badge {
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    font-size: 10px;
  }
}

/* ===== ACCESSIBILITY ===== */
.gallery-box:focus-within {
  outline: 2px solid #0d6efd;
  outline-offset: 4px;
}

.gallery-box:focus-within .gallery-title {
  color: #0d6efd;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #gallery-container {
    animation: none;
  }
  
  .gallery-box:hover {
    transform: none;
  }
  
  .gallery-box:hover .gallery-image img {
    transform: none;
  }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
  .gallery-box {
    border: 2px solid currentColor;
  }
  
  .gallery-badge {
    border: 1px solid currentColor;
  }
  
  .gallery-title::after {
    background: currentColor;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .gallery {
    background: white;
    padding: 40px 0;
  }
  
  #gallery-container {
    animation: none;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .gallery-box {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
  
  .gallery-badge {
    background: white;
    border: 1px solid #ddd;
  }
}

/* ===== ADDITIONAL ANIMATIONS ===== */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.gallery-box {
  animation: fadeInScale 0.5s ease-out;
}

.gallery-box:nth-child(1) { animation-delay: 0.1s; }
.gallery-box:nth-child(2) { animation-delay: 0.2s; }
.gallery-box:nth-child(3) { animation-delay: 0.3s; }
.gallery-box:nth-child(4) { animation-delay: 0.4s; }
.gallery-box:nth-child(5) { animation-delay: 0.5s; }

/* ===== IMAGE OVERLAY EFFECT ===== */
.gallery-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-box:hover .gallery-image::after {
  opacity: 1;
}

/* Dark mode overlay adjustment */
@media (prefers-color-scheme: dark) {
  .gallery-image::after {
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.5) 100%);
  }
}

[data-theme="dark"] .gallery-image::after {
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.5) 100%);
}

/* ===== SMOOTH SCROLLING FOR GALLERY ===== */
.gallery-wrapper {
  overflow: hidden;
  position: relative;
}

.gallery-wrapper::before,
.gallery-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100px;
  z-index: 10;
  pointer-events: none;
}

.gallery-wrapper::before {
  left: 0;
  background: linear-gradient(90deg, var(--gallery-bg) 0%, transparent 100%);
}

.gallery-wrapper::after {
  right: 0;
  background: linear-gradient(270deg, var(--gallery-bg) 0%, transparent 100%);
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
  .gallery-box:active {
    transform: scale(0.98);
  }
  
  #gallery-container {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  
  .gallery-box {
    scroll-snap-align: center;
  }
}

/* ===== GRADIENT SHIMMER EFFECT (Optional) ===== */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.gallery-box.loading {
  background: linear-gradient(
    90deg,
    var(--gallery-card-bg) 0%,
    var(--gallery-border) 50%,
    var(--gallery-card-bg) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* ===== FOCUS INDICATORS ===== */
.gallery-box a:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
  border-radius: 3px;
}

/* ===== THEME TRANSITION ===== */
.gallery,
.gallery-box,
.gallery-content,
.gallery-title,
.gallery-category,
.gallery-badge {
  transition: all 0.3s ease;
}