/* Image Gallery Modal Styles - Local CSS to avoid Tailwind conflicts */

/* Modal Backdrop */
.image-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.9) !important;
    z-index: 99999 !important; /* Very high z-index to ensure it's on top */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    overflow-x: hidden;
}

.image-modal-backdrop.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

/* Modal Container */
.image-modal-container {
    position: relative;
    background-color: white;
    border-radius: 0.5rem;
    max-width: 90vw;
    width: 100%;
    max-height: 90vh;
    overflow: hidden; /* Changed from overflow-y: auto to prevent double scrollbars */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    margin: 0 !important;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafb;
}

.image-modal-container::-webkit-scrollbar {
    width: 8px;
}

.image-modal-container::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 4px;
}

.image-modal-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.image-modal-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Description Section in Modal */
.image-modal-description-section {
    padding: 1rem !important; /* Padding for content */
    border-top: 1px solid #e5e7eb !important;
    background-color: #f9fafb !important;
    max-height: 200px !important; /* Fixed max height for scrolling */
    min-height: 100px !important; /* Minimum height to show content */
    overflow-y: auto !important; /* Enable scrolling */
    overflow-x: hidden !important;
    flex-shrink: 0 !important; /* Don't shrink this section */
    line-height: 1.6;
    scrollbar-width: thin !important;
    scrollbar-color: #cbd5e0 #f7fafb !important;
    position: relative !important; /* Ensure proper positioning */
    z-index: 1 !important; /* Ensure it's above image */
    box-sizing: border-box !important; /* Include padding in height calculation */
}

.image-modal-description-section::-webkit-scrollbar {
    width: 8px;
}

.image-modal-description-section::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 4px;
}

.image-modal-description-section::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.image-modal-description-section::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.image-modal-description-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.image-modal-description-section p {
    color: #4b5563;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Modal Header */
.image-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem; /* Reduced vertical padding */
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
    margin: 0;
    flex-shrink: 0; /* Don't shrink header */
}

.image-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.image-modal-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.image-modal-counter {
    font-size: 0.875rem;
    color: #6b7280;
}

.image-modal-close {
    color: #6b7280;
    font-size: 1.5rem;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.image-modal-close:hover {
    color: #374151;
}

/* Modal Content */
.image-modal-content {
    position: relative;
    flex: 1 1 auto; /* Allow flex to shrink and grow */
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center;
    min-height: 200px; /* Minimum height for image area */
    max-height: none; /* Remove max-height constraint, let flex handle it */
    overflow: visible; /* Allow image to be fully visible */
    overflow-x: hidden;
    padding: 1rem; /* Padding for visual spacing */
    margin: 0 !important; /* No margin */
    gap: 0 !important; /* No gap between flex items */
    flex-shrink: 1; /* Allow this section to shrink if needed */
}

.image-modal-content::-webkit-scrollbar {
    width: 8px;
}

.image-modal-content::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 4px;
}

.image-modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.image-modal-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Navigation Arrows */
.image-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s;
}

.image-modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.image-modal-nav.prev {
    left: 1rem;
}

.image-modal-nav.next {
    right: 1rem;
}

.image-modal-nav.hidden {
    display: none !important;
}

/* Debug styles to ensure visibility */
.image-modal-nav {
    display: block !important;
}

.image-modal-nav.prev {
    left: 1rem !important;
}

.image-modal-nav.next {
    right: 1rem !important;
}

.image-modal-nav i {
    font-size: 1.25rem;
}

/* Image Container */
.image-modal-image-container {
    padding: 0; /* Remove padding to prevent overlap */
    width: 100%;
    height: auto; /* Fit to content height */
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center;
    overflow: visible; /* Allow image to be fully visible */
    margin: 0 !important; /* No margin */
    flex-shrink: 1; /* Allow to shrink if needed */
    line-height: 0; /* Remove line-height spacing */
    position: relative; /* Ensure proper positioning */
}

.image-modal-image {
    max-width: 100%;
    max-height: calc(90vh - 400px); /* Account for header (~60px), thumbnails (~80px), description (~200px), padding (~60px) */
    width: auto;
    height: auto;
    object-fit: contain; /* Ensure full image is visible, no cropping */
    object-position: center;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: block;
    margin: 0 auto !important; /* Center horizontally */
    padding: 0 !important; /* No padding on image */
    vertical-align: top; /* Align to top */
}

/* Thumbnail Strip */
.image-modal-thumbnails {
    padding: 0.75rem 1rem; /* Reduced vertical padding */
    padding-bottom: 0.75rem;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0; /* Don't shrink thumbnails */
}

.image-modal-thumbnail-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

.image-modal-thumbnail-strip::-webkit-scrollbar {
    height: 4px;
}

.image-modal-thumbnail-strip::-webkit-scrollbar-track {
    background: #f7fafc;
}

.image-modal-thumbnail-strip::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.image-modal-thumbnail-strip::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.image-modal-thumbnail {
    width: 4rem;
    height: 3rem;
    object-fit: cover;
    border-radius: 0.25rem;
    cursor: pointer;
    border: 2px solid #d1d5db;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.image-modal-thumbnail:hover {
    transform: scale(1.05);
    border-color: #60a5fa;
}

.image-modal-thumbnail.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Property Card Gallery Styles */
.property-gallery-container {
    position: relative;
    overflow: hidden;
}

.property-gallery-container:hover .gallery-nav {
    opacity: 1;
}

.gallery-nav {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.property-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.property-gallery-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.property-gallery-nav.prev {
    left: 0;
}

.property-gallery-nav.next {
    right: 0;
}

.property-gallery-image {
    width: 100%;
    height: 12rem;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s;
}

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

.property-image-counter {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.property-thumbnail-strip {
    padding: 0.75rem 0.75rem 0.5rem;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.property-thumbnail-container {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

.property-thumbnail-container::-webkit-scrollbar {
    height: 4px;
}

.property-thumbnail-container::-webkit-scrollbar-track {
    background: #f7fafc;
}

.property-thumbnail-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.property-thumbnail-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.property-thumbnail {
    width: 3rem;
    height: 2rem;
    object-fit: cover;
    border-radius: 0.25rem;
    cursor: pointer;
    border: 2px solid #d1d5db;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.property-thumbnail:hover {
    opacity: 0.75;
    border-color: #60a5fa;
}

.property-thumbnail.active {
    border-color: #3b82f6;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .image-modal-backdrop {
        padding: 0.5rem;
    }
    
    .image-modal-container {
        max-height: 95vh;
        max-width: 95vw;
    }
    
    .image-modal-content {
        min-height: 150px;
        padding: 0.5rem;
    }
    
    .image-modal-image {
        max-height: calc(95vh - 350px) !important; /* Account for all sections on mobile */
    }
    
    .image-modal-description-section {
        max-height: 150px; /* Smaller on mobile */
        min-height: 80px;
    }
    
    .image-modal-thumbnail {
        width: 3rem;
        height: 2rem;
    }
    
    .image-modal-nav {
        padding: 0.5rem;
    }
    
    .image-modal-nav i {
        font-size: 1rem;
    }
    
    .image-modal-header {
        padding: 0.5rem;
    }
    
    .image-modal-thumbnails {
        padding: 0.5rem;
    }
}
