/**
 * Product Comparison Tool Styles
 *
 * @package Xpert_Energy
 * @since 4.2.0
 */

/* ==========================================================================
   COMPARE BUTTON — BASE (JS selector hook, minimal reset)
   Product card icons: .xpertenergy-compare-icon in product-cards.css
   Single product:     .xpert-compare-btn-single below
   ========================================================================== */

.xpert-compare-btn {
    cursor: pointer;
    transition: all 0.25s ease;
}

.xpert-compare-btn.active .xpert-icon {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Single Product Page Compare Button */
.xe-compare-action {
    margin-top: 12px;
}

.xpert-compare-btn-single {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1.5px solid #ddd;
    color: #666;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 0;
}

.xpert-compare-btn-single .xpert-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

.xpert-compare-btn-single:hover {
    border-color: #fb8104;
    color: #fb8104;
}

.xpert-compare-btn-single:hover .xpert-icon {
    transform: scale(1.15);
}

.xpert-compare-btn-single.active {
    background: #fb8104;
    border-color: #fb8104;
    color: #fff;
}

/* ==========================================================================
   FLOATING COMPARISON BAR
   ========================================================================== */

.xpert-compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    z-index: 9998;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.3);
}

.xpert-compare-bar.active {
    transform: translateY(0);
}

.xpert-compare-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.xpert-compare-bar-left {
    display: flex;
    align-items: center;
    gap: 25px;
}

.xpert-compare-bar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.xpert-compare-bar-title i {
    color: #fb8104;
    font-size: 18px;
}

.xpert-compare-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    background: #fb8104;
    color: #fff;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
}

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

.xpert-compare-item {
    width: 55px;
    height: 55px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}

.xpert-compare-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.xpert-compare-item-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: #dc2626;
    border: 2px solid #1a1a1a;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.xpert-compare-item:hover .xpert-compare-item-remove {
    opacity: 1;
}

.xpert-compare-item-remove:hover {
    background: #b91c1c;
    transform: scale(1.1);
}

.xpert-compare-item-empty {
    border: 2px dashed #444;
    background: transparent;
}

.xpert-compare-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.xpert-compare-clear {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 2px solid #444;
    color: #888;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.xpert-compare-clear:hover {
    border-color: #dc2626;
    color: #dc2626;
}

.xpert-compare-view-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fb8104;
    border: none;
    color: #fff;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.xpert-compare-view-btn:hover:not(:disabled) {
    background: #e06a00;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(251, 129, 4, 0.4);
}

.xpert-compare-view-btn:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ==========================================================================
   COMPARISON MODAL
   ========================================================================== */

.xpert-compare-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    overflow-y: auto;
}

.xpert-compare-modal.active {
    display: block;
}

.xpert-compare-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.xpert-compare-modal-content {
    position: relative;
    max-width: 1100px;
    margin: 30px auto;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xpert-compare-modal-header {
    background: linear-gradient(135deg, #fb8104 0%, #e06a00 100%);
    color: #fff;
    padding: 25px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.xpert-compare-modal-header h2 {
    font-family: 'Unbounded', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.xpert-compare-modal-header h2 i {
    font-size: 24px;
    color: #fff;
}

.xpert-compare-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: all 0.3s ease;
}

.xpert-compare-modal-close:hover {
    background: #fff;
    color: #fb8104;
}

.xpert-compare-modal-body {
    padding: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Loading State */
.xpert-compare-loading {
    padding: 60px;
    text-align: center;
    color: #666;
}

.xpert-compare-loading i {
    font-size: 40px;
    color: #fb8104;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   COMPARISON TABLE
   ========================================================================== */

.xpert-compare-table-wrapper {
    overflow-x: auto;
}

.xpert-compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.xpert-compare-table th,
.xpert-compare-table td {
    padding: 18px 20px;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

/* Label Column */
.xpert-compare-label-cell {
    background: #1a1a1a !important;
    color: #fff !important;
    font-family: 'Unbounded', sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left !important;
    width: 180px;
    min-width: 180px;
}

.xpert-compare-label {
    background: #fafafa;
    text-align: left !important;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.xpert-compare-label i {
    color: #fb8104;
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* Product Header Cell */
.xpert-compare-product-cell {
    background: #f8f8f8;
    padding: 25px 15px !important;
    min-width: 200px;
}

.xpert-compare-product-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.xpert-compare-product-image {
    display: block;
}

.xpert-compare-product-image img {
    max-height: 120px;
    max-width: 150px;
    object-fit: contain;
    border-radius: 10px;
    transition: transform 0.3s ease;
}

.xpert-compare-product-image:hover img {
    transform: scale(1.05);
}

.xpert-compare-product-info {
    text-align: center;
}

.xpert-compare-product-category {
    display: block;
    font-size: 11px;
    color: #fb8104;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    font-weight: 700;
}

.xpert-compare-product-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.xpert-compare-product-name:hover {
    color: #fb8104;
}

.xpert-compare-product-price {
    font-family: 'Unbounded', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #fb8104;
}

.xpert-compare-product-price del {
    color: #999;
    font-size: 13px;
    font-weight: 400;
}

.xpert-compare-product-price ins {
    text-decoration: none;
}

/* Data Cells */
.xpert-compare-table tbody td:not(.xpert-compare-label) {
    font-size: 15px;
    color: #333;
    position: relative;
}

/* Best Value Highlight */
.xpert-compare-best {
    background: #ecfdf5 !important;
}

.xpert-best-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #22c55e;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    margin-left: 8px;
    font-weight: 700;
}

/* Row Hover */
.xpert-compare-table tbody tr:hover td {
    background: #fff9f5;
}

.xpert-compare-table tbody tr:hover td.xpert-compare-label {
    background: #f5f5f5;
}

.xpert-compare-table tbody tr:hover td.xpert-compare-best {
    background: #dcfce7;
}

/* Action Row */
.xpert-compare-action-row td {
    padding: 25px 15px !important;
    border-bottom: none;
}

.xpert-compare-buy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fb8104;
    color: #fff !important;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.xpert-compare-buy-btn:hover {
    background: #000;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 991px) {
    .xpert-compare-bar-inner {
        flex-wrap: wrap;
        padding: 15px 20px;
    }
    
    .xpert-compare-bar-left {
        flex-wrap: wrap;
    }
    
    .xpert-compare-text,
    .xpert-compare-text-products {
        display: none;
    }
    
    .xpert-compare-items {
        gap: 8px;
    }
    
    .xpert-compare-item {
        width: 45px;
        height: 45px;
    }
    
    .xpert-compare-clear span {
        display: none;
    }
    
    .xpert-compare-view-btn span {
        display: none;
    }
}

@media (max-width: 768px) {
    .xpert-compare-modal-content {
        margin: 10px;
        border-radius: 15px;
    }
    
    .xpert-compare-modal-header {
        padding: 20px;
    }
    
    .xpert-compare-modal-header h2 {
        font-size: 18px;
    }
    
    .xpert-compare-table th,
    .xpert-compare-table td {
        padding: 12px 10px;
        font-size: 13px;
    }
    
    .xpert-compare-label-cell,
    .xpert-compare-label {
        width: 120px;
        min-width: 120px;
        font-size: 12px;
    }
    
    .xpert-compare-product-image img {
        max-height: 80px;
    }
    
    .xpert-compare-product-name {
        font-size: 12px;
    }
    
    .xpert-compare-product-price {
        font-size: 14px;
    }
    
    .xpert-compare-buy-btn {
        padding: 10px 15px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .xpert-compare-bar-inner {
        flex-direction: column;
        gap: 15px;
    }
    
    .xpert-compare-bar-left {
        width: 100%;
        justify-content: space-between;
    }
    
    .xpert-compare-bar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .xpert-compare-view-btn {
        flex: 1;
        justify-content: center;
    }
    
    .xpert-compare-view-btn span {
        display: inline;
    }
}

/* ==========================================================================
   INLINE COMPARE TAB (Single Product Page)
   ========================================================================== */

.xe-inline-compare {
    padding: 5px 0 0;
}

/* Slots Container */
.xe-inline-compare-slots {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* Individual Slot */
.xe-compare-slot {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    background: #f9f9f9;
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 16px;
    position: relative;
    transition: border-color 0.25s ease;
}

/* Locked Slot (current product) */
.xe-compare-slot-locked {
    border-color: #fb8104;
    background: #fff9f3;
}

.xe-compare-slot-locked::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 16px;
    right: 16px;
    height: 3px;
    background: #fb8104;
    border-radius: 0 0 3px 3px;
}

.xe-compare-slot-product {
    display: flex;
    align-items: center;
    gap: 14px;
}

.xe-compare-slot-product img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.xe-compare-slot-info {
    flex: 1;
    min-width: 0;
}

.xe-compare-slot-info strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xe-compare-slot-info span {
    font-size: 13px;
    color: #fb8104;
    font-weight: 600;
}

/* Selector Slot */
.xe-compare-slot-selector {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* Search Input */
.xe-compare-search-wrap {
    flex: 1;
    position: relative;
}

.xe-compare-search {
    width: 100%;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: #fff;
    transition: border-color 0.25s ease;
    box-sizing: border-box;
}

.xe-compare-search::placeholder {
    color: #999;
    font-weight: 400;
}

.xe-compare-search:focus {
    outline: none;
    border-color: #fb8104;
    box-shadow: 0 0 0 3px rgba(251, 129, 4, 0.1);
}

/* Search Results Dropdown */
.xe-compare-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 2px solid #fb8104;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.xe-search-hint {
    padding: 12px 14px;
    font-size: 13px;
    color: #999;
    font-style: italic;
}

.xe-search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
    font-family: inherit;
}

.xe-search-result-item:last-child {
    border-bottom: none;
}

.xe-search-result-item:hover {
    background: #fff8f0;
}

.xe-search-result-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.xe-search-result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.xe-search-result-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xe-search-result-price {
    font-size: 12px;
    color: #fb8104;
    font-weight: 500;
}

/* Selected Product Display (replaces search input after selection) */
.xe-compare-selected {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #fff;
    border: 2px solid #fb8104;
    border-radius: 8px;
    position: relative;
}

.xe-compare-selected img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.xe-compare-selected .xe-compare-slot-info {
    flex: 1;
    min-width: 0;
}

.xe-compare-selected .xe-compare-slot-info strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xe-compare-selected .xe-compare-slot-info span {
    font-size: 12px;
    color: #fb8104;
}

.xe-compare-slot-clear {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.xe-compare-slot-clear:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

.xe-compare-slot-clear .xpert-icon {
    width: 10px;
    height: 10px;
}

/* Remove Slot Button */
.xe-compare-slot-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
}

.xe-compare-slot-remove:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

.xe-compare-slot-remove .xpert-icon {
    width: 12px;
    height: 12px;
}

/* Actions (Add Another) */
.xe-inline-compare-actions {
    margin-bottom: 20px;
}

.xe-compare-add-slot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 2px dashed #ddd;
    color: #666;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.xe-compare-add-slot .xe-icon-plus {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.xe-compare-add-slot:hover {
    border-color: #fb8104;
    color: #fb8104;
}

.xe-compare-add-slot .xpert-icon {
    width: 14px;
    height: 14px;
}

/* Empty State */
.xe-inline-compare-empty {
    text-align: center;
    padding: 50px 20px;
    color: #999;
}

.xe-inline-compare-empty .xpert-icon {
    width: 40px;
    height: 40px;
    color: #ddd;
    margin-bottom: 12px;
}

.xe-inline-compare-empty p {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

/* Loading State */
.xe-inline-compare-loading {
    text-align: center;
    padding: 50px 20px;
    color: #666;
}

.xe-inline-compare-loading .xpert-icon-spinner {
    width: 32px;
    height: 32px;
    color: #fb8104;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.xe-inline-compare-loading p {
    font-size: 14px;
    margin: 0;
}

/* Result Table inside tab */
.xe-inline-compare-result .xpert-compare-table-wrapper {
    border: 1px solid #eee;
    border-radius: 12px;
    overflow-x: auto;
}

/* Inline Compare Responsive */
@media (max-width: 768px) {
    .xe-inline-compare-slots {
        flex-direction: column;
    }

    .xe-compare-slot {
        max-width: none;
        min-width: 0;
    }

    .xe-inline-compare-empty {
        padding: 35px 15px;
    }

    .xe-inline-compare-empty .xpert-icon {
        width: 32px;
        height: 32px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .xpert-compare-bar,
    .xpert-compare-modal-close,
    .xpert-compare-buy-btn {
        display: none !important;
    }
    
    .xpert-compare-modal {
        position: static;
        display: block;
    }
    
    .xpert-compare-modal-backdrop {
        display: none;
    }
    
    .xpert-compare-modal-content {
        box-shadow: none;
        margin: 0;
    }
}
