@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables for Design System */
:root {
  /* Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #8b5cf6;
  --secondary: #06b6d4;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  --scrollbarBG: var(--background);
  --thumbBG: var(--surface-light);
  scrollbar-color: var(--thumbBG) var(--scrollbarBG);
  scrollbar-width: thin;
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--background) 0%, #1a202c 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  padding-bottom: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Main content wrapper to push footer down */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 0;
}

/* Scrollbar Styles */
html::-webkit-scrollbar {
  width: 8px;
}

html::-webkit-scrollbar-track {
  background: var(--background);
}

html::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 4px;
  border: 2px solid var(--background);
}

html::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h1 { font-size: clamp(2.5rem, 5vw, 3.75rem); font-weight: 700; }
h2 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.5rem, 3vw, 1.875rem); }

/* Navbar Styles */
.navbar {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all var(--transition-normal);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

.navbar-brand:hover {
  text-decoration: none;
  opacity: 0.9;
}

.navbar-nav .nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  margin: 0 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
}

.navbar-nav .nav-link:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.navbar-nav .nav-link.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.15);
}

.navbar-toggler {
  border: none;
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-md);
  padding: 0.5rem;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28203, 213, 225, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Welcome Section */
.welcome-message {
  margin: 2rem 0 3rem 0;
  text-align: center;
  position: relative;
  padding: 0 1rem;
}

.welcome-message h1 {
  margin-bottom: 1rem;
  animation: fadeInUp 0.8s ease-out;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-message p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto 0.8rem auto;
  animation: fadeInUp 0.8s ease-out 0.2s both;
  line-height: 1.5;
}

.welcome-message .text-muted {
  color: var(--text-muted) !important;
  font-style: italic;
  animation: fadeInUp 0.8s ease-out 0.4s both;
  margin-bottom: 0;
}

/* Image Gallery - Responsive grid with consistent sizing */
.image-gallery-container {
  margin: 2rem 0 3rem 0;
  flex: 1;
}

#imageGallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 0 2rem;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 400px;
  position: relative;
  z-index: 1;
}

/* Large Desktop Screens (27"+ monitors) */
@media (min-width: 1920px) {
  #imageGallery {
    grid-template-columns: repeat(6, minmax(280px, 1fr));
    max-width: 1800px;
    gap: 2.5rem;
  }
}

/* Desktop Screens (24-27" monitors) */
@media (min-width: 1400px) and (max-width: 1919px) {
  #imageGallery {
    grid-template-columns: repeat(3, minmax(400px, 1fr));
    max-width: 1400px;
    gap: 2rem;
  }
}

/* Medium Desktop Screens */
@media (min-width: 1200px) and (max-width: 1399px) {
  #imageGallery {
    grid-template-columns: repeat(3, minmax(350px, 1fr));
    max-width: 1200px;
    gap: 1.5rem;
    padding: 0 1.5rem;
  }
  
  .pagination-container {
    margin: 0 1.5rem;
    padding: 1.5rem;
  }
}

/* Small Desktop/Large Tablet */
@media (min-width: 992px) and (max-width: 1199px) {
  #imageGallery {
    grid-template-columns: repeat(2, minmax(400px, 1fr));
    gap: 1.5rem;
    padding: 0 1.5rem;
    max-width: 1000px;
  }
}

/* Tablet Screens */
@media (min-width: 769px) and (max-width: 991px) {
  #imageGallery {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 1.25rem;
    padding: 0 1rem;
  }
}

.image-gallery-item {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(51, 65, 85, 0.3);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  opacity: 0;
  animation: fadeInUp 0.8s ease-out forwards;
  position: relative;
  z-index: 1;
  /* Force exact same dimensions */
  width: 100%;
  height: auto;
  /* Force consistent aspect ratio - no variation allowed */
  aspect-ratio: 1 / 1.2;
  display: flex;
  flex-direction: column;
  /* Prevent any size variation */
  flex-shrink: 0;
  flex-grow: 0;
}

.image-gallery-item:hover {
  transform: translateY(-8px);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: var(--shadow-xl);
  z-index: 2;
}

.image-wrapper {
  width: 100%;
  /* Fixed proportion of container - never varies */
  height: calc(100% - 80px); /* Subtract fixed button height */
  overflow: hidden;
  position: relative;
  background: rgba(30, 41, 59, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  /* Prevent any flex growth */
  flex-shrink: 0;
  flex-grow: 0;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.5s ease, transform 0.4s ease;
  opacity: 0;
  /* Ensure no size variations */
  display: block;
}

.thumbnail.loaded {
  opacity: 1;
}

.image-wrapper:hover .thumbnail.loaded {
  transform: scale(1.08);
}

.btn-container {
  /* Fixed height - never changes */
  height: 80px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Prevent any flex changes */
  flex-shrink: 0;
  flex-grow: 0;
}

.btn-view-image {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  width: 100%;
  justify-content: center;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  /* Fixed height for button */
  height: 48px;
}

/* No Images Container */
.no-images-container {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

/* Pagination Styles */
.pagination-wrapper {
  grid-column: 1 / -1;
  margin-top: 4rem;
  position: relative;
  z-index: 10;
}

.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(51, 65, 85, 0.3);
  border-radius: var(--radius-xl);
  margin: 0 2rem;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.pagination-nav .pagination {
  display: flex;
  list-style: none;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
}

.page-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  transition: all var(--transition-normal);
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 48px;
  min-height: 48px;
  justify-content: center;
  /* Fix text cutoff */
  line-height: 1.2;
  text-align: center;
}

.page-link:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.page-item.disabled .page-link {
  background: rgba(30, 41, 59, 0.3);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: rgba(51, 65, 85, 0.2);
}

.page-item.disabled .page-link:hover {
  background: rgba(30, 41, 59, 0.3);
  color: var(--text-muted);
  transform: none;
  box-shadow: none;
}

/* Copyright Page */
.copyright-content {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(51, 65, 85, 0.3);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  margin: 1.5rem 0;
  line-height: 1.8;
}

.copyright-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.copyright-content p:last-child {
  margin-bottom: 0;
}

/* Footer */
.footer {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(51, 65, 85, 0.3);
  position: relative;
  width: 100%;
  padding: 1.75rem 0;
  margin-top: auto;
  z-index: 10;
}

.footer .container {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 400;
}

.footer p {
  margin: 0;
  color: var(--text-secondary);
}

/* Error Pages */
.error-page .stats-card {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.error-page .stats-icon {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  margin: 0 auto 1.5rem auto;
}

.error-page h1 {
  font-size: clamp(2rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
}

.error-page .btn-container {
  margin-top: 2rem;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading {
  /* Remove pulse animation */
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 1400px) {
  .image-gallery-item {
    width: 260px;
  }
  
  #imageGallery {
    gap: 1.1rem;
  }
}

@media (max-width: 1200px) {
  #imageGallery {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    padding: 0 1.5rem;
  }
  
  .image-wrapper {
    height: 280px;
  }
  
  .pagination-container {
    margin: 0 1.5rem;
    padding: 1.5rem;
  }
}

@media (max-width: 992px) {
  .image-gallery-item {
    width: 220px;
  }
  
  #imageGallery {
    gap: 0.9rem;
  }
}

/* Tablet Screens */
@media (max-width: 991px) {
  #imageGallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    padding: 0 1rem;
  }
  
  .image-wrapper {
    height: 240px;
  }
}

/* Mobile Tablets */
@media (max-width: 768px) {
  .main-content {
    padding-top: 0.5rem;
  }
  
  .welcome-message {
    margin: 1.5rem 0 2rem 0;
    padding: 0 1rem;
  }
  
  .welcome-message h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    margin-bottom: 0.75rem;
    line-height: 1.2;
  }
  
  .welcome-message p {
    font-size: clamp(0.9rem, 2.5vw, 1.125rem);
    margin: 0 auto 0.75rem auto;
    line-height: 1.5;
  }
  
  #imageGallery {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 1rem;
    padding: 0 1rem;
    margin-bottom: 1rem;
  }
  
  .image-gallery-item {
    /* Force exact same size on mobile */
    aspect-ratio: 1 / 1.15;
    width: 100%;
    height: auto;
  }
  
  .image-wrapper {
    height: calc(100% - 70px); /* Subtract mobile button height */
  }
  
  .btn-container {
    height: 70px;
    padding: 0.75rem 1rem;
  }
  
  .btn-view-image {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    height: 44px;
  }
  
  .pagination-container {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    margin: 0 1rem;
    padding: 1.25rem;
  }
  
  .pagination-nav .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
  }
  
  .page-link {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.1;
  }
}

/* Mobile Phones */
@media (max-width: 576px) {
  .container,
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .welcome-message {
    margin: 1rem 0 1.5rem 0;
    padding: 0 0.5rem;
  }
  
  .welcome-message h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.1;
  }
  
  .welcome-message p {
    font-size: clamp(0.85rem, 3vw, 1rem);
    line-height: 1.4;
  }
  
  #imageGallery {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0.75rem;
    max-width: none;
  }
  
  .image-gallery-item {
    /* Single column - exact same size */
    aspect-ratio: 1 / 1.1;
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
    height: auto;
  }
  
  .image-wrapper {
    height: calc(100% - 75px); /* Subtract mobile button height */
  }
  
  .btn-container {
    height: 75px;
    padding: 1rem 1.25rem;
  }
  
  .btn-view-image {
    height: 48px;
  }
  
  .pagination-container {
    margin: 0 0.5rem;
    padding: 1rem;
  }
  
  .pagination-nav .pagination {
    gap: 0.25rem;
  }
  
  .page-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
  }
}

/* Very Small Screens */
@media (max-width: 480px) {
  .navbar-brand {
    font-size: 1.125rem;
  }
  
  .welcome-message {
    padding: 0 0.25rem;
  }
  
  #imageGallery {
    padding: 0 0.5rem;
    gap: 0.75rem;
  }
  
  .image-gallery-item {
    aspect-ratio: 1 / 1.05;
    width: 100%;
    height: auto;
  }
  
  .image-wrapper {
    height: calc(100% - 65px);
  }
  
  .btn-container {
    height: 65px;
    padding: 0.75rem 1rem;
  }
  
  .btn-view-image {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    height: 40px;
  }
  
  .pagination-container {
    margin: 0 0.25rem;
    padding: 0.75rem;
  }
}

/* Landscape Mobile Orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .welcome-message {
    margin: 1rem 0 1.5rem 0;
  }
  
  .welcome-message h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.5rem;
  }
  
  .welcome-message p {
    font-size: clamp(0.875rem, 2vw, 1rem);
    margin-bottom: 0.5rem;
  }
  
  #imageGallery {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.875rem;
  }
  
  .image-gallery-item {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
  }
}

/* Enhanced Touch Targets for Mobile */
@media (max-width: 768px) {
  .page-link,
  .btn-view-image,
  .navbar-toggler,
  .theme-btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }
  
  .navbar-nav .nav-link {
    min-height: 44px;
    touch-action: manipulation;
  }
}

/* Focus States for Accessibility */
.page-link:focus,
.btn-view-image:focus,
.navbar-nav .nav-link:focus,
.navbar-toggler:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Prevent Horizontal Scroll */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.container-fluid,
#imageGallery,
.pagination-container {
  max-width: 100%;
  overflow-x: hidden;
}

/* Optimize Image Loading Animation */
.thumbnail.loading {
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.4) 25%, rgba(30, 41, 59, 0.6) 50%, rgba(30, 41, 59, 0.4) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Improve Button States */
.btn-view-image:active,
.page-link:active {
  transform: translateY(1px);
}

/* Fix Footer Spacing */
.footer {
  margin-top: 2rem;
  padding: 1.5rem 0;
}

@media (max-width: 768px) {
  .footer {
    margin-top: 1.5rem;
    padding: 1.25rem 0;
  }
  
  .footer .container {
    padding: 0 1rem;
  }
  
  .footer p {
    font-size: 0.8rem;
    line-height: 1.4;
  }
}
