/**
 * Wishlist Page Styles - Horizontal Card Layout
 * Modern horizontal card design with inline variation selection
 */

/* ============================================
   Wishlist Section
   ============================================ */
.wishlist-section {
    padding: 60px 0;
    min-height: 400px;
}

/* ============================================
   Wishlist Header
   ============================================ */
.wishlist-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.wishlist-count {
    font-size: 18px;
    font-weight: 600;
    color: #24262b;
    margin: 0;
}

/* ============================================
   Wishlist Items List
   ============================================ */
.wishlist-items-wrapper {
    margin-top: 20px;
}

.wishlist-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================
   Wishlist Item (Horizontal Card)
   ============================================ */
.wishlist-item {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1; /* Base z-index */
}

/* Increase z-index when dropdown is open */
.wishlist-item:has(.nice-select.open) {
    z-index: 10002;
}

/* Fallback for browsers that don't support :has() - handled by JS */
.wishlist-item.dropdown-open {
    z-index: 10002;
}

.wishlist-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #24262b;
}

.wishlist-item.removing {
    opacity: 0.5;
    transform: scale(0.98);
    pointer-events: none;
}

/* Item Image */
.wishlist-item-image {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f8f8;
}

.wishlist-item-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.wishlist-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.wishlist-item:hover .wishlist-item-image img {
    transform: scale(1.05);
}

/* Sale Badge */
.wishlist-item-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #d32f2f;
    color: #fff;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
    z-index: 2;
}

/* Item Content */
.wishlist-item-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wishlist-item-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wishlist-item-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.wishlist-item-title a {
    color: #24262b;
    text-decoration: none;
    transition: color 0.3s ease;
}

.wishlist-item-title a:hover {
    color: #d4af37; /* Golden color from theme */
}

.wishlist-item-price {
    font-size: 20px;
    font-weight: 700;
    color: #24262b;
}

.wishlist-item-price del {
    color: #999;
    font-size: 16px;
    font-weight: 400;
    margin-right: 8px;
}

.wishlist-item-price ins {
    text-decoration: none;
    color: #d32f2f;
}

/* Stock Status */
.wishlist-item-stock {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.wishlist-item-stock-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.wishlist-item-stock--in-stock .wishlist-item-stock-icon {
    background: #4caf50;
}

.wishlist-item-stock--on-backorder .wishlist-item-stock-icon {
    background: #ff9800;
}

.wishlist-item-stock--out-of-stock .wishlist-item-stock-icon {
    background: #d32f2f;
}

.wishlist-item-stock-text {
    color: #666;
}

.wishlist-item-stock--in-stock .wishlist-item-stock-text {
    color: #4caf50;
}

.wishlist-item-stock--on-backorder .wishlist-item-stock-text {
    color: #ff9800;
}

.wishlist-item-stock--out-of-stock .wishlist-item-stock-text {
    color: #d32f2f;
}

/* Variation Selectors */
.wishlist-item-variations {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.wishlist-item-variation-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    z-index: 1; /* Base z-index, will be increased when dropdown is open */
}

.wishlist-item-variation-label {
    font-size: 13px;
    font-weight: 600;
    color: #24262b;
    margin: 0;
}

.wishlist-item-variation-select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    color: #24262b;
    cursor: pointer;
    transition: border-color 0.3s ease;
    max-width: 250px;
}

.wishlist-item-variation-select:hover,
.wishlist-item-variation-select:focus {
    border-color: #24262b;
    outline: none;
}

.wishlist-item-variation-select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.wishlist-item-variation-select option:disabled {
    color: #999;
    background-color: #f5f5f5;
}

/* Variation Info */
.wishlist-item-variation-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f8f8;
    border-radius: 4px;
    font-size: 14px;
}

.wishlist-item-variation-price {
    font-weight: 700;
    color: #24262b;
    margin-right: 12px;
}

.wishlist-item-variation-stock {
    font-size: 13px;
    color: #666;
}

/* Item Actions */
.wishlist-item-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    min-width: 200px;
}

/* Quantity Selector */
.wishlist-item-quantity {
    display: flex;
    align-items: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
    max-width: 120px;
}

.wishlist-item-qty-btn {
    width: 36px;
    height: 40px;
    border: none;
    background: #f8f8f8;
    color: #24262b;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wishlist-item-qty-btn:hover:not(:disabled) {
    background: #24262b;
    color: #fff;
}

.wishlist-item-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wishlist-item-qty-input {
    flex: 1;
    width: 100%;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #24262b;
    background: #fff;
    -moz-appearance: textfield;
    appearance: textfield;
}

.wishlist-item-qty-input::-webkit-outer-spin-button,
.wishlist-item-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wishlist-item-qty-input:focus {
    outline: none;
}

/* Add to Cart Button */
.wishlist-item-add-to-cart {
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-transform: capitalize;
    position: relative;
    transition: all 0.3s ease;
}

.wishlist-item-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wishlist-item-add-to-cart.loading {
    pointer-events: none;
}

.wishlist-item-add-to-cart-text {
    display: inline-block;
}

.wishlist-item-add-to-cart-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wishlist-item-add-to-cart-loader .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Success Message */
.wishlist-item-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #4caf50;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

.wishlist-item-success i {
    font-size: 16px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Remove Button */
.wishlist-item-remove {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
    flex-shrink: 0;
}

.wishlist-item-remove:hover {
    background: #d32f2f;
    border-color: #d32f2f;
    color: #fff;
    transform: scale(1.05);
}

.wishlist-item-remove.loading {
    pointer-events: none;
    opacity: 0.6;
}

.wishlist-item-remove i {
    font-size: 16px;
}

/* ============================================
   Empty Wishlist State
   ============================================ */
.wishlist-empty {
    padding: 80px 20px;
    text-align: center;
}

.wishlist-empty-content {
    max-width: 500px;
    margin: 0 auto;
}

.wishlist-empty-icon {
    font-size: 64px;
    color: #e5e5e5;
    margin-bottom: 24px;
}

.wishlist-empty-icon i {
    display: inline-block;
}

.wishlist-empty-title {
    font-size: 24px;
    font-weight: 600;
    color: #24262b;
    margin: 0 0 12px;
}

.wishlist-empty-text {
    font-size: 16px;
    color: #666;
    margin: 0 0 32px;
    line-height: 1.6;
}

.wishlist-empty-button {
    display: inline-block;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .wishlist-section {
        padding: 40px 0;
    }
    
    .wishlist-item {
        flex-direction: column;
        padding: 16px;
    }
    
    .wishlist-item-image {
        width: 100%;
        height: 200px;
    }
    
    .wishlist-item-actions {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .wishlist-item-quantity {
        max-width: 100px;
    }
    
    .wishlist-item-add-to-cart {
        flex: 1;
        margin: 0 12px;
    }
    
    .wishlist-item-remove {
        width: 48px;
        height: 48px;
    }
    
    .wishlist-item-variation-select {
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .wishlist-item-actions {
        flex-direction: column;
    }
    
    .wishlist-item-add-to-cart {
        margin: 0;
        width: 100%;
    }
    
    .wishlist-item-quantity {
        max-width: 100%;
    }
}

/* ============================================
   Loading States
   ============================================ */
.wishlist-items.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ============================================
   Animation for item appearance
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wishlist-item {
    animation: fadeInUp 0.4s ease forwards;
}

.wishlist-item:nth-child(1) { animation-delay: 0.05s; }
.wishlist-item:nth-child(2) { animation-delay: 0.1s; }
.wishlist-item:nth-child(3) { animation-delay: 0.15s; }
.wishlist-item:nth-child(n+4) { animation-delay: 0.2s; }

/* ============================================
   Nice Select Fixes for Wishlist
   ============================================ */

/* Ensure wishlist section and containers don't clip dropdowns */
.wishlist-section,
.wishlist-section .container,
.wishlist-items-wrapper,
.wishlist-items,
.wishlist-item,
.wishlist-item-content,
.wishlist-item-info,
.wishlist-item-variations,
.wishlist-item-variation-group {
    overflow: visible !important;
}

/* Fix for nice-select dropdown in wishlist */
.wishlist-section .nice-select {
    position: relative;
    /* NO z-index here - handled by parent .wishlist-item-variation-group */
}

/* When dropdown is open, increase parent z-index */
.wishlist-section .wishlist-item-variation-group:has(.nice-select.open) {
    z-index: 10001;
}

/* Fallback for browsers that don't support :has() */
.wishlist-section .wishlist-item-variation-group .nice-select.open {
    position: relative;
}

.wishlist-section .wishlist-item-variation-group .nice-select.open ~ * {
    position: relative;
}

/* Fix dropdown list - ensure it's visible and scrollable when open */
.wishlist-section .nice-select .list {
    position: absolute !important;
    /* NO z-index here - parent handles stacking */
    max-height: 240px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    min-width: 100% !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #e5e5e5 !important;
    border-radius: 4px !important;
    margin-top: 4px !important;
    background: #fff !important;
}

/* Hide dropdown list when nice-select is NOT open - HIGH SPECIFICITY */
.wishlist-section .wishlist-item-variation-group .nice-select:not(.open) .list,
.wishlist-section .nice-select.wishlist-item-variation-select:not(.open) .list {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: none !important;
    transform: scale(0.75) translateY(-21px) !important;
}

/* Show dropdown list when nice-select IS open - HIGH SPECIFICITY */
.wishlist-section .wishlist-item-variation-group .nice-select.open .list,
.wishlist-section .nice-select.wishlist-item-variation-select.open .list {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: block !important;
}

/* SimpleBar container styling */
.wishlist-section .nice-select .list[data-simplebar] {
    position: absolute !important;
    max-height: 240px !important;
}

/* SimpleBar content wrapper */
.wishlist-section .nice-select .list[data-simplebar] .simplebar-content-wrapper {
    overflow: auto;
    max-height: 240px;
}

/* SimpleBar content */
.wishlist-section .nice-select .list[data-simplebar] .simplebar-content {
    padding: 0;
}

/* Ensure all options are visible */
.wishlist-section .nice-select .list .option {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 40px !important;
    line-height: 40px !important;
    padding: 0 18px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
}

/* Mobile: Larger max-height for better UX */
@media (max-width: 768px) {
    .wishlist-section .nice-select .list {
        max-height: 250px !important;
    }
}

/* Desktop: More space for dropdown */
@media (min-width: 769px) {
    .wishlist-section .nice-select .list {
        max-height: 350px !important;
    }
}

/* Fix for variation group container - ensure dropdown can overflow */
.wishlist-item-variation-group {
    position: relative;
    z-index: 1;
}

.wishlist-item-variation-group .nice-select.open {
    z-index: 10001;
}

/* Ensure dropdown doesn't get clipped by parent containers */
.wishlist-item-variations {
    position: relative;
    z-index: 1;
}

/* Fix for when dropdown is near bottom of viewport - open upward */
.wishlist-section .nice-select.open.drop-up .list {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
    transform-origin: 50% 100% !important;
}

/* Scrollbar styling for dropdown - Fallback if SimpleBar is not available */
.wishlist-section .nice-select .list:not([data-simplebar-initialized])::-webkit-scrollbar {
    width: 6px;
}

.wishlist-section .nice-select .list:not([data-simplebar-initialized])::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.wishlist-section .nice-select .list:not([data-simplebar-initialized])::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.wishlist-section .nice-select .list:not([data-simplebar-initialized])::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* SimpleBar scrollbar styling for wishlist dropdowns */
.wishlist-section .nice-select .list[data-simplebar] .simplebar-scrollbar {
    right: 4px;
    width: 6px;
}

.wishlist-section .nice-select .list[data-simplebar] .simplebar-scrollbar::before {
    background: #888;
    border-radius: 3px;
    opacity: 0.6;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.wishlist-section .nice-select .list[data-simplebar] .simplebar-scrollbar:hover::before {
    opacity: 1;
    background: #555;
}

.wishlist-section .nice-select .list[data-simplebar] .simplebar-track {
    background: transparent;
    right: 0;
    width: 6px;
}

.wishlist-section .nice-select .list[data-simplebar] .simplebar-track.simplebar-vertical {
    top: 0;
    bottom: 0;
}

/* Mobile: Touch-friendly scrollbar */
@media (max-width: 768px) {
    .wishlist-section .nice-select .list[data-simplebar] .simplebar-scrollbar {
        width: 8px;
    }
    
    .wishlist-section .nice-select .list[data-simplebar] .simplebar-track {
        width: 8px;
    }
}

/* Ensure disabled options are still visible (just grayed out) */
.wishlist-section .nice-select .list .option.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
}

/* Fix for selected option visibility */
.wishlist-section .nice-select .list .option.selected {
    background-color: #f0f0f0 !important;
    font-weight: 600 !important;
}

/* Hover state for options */
.wishlist-section .nice-select .list .option:hover:not(.disabled) {
    background-color: #f8f8f8 !important;
}

/* Focus state for keyboard navigation */
.wishlist-section .nice-select .list .option.focus {
    background-color: #e8e8e8 !important;
}
