/* ==========================================================================
   Ansasna Gallery Design System & Stylesheet
   Crafted with modern CSS variables, glassmorphism, responsive grid & fluid UX
   ========================================================================== */

:root {
  /* Dark Theme Palette (Deep Slate & Soft Ocean Blue) */
  --bg-primary: #07090e;
  --bg-secondary: #0e121b;
  --bg-card: rgba(18, 22, 34, 0.75);
  --bg-card-hover: rgba(26, 32, 48, 0.85);
  --bg-glass: rgba(14, 18, 27, 0.7);
  --bg-glass-active: rgba(28, 35, 54, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.35);
  --border-active: rgba(96, 165, 250, 0.6);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #2563eb;
  --accent-secondary: #3b82f6;
  --accent-tertiary: #60a5fa;
  --accent-gradient: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #60a5fa 100%);
  --accent-glow: rgba(37, 99, 235, 0.22);

  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning-color: #f59e0b;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 20px 40px -12px rgba(37, 99, 235, 0.25);
  --shadow-glow: 0 0 25px var(--accent-glow);
}

/* Light Theme Overrides */
body.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-glass-active: rgba(241, 245, 249, 0.9);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(59, 130, 246, 0.4);
  --border-active: rgba(59, 130, 246, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 20px 40px -12px rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-color: var(--bg-primary);
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Background Ambient Lighting */
.ambient-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(140px);
  opacity: 0.18;
  z-index: 0;
  transition: opacity var(--transition-slow);
}

.glow-top-left {
  top: -200px;
  left: -200px;
  background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
}

.glow-bottom-right {
  bottom: -200px;
  right: -200px;
  background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  user-select: none;
}

.brand-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}

.brand-icon {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.brand-highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Status Indicators */
.status-pill-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.status-icon {
  width: 13px;
  height: 13px;
  color: var(--accent-primary);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-smooth);
}

.btn-icon.spinning #refreshSvg {
  animation: spin 0.7s infinite linear;
}

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

/* Theme Toggle SVG Icon States */
body.theme-dark .theme-icon-dark { display: none; }
body.theme-dark .theme-icon-light { display: block; }
body.theme-light .theme-icon-dark { display: block; }
body.theme-light .theme-icon-light { display: none; }

/* ==========================================================================
   Main Layout & Hero Section
   ========================================================================== */

.main-content {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem 1.5rem;
}

.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0 3rem 0;
  gap: 1.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid var(--border-glow);
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-sparkle {
  color: var(--accent-secondary);
}

.hero-title {
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  background: linear-gradient(180deg, var(--text-primary) 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  max-width: 960px;
  text-wrap: balance;
}

.hero-description {
  font-size: clamp(0.95rem, 1.35vw, 1.05rem);
  color: var(--text-secondary);
  max-width: 960px;
  line-height: 1.6;
}

@media (min-width: 960px) {
  .hero-description {
    white-space: nowrap;
  }
}

/* Metrics Bar */
.metrics-bar {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.6rem 1.6rem;
  box-shadow: var(--shadow-card);
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.metric-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.metric-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-subtle);
}

/* ==========================================================================
   Toolbar: Search, Filters & Density
   ========================================================================== */

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.gallery-search-input {
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 2.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.gallery-search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-clear-btn {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

/* Category Filter Pills */
.category-filter-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 2px;
  max-width: 100%;
}

.category-filter-group::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  flex-shrink: 0;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  touch-action: pan-x;
  -webkit-tap-highlight-color: transparent;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  background: var(--bg-glass-active);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.filter-pill.active {
  background: var(--accent-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* Layout Density Controls */
.layout-toggle-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.layout-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.layout-toggle-btn svg {
  width: 16px;
  height: 16px;
}

.layout-toggle-btn.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Gallery Grid & Media Cards
   ========================================================================== */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.6rem;
  transition: gap var(--transition-smooth);
}

.gallery-grid.grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

/* Card Structure */
.media-card {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform var(--transition-smooth), border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.media-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-card-hover);
}

.media-thumbnail-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-secondary);
}

.grid-compact .media-thumbnail-box {
  aspect-ratio: 1 / 1;
}

.media-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow), filter var(--transition-smooth);
  opacity: 0;
}

.media-img.loaded {
  opacity: 1;
}

.media-card:hover .media-img {
  transform: scale(1.06);
}

/* Floating Card Badges */
.card-badge-top {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  right: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.badge-pill {
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(7, 9, 14, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: 0.03em;
}

.badge-resolution {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
}

/* Card Overlay on Hover */
.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 9, 14, 0.1) 0%, rgba(7, 9, 14, 0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.2rem;
  opacity: 0;
  transition: opacity var(--transition-smooth);
  z-index: 2;
}

.media-card:hover .media-overlay {
  opacity: 1;
}

.card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: #cbd5e1;
}

.card-quick-view {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent-primary);
  font-weight: 600;
  margin-top: 0.5rem;
  font-size: 0.78rem;
}

.card-quick-view svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Skeleton Loading Animation
   ========================================================================== */

.skeleton-grid .skeleton-card {
  height: 250px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.6s infinite ease-in-out;
  border: 1px solid var(--border-subtle);
}

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4rem 1.5rem;
  gap: 1rem;
}

.empty-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-icon-box svg {
  width: 32px;
  height: 32px;
}

.empty-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-detail {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 400px;
}

.btn-primary {
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  border: none;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* ==========================================================================
   Infinite Scroll & Loading Sentinel
   ========================================================================== */

.infinite-scroll-container {
  width: 100%;
  padding: 1.5rem 0 2.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.infinite-loader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.infinite-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: infiniteSpin 0.75s linear infinite;
}

@keyframes infiniteSpin {
  to {
    transform: rotate(360deg);
  }
}

.infinite-text {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.end-of-gallery {
  padding: 1rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sentinel-anchor {
  width: 100%;
  height: 20px;
  pointer-events: none;
}

/* ==========================================================================
   Modern Lightbox Modal (<dialog closedby="any">)
   Adhering to Modern Web Guidance
   ========================================================================== */

.lightbox-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  overflow: hidden;
  z-index: 1000;
  color: #f8fafc;
}

.lightbox-dialog::backdrop {
  background-color: rgba(4, 6, 12, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: opacity var(--transition-smooth);
}

.lightbox-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
  user-select: none;
}

/* Lightbox Header */
.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(4, 6, 12, 0.8) 0%, transparent 100%);
  z-index: 20;
  gap: 1rem;
}

.lightbox-info {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  overflow: hidden;
}

.lightbox-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-counter {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lightbox-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.lightbox-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}

.btn-close {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-close:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

.zoom-level-text {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Lightbox Stage (Center Canvas) */
.lightbox-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4rem 1rem;
}

.lightbox-img-box {
  position: relative;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-img.loaded {
  opacity: 1;
}

.lightbox-video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  background: #000;
  outline: none;
}

.lightbox-iframe {
  width: 85vw;
  height: 75vh;
  max-width: 1200px;
  max-height: 700px;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  background: #000;
}

.card-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(14, 18, 27, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-fast), background var(--transition-fast);
  pointer-events: none;
  z-index: 2;
}

.media-card:hover .card-play-badge {
  transform: translate(-50%, -50%) scale(1.15);
  background: var(--accent-gradient);
  border-color: transparent;
}

.card-play-badge svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

.badge-video {
  background: rgba(37, 99, 235, 0.85);
  border-color: rgba(59, 130, 246, 0.5);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Floating Navigation Arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: all var(--transition-fast);
}

.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-50%) scale(1.08);
  border-color: var(--accent-primary);
}

.nav-arrow svg {
  width: 26px;
  height: 26px;
}

.nav-prev { left: 1.5rem; }
.nav-next { right: 1.5rem; }

/* Lightbox Spinner */
.lightbox-spinner {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-primary);
  animation: spin 0.8s infinite linear;
  z-index: 5;
}

.lightbox-spinner.hidden {
  display: none;
}

/* Lightbox Footer */
.lightbox-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(0deg, rgba(4, 6, 12, 0.85) 0%, transparent 100%);
  z-index: 20;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.meta-tag-list {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.meta-tag {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #cbd5e1;
}

.lightbox-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Table / Detail List View
   ========================================================================== */

.gallery-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin-top: 0.5rem;
  transition: all var(--transition-smooth);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.gallery-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.gallery-table thead {
  background: rgba(14, 18, 27, 0.7);
  border-bottom: 1px solid var(--border-subtle);
}

.gallery-table th {
  padding: 0.9rem 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.gallery-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.gallery-table tbody tr:last-child {
  border-bottom: none;
}

.gallery-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

.gallery-table td {
  padding: 0.85rem 1.1rem;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.td-preview {
  width: 58px;
  padding-right: 0.2rem;
}

.table-thumb-box {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-fast);
}

tr:hover .table-thumb-img {
  transform: scale(1.1);
}

.table-play-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  background: rgba(37, 99, 235, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.table-play-icon svg {
  width: 9px;
  height: 9px;
  margin-left: 1px;
}

.table-file-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.table-file-title {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-badge-cat {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.75rem;
  font-weight: 500;
}

.table-badge-type {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.table-action-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.table-action-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.table-action-btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Lightbox Slide-over Metadata & Location Sidebar (Right to Left)
   ========================================================================== */

.lightbox-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: rgba(10, 14, 23, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
  user-select: text;
}

.lightbox-sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-secondary);
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.meta-data-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.meta-data-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
  gap: 0.8rem;
}

.meta-data-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.meta-val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.sidebar-map-box {
  margin-top: 0.85rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.sidebar-map-frame {
  width: 100%;
  height: 180px;
  border: none;
  display: block;
  background: #0f172a;
}

.sidebar-map-link {
  display: block;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  color: var(--accent-secondary);
  font-size: 0.72rem;
  text-align: center;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar-map-link:hover {
  background: rgba(37, 99, 235, 0.2);
  color: #ffffff;
}

/* Toggle Info Button Active State in Lightbox */
.lightbox-btn.info-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ==========================================================================
   Responsive Adaptations (Mobile & Tablet)
   ========================================================================== */

@media (max-width: 768px) {
  .header-container {
    padding: 0.75rem 1rem;
    gap: 0.8rem;
  }

  .status-pill-group {
    display: none; /* Conserve navbar real estate on small phones */
  }

  .main-content {
    padding: 1.2rem 1rem 4rem 1rem;
  }

  .hero-section {
    margin: 0.8rem 0 2rem 0;
    gap: 1rem;
  }

  .metrics-bar {
    padding: 0.5rem 1.2rem;
    gap: 1rem;
  }

  .gallery-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "search layout"
      "filters filters";
    align-items: center;
    padding: 0.65rem 0.75rem;
    gap: 0.65rem 0.5rem;
    overflow: hidden;
  }

  .search-input-wrapper {
    grid-area: search;
    min-width: 0;
    width: 100%;
    flex: unset;
  }

  .gallery-search-input {
    padding: 0.52rem 1.8rem 0.52rem 2.2rem;
    font-size: 0.84rem;
  }

  .search-icon {
    left: 0.75rem;
    width: 15px;
    height: 15px;
  }

  .layout-toggle-group {
    grid-area: layout;
    align-self: center;
    padding: 2px;
    gap: 2px;
    margin: 0;
  }

  .layout-toggle-btn {
    width: 30px;
    height: 30px;
  }

  .layout-toggle-btn svg {
    width: 15px;
    height: 15px;
  }

  .category-filter-group {
    grid-area: filters;
    width: 100%;
    order: unset;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.15rem 0.1rem 0.3rem 0.1rem;
    margin: 0;
  }

  .category-filter-group::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    flex-shrink: 0;
    padding: 0.38rem 0.82rem;
    font-size: 0.78rem;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .lightbox-sidebar {
    width: 100%;
    max-width: 100%;
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
  }

  .nav-arrow svg {
    width: 20px;
    height: 20px;
  }

  .nav-prev { left: 0.5rem; }
  .nav-next { right: 0.5rem; }

  .lightbox-shortcuts {
    display: none;
  }

  .lightbox-header {
    padding: 0.75rem 1rem;
  }

  .lightbox-footer {
    padding: 0.75rem 1rem;
  }

  #btnZoomOut, #btnZoomIn, #btnZoomReset {
    display: none; /* Simplify lightbox header on mobile */
  }
}
