/**
 * Gnarly Booking Engine - Compare Feature Styles
 * Copyright (c) 2025 Brand Wars LLC
 * Licensed under proprietary license. See LICENSE.txt for details.
 */

/* Compare Button */
.hostapi-compare-button {
    position: absolute;
    bottom: 20px;
    right: 15px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
    cursor: pointer;
    z-index: 50; /* Higher z-index to ensure it appears above carousel controls */
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.hostapi-compare-button:hover {
    background-color: #f8f8f8;
    transform: translateY(-2px);
}

.hostapi-compare-button.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.hostapi-compare-button.active:hover {
    background-color: #3e8e41;
}

.hostapi-compare-button i {
    margin-right: 5px;
}

/* Compare Drawer */
.hostapi-compare-drawer {
    position: fixed;
    right: -320px; /* Start off-screen */
    top: 0;
    width: 320px;
    height: 100vh;
    background-color: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.hostapi-compare-drawer.open {
    right: 0;
}

/* Position the drawer toggle button correctly */
.hostapi-compare-drawer-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background-color: white;
    border: 1px solid #eee;
    border-right: none;
    border-radius: 6px 0 0 6px;
    height: 60px;
    width: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9998;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.08);
    transition: right 0.3s ease;
}

.hostapi-compare-drawer.open + .hostapi-compare-drawer-toggle {
    right: 320px; /* Should match the drawer width */
}

.hostapi-compare-drawer.open + .hostapi-compare-drawer-toggle i {
    transform: rotate(180deg);
}

.hostapi-compare-drawer.open .hostapi-compare-drawer-toggle {
    right: 300px;
}

.hostapi-compare-drawer-toggle i {
    color: #555;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.hostapi-compare-drawer.open .hostapi-compare-drawer-toggle i {
    transform: rotate(180deg);
}

.hostapi-compare-drawer-counter:empty {
    display: none !important;
}

/* Counter badge */
.hostapi-compare-drawer-counter {
    position: absolute;
    top: -8px;
    right: 3px;
    background-color: #ff575e;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.hostapi-compare-drawer-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hostapi-compare-drawer-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
}

.hostapi-compare-drawer-clear {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

.hostapi-compare-drawer-clear:hover {
    color: #F44336;
    background-color: rgba(0,0,0,0.05);
}

.hostapi-compare-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.hostapi-compare-drawer-footer {
    padding: 15px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
}

.hostapi-compare-drawer-item {
    margin-bottom: 15px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.hostapi-compare-drawer-item-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.hostapi-compare-drawer-item-details {
    padding: 10px;
}

.hostapi-compare-drawer-item-title {
    font-size: 14px;
    font-weight: bold;
    margin: 0 0 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hostapi-compare-drawer-item-price {
    font-size: 14px;
    color: #555;
}

.hostapi-compare-drawer-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hostapi-compare-drawer-item-remove:hover {
    background-color: #f44336;
    color: white;
}

.hostapi-compare-button-large {
    background-color: #FE595E;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.hostapi-compare-button-large:hover {
    background-color: #e63946;
    transform: translateY(-2px);
}

.hostapi-compare-button-large:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Compare Page Styles */
.hostapi-compare-page {
    width: 100%;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
}

.hostapi-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.hostapi-compare-grid {
    display: grid;
    grid-template-columns: 1fr repeat(var(--listings-count, 2), 2fr);
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.hostapi-compare-header h1 {
    margin: 0;
    font-size: 32px;
    font-weight: 600;
}

.hostapi-compare-back-button {
    background-color: #f5f5f5;
    color: #333;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}

.hostapi-compare-back-button:hover {
    background-color: #e5e5e5;
}

/* Table-based comparison layout */
.hostapi-compare-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.hostapi-compare-table th,
.hostapi-compare-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f2f2f2;
    vertical-align: middle;
}

.hostapi-compare-table th {
    background-color: #f9f9f9;
    font-weight: 600;
    text-align: left;
    color: #333;
}

.hostapi-compare-table td {
    text-align: center;
}

/* Left align header cells */
.hostapi-compare-table th {
    text-align: left;
}

.hostapi-compare-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.hostapi-compare-table td.property-image {
    padding: 0;
    height: 200px;
}

.hostapi-compare-table img.listing-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hostapi-compare-feature-available {
    color: #4CAF50;
    font-size: 18px;
}

.hostapi-compare-feature-unavailable {
    color: #F44336;
    font-size: 18px;
}

/* Section headers */
.hostapi-compare-section-header {
    background-color: #f0f0f0 !important;
    font-weight: 600;
}

.hostapi-compare-section-header td {
    padding: 10px 15px;
}

.hostapi-compare-grid-row {
    display: grid;
    grid-template-columns: 1fr repeat(var(--listings-count, 2), 2fr);
    border-bottom: 1px solid #ddd;
}

.hostapi-compare-grid-row:last-child {
    border-bottom: none;
}

.hostapi-compare-grid-cell {
    padding: 15px;
    border-right: 1px solid #ddd;
    display: flex;
    align-items: center;
}

.hostapi-compare-grid-row:nth-child(odd) .hostapi-compare-grid-cell {
    background-color: #f9f9f9;
}

.hostapi-compare-grid-cell:last-child {
    border-right: none;
}

.hostapi-compare-grid-label {
    font-weight: bold;
    color: #555;
}

.hostapi-compare-grid-image-cell {
    padding: 0;
    position: relative;
    height: 200px;
}

.hostapi-compare-grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hostapi-compare-grid-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.hostapi-compare-feature-available {
    color: #4CAF50;
}

.hostapi-compare-feature-unavailable {
    color: #F44336;
}

/* Bottom comparison bar for mobile */
.hostapi-compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    background-color: white;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    font-size: 16px;
    font-weight: 500;
}

.hostapi-compare-bar > div {
    display: flex;
    align-items: center;
    white-space: nowrap; /* Prevent wrapping to next line */
}

.hostapi-compare-bar-count {
    margin-right: 5px;
}

/* Adjust spacing for the button */
.hostapi-compare-bar .hostapi-compare-button-large {
    margin-left: 20px;
}

.hostapi-compare-bar .hostapi-compare-button-large {
    background-color: #ff575e;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-weight: 500;
    cursor: pointer;
}

.hostapi-compare-bar .hostapi-compare-button-large:hover {
    background-color: #e63946;
}

.hostapi-compare-bar-items {
    display: flex;
    gap: 10px;
}

/* Specific styling for amenities and features */
.hostapi-compare-table .feature-row td {
    text-align: center;
}

/* Floating back to top button */
.hostapi-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #ff575e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.hostapi-back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Toggle comparison categories */
.hostapi-toggle-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.hostapi-toggle-button {
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}

.hostapi-toggle-button.active {
    background-color: #ff575e;
    color: white;
}

/* Header and filters bar */
.hostapi-compare-header {
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 10;
    padding: 15px 0;
}

/* Responsive Styles for Compare Page */
@media (max-width: 768px) {
    .hostapi-compare-grid {
        grid-template-columns: 1fr;
        border: none;
    }
    
    .hostapi-compare-grid-row {
        display: grid;
        grid-template-columns: 1fr;
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .hostapi-compare-grid-cell {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .hostapi-compare-grid-cell:last-child {
        border-bottom: none;
    }
    
    .hostapi-compare-grid-label {
        margin-bottom: 10px;
        display: block;
        width: 100%;
        border-bottom: 1px solid #eee;
        padding-bottom: 5px;
    }
    
    /* Show bottom comparison bar on mobile */
    .hostapi-compare-bar {
        display: flex;
    }
    
    .hostapi-compare-drawer.open + .hostapi-compare-drawer-toggle {
        right: 280px; /* Should match the drawer width */
    }
    
    .hostapi-compare-drawer {
        width: 280px;
        right: -280px;
    }
    
    .hostapi-compare-drawer.open .hostapi-compare-drawer-toggle {
        right: 280px;
    }
    
     /* Make the table scrollable horizontally */
    .hostapi-compare-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
        padding-bottom: 5px; /* Space for scroll indicator */
    }
    
    /* Fixed left column */
    .hostapi-compare-table th {
        position: sticky;
        left: 0;
        z-index: 2;
        background-color: #f9f9f9;
        box-shadow: 2px 0 5px rgba(0,0,0,0.05);
        width: 120px; /* Fixed width for the label column */
        min-width: 120px;
    }
    
    /* Adjust column widths */
    .hostapi-compare-table td {
        min-width: 120px; /* Ensure columns don't get too narrow */
        white-space: normal; /* Allow text wrapping */
    }
    
    /* Alternating row colors for better readability */
    .hostapi-compare-table tr:nth-child(even) {
        background-color: #fafafa;
    }
    
    .hostapi-compare-table tr:nth-child(even) th {
        background-color: #f5f5f5;
    }
    
    /* Make sure the first cell of each row has a consistent background */
    .hostapi-compare-table tr th {
        border-right: 1px solid #e0e0e0;
    }
    
    /* Style for property images */
    .property-image {
        height: 120px;
        padding: 0 !important;
    }
    
    .property-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Style for amenity indicators */
    .hostapi-compare-feature-available,
    .hostapi-compare-feature-unavailable {
        font-size: 18px;
        display: block;
        text-align: center;
    }
    
    /* Section headers */
    .hostapi-compare-section-header th,
    .hostapi-compare-section-header td {
        background-color: #f0f0f0 !important;
        font-weight: 600;
        text-align: center;
        color: #333;
    }
    
    /* Style for buttons */
    .hostapi-compare-button-large {
        width: 100%;
        padding: 8px 0;
        font-size: 14px;
        text-align: center;
    }
    
    /* Add scroll indicator */
    .hostapi-scroll-indicator {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, #ff575e 0%, rgba(255,87,94,0.2) 100%);
        opacity: 0.7;
        border-radius: 2px;
        animation: scroll-hint 1.5s ease-in-out infinite;
    }
    
    @keyframes scroll-hint {
        0% { opacity: 0.7; }
        50% { opacity: 0.3; }
        100% { opacity: 0.7; }
    }
    
    /* Price and title styling */
    .hostapi-compare-table .listing-title {
        font-weight: 600;
        font-size: 14px;
        line-height: 1.3;
    }
    
    .hostapi-compare-table .listing-price {
        font-weight: 600;
        color: #ff575e;
    }
    
    /* Column highlighting on tap/touch */
    .hostapi-compare-table td.highlight,
    .hostapi-compare-table th.highlight {
        background-color: rgba(255, 87, 94, 0.05);
    }
    
    /* Sticky comparison header */
    .hostapi-sticky-header {
        position: sticky;
        top: 0;
        z-index: 3;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .hostapi-sticky-header th,
    .hostapi-sticky-header td {
        background-color: #fff !important;
    }
    
    /* Adjust for very small screens */
    @media (max-width: 320px) {
        .hostapi-compare-table th {
            width: 100px;
            min-width: 100px;
            font-size: 13px;
        }
        
        .hostapi-compare-table td {
            min-width: 110px;
            font-size: 13px;
            padding: 10px 12px;
        }
    }

}