/**
 * Gallery Page Styles
 * Enhanced UI with tooltips and modern design
 */

/* Tooltip System */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background-color: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.875rem;
  line-height: 1.4;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Tooltip positioning variants */
[data-tooltip-pos="top"]::before {
  bottom: calc(100% + 8px);
  top: auto;
}

[data-tooltip-pos="bottom"]::before {
  top: calc(100% + 8px);
  bottom: auto;
}

[data-tooltip-pos="bottom"]::after {
  top: calc(100% + 2px);
  bottom: auto;
  border-top-color: transparent;
  border-bottom-color: rgba(0, 0, 0, 0.9);
}

[data-tooltip-pos="left"]::before {
  right: calc(100% + 8px);
  left: auto;
  transform: translateY(-50%);
  top: 50%;
  bottom: auto;
}

[data-tooltip-pos="left"]::after {
  right: calc(100% + 2px);
  left: auto;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  border-top-color: transparent;
  border-left-color: rgba(0, 0, 0, 0.9);
}

[data-tooltip-pos="right"]::before {
  left: calc(100% + 8px);
  transform: translateY(-50%);
  top: 50%;
  bottom: auto;
}

[data-tooltip-pos="right"]::after {
  left: calc(100% + 2px);
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  border-top-color: transparent;
  border-right-color: rgba(0, 0, 0, 0.9);
}

/* Enhanced Header with Gradient */
.gallery-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.gallery-header h1 {
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-header p {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.125rem;
}

/* Enhanced Cards */
.gallery-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Image Zoom Effect */
.gallery-card img {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-card:hover img {
  transform: scale(1.08);
}

/* Button Enhancements */
.btn-enhanced {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

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

.btn-enhanced:hover::before {
  width: 300px;
  height: 300px;
}

/* Filter Pills */
.filter-pill {
  position: relative;
  transition: all 0.2s ease;
}

.filter-pill.active {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Loading Skeleton */
.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;
  }
}

/* Enhanced Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.empty-state-icon svg {
  width: 64px;
  height: 64px;
  color: white;
}

/* AI Badge */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* View Mode Toggle */
.view-toggle {
  display: flex;
  background: white;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.view-toggle button {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle button.active {
  background: #3b82f6;
  color: white;
}

/* Search Bar Enhancement */
.search-wrapper {
  position: relative;
}

.search-wrapper input {
  transition: all 0.3s ease;
}

.search-wrapper input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

/* Tag Pills */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.1);
  color: #1e40af;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tag-pill:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: scale(1.05);
}

/* Lightbox Enhancements */
.lightbox-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 1rem;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* Lightbox Image Sizing - Fit within viewport */
.lightbox-media-container {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 70vh;
  max-width: 90vw;
  margin: 0 auto;
}

.lightbox-media-container img,
.lightbox-media-container video {
  max-height: 70vh;
  max-width: 90vw;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Back to Gallery button */
.back-to-gallery-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.back-to-gallery-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* Lightbox header bar */
.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
}

/* EXIF metadata grid */
.exif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.exif-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.75rem;
  border-radius: 8px;
}

/* Stats Badge */
.stats-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stats-badge-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
}

.stats-badge-label {
  font-size: 0.875rem;
  color: #6b7280;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .gallery-header {
    padding: 1.5rem;
  }

  .gallery-header h1 {
    font-size: 1.875rem;
  }

  [data-tooltip]::before {
    white-space: normal;
    max-width: 200px;
  }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus states */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Smooth transitions */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Drag and Drop Styles */
.gallery-card[draggable="true"] {
  cursor: grab;
  position: relative;
}

.gallery-card[draggable="true"]:active {
  cursor: grabbing;
}

.gallery-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Album drop target */
.album-drop-target {
  transition: all 0.2s ease;
  position: relative;
}

.album-drop-target.drag-over {
  transform: scale(1.05);
  border-color: #8b5cf6 !important;
  border-width: 2px;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2), 0 8px 25px rgba(139, 92, 246, 0.3);
}

.album-drop-target.drag-over::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(139, 92, 246, 0.1);
  border-radius: inherit;
  pointer-events: none;
  z-index: 10;
}

/* Drag hint when dragging */
.gallery-card[draggable="true"]:not(.dragging):hover::after {
  content: 'Drag to album';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

/* Show hint on hover when albums exist */
body:has(.album-drop-target) .gallery-card[draggable="true"]:not(.dragging):hover::after {
  opacity: 1;
}
