/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f8f9fa;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 20px;
}

.logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

.logo a {
  text-decoration: none;
  color: #2563eb;
}

.nav {
  display: flex;
  gap: 30px;
}

.nav-link {
  text-decoration: none;
  color: #64748b;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: #2563eb;
}

.search-container {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 50px;
  padding: 8px 20px;
  min-width: 300px;
  flex: 1;
  max-width: 500px;
}

.search-container input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: #333;
}

.search-container input::placeholder {
  color: #94a3b8;
}

.search-container button {
  border: none;
  background: transparent;
  color: #2563eb;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 10px;
}

/* Main content */
.main {
  padding: 2rem 0;
  min-height: calc(100vh - 200px);
}

.main h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: #1e293b;
}

/* Masonry Layout */
.masonry-container,
.masonry-grid,
#imageGrid {
  column-count: 4;
  column-gap: 16px;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.masonry-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.masonry-item:hover img {
  transform: scale(1.05);
}

.masonry-item .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
  padding: 20px 15px 15px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.masonry-item:hover .overlay {
  transform: translateY(0);
}

.masonry-item .title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masonry-item .author {
  font-size: 12px;
  opacity: 0.9;
}

.masonry-item .likes {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  display: flex;
  align-items: center;
  gap: 4px;
}

.masonry-item .likes .heart {
  color: #ef4444;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 4rem 2rem;
  color: #64748b;
  font-size: 18px;
  grid-column: 1 / -1;
}

/* Footer */
.footer {
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 2rem 0;
  margin-top: 4rem;
}

.footer p {
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

.skeleton-item {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 12px;
  background: #f8f9fa;
}

.skeleton-item .skeleton-image {
  width: 100%;
  height: 200px;
  border-radius: 12px;
}

.skeleton-item .skeleton-text {
  height: 16px;
  margin: 12px;
  border-radius: 4px;
  width: 80%;
}

.skeleton-item .skeleton-text.small {
  height: 12px;
  width: 60%;
  margin-top: 8px;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .masonry-container,
  .masonry-grid,
  #imageGrid {
    column-count: 3;
  }

  .header-content {
    flex-wrap: wrap;
  }

  .search-container {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .masonry-container,
  .masonry-grid,
  #imageGrid {
    column-count: 2;
    column-gap: 12px;
  }

  .masonry-item {
    margin-bottom: 12px;
  }

  .header-content {
    gap: 10px;
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .nav {
    gap: 20px;
  }

  .search-container {
    min-width: 200px;
  }

  .container {
    padding: 0 15px;
  }

  .main {
    padding: 1.5rem 0;
  }

  .main h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 480px) {
  .masonry-container,
  .masonry-grid,
  #imageGrid {
    column-count: 1;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .search-container {
    order: 2;
    margin-top: 10px;
  }

  .logo {
    text-align: center;
    order: 1;
  }

  .nav {
    order: 3;
    justify-content: center;
    margin-top: 10px;
  }
}

/* Fix pre tag white-space */
pre {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}

/* Tags for image detail page */
.tags {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  margin-bottom: 32px !important;
  padding: 4px !important;
}

/* Tag styles */
.tag {
  display: inline-flex !important;
  align-items: center !important;
  padding: 10px 20px !important;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
  color: #475569 !important;
  text-decoration: none !important;
  border-radius: 25px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border: 2px solid transparent !important;
  background-image:
    linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important,
    linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%) !important;
  background-origin: border-box !important;
  background-clip: content-box, border-box !important;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset !important;
  position: relative !important;
  overflow: hidden !important;
}

.tag:hover {
  background-image:
    linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%) !important,
    linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  transform: translateY(-3px) scale(1.05) !important;
  box-shadow:
    0 8px 25px rgba(99, 102, 241, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset !important;
  color: #4f46e5 !important;
}

.tag-icon {
  display: inline-block !important;
  font-size: 18px !important;
  margin-right: 8px !important;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  font-weight: 700 !important;
}

.tag-text {
  position: relative !important;
  z-index: 1 !important;
  letter-spacing: 0.025em !important;
}

/* Utility classes */
.text-center {
  text-align: center;
}

.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.p-2 { padding: 2rem; }

.hidden {
  display: none;
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Image placeholder for loading state */
.image-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 12px;
  opacity: 1;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.image-placeholder svg {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.loading-text {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 32px;
  font-weight: 500;
}

.error-text {
  font-size: 12px;
  color: #dc2626;
  margin-top: 8px;
  font-weight: 500;
}

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


.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.footer-nav {
    display: flex;
    gap: 20px;
}

.footer-nav a {
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-nav a:hover {
    color: #2563eb;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
}