/* styles.css */
.json-formatted {
    margin-left: 260px;
    font-family: monospace;
    background-color: #f6f8fa;
    border: 1px solid #e1e4e8;
    padding: 10px;
    margin-top: 10px;
    white-space: pre-wrap;
    line-height: 1.5em;
    max-width: 100%;
    overflow-x: auto;
}

.json-key {
    color: #d73a49;
    font-weight: bold;
}

.json-value {
    color: #032f62;
}

/* Basic reset for padding and margin to avoid cross-browser inconsistencies - scoped to plugin namespace */
.awesome-ebay-feeds * {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

/* New wrapper for search box and grid container */
.awesome-ebay-feeds.grid-wrapper {
    display: flex;
    flex-direction: column; /* Stack the children vertically */
    align-items: center; /* Center children horizontally */
    margin: 20px 0;
}

/* Improved text handling for product grid content */
.awesome-ebay-feeds .grid-item-content p {
    margin-bottom: 0.5em;
    line-height: 1.4em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Product name styling - allow more lines for titles */
.awesome-ebay-feeds .grid-item-content .product-name {
    font-size: 0.95em;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.6em;
    line-height: 1.3em;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Allow up to 3 lines for product titles */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3.9em; /* 3 lines * 1.3em line-height */
}

/* Price styling - single line */
.awesome-ebay-feeds .grid-item-content .product-price {
    font-size: 0.9em;
    color: #2c5530;
    font-weight: 600;
    margin-bottom: 0.4em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Condition styling - single line */
.awesome-ebay-feeds .grid-item-content .product-condition {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 0.4em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Affiliate disclaimer styling - show full text */
.awesome-ebay-feeds .grid-item-content .affiliate-disclaimer {
    font-size: 0.75em;
    color: #888;
    font-style: italic;
    line-height: 1.3em;
    margin-bottom: 0.3em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}


/* Product title styles */
.awesome-ebay-feeds .grid-item-content .product-code { /* Assuming .product-code class is added to such <p> tags */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* Enhanced Filter Bar Styles */
.awesome-ebay-feeds .filter-bar {
    width: 100%;
    margin-bottom: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
}

.awesome-ebay-feeds .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.awesome-ebay-feeds .filter-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.awesome-ebay-feeds .filter-input, .awesome-ebay-feeds .filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white !important;
    color: #333 !important;
    transition: border-color 0.3s ease;
    height: 40px;
    box-sizing: border-box;
}

.awesome-ebay-feeds .filter-input:focus, .awesome-ebay-feeds .filter-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    background: white !important;
    color: #333 !important;
}

.awesome-ebay-feeds .filter-input {
    min-width: 120px;
    background: white !important;
    color: #333 !important;
}

.awesome-ebay-feeds .filter-select {
    min-width: 140px;
    background: white !important;
    color: #333 !important;
}

.awesome-ebay-feeds .price-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.awesome-ebay-feeds .price-input {
    width: 80px;
    background: white !important;
    color: #333 !important;
}

.awesome-ebay-feeds .price-separator {
    color: #666 !important;
    font-weight: bold;
}

.awesome-ebay-feeds .clear-filters-btn {
    background: #6c757d !important;
    color: white !important;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    height: 40px;
    box-sizing: border-box;
}

.awesome-ebay-feeds .clear-filters-btn:hover {
    background: #5a6268 !important;
    color: white !important;
}

.awesome-ebay-feeds .results-counter {
    text-align: center;
    color: #666 !important;
    font-size: 14px;
    font-weight: 500;
}

.awesome-ebay-feeds .filters-applied {
    color: #888 !important;
    font-size: 13px;
}

.awesome-ebay-feeds .filters-applied a {
    color: #007bff !important;
    text-decoration: underline;
    cursor: pointer;
}

.awesome-ebay-feeds .filters-applied a:hover {
    color: #0056b3 !important;
}

/* Best Offer Highlighting - removed border, keeping only badge */
.awesome-ebay-feeds .best-offer-item {
    position: relative;
}

.awesome-ebay-feeds .best-offer-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffa500;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Load More Button Styles */
.awesome-ebay-feeds .load-more-container {
    text-align: center;
    margin: 30px 0;
}

.awesome-ebay-feeds .load-more-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.awesome-ebay-feeds .load-more-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

.awesome-ebay-feeds .load-more-btn:active {
    transform: translateY(0);
}

/* Loading Spinner */
.awesome-ebay-feeds .loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
}

.awesome-ebay-feeds .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* No Products Message */
.awesome-ebay-feeds .no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Enhanced Grid Item Styles - removed duplicate .grid-item rule */

/* Removed special hover effect for best offer items since border was removed */

/* Responsive Filter Bar */
@media (max-width: 768px) {
    .awesome-ebay-feeds .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .awesome-ebay-feeds .filter-group {
        width: 100%;
    }
    
    .awesome-ebay-feeds .filter-input, .awesome-ebay-feeds .filter-select {
        width: 100%;
        min-width: auto;
    }
    
    .awesome-ebay-feeds .price-range {
        justify-content: center;
    }
    
    .awesome-ebay-feeds .price-input {
        width: 100px;
    }
}

@media (max-width: 480px) {
    .awesome-ebay-feeds .filter-bar {
        padding: 15px;
    }
    
    .awesome-ebay-feeds .filter-row {
        gap: 10px;
    }
    
    .awesome-ebay-feeds .price-range {
        flex-direction: column;
        gap: 5px;
    }
    
    .awesome-ebay-feeds .price-input {
        width: 100%;
    }
}

/* Container for all grid items */
.awesome-ebay-feeds .grid-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start; /* Align items to the start */
    width: 100%;
}


/* Individual grid item styles */
.awesome-ebay-feeds .grid-item {
    position: relative; /* Ensure positioning for the background */
    flex: 0 0 calc(33% - 20px); /* Subtracts margin from 25% width */
    margin: 10px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 480px; /* Increased minimum height */
    max-height: none; /* Remove max height constraint */
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Shadow effect on hover */
.awesome-ebay-feeds .grid-item:hover {
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
    transform: translateY(-5px);
}

/* Apply object-fit to your existing img styles */
.awesome-ebay-feeds .grid-item img {
    width: 100%; /* Set width to cover container */
    height: 100%; /* Set height to cover container */
    object-fit: contain; /* Contain the image within the container to show background */
    object-position: center; /* Center the image within the container */
}

/* Product Title */
.awesome-ebay-feeds .product-title {
    padding: 16px 16px 8px 16px;
}

.awesome-ebay-feeds .product-title h3 {
    font-size: 0.95em;
    font-weight: bold;
    color: #333 !important;
    margin: 0;
    line-height: 1.3em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3.9em;
}

/* Product Information in Columns */
.awesome-ebay-feeds .product-info {
    padding: 0 16px 2px 16px;
    display: flex !important;
    gap: 12px;
    flex-grow: 1;
    flex-direction: row !important;
    min-height: auto; /* Allow natural height */
}

.awesome-ebay-feeds .info-left, .awesome-ebay-feeds .info-right {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px;
    width: 50% !important;
    justify-content: flex-start; /* Align content to top */
}

/* Typography Hierarchy */
.awesome-ebay-feeds .product-price {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c5530 !important;
    margin: 0 16px 8px 16px;
    line-height: 1.2;
}

/* Combined lines styling */
.awesome-ebay-feeds .seller-account-line {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.awesome-ebay-feeds .buying-options {
    font-size: 0.85em;
    color: #666 !important;
    margin-bottom: 4px;
}

.awesome-ebay-feeds .product-condition {
    font-size: 0.85em;
    color: #666 !important;
    margin-bottom: 4px;
}

.awesome-ebay-feeds .shipping {
    font-size: 0.85em;
    color: #666 !important;
    margin-bottom: 4px;
}

.awesome-ebay-feeds .seller {
    font-size: 0.8em;
    color: #555 !important;
}

.awesome-ebay-feeds .location {
    font-size: 0.8em;
    color: #555 !important;
    margin-bottom: 4px;
}

.awesome-ebay-feeds .account-type {
    font-size: 0.8em;
    color: #555 !important;
}

.awesome-ebay-feeds .seller-info {
    font-size: 0.8em;
    color: #555 !important;
}

.awesome-ebay-feeds .seller-info .seller,
.awesome-ebay-feeds .seller-info .account-type {
    margin-bottom: 2px;
    color: #555 !important;
}

.awesome-ebay-feeds .shipping-info {
    font-size: 0.8em;
    color: #555 !important;
}

.awesome-ebay-feeds .shipping-info .shipping {
    margin-bottom: 4px;
    color: #555 !important;
}

.awesome-ebay-feeds .location-info {
    font-size: 0.8em;
    color: #555 !important;
}

.awesome-ebay-feeds .location-info .location {
    margin-bottom: 4px;
    color: #555 !important;
}

/* Trust Indicators */
.awesome-ebay-feeds .trust-indicators {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 16px 4px 16px;
}

.awesome-ebay-feeds .trust-item {
    font-size: 0.75em;
    color: #28a745 !important;
    font-weight: bold;
    background: #d4edda;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #c3e6cb;
}

/* Affiliate Disclaimer */
.awesome-ebay-feeds .affiliate-disclaimer {
    padding: 8px 16px;
    font-size: 0.75em;
    color: #888 !important;
    font-style: italic;
    line-height: 1.3em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Button container */
.awesome-ebay-feeds .button-container {
    margin-top: auto; /* Pushes the container to the bottom */
}

/* Button styles */
.awesome-ebay-feeds .view-now-button {
    background-color: #007bff;
    color: white;
    padding: 12px 20px;
    text-align: center;
    display: block;
    text-decoration: none;
    border-radius: 0 0 8px 8px; /* Match the grid item border radius */
    font-weight: 600;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
    margin-top: auto; /* Push button to bottom */
    flex-shrink: 0; /* Prevent button from shrinking */
}

/* Hover effect for button */
.awesome-ebay-feeds .view-now-button:hover {
    background-color: #0056b3;
}

/* Container for the image within each grid item */
.awesome-ebay-feeds .grid-item-image-container {
    position: relative; /* Ensure the image is positioned above the background */
    width: 100%; /* Container width is full width of the grid item */
    height: 200px; /* Fixed height for all images */
    overflow: hidden; /* Ensures no overflow of content outside this container */
}

/* Product image link styling */
.awesome-ebay-feeds .grid-item-image-container .product-image-link {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.awesome-ebay-feeds .grid-item-image-container .product-image-link:hover {
    opacity: 0.9;
}

/* Styles for the image within each grid item */
.awesome-ebay-feeds .grid-item-image-container img {
    position: relative; /* Position relative to its container */
    z-index: 2; /* Ensure it's above the background */
    width: 100%; /* Ensures image takes full width of the container */
    height: 100%; /* Ensures image takes full height of the container */
    object-fit: contain; /* Contain the image within the container to show background */
    object-position: center; /* Center the image within the container */
}

/* Background div for the image */
.awesome-ebay-feeds .grid-item-image-container .image-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(10px)!important; /* Blur effect */
    opacity: 0.4!important; /* Transparency */
    z-index: 1!important; /* Ensure it's behind the image */
}

.awesome-ebay-feeds .grid-item-image-container img::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 20;
    display: none;
    background-color: #333;
    color: white;
    text-transform: uppercase;
    font-weight: bold;
    padding: 8px;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s;
}

.awesome-ebay-feeds .grid-item-image-container img:hover::after {
    display: block;
    opacity: 1;
}

/* Disclosure text styling */
.awesome-ebay-feeds .disclosure {
    font-style: italic;
    margin: 2px 2px; /* Give some space around the text */
    padding: 0;
    text-align: left; /* Align text to the left */
    font-size: 0.9em; /* Smaller font size */
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .awesome-ebay-feeds .grid-item {
        flex: 0 1 calc(50% - 20px); /* Two columns on smaller screens */
    }
    
    /* Stack columns vertically on mobile */
    .awesome-ebay-feeds .product-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .awesome-ebay-feeds .info-left, .awesome-ebay-feeds .info-right {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .awesome-ebay-feeds .grid-item {
        flex: 0 1 calc(100% - 20px); /* Full width for mobile screens */
    }
    
    /* Adjust typography for mobile */
    .awesome-ebay-feeds .product-title h3 {
        font-size: 0.9em;
    }
    
    .awesome-ebay-feeds .product-price {
        font-size: 1.0em;
    }
    
    .awesome-ebay-feeds .product-info {
        padding: 0 12px 8px 12px;
    }
    
    .awesome-ebay-feeds .product-title {
        padding: 12px 12px 6px 12px;
    }
    
    .awesome-ebay-feeds .affiliate-disclaimer {
        padding: 6px 12px;
    }
}


/* Content area max-height removed for better text display */



/* Ensure button visibility */
.awesome-ebay-feeds .view-now-button {
    flex-shrink: 0; /* Prevents the button from shrinking */
}

/* Ensuring specificity by targeting the container and item class */
.awesome-ebay-feeds .grid-container .grid-item .grid-item-image-container .image-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(10px);
    opacity: 0.4;
    z-index: 1;
}

.awesome-ebay-feeds .grid-container .grid-item .grid-item-image-container .product-image-link {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.awesome-ebay-feeds .grid-container .grid-item .grid-item-image-container .product-image-link:hover {
    opacity: 0.9;
}

.awesome-ebay-feeds .grid-container .grid-item .grid-item-image-container img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}
