/**
 * Rental Listing Image Carousel Styles
 * Enhanced image gallery with swipe support and upgrade prompts
 */

/* Base Gallery Styles */
.property-image-gallery {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    cursor: grab;
    touch-action: pan-y;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.property-image-gallery:active {
    cursor: grabbing;
}

.property-image-gallery:focus {
    outline: 2px solid #5598E9;
    outline-offset: 2px;
}

/* Image Items */
.image-item {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.image-item.active {
    display: block;
    opacity: 1;
    position: relative;
}

.image-item img,
.image-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 12px 12px 0 0;
    transition: transform 0.3s ease;
}

.property-image-gallery:hover .image-item img,
.property-image-gallery:hover .image-item video {
    transform: scale(1.02);
}

/* Navigation Dots */
.image-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.property-image-gallery:not(:hover) .image-dots {
    opacity: 0.8;
}

.property-image-gallery:hover .image-dots {
    opacity: 1;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    padding: 0;
}

.dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.dot.active {
    background: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.dot:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.dot-more {
    font-size: 10px;
    color: #fff;
    font-weight: 600;
    background: rgba(85, 152, 233, 0.9);
    padding: 3px 8px;
    border-radius: 12px;
    margin-left: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(85, 152, 233, 0.7);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(85, 152, 233, 0);
    }
}

/* Swipe Upgrade Overlay */
.upgrade-swipe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    border-radius: 12px 12px 0 0;
}

.upgrade-swipe-overlay.active {
    opacity: 1;
    visibility: visible;
}

.upgrade-swipe-content {
    text-align: center;
    color: #fff;
    padding: 20px 18px;
    max-width: 260px;
    position: relative;
    animation: slideInUp 0.4s ease-out;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upgrade-swipe-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
    color: #5598E9;
    filter: drop-shadow(0 4px 8px rgba(85, 152, 233, 0.3));
}

.upgrade-swipe-content h4 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.upgrade-swipe-content p {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 16px;
    color: #fff;
    opacity: 0.95;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.upgrade-swipe-btn {
    background: linear-gradient(135deg, #5598E9, #ACC6DD);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(85, 152, 233, 0.4);
    margin-bottom: 0;
    text-transform: none;
}

.upgrade-swipe-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(85, 152, 233, 0.5);
    background: linear-gradient(135deg, #4A85D6, #C5D7E8);
}

.upgrade-swipe-btn i {
    font-size: 11px;
}

.upgrade-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-close-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    transform: scale(1.1);
}

.upgrade-close-btn i {
    font-size: 10px;
}

/* Keyboard Navigation Hint */
.keyboard-hint {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.property-image-gallery:focus .keyboard-hint {
    opacity: 1;
}

/* Loading States */
.image-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* Touch Feedback */
.property-image-gallery.touching {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .image-dots {
        background: rgba(0, 0, 0, 0.9);
        border: 1px solid #fff;
    }
    
    .dot {
        border: 1px solid #fff;
    }
    
    .upgrade-swipe-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .upgrade-swipe-btn {
        border: 2px solid #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .image-item,
    .dot,
    .upgrade-swipe-overlay,
    .upgrade-swipe-content {
        transition: none;
        animation: none;
    }
    
    .property-image-gallery:hover .image-item img {
        transform: none;
    }
    
    .dot-more {
        animation: none;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    /* .property-image-gallery {
        height: 220px;
    } */
    
    .image-dots {
        bottom: 8px;
        padding: 6px 10px;
    }
    
    .dot {
        width: 6px;
        height: 6px;
    }
    
    .upgrade-swipe-content {
        padding: 25px 20px;
        max-width: 280px;
    }
    
    .upgrade-swipe-content h4 {
        font-size: 20px;
    }
    
    .upgrade-swipe-content p {
        font-size: 15px;
    }
    
    .upgrade-swipe-btn {
        padding: 12px 24px;
        font-size: 15px;
    }
    
    .keyboard-hint {
        display: none; /* Hide on mobile since it's touch-based */
    }
}

@media (max-width: 480px) {
    /* .property-image-gallery {
        height: 200px;
    } */
    
    .upgrade-swipe-content {
        padding: 20px 15px;
        max-width: 250px;
    }
    
    .upgrade-swipe-content h4 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .upgrade-swipe-content p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .upgrade-swipe-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Focus Management for Accessibility */
.property-image-gallery:focus-within .image-dots {
    opacity: 1;
}

.property-image-gallery[tabindex="0"]:focus {
    outline: 2px solid #5598E9;
    outline-offset: 2px;
}

/* Image Error State */
.image-item img[src=""],
.image-item img:not([src]) {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-item img[src=""]:after,
.image-item img:not([src]):after {
    content: "Image not available";
    color: #999;
    font-size: 14px;
}

/* Smooth Scrolling Prevention During Swipe */
body.swiping {
    overflow: hidden;
    touch-action: none;
}

/* Loading Placeholder for New Images */
.image-item-placeholder {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    animation: loading-pattern 1s linear infinite;
}

@keyframes loading-pattern {
    0% {
        background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    100% {
        background-position: 20px 20px, 20px 30px, 30px 10px, 10px 20px;
    }
}

/* Video Styles */
.image-item video {
    cursor: pointer;
    display: block;
    background-color: #f5f5f5;
    object-fit: cover;
    object-position: center;
}

/* Ensure video poster displays correctly */
.image-item video[poster] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.image-item.video-loading {
    position: relative;
}

.image-item.video-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

/* Video Overlay Styles */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
    opacity: 1;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 5;
}

.video-overlay:hover {
    background: rgba(0, 0, 0, 0.6);
}

.video-overlay.playing {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.video-overlay.playing:hover {
    opacity: 0.9;
    pointer-events: all;
    transition: opacity 0.2s ease;
}

.video-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    text-align: center;
    padding: 10px;
}

.video-play-icon {
    color: #fff;
    font-size: 3rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 18px;
    border-radius: 50%;
    transition: all 0.3s ease;
    cursor: pointer;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.video-play-icon:hover {
    transform: scale(1.15);
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.7));
}

.video-play-icon.playing {
    font-size: 2.5rem;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-color: rgba(255, 255, 255, 0.4);
}

.video-duration {
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    min-width: 45px;
    text-align: center;
}

/* Video Progress Bar */
.video-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-overlay.playing:hover .video-progress {
    opacity: 1;
}

.video-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #5598E9, #ACC6DD);
    width: 0%;
    transition: width 0.1s ease;
}

/* Video Thumbnail Indicator */
/* .video-thumbnail-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
} */

.video-thumbnail-indicator {
  position: absolute;
  top: 12px;           /* a bit lower for balance */
  left: 16px;          /* margin from left edge */
  right: auto;         /* disable right alignment */
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 20 !important; /* stays on top of overlay & badges */
}

/* Enhanced video loading state */
.image-item.video-loading .video-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.image-item.video-loading .video-play-icon {
    animation: videoLoading 1.5s infinite ease-in-out;
}

@keyframes videoLoading {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Video mute/unmute indicator */
.video-sound-indicator {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 10;
}

.video-overlay:hover .video-sound-indicator,
.video-overlay.playing:hover .video-sound-indicator {
    opacity: 1;
}

.video-sound-indicator.muted {
    color: #ff6b6b;
}

/* Video Error States */
.image-item.video-error .video-overlay {
    background: rgba(220, 53, 69, 0.8);
}

.video-error-icon {
    color: #fff;
    font-size: 2rem;
    margin-bottom: 8px;
}

.video-error-message {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* Video Thumbnail Support */
.image-item video[poster] {
    background-size: cover;
    background-position: center;
}

/* Mobile Video Styles */
@media (max-width: 768px) {
    .video-play-icon {
        font-size: 2rem;
        padding: 12px;
        width: 50px;
        height: 50px;
    }
    
    .video-duration {
        font-size: 11px;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    .video-play-icon {
        font-size: 1.8rem;
        padding: 10px;
        width: 45px;
        height: 45px;
    }
    
    .video-duration {
        font-size: 10px;
        padding: 2px 5px;
    }
}

/* Video Loading Animation */
.image-item.video-loading .video-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* Enhanced video hover effects */
.image-item:hover .video-overlay:not(.playing) {
    background: rgba(0, 0, 0, 0.4);
}

.image-item:hover .video-play-icon {
    transform: scale(1.05);
}

/* Video Controls Animation */
@keyframes videoControlsAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-controls {
    animation: videoControlsAppear 0.3s ease-out;
}

/* Reduced Motion for Video Controls */
@media (prefers-reduced-motion: reduce) {
    .video-overlay,
    .video-play-icon,
    .video-controls {
        transition: none;
        animation: none;
    }
    
    .video-play-icon:hover {
        transform: none;
    }
}

/* Specific fix for My Account favorites tab carousel dots */
#favorites .property-image {
    position: relative !important;
    padding-bottom: 40px !important;
    /* margin-bottom: -40px !important; */
}

#favorites .property-image-gallery {
    position: relative !important;
    overflow: hidden !important;
}

#favorites .property-image-gallery .image-dots {
    position: absolute !important;
    bottom: -30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 1000 !important;
    pointer-events: auto !important;
    opacity: 0.9 !important;
    display: flex !important;
}

#favorites .property-image-gallery:hover .image-dots {
    opacity: 1 !important;
}

#favorites .property-image-gallery .dot {
    pointer-events: auto !important;
    z-index: 1001 !important;
}

/* Specific fix for My Account listings tab carousel dots */
#listings .property-image {
    position: relative !important;
    padding-bottom: 40px !important;
    /* margin-bottom: -40px !important; */
}

#listings .property-image-gallery {
    position: relative !important;
    overflow: hidden !important;
}

#listings .property-image-gallery .image-dots {
    position: absolute !important;
    bottom: -30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 1000 !important;
    pointer-events: auto !important;
    opacity: 0.9 !important;
    display: flex !important;
}

#listings .property-image-gallery:hover .image-dots {
    opacity: 1 !important;
}

#listings .property-image-gallery .dot {
    pointer-events: auto !important;
    z-index: 1001 !important;
    display: block !important;
}

/* Fallback for any tab panels with carousel */
.tab-pane .property-image-gallery {
    position: relative !important;
}

.tab-pane .property-image-gallery .image-dots {
    position: absolute !important;
    bottom: 12px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 999 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 0.9 !important;
}

.tab-pane .property-image-gallery .dot {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
