/**
 * Google Drive Photo Gallery Styles
 * 
 * Features:
 * - Responsive masonry grid layout
 * - Smooth hover effects and transitions
 * - Accessible lightbox with keyboard navigation
 * - Loading states and error handling
 * - Mobile-first responsive design
 * 
 * To customize:
 * - Adjust --gallery-columns variables for different layouts
 * - Modify --gallery-gap for spacing
 * - Change --gallery-border-radius for corner rounding
 * - Update color variables to match your theme
 */

/* ===== CSS VARIABLES ===== */
:root {
  /* Gallery Layout */
  --gallery-columns-mobile: 2;
  --gallery-columns-tablet: 3;
  --gallery-columns-desktop: 4;
  --gallery-gap: 1rem;
  --gallery-border-radius: 12px;
  
  /* Gallery Colors */
  --gallery-bg: var(--bg-secondary, #262626);
  --gallery-item-bg: var(--bg-primary, #1F1F1F);
  --gallery-border: rgba(246, 182, 207, 0.2);
  --gallery-hover-border: var(--accent-pink, #F6B6CF);
  --gallery-text: var(--text-primary, #F3F3F3);
  --gallery-text-secondary: var(--text-secondary, #CFCFCF);
  
  /* Lightbox Colors */
  --lightbox-bg: rgba(0, 0, 0, 0.95);
  --lightbox-text: #FFFFFF;
  --lightbox-button-bg: rgba(255, 255, 255, 0.1);
  --lightbox-button-hover: rgba(255, 255, 255, 0.2);
  
  /* Transitions */
  --gallery-transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --gallery-transition-fast: all 0.2s ease;
}

/* ===== GALLERY CONTAINER ===== */
.drive-gallery-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===== MOBILE SWIPEABLE GALLERY ===== */
.drive-gallery-container {
  position: relative;
  overflow: hidden;
}

.drive-gallery-swipe-container {
  display: flex;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 100%;
}

.drive-gallery-swipe-page {
  flex: 0 0 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gallery-gap);
  padding: 0 1rem;
  min-height: 400px;
}

/* ===== DESKTOP GRID LAYOUT ===== */
@media (min-width: 768px) {
  .drive-gallery-swipe-container {
    display: block;
  }
  
  .drive-gallery-swipe-page {
    display: grid;
    grid-template-columns: repeat(var(--gallery-columns-tablet), 1fr);
    flex: none;
    padding: 0;
  }
}

@media (min-width: 1024px) {
  .drive-gallery-swipe-page {
    grid-template-columns: repeat(var(--gallery-columns-desktop), 1fr);
  }
}

/* ===== MOBILE PAGINATION INDICATORS ===== */
.drive-gallery-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
  padding: 0 1rem;
}

.drive-gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(246, 182, 207, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.drive-gallery-dot.active {
  background: var(--gallery-hover-border);
  transform: scale(1.2);
}

.drive-gallery-dot:hover {
  background: var(--gallery-hover-border);
  transform: scale(1.1);
}

/* Hide pagination on desktop */
@media (min-width: 768px) {
  .drive-gallery-pagination {
    display: none;
  }
}

/* ===== MOBILE NAVIGATION ARROWS ===== */
.drive-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s ease;
  z-index: 10;
}

.drive-gallery-nav:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-50%) scale(1.1);
}

.drive-gallery-nav.prev {
  left: 10px;
}

.drive-gallery-nav.next {
  right: 10px;
}

.drive-gallery-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: translateY(-50%);
}

.drive-gallery-nav:disabled:hover {
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
}

/* Hide navigation arrows on desktop */
@media (min-width: 768px) {
  .drive-gallery-nav {
    display: none;
  }
}

/* ===== GALLERY ITEMS ===== */
.drive-gallery-item {
  position: relative;
  background: var(--gallery-item-bg);
  border: 2px solid var(--gallery-border);
  border-radius: var(--gallery-border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--gallery-transition);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  will-change: transform, box-shadow;
  backface-visibility: hidden;
}

.drive-gallery-item:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--gallery-hover-border);
  box-shadow: 
    0 20px 40px rgba(246, 182, 207, 0.3),
    0 0 0 1px var(--gallery-hover-border);
  z-index: 10;
}

.drive-gallery-item:focus {
  outline: 3px solid var(--gallery-hover-border);
  outline-offset: 2px;
}

.drive-gallery-item:focus:not(:focus-visible) {
  outline: none;
}

/* ===== GALLERY IMAGES ===== */
.drive-gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--gallery-transition);
  border-radius: calc(var(--gallery-border-radius) - 2px);
  opacity: 0.9;
}

.drive-gallery-image.loaded {
  opacity: 1;
}

.drive-gallery-item:hover .drive-gallery-image {
  transform: scale(1.05);
  opacity: 1;
}

/* ===== LOADING STATES ===== */
.drive-gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--gallery-text-secondary);
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(246, 182, 207, 0.3);
  border-top: 3px solid var(--accent-pink, #F6B6CF);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.drive-gallery-loading p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

/* ===== ERROR STATE ===== */
.drive-gallery-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.2);
  border-radius: var(--gallery-border-radius);
  margin: 2rem 0;
}

.drive-gallery-error p {
  margin: 0 0 1rem 0;
  color: #E57373;
  font-size: 1rem;
}

.drive-gallery-error .btn {
  margin-top: 0.5rem;
}

/* ===== LOAD MORE BUTTON ===== */
.drive-gallery-load-more {
  display: none;
  text-align: center;
  margin: 2rem 0;
}

.drive-gallery-load-more .btn {
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50px;
  transition: var(--gallery-transition);
}

.drive-gallery-load-more .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(247, 213, 106, 0.3);
}

/* ===== EMPTY STATE ===== */
.drive-gallery-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--gallery-text-secondary);
  background: var(--gallery-item-bg);
  border: 2px dashed var(--gallery-border);
  border-radius: var(--gallery-border-radius);
}

.drive-gallery-empty p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ===== LIGHTBOX ===== */
.drive-lightbox {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 999999 !important;
  background: rgba(0, 0, 0, 0.8) !important;
  align-items: center !important;
  justify-content: center !important;
}

.drive-lightbox[style*="display: none"],
.drive-lightbox[style*="display:none"] {
  display: none !important;
}

.drive-lightbox[style*="display: flex"],
.drive-lightbox[style*="display:flex"],
.drive-lightbox[style*="display: block"] {
  display: flex !important;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.lightbox-container {
  position: relative;
  z-index: 1000000;
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.lightbox-caption {
  margin-top: 20px;
  color: #333;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

/* ===== LIGHTBOX BUTTONS ===== */
.lightbox-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: #f0f0f0;
  border: none;
  color: #333;
  cursor: pointer;
  width: 36px;
  height: 36px;
  font-size: 24px;
  font-weight: bold;
  z-index: 1000001;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: #e0e0e0;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  cursor: pointer;
  width: 48px;
  height: 48px;
  font-size: 24px;
  font-weight: bold;
  z-index: 1000001;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-prev {
  left: -60px;
}

.lightbox-next {
  right: -60px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .drive-gallery-container {
    padding: 0 0.5rem;
  }
  
  .drive-gallery-swipe-page {
    gap: 0.75rem;
    padding: 0 0.5rem;
  }
  
  .drive-gallery-item {
    min-height: 150px;
    aspect-ratio: 1;
  }
  
  /* Improve touch targets */
  .drive-gallery-nav {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  
  .drive-gallery-dot {
    width: 10px;
    height: 10px;
  }
  
  .lightbox-container {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .lightbox-image {
    max-height: 70vh;
  }
  
  .lightbox-close {
    top: -2.5rem;
    right: -0.5rem;
    width: 40px;
    height: 40px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 48px;
    height: 48px;
  }
  
  .lightbox-prev {
    left: -2rem;
  }
  
  .lightbox-next {
    right: -2rem;
  }
  
  .lightbox-caption {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    max-width: 90%;
  }
  
  .lightbox-counter {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .drive-gallery-swipe-page {
    gap: 0.5rem;
    padding: 0 0.25rem;
  }
  
  .drive-gallery-item {
    min-height: 120px;
  }
  
  .drive-gallery-nav {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  .drive-gallery-dot {
    width: 8px;
    height: 8px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    display: none; /* Hide navigation arrows on very small screens */
  }
  
  .lightbox-caption {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .drive-gallery-item,
  .drive-gallery-image,
  .lightbox-image,
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    transition: none;
  }
  
  .loading-spinner {
    animation: none;
  }
}

/* Focus management for keyboard navigation */
.drive-gallery-item:focus-visible {
  outline: 3px solid var(--gallery-hover-border);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .drive-gallery-item {
    border-width: 3px;
  }
  
  .drive-gallery-item:hover {
    border-color: #FFFFFF;
  }
  
  .lightbox-caption {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #FFFFFF;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .drive-lightbox,
  .drive-gallery-loading,
  .drive-gallery-error,
  .drive-gallery-load-more {
    display: none !important;
  }
  
  .drive-gallery-grid {
    display: block;
  }
  
  .drive-gallery-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    border: 1px solid #000;
  }
}

/* ===== CUSTOM SCROLLBAR ===== */
.drive-gallery-container::-webkit-scrollbar {
  width: 8px;
}

.drive-gallery-container::-webkit-scrollbar-track {
  background: var(--gallery-bg);
}

.drive-gallery-container::-webkit-scrollbar-thumb {
  background: var(--gallery-hover-border);
  border-radius: 4px;
}

.drive-gallery-container::-webkit-scrollbar-thumb:hover {
  background: rgba(246, 182, 207, 0.8);
}
