/* Gallery Slider Frontend Styles */

/* Reset all margins and padding for gallery elements */
.gallery-slider-container,
.gallery-slider-container *,
.gallery-slider-container *::before,
.gallery-slider-container *::after {
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: top !important;
    line-height: 1 !important;
}

/* Exception for caption overlay - restore padding */
.gallery-caption-overlay {
    padding: 20px !important;
}

/* Exception for navigation controls - restore margin */
.gallery-controls {
    margin: 20px 0 0 0 !important;
    padding: 0 !important;
}

.gallery-slider-container {
    position: relative;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible;
    background: transparent;
    touch-action: pan-y;
    user-select: none;
    display: block;
    box-sizing: border-box !important;
    line-height: 0 !important;
    font-size: 0 !important;
    margin: 0 auto !important;
}

/* Custom height support */
.gallery-slider-container[data-height="100vh"] {
    height: 100vh;
}

/* Max width support - ensure inline styles take precedence */
.gallery-slider-container[data-max-width] {
    box-sizing: border-box;
}

.gallery-slider-viewport {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    box-sizing: border-box;
    line-height: 0;
    font-size: 0;
}

/* Left preview area */
.gallery-zone-left {
    flex: 0 0 25%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* Center main image area */
.gallery-zone-center {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* Right preview area */
.gallery-zone-right {
    flex: 0 0 25%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* Show zones when they have content */
.gallery-zone-left.active,
.gallery-zone-center.active,
.gallery-zone-right.active {
    visibility: visible;
}

/* Shuffle animation states */
.gallery-zone-left.shuffle-in,
.gallery-zone-center.shuffle-in,
.gallery-zone-right.shuffle-in {
    animation: shuffleIn 0.6s ease-out forwards;
}

@keyframes shuffleIn {
    0% {
        transform: translateY(-30px);
    }
    100% {
        transform: translateY(0);
    }
}

.slide-image {
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    vertical-align: bottom;
    line-height: 0;
}

/* Main center image - 50% of container width */
.gallery-zone-center .slide-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    transform: scale(1);
}

/* Side images - proportional to main image */
.gallery-zone-left .slide-image,
.gallery-zone-right .slide-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    opacity: 0.8;
}

/* Navigation controls beneath gallery */
.gallery-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    font-size: 14px;
    line-height: normal;
}

.gallery-control-btn {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    position: relative;
}

.gallery-control-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.gallery-control-btn:active {
    transform: scale(0.95);
}

.gallery-control-btn svg {
    width: 12px;
    height: 12px;
    color: #333;
    stroke-width: 2.5;
}

/* Tooltip styles */
.gallery-tooltip {
    position: absolute !important;
    background: white !important;
    color: #333 !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    pointer-events: none !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* Tooltip arrow/caret pointing down */
.gallery-tooltip::after {
    content: '' !important;
    position: absolute !important;
    top: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border: 6px solid transparent !important;
    border-top-color: white !important;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1)) !important;
}

/* Slide indicators */
.gallery-indicators {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 10;
}

.gallery-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-indicator:hover {
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
}

.gallery-indicator.active {
    background: white;
    border-color: white;
    transform: scale(1.3);
}

/* Slide counter - hidden */
.gallery-counter {
    display: none;
}

.slide-separator {
    margin: 0 4px;
    opacity: 0.7;
}

/* Loading indicator */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-loading.visible {
    opacity: 1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Hover overlay for captions */
.gallery-zone-left,
.gallery-zone-center,
.gallery-zone-right {
    position: relative;
}

/* Image wrapper to contain the overlay */
.image-overlay-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    vertical-align: top;
}

.gallery-zone-center .slide-image {
    transition: all 0.3s ease;
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    vertical-align: top;
}

.image-overlay-wrapper:hover .slide-image {
    opacity: 0.9;
}

.gallery-caption-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 10;
    border-radius: 4px;
}

.image-overlay-wrapper:hover .gallery-caption-overlay {
    opacity: 1;
    transform: translateY(0);
}

.overlay-title {
    margin: 0 0 4px 0;
    padding-bottom: 4px !important;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.overlay-description {
    margin: 0;
    font-size: 14px;
    color: #555;
    line-height: 1.4 !important;
}

/* Responsive overlay styles */
@media (max-width: 768px) {
    .gallery-caption-overlay {
        padding: 30px 15px 15px 15px;
    }
    
    .overlay-title {
        font-size: 18px;
        margin-bottom: 6px;
    }
    
    .overlay-description {
        font-size: 13px;
    }
}

/* Touch/swipe states */
.gallery-slider-container.dragging {
    cursor: grabbing;
}

.gallery-slider-container.dragging .gallery-slide {
    transition: none;
}

/* Mobile responsive design */
@media (max-width: 768px) {
    .gallery-slider-viewport {
        gap: 0;
        flex-direction: column;
        align-items: center;
    }
    
    /* Hide side zones on mobile - show only center image */
    .gallery-zone-left,
    .gallery-zone-right {
        display: none !important;
    }
    
    /* Center zone takes full width on mobile */
    .gallery-zone-center {
        flex: 1;
        width: 100%;
        max-width: 100%;
    }
    
    /* Center image takes full width on mobile */
    .gallery-zone-center .slide-image {
        width: 100%;
        max-width: 100%;
        height: auto;
    }
    
    /* Ensure controls are visible and properly spaced on mobile */
    .gallery-controls {
        margin: 15px 0 0 0 !important;
        gap: 15px;
    }
    
    /* Make control buttons slightly larger on mobile */
    .gallery-control-btn {
        width: 40px;
        height: 40px;
    }
    
    .gallery-control-btn svg {
        width: 16px;
        height: 16px;
    }
}
    
    .gallery-nav {
        width: 50px;
        height: 50px;
    }
    
    .gallery-nav-prev {
        left: 20px;
    }
    
    .gallery-nav-next {
        right: 20px;
    }
    
    .gallery-nav svg {
        width: 20px;
        height: 20px;
    }
    
    .gallery-counter {
        top: 20px;
        right: 20px;
        font-size: 14px;
        padding: 6px 12px;
    }
    
    .gallery-indicators {
        bottom: 20px;
        gap: 8px;
    }
    
    .gallery-indicator {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .gallery-nav {
        width: 44px;
        height: 44px;
    }
    
    .gallery-nav-prev {
        left: 15px;
    }
    
    .gallery-nav-next {
        right: 15px;
    }
    
    .gallery-nav svg {
        width: 18px;
        height: 18px;
    }
    
    .gallery-counter {
        top: 15px;
        right: 15px;
        font-size: 13px;
    }
    
    .gallery-indicators {
        bottom: 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .gallery-slider-track,
    .gallery-slide,
    .gallery-nav,
    .gallery-indicator {
        transition: none;
    }
}

/* Focus states for keyboard navigation */
.gallery-nav:focus,
.gallery-indicator:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gallery-nav {
        background: rgba(0, 0, 0, 0.8);
        border-color: white;
    }
    
    .gallery-indicator {
        border-color: white;
        background: black;
    }
    
    .gallery-indicator.active {
        background: white;
    }
}