/* Main Comparison Container */
#product-compare {
    width: 80% !important;
    max-width: 1400px !important;
    margin: 40px auto !important;
    padding: 30px !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1) !important;
    border-radius: 15px !important;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
    box-sizing: border-box !important;
    background: white !important;
    position: relative;
}

#product-compare.rtl {
    direction: rtl !important;
    text-align: right !important;
}

#product-compare.ltr {
    direction: ltr !important;
    text-align: left !important;
}

#product-compare h2 {
    font-size: 32px !important;
    margin-bottom: 30px !important;
    text-align: center !important;
    font-weight: 700 !important;
    color: #2c3e50 !important;
}

/* Category Filter */
.category-filter {
    margin-bottom: 30px !important;
    text-align: center !important;
    display: block !important;
}

.category-filter label {
    font-weight: 600 !important;
    font-size: 16px !important;
    display: block !important;
    margin-bottom: 12px !important;
    color: #34495e !important;
}

.category-filter select {
    padding: 15px 20px !important;
    border: 2px solid #bdc3c7 !important;
    border-radius: 10px !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    cursor: pointer !important;
    appearance: none !important;
    background-image: url('data:image/svg+xml;utf8,<svg fill="gray" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 15px center !important;
    background-size: 16px !important;
    transition: all 0.3s ease !important;
    max-width: 300px !important;
    width: 100% !important;
}

.category-filter select:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2) !important;
    border-color: #3498db !important;
    transform: translateY(-2px) !important;
}

/* Select Container - Side by Side on Desktop */
.select-container {
    display: flex !important;
    gap: 30px !important;
    margin-bottom: 30px !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
}

.select-group {
    flex: 1 1 45% !important;
    min-width: 300px !important;
}

#product-compare label {
    font-weight: 600 !important;
    font-size: 16px !important;
    display: block !important;
    margin-bottom: 12px !important;
    color: #34495e !important;
}

/* Enhanced Select Styles */
#product-compare select {
    width: 100% !important;
    padding: 0px 20px !important;
    border: 2px solid #bdc3c7 !important;
    border-radius: 10px !important;
    font-size: 16px !important;
    line-height: 1.2 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    cursor: pointer !important;
    appearance: none !important;
    background-image: url('data:image/svg+xml;utf8,<svg fill="gray" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 15px center !important;
    background-size: 16px !important;
    transition: all 0.3s ease !important;
}

#product-compare select:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2) !important;
    border-color: #3498db !important;
    transform: translateY(-2px) !important;
}

/* Enhanced Select Dropdown Styles */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

.custom-select-selected {
    padding: 15px 20px;
    border: 2px solid #bdc3c7;
    border-radius: 10px;
    cursor: pointer;
    background: white;
    display: flex;
    align-items: center;
    min-height: 60px;
    transition: all 0.3s ease;
}

.custom-select-selected:hover {
    border-color: #3498db;
}

.custom-select-selected .placeholder {
    color: #7f8c8d;
    font-style: italic;
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #3498db;
    border-radius: 10px;
    margin-top: 5px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.custom-select-option {
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid #ecf0f1;
    transition: background-color 0.2s;
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background-color: #f8f9fa;
}

.custom-select-option.disabled {
    display: none !important;
}

/* Product Option Styles */
.product-option {
    display: flex;
    align-items: center;
    gap: 15px;
}

.product-option-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #eee;
    padding: 3px;
    background: white;
}

.product-option-details {
    flex: 1;
}

.product-option-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    color: #2c3e50;
}

.product-option-prices {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.product-option-regular-price {
    text-decoration: line-through;
    color: #95a5a6;
    font-size: 14px;
    font-weight: 500;
}

.product-option-sale-price {
    color: #e74c3c;
    font-weight: 700;
    font-size: 16px;
}

.product-option-price {
    color: #2c3e50;
    font-weight: 700;
    font-size: 16px;
}

.product-option-brand {
    font-size: 12px;
    color: #7f8c8d;
    font-weight: 600;
    background: #ecf0f1;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-block;
}

/* Comparison Result Area */
#comparison-result {
    position: relative !important;
    margin-top: 30px !important;
    overflow-x: auto !important;
    min-height: 200px !important;
}

/* Comparison Table */
.comparison-table {
    width: 100% !important;
    border-collapse: collapse !important;
    min-width: 800px !important;
    background: white !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08) !important;
    table-layout: fixed; /* <-- أضف هذا السطر */
}

.comparison-table th,
.comparison-table td {
    padding: 18px 20px !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    font-size: 15px !important;
    vertical-align: top !important;
    line-height: 1.5 !important;
}

.comparison-table th {
    font-weight: 700 !important;
    text-align: center !important;
    color: white !important;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
    width: 20% !important;
    font-weight: 600 !important;
    background-color: rgba(52, 152, 219, 0.1) !important;
}

.comparison-table tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

.comparison-table tr:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

/* Product Header in Table */
#product-compare .product-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0px !important;
    text-align: center !important;
}

#product-compare .product-thumbnail {
    width: 120px !important;
    height: 120px !important;
    object-fit: contain !important;
    border-radius: 10px !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
    background: white !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#product-compare .product-name {
    font-weight: 700 !important;
    font-size: 18px !important;
    margin-bottom: 8px !important;
    color: #2c3e50;
}

#product-compare .product-price {
    display: flex;
    flex-direction: row; /* Changed from column */
    align-items: baseline; /* Aligns prices nicely */
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

#product-compare .product-price .regular-price {
    text-decoration: line-through;
    color: #95a5a6;
    font-size: 16px;
}

#product-compare .product-price .sale-price {
    color: #e74c3c;
    font-weight: 700;
    font-size: 20px;
}

#product-compare .product-price .price {
    color: #2c3e50;
    font-weight: 700;
    font-size: 20px;
}

#product-compare .product-brand {
    font-size: 13px;
    color: #7f8c8d;
    font-weight: 600;
    background: #ecf0f1;
    padding: 5px 12px;
    border-radius: 15px;
    display: inline-block;
}

#product-compare .product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    font-size: 14px;
    color: #f39c12;
}

/* Attribute ID display */
.attribute-id {
    display: none !important; /* إخفاء معرفات الخصائص */
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute !important;
    top: 50% !important;
    font-size: 32px !important;
    font-weight: bold !important;
    user-select: none !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
    animation: bounceArrow 1.5s infinite !important;
    z-index: 10 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#product-compare.ltr #comparison-result .scroll-indicator {
    right: 10px !important;
}

#product-compare.rtl #comparison-result .scroll-indicator {
    left: 10px !important;
}

@keyframes bounceArrow {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(10px); }
}

#product-compare.rtl #comparison-result .scroll-indicator {
    animation: bounceArrowRTL 1.5s infinite !important;
}

@keyframes bounceArrowRTL {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(-10px); }
}

/* RTL Support for Custom Select */

#product-compare.rtl .product-option {
    flex-direction: row-reverse;
}

#product-compare.rtl .product-option-details {
    text-align: right;
}

/* Loading Animation */
.comparison-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.comparison-loading::after {
    content: "";
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Message */
.comparison-error {
    text-align: center;
    padding: 30px;
    color: #e74c3c;
    font-weight: 600;
    font-size: 18px;
}

/* No Products Message */
.comparison-empty {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-style: italic;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    #product-compare {
        width: 90% !important;
    }
}

@media (max-width: 992px) {
    .select-container {
        flex-wrap: wrap !important;
    }
    
    .select-group {
        flex: 1 1 100% !important;
    }
}

@media (max-width: 768px) {
    #product-compare {
        width: 95% !important;
        padding: 20px 15px !important;
        margin: 20px auto !important;
    }
    
    .select-container {
        gap: 20px !important;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 12px 15px !important;
        font-size: 14px !important;
    }
    
    .product-thumbnail {
        width: 80px !important;
        height: 80px !important;
    }
    
    .product-name {
        font-size: 16px !important;
    }
    
    .product-price .sale-price,
    .product-price .price {
        font-size: 18px !important;
    }
    
    .custom-select-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
        max-height: 80vh;
    }
    
    .product-option-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .product-option-name {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #product-compare h2 {
        font-size: 24px !important;
    }
    
    .select-group {
        min-width: 100% !important;
    }
    
    #product-compare select {
        padding: 12px 15px !important;
        font-size: 14px !important;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 10px 12px !important;
    }
    
    .product-thumbnail {
        width: 70px !important;
        height: 70px !important;
    }
    
    .product-option {
    
    }
    
    .product-option-thumbnail {
        width: 60px;
    }

    /* LTR (English) Version Styling */
#product-compare.ltr .category-filter select {
    padding: 0px 50px 0px 15px !important;
    background-position: right 15px center !important;
    text-align: left;
}
}
/* RTL Fixes for Category Filter */
#product-compare.rtl .category-filter select {
    background-position: left 15px center !important;
    padding: 0px 15px 0px 50px !important;
    text-align: right !important;
}

#product-compare.rtl .category-filter select option {
    direction: rtl;
    text-align: right;
}

/* Long Text Toggle Styles */
.long-text-wrapper .full-text {
    display: none;
}
.long-text-wrapper.expanded .short-text {
    display: none;
}
.long-text-wrapper.expanded .full-text {
    display: inline;
}
.toggle-text-btn {
    display: inline-block;
    margin-left: 5px;
    margin-right: 5px; /* For RTL support */
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    font-weight: bold;
    text-decoration: underline;
}
.toggle-text-btn:hover {
    color: #2980b9;
}

/* --- Feature: Highlight Differences --- */
.comparison-table .attributes-header {
    background: #f8f9fa;
    font-weight: bold;
    text-align: center;
}

.comparison-table .highlight-diff td {
    background-color: #eaf5ff !important;
}

.comparison-table tr:nth-child(even).highlight-diff td {
    background-color: #ddecf8 !important;
}

/* --- Feature: Add to Cart Button --- */
.product-header .add-to-cart-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: #27ae60;
    color: #ffffff !important;
    text-decoration: none;
    font-weight: bold;
    border-radius: 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-align: center;
    border: none;
    cursor: pointer;
}

.product-header .add-to-cart-btn:hover {
    background-color: #229954;
    transform: translateY(-2px);
    color: #ffffff !important;
}

/* --- Feature: Sticky Header & Compact Layout --- */

/* Sticky Behavior */
.comparison-table thead th {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0px; /* Adjust this value if you have a sticky top admin bar. 0px if you don't. */
    z-index: 10;
}

/* Wrapper for Brand and Rating */
#product-compare .product-meta-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap; /* Allows wrapping on small screens if needed */
}

/* --- Enhancement: Optimize Product Header Padding --- */
.comparison-table thead th:not(:first-child) {
    padding-top: 5px !important;
    padding-bottom: 15px !important;
}

/* --- Feature: Add to Compare Button on Single Product Page --- */
.apc-add-to-compare-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    border: 2px solid #3498db;
    color: #3498db;
    background-color: transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.apc-add-to-compare-btn:hover {
    background-color: #3498db;
    color: #ffffff;
}

/* Style for when the product is already added */
.apc-add-to-compare-btn.added {
    background-color: #2ecc71;
    border-color: #2ecc71;
    color: #ffffff;
}

.apc-add-to-compare-btn.added:hover {
    background-color: #27ae60;
    border-color: #27ae60;
}
/* --- Feature: New Accordion Comparison Page --- */

.apc-accordion-compare {
    margin-top: 30px;
}

.apc-accordion-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}

.apc-accordion-header {
    padding: 15px 20px;
    background-color: #f9f9f9;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    transition: background-color 0.3s ease;
}

.apc-accordion-item.active .apc-accordion-header,
.apc-accordion-header:hover {
    background-color: #f0f0f0;
}

.apc-accordion-header .apc-product-count {
    font-size: 14px;
    font-weight: 400;
    color: #777;
    margin: 0 10px;
}

.apc-accordion-header .apc-accordion-icon {
    font-size: 24px;
    font-weight: bold;
}

.apc-accordion-content {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: none; /* Hidden by default */
}

.apc-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.apc-product-card {
    border: 1px solid #eee;
    border-radius: 8px;
    text-align: center;
    padding: 10px;
    position: relative;
}

.apc-product-card .apc-product-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
}

#product-compare.rtl .apc-product-card .apc-product-checkbox {
    right: auto;
    left: 10px;
}

.apc-product-card .apc-product-image img {
    max-width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 10px;
}

.apc-product-card .apc-product-name {
    font-weight: 600;
    margin-bottom: 10px;
    height: 40px; /* To align heights */
}

.apc-product-card .apc-product-price {
    font-weight: bold;
    color: #27ae60;
}

.apc-category-actions {
    text-align: center;
    margin-bottom: 20px;
}

.apc-compare-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    border: none;
    background-color: #3498db;
    color: white;
    transition: background-color 0.3s ease;
}

.apc-compare-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.apc-compare-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.apc-new-compare-empty {
    text-align: center;
    padding: 50px 20px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
}
/* --- Enhancement: Go to Shop Button on Empty Compare Page --- */
.apc-go-to-shop-btn {
    display: inline-block;
    margin-top: 25px;
    padding: 12px 30px;
    background-color: #3498db;
    color: #ffffff !important;
    text-decoration: none;
    font-weight: bold;
    border-radius: 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.apc-go-to-shop-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}
/* --- Feature: Clear/Reset Button --- */
body .apc-page-actions {
    text-align: right;
    margin-bottom: 20px;
}

body #product-compare.rtl .apc-page-actions,
body .apc-accordion-compare.rtl .apc-page-actions {
    text-align: left;
}

body .apc-clear-compare-list-btn {
    padding: 8px 20px;
    background-color: #e74c3c !important;
    color: white !important;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

body .apc-clear-compare-list-btn:hover {
    background-color: #c0392b !important;
}
/* --- Feature: Equal Column Widths --- */
.comparison-table th:not(:first-child) {
    width: 40%;
}