/**
 * Latest Products Section
 * بخش جدیدترین محصولات با قابلیت تغییر نمایش
 */

/* Section Header with View Toggle */
.latest-products-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.latest-products-section .section-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.view-toggle__btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-toggle__btn:hover {
    color: var(--primary);
    background: var(--primary-50);
}

.view-toggle__btn.is-active {
    background: var(--primary);
    color: #fff;
}

.view-toggle__btn i {
    width: 18px;
    height: 18px;
}

/* View Toggle Tooltip */
.view-toggle__btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--text-primary);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 20;
}

.view-toggle__btn[data-tooltip]::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 20;
}

.view-toggle__btn:hover[data-tooltip]::after,
.view-toggle__btn:hover[data-tooltip]::before {
    opacity: 1;
    visibility: visible;
}

/* Grid Container */
.latest-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    transition: all 0.3s ease;
}

/* 3 Column View (Shop Page) */
.latest-products-grid.view-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 2 Column View */
.latest-products-grid.view-2 {
    grid-template-columns: repeat(2, 1fr);
}

.latest-products-grid.view-2 .latest-card {
    flex-direction: row;
}

.latest-products-grid.view-2 .latest-card__image {
    width: 200px;
    flex-shrink: 0;
}

.latest-products-grid.view-2 .latest-card__content {
    flex: 1;
}

.latest-products-grid.view-2 .latest-card__desc {
    display: block;
}

/* Latest Card */
.latest-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: border-color 0.3s ease;
}

.latest-card:hover {
    border-color: var(--accent);
}

/* Discount Badge */
.latest-card__badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--danger);
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    z-index: 2;
}

/* Product Image */
.latest-card__image {
    position: relative;
    background: var(--bg-body);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.latest-card__image img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.latest-card:hover .latest-card__image img {
    transform: scale(1.05);
}

/* Quick Actions - Vertical on top-left corner */
.latest-card__actions {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.latest-card__icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.latest-card__icon-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.latest-card__icon-btn.is-active {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* Tooltip - Right position for vertical buttons */
.latest-card__icon-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    padding: 6px 12px;
    background: var(--text-primary);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 20;
}

.latest-card__icon-btn[data-tooltip]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(100% + 2px);
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 20;
}

.latest-card__icon-btn:hover[data-tooltip]::after,
.latest-card__icon-btn:hover[data-tooltip]::before {
    opacity: 1;
    visibility: visible;
}

/* Content */
.latest-card__content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

/* Title */
.latest-card__title {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    line-height: 1.6;
}

.latest-card__title a {
    color: var(--text-primary);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.latest-card__title a:hover {
    color: var(--accent);
}

/* Description - Hidden by default, shown in 2-col view */
.latest-card__desc {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

/* Price */
.latest-card__price {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.latest-card__price-new,
.latest-card__price-current {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.latest-card__price-old {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: line-through;
}

/* Stock Status */
.latest-card__stock {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-right: auto;
}

.latest-card__stock.in-stock {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.latest-card__stock.out-of-stock {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Action Button - Same style as sale card */
.latest-card__action {
    margin-top: auto;
}

.latest-card__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-50) !important;
    color: var(--primary) !important;
    border: 1px solid var(--primary-light) !important;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.latest-card__btn:hover {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

.latest-card__btn i {
    transition: transform 0.3s ease;
}

.latest-card__btn:hover i {
    transform: scale(1.1);
}

.latest-card__stock-out {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-body);
    color: var(--text-muted);
    border-radius: var(--radius);
    font-size: 13px;
    text-align: center;
}

/* Responsive */
@media (max-width: 1023px) {
    .latest-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .latest-products-grid.view-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .latest-products-grid.view-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .latest-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .latest-products-grid.view-2 {
        grid-template-columns: 1fr;
    }

    .latest-products-grid.view-2 .latest-card {
        flex-direction: column;
    }

    .latest-products-grid.view-2 .latest-card__image {
        width: 100%;
    }

    .view-toggle {
        display: none;
    }
}

@media (max-width: 480px) {
    .latest-products-grid {
        grid-template-columns: 1fr;
    }
}


/* Load More Button */
.load-more-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.load-more-btn {
    min-width: 200px;
    gap: 10px;
}

.load-more-btn .btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton Loading */
.latest-products-skeleton {
    margin-top: 20px;
}

.skeleton-card {
    pointer-events: none;
}

.skeleton-box {
    background: linear-gradient(90deg, var(--bg-body) 25%, var(--bg-hover) 50%, var(--bg-body) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeletonShimmer 1.5s infinite;
}

.skeleton-image {
    width: 100%;
    height: 160px;
}

.skeleton-title {
    height: 20px;
    width: 80%;
}

.skeleton-price {
    height: 24px;
    width: 50%;
}

.skeleton-btn {
    height: 42px;
    width: 100%;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}