/* --- Tier Sections --- */
.tier-section {
    margin-bottom: 2rem;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-bottom: 1px solid var(--border-color);
}

.tier-section:last-child {
    border-bottom: none;
}

.tier-header {
    padding: 1rem 1.5rem;
    margin: 0;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 600;
    padding-bottom: 0.5em;
}

.tier-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
}

.tier-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    background-color: var(--primary);
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}

.tier-subtitle {
    flex: 1 1 100%;
    font-size: 0.9rem;
    color: var(--secondary);
    font-style: italic;
    font-weight: 400;
    opacity: 0.9;
    order: 99; /* Ensure it appears after all other flex items */
}

/* --- Product Grid --- */
.product-grid {
    display: grid;
    /* 
     * Ensure that the grid always uses auto-fill to maximize the number of cards
     * that can fit in the available space, regardless of screen size.
     * 
     * auto-fill: Creates as many columns as can fit in the container
     * minmax(var(--card-width), 1fr): Each column is at least --card-width wide,
     * and can grow equally to fill available space
     */
    grid-template-columns: repeat(auto-fit, minmax(var(--card-width), var(--card-width)));
    justify-content: center;
    row-gap: var(--gap);
    column-gap: var(--product-col-gap);
    max-width: var(--grid-max-width);
    margin: 0 auto;
}

/* Creator Products Section - Keeping for backward compatibility */
.creator-products {
    margin-top: 20px;
    margin-bottom: 30px;
    width: 100%;
}

/* Use the same grid layout as product-grid for consistency */
.creator-products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
    gap: var(--gap);
    width: 100%;
}

/* 
 * Mobile-specific grid adjustments
 * Force exactly 4 columns on mobile screens to match banner layout
 * This ensures consistent layout with the banner products
 * 
 * The gap between products will automatically adjust based on the
 * media queries in style.css:
 * - Standard mobile (≤480px): gap = 2px
 * - Small mobile (≤360px): gap = 1px
 */

 @media (max-width: 440px) {
    :root {
        --product-col-gap: var(--small-gap);
      }  
   }

   @media (max-width: 430px) {
    :root {
        --product-col-gap: 0px;
      }  
   }

   @media (max-width: 400px) {
    :root {
      --card-width: 97px;
    }  
   }

     @media (max-width: 390px) {
        :root {
          --card-width: 100px;
        }  
        .product-grid {
            column-gap: 20px;
          }  
       }
    
       @media (max-width: 350px) {
        .product-grid {
            column-gap: 10px;
          }  
       }
       
       @media (max-width: 330px) {
        .product-grid {
            column-gap: 5px;
          }  
       }
    
       @media (max-width: 320px) {
        .product-grid {
            column-gap: 0px;
          }  
       }
    
    
       @media (max-width: 300px) {
        :root {
            --card-width: 100px;
    
          }  
          .product-grid {
            column-gap: 20px;
            }  
         }

.loading-products {
    padding: 10px;
    text-align: center;
    color: var(--secondary);
    font-style: italic;
}

/* Import heart icons styles */
@import url('heart-icons.css');

/* --- Product Card --- */
.product-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: var(--card-width);
    position: relative;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-sizing: border-box; /* Ensure border is included in width calculation */
}

.product-card-container {
    position: relative;
    width: var(--card-width);
    box-sizing: border-box; /* Ensure border is included in width calculation */
}


.product-item {
  position: relative; /* Establishes positioning context for the hover card */
}

.product-image {
    width: 100%;
    height: 80px;
    overflow: hidden;
    background-color: #eee;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s ease; /* Add transition for tap feedback */
}

.product-image img:active {
    opacity: 0.7; /* Visual feedback when tapped */
}

.product-info {
    padding: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    height: 25px;
}

.price {
    font-weight: bold;
    color: var(--text-color);
    font-size: 0.85rem;
}

.heart-icon {
    color: var(--secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
}

.heart-icon:hover {
    transform: scale(1.1);
}

.heart-icon.liked {
    color: var(--accent);
    font-weight: bold;
}

    
.product-hover-card {
    display: none;
    position: absolute;
    width: 250px; /* Reduced width to be more compact */
    background-color: #f0f0f0; /* Light grey background */
    border-radius: 5px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px;
    z-index: 10;
    font-size: 0.9rem;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    overflow: visible; /* Remove scrollbars */
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.product-hover-card.hover-left {
    top: 100%; /* Position at the bottom of the product card */
    left: 0; /* Align with left edge by default */
}

.product-hover-card.hover-right {
    bottom: 0; /* Position at the top of the hover card */
    transform: translateY(100%); /* Move below the product card */
    right: 0; /* Always align with right edge */
}

/* Dark mode styles for hover card */
body.dark-mode .product-hover-card {
    background-color: #2c3e50; /* Dark blue/gray background */
    color: #ecf0f1; /* Light text color */
    border-color: #4a657b; /* Darker border */
}

/* Show the hover card when container is hovered or card is pinned (unless force-hide) */
.product-card-container:hover > .product-hover-card:not(.force-hide),
.product-hover-card.pinned:not(.force-hide) {
  display: block;
}

/* Force hide class - higher specificity than hover */
.product-hover-card.force-hide {
  display: none !important;
}

.product-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.product-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.product-title-row h3 {
    margin: 0;
    font-size: 1.1em;
    line-height: 1.4;
}

.product-hover-card .pin-hover-btn {
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    margin: -4px 0;
    width: 22px;
    height: 22px;
    position: relative;
}

.pin-hover-btn::before {
    content: '';
    width: 14px;
    height: 14px;
    background-image: url('/images/pin-icon.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: var(--icon-filter);
}

body.dark-mode .pin-hover-btn::before {
    filter: invert(1);
}

.product-hover-card .close-hover-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    font-size: 1.2em;
    margin: -4px -8px -4px 0;
}

.product-hover-card .close-hover-btn {
    font-size: 1.2em;
    line-height: 1;
    width: 24px;
    height: 24px;
}

.product-hover-card .pin-hover-btn:hover,
.product-hover-card .close-hover-btn:hover {
    transform: scale(1.1);
    background-color: rgba(0, 0, 0, 0.05);
}

.product-hover-card.pinned .pin-hover-btn {
    color: var(--accent);
    transform: rotate(-45deg);
}

.product-hover-card .pin-icon {
    display: block;
    width: 14px;
    height: 14px;
}

body.dark-mode .product-hover-card .close-hover-btn {
  color: var(--dm-text-color, #ecf0f1); /* Fallback color for dark mode */
}

body.dark-mode .product-details-header {
    border-bottom-color: #4a657b;
}

body.dark-mode .product-creator {
    color: #adb5bd; /* Lighter secondary color for dark mode */
}

body.dark-mode .category-path {
    border-bottom-color: #4a657b;
}

body.dark-mode .category-path a {
    color: #5dade2; /* Lighter accent color for links in dark mode */
}

body.dark-mode .preview-image {
    border-color: #4a657b;
    background-color: #34495e; /* Slightly lighter than the hover card background */
}


body.dark-mode .pin-hover-btn,
body.dark-mode .close-hover-btn {
    color: #ecf0f1;
}

body.dark-mode .pin-hover-btn:hover,
body.dark-mode .close-hover-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .pin-hover-btn.pinned {
    color: var(--dm-accent, #3498db);
}

.product-card:hover + .product-hover-content,
.product-hover-content:hover,
.product-hover-content.pinned {
    display: block;
}

.product-card:hover {
    transform: none; /* Remove the upward movement on hover */
    box-shadow: var(--shadow), 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Removed media query for right alignment since we always align right */

.product-details-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.product-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.product-header-top h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    flex: 1;
}

.close-hover-btn {
    background-color: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #333;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 20; /* Ensure it's above other elements */
    margin-left: 5px;
}

.close-hover-btn:hover {
    background-color: rgba(0, 0, 0, 0.2);
    color: #000;
}

.close-hover-btn:active {
    background-color: rgba(0, 0, 0, 0.3);
}

.product-creator {
    font-size: 0.8rem;
    margin: 0 0 8px 0;
    color: var(--secondary);
}

.product-details-body {
    margin-bottom: 10px;
}

.product-details-main {
    display: flex;
    gap: 10px; /* Reduced gap */
    margin-bottom: 10px;
}

.product-details-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0; /* Allow text to truncate if needed */
}

.product-details-media {
    width: 120px; /* Reduced width */
    min-width: 120px;
}

.product-details-columns {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.product-details-column {
    min-width: 0;
}

.product-details-column p {
    margin: 2px 0; /* Reduced margin */
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-image-container {
    width: 100%;
    height: auto;
}

.preview-image {
    width: 100%;
    height: auto;
    max-height: 100px; /* Reduced max height */
    object-fit: contain;
    border: 1px solid var(--border-color);
    padding: 2px;
    background-color: white;
    border-radius: 3px;
}

.tag-cloud-container {
    width: 100%;
    margin-top: 10px;
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%; /* Full width of container */
    justify-content: flex-start; /* Align tags to the start */
}

.product-tag {
    background-color: var(--highlight);
    color: var(--text-color);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    white-space: nowrap;
    display: inline-block; /* Ensure proper display */
}

.product-action-buttons {
    display: flex;
    flex-direction: row; /* Horizontal layout */
    justify-content: space-between;
    gap: 5px;
    margin-top: 8px;
}

.product-btn {
    display: block;
    padding: 5px 8px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.75rem;
    transition: background-color 0.2s ease;
    text-align: center;
    font-weight: bold;
    flex: 1; /* Equal width for all buttons */
}

.classic-btn {
    background-color: var(--accent);
    color: white;
}

.classic-btn:hover {
    background-color: var(--primary-darker);
}

.next-btn {
    background-color: #6c5ce7; /* Purple for IMVU Next */
    color: white;
}

.next-btn:hover {
    background-color: #5541d8;
}

.try-btn {
    background-color: #00b894; /* Green for Try It */
    color: white;
}

.try-btn:hover {
    background-color: #00a382;
}

.category-path {
    font-size: 0.75rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
    white-space: normal; /* Allow wrapping */
    line-height: 1.4;
    max-height: 40px; /* Fixed height for category path */
    overflow: hidden; /* Hide overflow instead of scrolling */
}

.category-path a {
    color: var(--accent);
    text-decoration: none;
}

.category-path a:hover {
    text-decoration: underline;
}

.toggle-product-details {
    cursor: pointer;
}

/* Mobile responsiveness for products */
@media (max-width: 767px) {
    .product-hover-content {
        display: none !important; /* Never show hover cards on mobile */
    }
    
    .product-card {
        cursor: pointer; /* Show pointer cursor to indicate clickable */
    }
}

div.credits-symbol {
    float: left;
    margin-top: var(--small-gap);
    width: 13px;
    height: 12px;
    background: url(/images/shop_sprite.png) -45px -218px;
}
