/* ================================================================
   Smart Gallery Widget – Frontend CSS
   All rules are scoped under .sgw-* to avoid conflicts
   ================================================================ */

/* ── CSS Variables (overridable via PHP inline style) ── */
:root {
  --sgw-primary:   #F26A21;
  --sgw-secondary: #F4B400;
  --sgw-accent:    #2E7D32;
  --sgw-danger:    #E53935;
  --sgw-dark:      #222222;
  --sgw-bg:        #FAFAFA;
  --sgw-card-bg:   #FFFFFF;
  --sgw-border:    #E5E0D8;
  --sgw-text:      #666666;
  --sgw-overlay:   #000000;
  --sgw-gap:       16px;
  --sgw-radius:    12px;
}

/* ── Wrapper ── */
.sgw-gallery-wrap {
  width: 100% !important;
  position: relative !important;
  font-family: 'Figtree', 'Segoe UI', sans-serif !important;
}

/* ── Grid ── */
.sgw-grid {
  display: grid !important;
  gap: var(--sgw-gap) !important;
  width: 100% !important;
}

.sgw-cols-2 { grid-template-columns: repeat(2, 1fr) !important; }
.sgw-cols-3 { grid-template-columns: repeat(3, 1fr) !important; }
.sgw-cols-4 { grid-template-columns: repeat(4, 1fr) !important; }
.sgw-cols-5 { grid-template-columns: repeat(5, 1fr) !important; }
.sgw-cols-6 { grid-template-columns: repeat(6, 1fr) !important; }

@media (max-width: 900px) {
  .sgw-cols-4, .sgw-cols-5, .sgw-cols-6 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (max-width: 600px) {
  .sgw-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 380px) {
  .sgw-grid { grid-template-columns: 1fr !important; }
}

/* ── Grid Item ── */
.sgw-item {
  position: relative !important;
  overflow: hidden !important;
  border-radius: var(--sgw-radius) !important;
  aspect-ratio: 1 / 1 !important;
  background: var(--sgw-border) !important;
}

.sgw-item-btn {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: none !important;
  cursor: pointer !important;
  position: relative !important;
  overflow: hidden !important;
}

.sgw-item-btn picture,
.sgw-item-btn img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  border-radius: 0 !important;
}

/* ── Hover: Zoom ── */
.sgw-hover-zoom .sgw-item-btn:hover img {
  transform: scale(1.08) !important;
}

/* ── Hover: Fade overlay ── */
.sgw-hover-fade .sgw-item-overlay {
  opacity: 0 !important;
  transition: opacity 0.35s ease !important;
}
.sgw-hover-fade .sgw-item-btn:hover .sgw-item-overlay {
  opacity: 1 !important;
}

/* ── Hover: Slide up caption ── */
.sgw-hover-slide .sgw-item-caption {
  transform: translateY(100%) !important;
  transition: transform 0.35s ease !important;
}
.sgw-hover-slide .sgw-item-btn:hover .sgw-item-caption {
  transform: translateY(0) !important;
}

/* ── Overlay ── */
.sgw-item-overlay {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0,0,0,0.35) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
}

.sgw-item-btn:hover .sgw-item-overlay { opacity: 1 !important; }

.sgw-zoom-icon {
  width: 40px !important;
  height: 40px !important;
  color: #ffffff !important;
  stroke: #ffffff !important;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4)) !important;
}

/* ── Caption ── */
.sgw-item-caption {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: linear-gradient(transparent, rgba(0,0,0,0.75)) !important;
  padding: 28px 14px 12px !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
  text-align: left !important;
}

/* ── See All Button ── */
.sgw-see-all-wrap {
  display: flex !important;
  justify-content: center !important;
  margin-top: 28px !important;
}

.sgw-see-all-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  background: var(--sgw-primary) !important;
  color: #ffffff !important;
  font-family: 'Poppins', 'Segoe UI', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  padding: 12px 32px !important;
  border-radius: 100px !important;
  border: none !important;
  cursor: pointer !important;
  transition: transform 0.25s ease, box-shadow 0.25s ease !important;
  text-decoration: none !important;
  line-height: 1 !important;
}

.sgw-see-all-btn:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 14px 32px rgba(242, 106, 33, 0.38) !important;
  color: #ffffff !important;
}

.sgw-see-all-count {
  font-size: 12px !important;
  opacity: 0.8 !important;
  font-weight: 400 !important;
}

.sgw-error {
  color: #E53935 !important;
  font-size: 14px !important;
  padding: 12px !important;
  border: 1px solid #fcc !important;
  border-radius: 6px !important;
  background: #fff5f5 !important;
}

/* ================================================================
   LIGHTBOX
   ================================================================ */
.sgw-lightbox-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  background: rgba(0, 0, 0, 0.92) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
  backdrop-filter: blur(4px) !important;
}

.sgw-lightbox-backdrop.sgw-lb-open {
  opacity: 1 !important;
}

.sgw-lightbox-inner {
  position: relative !important;
  max-width: 92vw !important;
  max-height: 92vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Image wrapper handles transitions */
.sgw-lb-img-wrap {
  position: relative !important;
  max-width: 88vw !important;
  max-height: 85vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: opacity 0.25s ease !important;
}

.sgw-lb-img-wrap.sgw-transitioning {
  opacity: 0 !important;
}

.sgw-lb-img-wrap picture,
.sgw-lb-img-wrap img {
  max-width: 88vw !important;
  max-height: 82vh !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  display: block !important;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6) !important;
}

/* Caption in lightbox */
.sgw-lb-caption {
  position: absolute !important;
  bottom: -40px !important;
  left: 0 !important;
  right: 0 !important;
  text-align: center !important;
  color: rgba(255,255,255,0.75) !important;
  font-size: 14px !important;
  font-family: 'Figtree', sans-serif !important;
}

/* Counter */
.sgw-lb-counter {
  position: fixed !important;
  top: 20px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  color: rgba(255,255,255,0.55) !important;
  font-size: 13px !important;
  font-family: 'Poppins', sans-serif !important;
  letter-spacing: 0.08em !important;
  z-index: 1000001 !important;
}

/* Close button */
.sgw-lb-close {
  position: fixed !important;
  top: 18px !important;
  right: 22px !important;
  z-index: 1000001 !important;
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  border-radius: 50% !important;
  width: 44px !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  color: #ffffff !important;
  transition: background 0.2s ease !important;
}
.sgw-lb-close:hover { background: rgba(255,255,255,0.25) !important; }

/* Arrow buttons */
.sgw-lb-arrow {
  position: fixed !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 1000001 !important;
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 50% !important;
  width: 52px !important;
  height: 52px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  color: #ffffff !important;
  transition: background 0.2s ease, transform 0.2s ease !important;
  backdrop-filter: blur(8px) !important;
}

.sgw-lb-arrow:hover {
  background: var(--sgw-primary) !important;
  border-color: var(--sgw-primary) !important;
}

.sgw-lb-prev {
  left: 16px !important;
}
.sgw-lb-prev:hover { transform: translateY(-50%) scale(1.08) translateX(-2px) !important; }

.sgw-lb-next {
  right: 16px !important;
}
.sgw-lb-next:hover { transform: translateY(-50%) scale(1.08) translateX(2px) !important; }

/* Thumbnail strip */
.sgw-lb-thumbs {
  position: fixed !important;
  bottom: 16px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  display: flex !important;
  gap: 6px !important;
  z-index: 1000001 !important;
  max-width: 90vw !important;
  overflow-x: auto !important;
  padding: 6px !important;
  background: rgba(0,0,0,0.4) !important;
  border-radius: 12px !important;
}

.sgw-lb-thumb {
  width: 48px !important;
  height: 48px !important;
  border-radius: 7px !important;
  object-fit: cover !important;
  cursor: pointer !important;
  opacity: 0.5 !important;
  transition: opacity 0.2s, transform 0.2s !important;
  flex-shrink: 0 !important;
  border: 2px solid transparent !important;
}

.sgw-lb-thumb:hover,
.sgw-lb-thumb.sgw-lb-thumb-active {
  opacity: 1 !important;
  transform: scale(1.1) !important;
  border-color: var(--sgw-primary) !important;
}

/* Loading spinner */
.sgw-lb-spinner {
  position: absolute !important;
  width: 40px !important;
  height: 40px !important;
  border: 3px solid rgba(255,255,255,0.2) !important;
  border-top-color: var(--sgw-primary) !important;
  border-radius: 50% !important;
  animation: sgw-spin 0.7s linear infinite !important;
}

@keyframes sgw-spin {
  to { transform: rotate(360deg); }
}

/* Touch swipe hint */
.sgw-lb-swipe-hint {
  position: fixed !important;
  bottom: 80px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  color: rgba(255,255,255,0.35) !important;
  font-size: 12px !important;
  font-family: 'Figtree', sans-serif !important;
  pointer-events: none !important;
}

/* ── Gallery item entrance animation ── */
.sgw-item {
  animation: sgw-fadeIn 0.5s ease forwards !important;
}

@keyframes sgw-fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* ================================================================
   WIDGET HEADER — Heading + Description
   ================================================================ */
.sgw-widget-header {
  text-align: center !important;
  margin-bottom: 28px !important;
}

.sgw-widget-heading {
  font-family: 'Poppins', 'Segoe UI', sans-serif !important;
  font-size: clamp(24px, 4vw, 36px) !important;
  font-weight: 700 !important;
  color: var(--sgw-dark) !important;
  margin: 0 0 10px 0 !important;
  line-height: 1.2 !important;
  letter-spacing: -0.02em !important;
}

/* Gallery page uses h1, homepage uses h2 – share same style */
.sgw-page-widget .sgw-widget-heading {
  font-size: clamp(28px, 5vw, 42px) !important;
}

.sgw-widget-description {
  font-family: 'Figtree', 'Segoe UI', sans-serif !important;
  font-size: 16px !important;
  color: var(--sgw-text) !important;
  margin: 0 auto 6px !important;
  max-width: 560px !important;
  line-height: 1.6 !important;
}

.sgw-widget-count {
  font-family: 'Figtree', 'Segoe UI', sans-serif !important;
  font-size: 13px !important;
  color: var(--sgw-text) !important;
  opacity: 0.65 !important;
  margin: 4px 0 0 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
}

/* "See All" as a link (homepage widget) */
a.sgw-see-all-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  background: var(--sgw-primary) !important;
  color: #ffffff !important;
  font-family: 'Poppins', 'Segoe UI', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  padding: 12px 32px !important;
  border-radius: 100px !important;
  border: none !important;
  cursor: pointer !important;
  transition: transform 0.25s ease, box-shadow 0.25s ease !important;
  text-decoration: none !important;
  line-height: 1 !important;
}

a.sgw-see-all-btn:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 14px 32px rgba(242, 106, 33, 0.38) !important;
  color: #ffffff !important;
  text-decoration: none !important;
}
