/* استایل‌های اختصاصی برای صفحه سبد خرید (cart.html) - بازنویسی کامل */

.cart-section {
    padding: 60px 20px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    margin-top: 40px;
    position: relative;
    overflow: hidden;
}

.cart-page-title {
    font-size: 2.8rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 40px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.cart-page-title i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

/* Decorative elements for cart page */
.decorative-element {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%),
                rgba(var(--primary-color), 0.05);
    backdrop-filter: blur(5px);
    animation: pulseScale 8s infinite ease-in-out;
    z-index: 0;
}

.decorative-element.shape-1 {
    width: 280px;
    height: 280px;
    top: -50px;
    left: -100px; /* In RTL, left side */
    animation-delay: 0s;
}

.decorative-element.shape-2 {
    width: 200px;
    height: 200px;
    bottom: -80px;
    right: -70px; /* In RTL, right side */
    animation-delay: 4s;
    opacity: 0.7;
}

/* Main cart content layout */
.cart-content-wrapper {
    display: flex;
    flex-direction: row-reverse; /* Items list on right, summary on left */
    gap: 40px;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

.cart-items-list {
    flex: 2; /* Takes more space */
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.empty-cart-message {
    text-align: center;
    font-size: 1.5rem;
    color: var(--secondary-color);
    padding: 50px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.empty-cart-message i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #ccc;
}


/* Cart Item Card - DESKTOP LAYOUT (Default) */
.cart-item {
    display: flex;
    /* ترتیب در دسکتاپ: عکس (راست) -> جزئیات (وسط) -> کنترل‌ها (چپ) */
    flex-direction: row; /* در RTL: آیتم‌ها از چپ به راست چیده می‌شوند (عکس، جزئیات، کنترل) */
    align-items: center; /* تراز عمودی عناصر */
    justify-content: space-between; /* فاصله بین گروه‌های اصلی */
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
    opacity: 0; /* For animated entry */
    transform: translateX(20px);
    position: relative; /* برای دکمه حذف موبایل (که در دسکتاپ پنهان است) */
}

.cart-item.animated {
    animation: fadeInRight 0.6s ease-out forwards;
}

.cart-item.removing {
    animation: fadeOutLeft 0.5s ease-out forwards; /* Animation for removal */
}

.cart-item-image {
    width: 90px;
    height: 90px;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-right: 0; 
    margin-left: 15px; /* فضای از متن در LTR */
    flex-shrink: 0; 
    order: 1; /* ترتیب در دسکتاپ: عکس (راست) */
}
.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-main-details { /* نام جدید برای کانتینر نام و قیمت واحد */
    flex-grow: 1; 
    text-align: right; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 0; 
    margin-right: auto; /* به سمت چپ متمایل شود */
    order: 2; /* ترتیب در دسکتاپ: جزئیات (وسط) */
}
.cart-item-main-details h3 {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 5px;
    font-weight: 700;
}
.cart-item-main-details .item-price-per-unit {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 0;
}
/* قیمت کل برای نمایش فقط در موبایل (در دسکتاپ مخفی است) */
.item-total-price-mobile-only {
    display: none; 
}


/* Container for price and delete button (desktop version) */
.cart-item-desktop-price-delete {
    display: flex; /* Flexbox برای قیمت و حذف در دسکتاپ */
    align-items: center;
    flex-direction: row-reverse; /* دکمه حذف (راست) و قیمت کلی (چپ) */
    gap: 15px; 
    flex-shrink: 0; 
    margin-left: 0; 
    order: 3; /* ترتیب در دسکتاپ: این گروه (چپ) */
}
.cart-item-desktop-price-delete .cart-item-total-price {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 700;
    white-space: nowrap; 
}
.cart-item-desktop-price-delete .remove-item-btn {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease, transform 0.2s ease;
}
.cart-item-desktop-price-delete .remove-item-btn:hover {
    color: #c82333;
    transform: scale(1.1);
}

/* دکمه حذف مخصوص موبایل (در دسکتاپ مخفی است) */
.remove-item-btn-mobile {
    display: none; /* در دسکتاپ مخفی است */
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.4rem; 
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease, transform 0.2s ease;
}
.remove-item-btn-mobile:hover {
    color: #c82333;
    transform: scale(1.1);
}



/* Order Summary Section */
.cart-summary {
    flex: 1; /* Takes less space */
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cart-summary h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.summary-details {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    color: var(--text-color);
    padding-bottom: 5px;
    border-bottom: 1px dashed #eee;
}

.summary-line span:first-child {
    font-weight: bold;
}

.summary-line.total-line {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: none; /* No border for total */
    padding-top: 10px;
}

.summary-line.total-line span:last-child {
    font-size: 1.6rem; /* Larger total price */
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.checkout-btn {
    width: 100%;
}
.continue-shopping-btn {
    width: 100%;
}
.continue-shopping-btn i {
    margin-right: 8px; /* Space for icon in RTL */
    transform: rotateY(180deg); /* Flip arrow for RTL */
}

/* Animations (copied from style.css for independence) */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOutLeft { /* New animation for removing items */
    from { opacity: 1; transform: translateX(0); height: auto; padding: 15px; }
    to { opacity: 0; transform: translateX(-50px); height: 0; padding: 0; margin-bottom: 0; border: none; } /* Shrink and hide */
}

@keyframes pulseScale { /* From decorative elements */
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 0.4; }
    100% { transform: scale(0.8); opacity: 0.6; }
}


/* Responsive adjustments for cart page */
@media (max-width: 992px) {
    .cart-content-wrapper {
        flex-direction: column; /* Stack vertically on tablets/mobiles */
        align-items: center;
    }
    .cart-items-list, .cart-summary {
        width: 100%;
        max-width: 600px; /* Constrain width for better readability */
    }
    .cart-summary {
        margin-top: 30px;
    }
}

/* Cart Item Card - MOBILE LAYOUT (Specific to phone sizes) */
@media (max-width: 768px) {
    .cart-page-title {
        font-size: 2.2rem;
        gap: 10px;
    }
    .cart-page-title i {
        font-size: 2rem;
    }
    .cart-item {
        flex-direction: column; /* چیدمان ستونی: عکس بالا، بقیه زیر آن */
        text-align: center;
        align-items: center; /* همه عناصر وسط‌چین شوند */
        padding-bottom: 20px; 
        position: relative; /* برای موقعیت‌یابی دکمه حذف absolute */
        padding-top: 20px; /* فضای بالا برای دکمه حذف */
    }
    
    .cart-item-image {
        margin: 0 0 10px 0; /* فاصله از پایین */
        order: 1; /* عکس در بالا */
    }
    .cart-item-main-details {
        text-align: center; 
        order: 2; /* نام محصول، قیمت واحد و قیمت کل (موبایلی) */
        margin: 0; /* حذف مارجین‌های اضافی */
    }
    .cart-item-main-details h3,
    .cart-item-main-details .item-price-per-unit,
    .cart-item-main-details .item-quantity { /* اگر تعداد اضافه شود */
        text-align: center;
        width: 100%;
    }
    
    .cart-item-desktop-price-delete { /* بخش قیمت و حذف دسکتاپ */
        display: none; /* در موبایل مخفی می‌شود */
    }
    .cart-item-total-price { /* قیمت کلی در دسکتاپ */
        display: none; /* مخفی می‌شود */
    }
    .item-total-price-mobile-only { /* قیمت کلی فقط برای موبایل */
        display: block; /* نمایش داده می‌شود */
        font-size: 1.1rem;
        color: var(--primary-color);
        font-weight: 700;
        margin-top: 10px;
    }

    /* دکمه حذف مخصوص موبایل */
    .remove-item-btn-mobile {
        display: block; /* نمایش داده می‌شود */
        position: absolute;
        top: 10px;
        right: 10px; /* در RTL، گوشه بالا-راست */
        z-index: 10;
        font-size: 1.2rem; /* اندازه مناسب برای موبایل */
    }
    .remove-item-btn-mobile i {
        margin: 0; /* آیکون بدون متن اضافی */
    }

    .summary-line {
        font-size: 1rem;
    }
    .summary-line.total-line {
        font-size: 1.2rem;
    }
    .summary-line.total-line span:last-child {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .cart-section {
        padding: 30px 15px;
    }
    .cart-page-title {
        font-size: 1.8rem;
    }
    .cart-page-title i {
        font-size: 1.6rem;
    }
    .cart-item-image {
        width: 80px;
        height: 80px;
    }
    .cart-item-main-details h3 {
        font-size: 1.0rem;
    }
    .cart-item-main-details .item-price-per-unit {
        font-size: 0.85rem;
    }
    .item-total-price-mobile-only {
        font-size: 1.0rem;
    }
    .remove-item-btn-mobile {
        font-size: 1.0rem; 
    }
    .btn-lg {
        font-size: 1rem;
        padding: 12px 20px;
    }
}