/* E360 Sorting Styles */

/* E360 Sort Options in Toolbar */
.toolbar-sorter [data-role="sorter"].e360-sort-option {
    position: relative;
    font-weight: 500;
}

.toolbar-sorter [data-role="sorter"].e360-sort-option:before {
    content: "";
    margin-right: 0;
    font-size: 12px;
}

.toolbar-sorter .e360-badge {
    background: #007bff;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-left: 5px;
    vertical-align: middle;
}

/* Loading state */
.products.wrapper.e360-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.products.wrapper.e360-loading:after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

/* E360 Product Metadata */
.e360-product-meta {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.e360-product-meta span {
    display: inline-block;
    margin-right: 10px;
    padding: 2px 6px;
    background: #f8f9fa;
    border-radius: 3px;
    border: 1px solid #e9ecef;
}

.e360-product-meta .store-count {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1976d2;
}

.e360-product-meta .popularity-score {
    background: #fff3e0;
    border-color: #ffcc02;
    color: #f57c00;
}

.e360-product-meta .deal-badge {
    background: #e8f5e8;
    border-color: #c8e6c9;
    color: #388e3c;
    font-weight: bold;
}

/* Debug Info Styling */
.e360-debug-info {
    background: #f0f0f0 !important;
    padding: 10px !important;
    margin: 10px 0 !important;
    font-size: 12px !important;
    border-left: 4px solid #007bff !important;
    font-family: monospace;
}

.e360-debug-info code {
    background: #fff;
    padding: 5px;
    border-radius: 3px;
    display: block;
    margin-top: 5px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .e360-product-meta span {
        display: block;
        margin: 2px 0;
    }
    
    .e360-debug-info {
        font-size: 10px !important;
    }
}

/* Integration with Athlete2 theme toolbar styles */
.toolbar-sorter .js-toolbar-dropdown .e360-sort-option {
    transition: background-color 0.2s ease;
}

.toolbar-sorter .js-toolbar-dropdown .e360-sort-option:hover {
    background-color: #f8f9fa;
}

/* Fix mobile dropdown arrow alignment */
@media (max-width: 768px) {
    /* Make the button container wider */
    .toolbar .sorter .js-toolbar-switch {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        min-width: 140px !important;
        width: auto !important;
        position: relative !important;
        padding-right: 25px !important;
    }
    
    .toolbar .sorter .js-toolbar-switch .current {
        flex: 1 !important;
        text-align: left !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: initial !important;
        margin-right: 5px !important;
        padding-right: 5px !important;
        min-width: 100px !important;
    }
    
    .toolbar .sorter .js-toolbar-switch:after {
        content: "" !important;
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 0 !important;
        height: 0 !important;
        border-left: 4px solid transparent !important;
        border-right: 4px solid transparent !important;
        border-top: 4px solid #666 !important;
        pointer-events: none !important;
    }
    
    /* Fix dropdown width - override inline JS styles */
    .toolbar .sorter .js-toolbar-dropdown.sorter-options,
    .toolbar-sorter .sorter .js-toolbar-dropdown#sorter,
    #sorter.js-toolbar-dropdown,
    .js-toolbar-dropdown.sorter-options[style] {
        min-width: 220px !important;
        width: 220px !important;
        max-width: none !important;
    }
    
    /* Fix E360 options to display in single line */
    .toolbar .sorter .js-toolbar-dropdown .e360-sort-option {
        white-space: nowrap !important;
        padding: 10px 15px !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Hide non-E360 options that might appear */
    .toolbar .sorter .js-toolbar-dropdown [data-role="sorter"]:not(.e360-sort-option) {
        display: none !important;
    }
    
    /* Hide specific unwanted options even if they have e360-sort-option class */
    .toolbar .sorter .js-toolbar-dropdown [data-value="e360_stores"],
    .toolbar .sorter .js-toolbar-dropdown [data-value="e360_rating"] {
        display: none !important;
    }
    
    /* Hide Sort By label on mobile to save space */
    .toolbar .sorter .sorter-label {
        display: none !important;
    }
}

/* Error message styling */
.page.messages .message-error.error.message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    padding: 10px 15px;
    margin: 10px 0;
}

/* E360 Price Label - "Desde" text styling */
.e360-price-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
    font-weight: normal;
}

/* E360 Offer Count - "en X tiendas" text styling */
.e360-offer-count {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-weight: normal;
}

.e360-offer-count strong {
    font-weight: 700;
    color: #333;
}

/* E360 Short Description - smaller text for 2 lines */
.e360-short-description {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    margin-bottom: 6px;
    font-weight: normal;
    line-height: 1.4;
    /* Limit to 2 lines of text */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Ensure exact height for 2 complete lines */
    max-height: 31px; /* 11px font * 1.4 line-height * 2 lines = 30.8px */
    min-height: 15px; /* At least one line */
}

/* Limitar nombre del producto a 2 líneas máximo */
.product-item-name,
.product.name.product-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    /* Altura máxima calculada: font-size * line-height * 2 líneas */
    max-height: 36px; /* Aproximadamente 14px * 1.3 * 2 = 36px */
    /* Solo primera letra en mayúscula */
    text-transform: capitalize;
}