/**
 * Property Comparison Selection Styles
 * Complete CSS for Elementor Directorist Integration
 * Version: 2.0 - Fixed for Elementor Widgets
 */

/* ============================================
   COMPARISON BUTTON - BASE STYLES
   ============================================ */

.compare-property-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ddd;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 0;
    outline: none;
}

.compare-property-btn:hover {
    background: #fff;
    border-color: #4CAF50;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.compare-property-btn:active {
    transform: scale(0.95);
}

.compare-property-btn.active {
    background: #4CAF50;
    border-color: #4CAF50;
    box-shadow: 0 4px 12px rgba(76,175,80,0.4);
}

.compare-property-btn .icon {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.3s ease;
    display: block;
}

.compare-property-btn:hover .icon {
    transform: rotate(10deg);
}

.compare-property-btn.active .icon {
    filter: brightness(0) invert(1);
}

/* ============================================
   BUTTON POSITIONING - DIFFERENT LAYOUTS
   ============================================ */

/* When button is placed inside image container */
.compare-property-btn.in-image {
    position: absolute;
    top: 15px;
    right: 15px;
}

/* When button is placed inside actions/buttons area */
.compare-property-btn.in-actions {
    position: relative;
    top: auto;
    right: auto;
    margin-left: 8px;
    display: inline-flex;
    vertical-align: middle;
}

/* When button is placed directly in card root */
.compare-property-btn.in-card {
    position: absolute;
    top: 15px;
    right: 15px;
}

/* ============================================
   CONTAINER POSITIONING
   Ensure parent containers have relative positioning
   ============================================ */

/* Elementor widget containers */
.elementor-widget-gva-archive-listing {
    position: relative;
}

/* Generic listing containers */
[class*="listing-image"],
[class*="property-image"],
[class*="thumbnail"],
[class*="listing-single"],
.directorist-listing-single,
.directorist-listing-card,
.listing-item,
.property-item {
    position: relative;
}

/* Directorist specific containers */
.atbd_thumbnail_wrapper,
.atbd_listing_thumbnail,
.directorist-card__image,
.directorist-listing-image {
    position: relative;
}

/* ============================================
   DIRECTORIST SPECIFIC POSITIONING
   For standard Directorist themes/layouts
   ============================================ */

.atbd_single_listing {
    position: relative;
}

.atbd_single_listing .compare-property-btn {
    position: absolute;
    top: 15px;
    right: 55px;
    z-index: 11;
}

.atbd_single_listing .atbd_action {
    position: relative;
}

/* If compare button is inside action area */
.atbd_action .compare-property-btn {
    position: relative;
    top: auto;
    right: auto;
    margin-left: 5px;
}

/* Grid view layout */
.atbd_content_active .atbd_single_listing .compare-property-btn {
    top: 10px;
    right: 50px;
}

/* List view layout */
.atbd_content_active.list .atbd_single_listing .compare-property-btn {
    top: 15px;
    right: 60px;
}

/* ============================================
   FLOATING COMPARE LINK
   Bottom-right sticky button
   ============================================ */

#floating-compare-link {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(76,175,80,0.4);
    font-weight: 600;
    font-size: 16px;
    z-index: 9999;
    transition: all 0.3s ease;
    animation: slideInRight 0.5s ease;
}

#floating-compare-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(76,175,80,0.6);
    background: linear-gradient(135deg, #45a049, #4CAF50);
    text-decoration: none;
    color: white;
}

#floating-compare-link:active {
    transform: translateY(-1px);
}

#floating-compare-link .icon {
    font-size: 24px;
    animation: pulse 2s infinite;
    line-height: 1;
}

#floating-compare-link .text {
    white-space: nowrap;
}

#floating-compare-link .count {
    background: rgba(255,255,255,0.3);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    min-width: 28px;
    text-align: center;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade in animation for buttons */
.compare-property-btn {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   TOOLTIP (Optional Enhancement)
   ============================================ */

.compare-property-btn::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.compare-property-btn::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    right: 15px;
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.compare-property-btn:hover::before,
.compare-property-btn:hover::after {
    opacity: 1;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (max-width: 1024px) {
    .compare-property-btn {
        width: 40px;
        height: 40px;
    }
    
    .compare-property-btn .icon {
        font-size: 18px;
    }
    
    #floating-compare-link {
        bottom: 25px;
        right: 25px;
        padding: 14px 22px;
        font-size: 15px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    .compare-property-btn {
        width: 36px;
        height: 36px;
        top: 8px;
        right: 8px;
    }
    
    .compare-property-btn.in-image {
        top: 10px;
        right: 10px;
    }
    
    .compare-property-btn .icon {
        font-size: 16px;
    }
    
    /* Hide tooltip on mobile */
    .compare-property-btn::before,
    .compare-property-btn::after {
        display: none;
    }
    
    #floating-compare-link {
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Hide text on mobile, show only icon and count */
    #floating-compare-link .text {
        display: none;
    }
    
    #floating-compare-link .icon {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .compare-property-btn {
        width: 32px;
        height: 32px;
        top: 6px;
        right: 6px;
    }
    
    .compare-property-btn .icon {
        font-size: 14px;
    }
    
    #floating-compare-link {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
    }
}

/* ============================================
   RTL SUPPORT (Right-to-Left Languages)
   ============================================ */

[dir="rtl"] .compare-property-btn {
    left: 10px;
    right: auto;
}

[dir="rtl"] .compare-property-btn.in-image {
    left: 15px;
    right: auto;
}

[dir="rtl"] .compare-property-btn.in-actions {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] #floating-compare-link {
    left: 30px;
    right: auto;
}

@media (max-width: 768px) {
    [dir="rtl"] #floating-compare-link {
        left: 20px;
        right: auto;
    }
}

/* ============================================
   PRINT STYLES
   Hide comparison buttons when printing
   ============================================ */

@media print {
    .compare-property-btn,
    #floating-compare-link {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus styles for keyboard navigation */
.compare-property-btn:focus {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

.compare-property-btn:focus:not(:focus-visible) {
    outline: none;
}

.compare-property-btn:focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

#floating-compare-link:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

#floating-compare-link:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .compare-property-btn {
        border-width: 3px;
        border-color: #000;
    }
    
    .compare-property-btn.active {
        background: #000;
        border-color: #000;
    }
    
    #floating-compare-link {
        background: #000;
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .compare-property-btn,
    .compare-property-btn .icon,
    #floating-compare-link,
    #floating-compare-link .icon {
        animation: none;
        transition: none;
    }
}

/* ============================================
   THEME COMPATIBILITY OVERRIDES
   ============================================ */

/* Ensure button appears above other elements */
.listing-item .compare-property-btn,
.property-item .compare-property-btn,
.directorist-listing-single .compare-property-btn {
    z-index: 100 !important;
}

/* Override any theme styles that might conflict */
.compare-property-btn {
    font-family: inherit !important;
    line-height: 1 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Ensure button works with image overlays */
[class*="listing"] [class*="overlay"] + .compare-property-btn,
[class*="property"] [class*="overlay"] + .compare-property-btn {
    z-index: 101;
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .compare-property-btn {
        background: rgba(30, 30, 30, 0.95);
        border-color: #555;
    }
    
    .compare-property-btn:hover {
        background: rgba(50, 50, 50, 0.98);
        border-color: #4CAF50;
    }
}

/* ============================================
   LOADING STATE (Optional Enhancement)
   ============================================ */

.compare-property-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

.compare-property-btn.loading .icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   END OF STYLES
   ============================================ */