/**
 * QR Gallery Styles - Compatible avec Elementor Hello Theme
 * Brique 5 - Intégration Elementor + Téléchargements
 */

/* ========================================
   Container Principal
   ======================================== */
.qr-gallery-container {
  max-width: 100%;
  margin: 0 auto;
}

/* ========================================
   Header & Meta
   ======================================== */
.qr-gallery-header {
  margin-bottom: 1.5rem;
}

.qr-gallery-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: #333;
}

.qr-gallery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  color: #666;
}

.qr-gallery-count,
.qr-gallery-expiration {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.qr-gallery-expiration.expired {
  color: #dc3545;
  font-weight: 600;
}

.qr-gallery-expiration.expiring-soon {
  color: #ff9800;
  font-weight: 600;
}

/* ========================================
   Grid Layout
   ======================================== */
.qr-gallery-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

/* Colonnes responsives */
.qr-gallery-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.qr-gallery-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.qr-gallery-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Responsive - Tablette */
@media (max-width: 1024px) {
  .qr-gallery-cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .qr-gallery-cols-3,
  .qr-gallery-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .qr-gallery-grid {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .qr-gallery-cols-2,
  .qr-gallery-cols-3,
  .qr-gallery-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Gallery Item (Figure)
   ======================================== */
.qr-gallery-item {
  margin: 0;
  position: relative;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.qr-gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Image Wrapper & Image
   ======================================== */
.qr-gallery-image-wrapper {
  position: relative; /* Force position relative for stacking context */
  width: 100%;
  padding-top: 75%; /* Aspect ratio 4:3 */
  overflow: hidden; /* Prevent image overflow */
  background: #f5f5f5;
}

.qr-gallery-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  cursor: zoom-in; /* Indicate image is clickable for lightbox */
}

.qr-gallery-item:hover .qr-gallery-image {
  transform: scale(1.05);
}

/* ========================================
   Lightbox Link
   ======================================== */
.qr-lightbox {
  position: absolute; /* Cover entire image wrapper */
  inset: 0; /* Shorthand for top, right, bottom, left: 0 */
  display: block;
  z-index: 1; /* Place above image but below overlay */
  cursor: pointer;
}

.qr-lightbox img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ========================================
   Download Overlay
   ======================================== */
.qr-gallery-overlay {
  position: absolute;
  inset: 0; /* Shorthand for top, right, bottom, left: 0 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 55%, rgba(0,0,0,0.35) 100%); /* Subtle gradient */
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2; /* Place above lightbox link */
  pointer-events: none; /* Allow clicks to pass through to lightbox link */
}

/* Show overlay on hover or focus */
.qr-gallery-image-wrapper:hover .qr-gallery-overlay,
.qr-gallery-image-wrapper:focus-within .qr-gallery-overlay {
  opacity: 1;
}

.qr-gallery-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #4CAF50;
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.3s ease, transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: auto; /* Button should be clickable */
}

.qr-gallery-download-btn:hover {
  background: #45a049;
  transform: scale(1.05);
}

.qr-gallery-download-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ========================================
   Caption
   ======================================== */
.qr-gallery-caption {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #666;
  text-align: center;
  background: #fff;
}

.pc-caption {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

/* ========================================
   Download Button (Mobile/Desktop)
   ======================================== */
.pc-dl {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  text-decoration: none;
  background: #fff;
  color: #333 !important;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.pc-dl:hover {
  background: #f5f5f5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pc-dl .pc-ico {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Desktop styles (> 768px): button below thumbnail, caption visible */
@media (min-width: 769px) {
  .qr-gallery-item {
    position: relative;
  }

  .pc-caption {
    display: block;
  }

  .pc-dl {
    position: static;
    margin-top: 0.5rem;
  }
}

/* Mobile styles (≤ 768px): overlay button, hide caption */
@media (max-width: 768px) {
  .qr-gallery-item {
    position: relative;
  }

  .pc-caption {
    display: none !important;
  }

  .pc-dl {
    position: absolute !important;
    right: 0.5rem !important;
    bottom: 0.5rem !important;
    z-index: 3 !important; /* Above overlay */
    margin-top: 0 !important;
  }
}

/* ========================================
   WebP Variants & Responsive Images
   ======================================== */
.pc-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc-placeholder {
  background: #f0f0f0;
  opacity: 0.6;
}

.qr-gallery-filesize {
  display: block;
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.25rem;
}

/* ========================================
   Actions (Download All)
   ======================================== */
.qr-gallery-actions {
  text-align: center;
  padding: 2rem 0;
  border-top: 1px solid #e0e0e0;
  margin-top: 1rem;
}

.qr-gallery-download-all {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  background: #2196F3;
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1.1rem;
  transition: background 0.3s ease, transform 0.2s ease;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.qr-gallery-download-all:hover {
  background: #1976D2;
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.qr-gallery-download-all svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.qr-gallery-zip-size {
  display: inline-block;
  margin-left: 0.5rem;
  font-weight: 400;
  opacity: 0.9;
  font-size: 0.95rem;
}

/* ========================================
   États vides
   ======================================== */
.qr-gallery-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #999;
}

.qr-gallery-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.3;
}

/* ========================================
   Compatibilité Elementor
   ======================================== */

/* Reset des marges Elementor si nécessaire */
.elementor-widget-shortcode .qr-gallery-container {
  margin-top: 0;
}

/* Support du mode sombre Elementor (si activé) */
@media (prefers-color-scheme: dark) {
  .qr-gallery-container {
    color: #e0e0e0;
  }

  .qr-gallery-title {
    color: #fff;
  }

  .qr-gallery-item {
    background: #2a2a2a;
  }

  .qr-gallery-caption {
    background: #2a2a2a;
    color: #ccc;
  }
}

/* ========================================
   Loading state (optionnel)
   ======================================== */
.qr-gallery-loading {
  text-align: center;
  padding: 3rem;
  color: #999;
}

.qr-gallery-loading::after {
  content: '...';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}
