/**
 * Cart Styles
 * استایل‌های سبد خرید
 */

/* Global Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.12);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.15);
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Container */
.cart-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 2rem 0;
    position: relative;
    overflow: hidden;
}

.cart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* Header Section */
.cart-header {
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-medium);
    position: relative;
    overflow: hidden;
}

.cart-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

.cart-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cart-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

/* Cart Summary */
.cart-summary {
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.summary-item:last-child {
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1.2rem;
}

.summary-item .label {
    opacity: 0.9;
}

.summary-item .value {
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Cart Items */
.cart-items {
    margin-bottom: 2rem;
}

/* Cart Item */
.cart-item {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.cart-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.cart-item:hover::before {
    left: 100%;
}

.cart-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Product Image */
.product-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-light);
}

.product-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    transition: var(--transition);
}

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

/* Product Info */
.product-info {
    padding: 0.5rem 0;
}

.product-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.product-sku {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

.variant-info, .supplier-info {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.variant-label, .supplier-label {
    color: #7f8c8d;
    margin-left: 0.5rem;
}

.variant-value, .supplier-name {
    color: #2c3e50;
    font-weight: 500;
}

/* Price Info */
.price-info {
    text-align: center;
    padding: 0.5rem 0;
}

.current-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #27ae60;
    margin-bottom: 0.25rem;
}

.original-price {
    font-size: 1rem;
    color: #95a5a6;
    text-decoration: line-through;
    margin-bottom: 0.25rem;
}

.discount-badge {
    background: var(--danger-gradient);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

/* Quantity Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.quantity-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e9ecef;
    background: white;
    color: #6c757d;
    transition: var(--transition);
    font-size: 0.9rem;
}

.quantity-btn:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: scale(1.1);
}

.quantity-input {
    width: 60px;
    text-align: center;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    font-weight: 600;
    transition: var(--transition);
}

.quantity-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: none;
}

/* Total Price */
.total-price {
    text-align: center;
    padding: 0.5rem 0;
}

.total-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
    display: block;
}

/* Item Actions */
.item-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0;
}

.item-actions .btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.item-actions .btn:hover {
    transform: scale(1.1);
}

/* Cart Summary Section */
.cart-summary-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-medium);
    margin-top: 2rem;
}

.cart-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cart-actions .btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    transition: var(--transition);
}

.cart-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Final Summary */
.final-summary {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    padding-top: 0.75rem;
    border-top: 2px solid #e9ecef;
}

.summary-row .label {
    color: #6c757d;
}

.summary-row .value {
    font-weight: 600;
    color: #2c3e50;
}

.summary-row .value.discount {
    color: #e74c3c;
}

/* Empty Cart */
.empty-cart {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin: 2rem 0;
}

.empty-cart-icon {
    font-size: 4rem;
    color: #bdc3c7;
    margin-bottom: 1.5rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.empty-cart h4 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-weight: 600;
}

.empty-cart p {
    color: #7f8c8d;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-heavy);
}

.loading-spinner i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 1rem;
    display: block;
}

.loading-spinner span {
    color: #2c3e50;
    font-weight: 600;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    min-width: 300px;
    max-width: 400px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    animation: slideInRight 0.3s ease;
    border: none;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-notification .btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    margin-left: 1rem;
}

.toast-notification .btn-close:hover {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* مخفی کردن footer فقط در صفحه سبد خرید */
    body:has(.cart-container) > footer {
        display: none !important;
    }
    
    /* margin پایین فقط برای آیتم‌های سبد */
    .cart-container {
        padding: 0.5rem 0;
    }
    
    .cart-items {
        margin-bottom: 120px;
    }
    
    .cart-header {
        padding: 0.75rem;
        text-align: center;
        margin-bottom: 0.75rem;
    }
    
    .cart-header h1 {
        font-size: 1.1rem;
        margin-bottom: 0.15rem;
    }
    
    .cart-header h1 i {
        font-size: 0.9rem;
    }
    
    .cart-header p {
        font-size: 0.7rem;
    }
    
    .cart-summary {
        padding: 0.5rem;
    }
    
    .summary-item {
        font-size: 0.7rem;
        margin-bottom: 0.35rem;
    }
    
    .summary-item:last-child {
        font-size: 0.75rem;
    }
    
    .cart-items {
        margin-bottom: 0.75rem;
    }
    
    .cart-item {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
        border-radius: 8px;
    }
    
    /* چیدمان موبایل: عکس بالا، بقیه افقی */
    .cart-item .row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    
    /* سطر 1: عکس محصول - تمام عرض */
    .cart-item .col-md-2:first-child,
    .cart-item .col-sm-3:first-child {
        flex: 0 0 100%;
        max-width: 100%;
        display: flex;
        justify-content: center;
        padding: 0;
        margin-bottom: 0.4rem;
    }
    
    /* سطر 2: نام محصول - تمام عرض */
    .cart-item .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0;
        margin-bottom: 0.3rem;
    }
    
    /* سطر 3: قیمت، تعداد، جمع، حذف - در کنار هم */
    .cart-item .col-md-2:nth-child(3),
    .cart-item .col-sm-6:nth-child(3) {
        flex: 0 0 auto;
        max-width: none;
        padding: 0 0.2rem;
    }
    
    .cart-item .col-md-2:nth-child(4),
    .cart-item .col-sm-6:nth-child(4) {
        flex: 1 1 auto;
        max-width: none;
        padding: 0 0.2rem;
    }
    
    .cart-item .col-md-1:nth-child(5),
    .cart-item .col-sm-6:nth-child(5) {
        flex: 0 0 auto;
        max-width: none;
        padding: 0 0.2rem;
    }
    
    .cart-item .col-md-1:nth-child(6),
    .cart-item .col-sm-6:nth-child(6) {
        flex: 0 0 auto;
        max-width: none;
        padding: 0 0.2rem;
    }
    
    .product-image {
        width: 70px;
        margin: 0 auto;
    }
    
    .product-image img {
        height: 70px;
        width: 70px;
        object-fit: contain;
    }
    
    .product-info {
        padding: 0;
        text-align: right;
    }
    
    .product-name {
        font-size: 0.75rem;
        margin-bottom: 0.15rem;
        line-height: 1.2;
        font-weight: 600;
    }
    
    .product-sku {
        font-size: 0.6rem;
        margin-bottom: 0.1rem;
    }
    
    .variant-info, .supplier-info {
        font-size: 0.6rem;
        margin-bottom: 0.05rem;
    }
    
    .variant-info {
        display: inline-flex;
        align-items: center;
        gap: 0.2rem;
    }
    
    .supplier-info {
        display: inline-flex;
        align-items: center;
        gap: 0.2rem;
    }
    
    .price-info {
        padding: 0;
        text-align: center;
    }
    
    .current-price {
        font-size: 0.7rem;
        margin-bottom: 0;
        font-weight: 700;
    }
    
    .original-price {
        font-size: 0.6rem;
        margin-bottom: 0;
        display: none; /* مخفی کردن برای صرفه‌جویی در فضا */
    }
    
    .discount-badge {
        font-size: 0.55rem;
        padding: 0.1rem 0.25rem;
        display: none; /* مخفی کردن برای صرفه‌جویی در فضا */
    }
    
    .quantity-controls {
        gap: 0.25rem;
        padding: 0;
        justify-content: center;
    }
    
    .quantity-btn {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
        border-width: 1px;
        padding: 0;
    }
    
    .quantity-input {
        width: 32px;
        padding: 0.15rem;
        font-size: 0.65rem;
        border-width: 1px;
        text-align: center;
    }
    
    .total-price {
        padding: 0;
        text-align: center;
    }
    
    .total-amount {
        font-size: 0.7rem;
        font-weight: 700;
        display: block;
    }
    
    .total-amount + small {
        font-size: 0.55rem;
    }
    
    .item-actions {
        padding: 0;
        display: flex;
        justify-content: center;
    }
    
    .item-actions .btn {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
        padding: 0;
    }
    
    .cart-summary-section {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .final-summary {
        padding: 0.75rem;
    }
    
    .summary-row {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }
    
    .summary-row.total {
        font-size: 0.85rem;
        padding-top: 0.4rem;
    }
    
    .cart-actions {
        flex-direction: column;
        gap: 0.4rem;
    }
    
    .cart-actions .btn {
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* خلاصه و دکمه تسویه ثابت پایین صفحه */
    .cart-summary-section {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 0.75rem 1rem;
        margin: 0 !important;
        border-radius: 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        border-top: 3px solid #667eea;
    }
    
    .cart-summary-section .row {
        margin: 0;
    }
    
    .cart-summary-section .col-md-8 {
        display: none;
    }
    
    .cart-summary-section .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0;
    }
    
    .final-summary {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .final-summary .summary-row {
        font-size: 0.7rem;
        margin-bottom: 0.3rem;
    }
    
    .final-summary .summary-row.total {
        font-size: 0.85rem;
        padding-top: 0.3rem;
        border-top: 2px solid #667eea;
    }
    
    .final-summary .btn-primary {
        font-size: 0.85rem;
        padding: 0.65rem 1rem;
        font-weight: 700;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
}

@media (max-width: 576px) {
    .cart-container {
        padding: 0.4rem 0;
    }
    
    .cart-items {
        margin-bottom: 110px;
    }
    
    .cart-header {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .cart-header h1 {
        font-size: 0.9rem;
    }
    
    .cart-header h1 i {
        font-size: 0.75rem;
    }
    
    .cart-header p {
        font-size: 0.6rem;
    }
    
    .cart-summary {
        padding: 0.35rem;
    }
    
    .summary-item {
        font-size: 0.6rem;
        margin-bottom: 0.25rem;
    }
    
    .summary-item:last-child {
        font-size: 0.65rem;
    }
    
    .cart-items {
        margin-bottom: 0.5rem;
    }
    
    .cart-item {
        padding: 0.4rem;
        margin-bottom: 0.5rem;
        border-radius: 6px;
    }
    
    .cart-item .row {
        gap: 0.3rem;
    }
    
    /* چیدمان بهینه: همه المان‌ها بعد از عکس و نام، در یک سطر */
    .cart-item .col-md-2:nth-child(3),
    .cart-item .col-md-2:nth-child(4),
    .cart-item .col-md-1:nth-child(5),
    .cart-item .col-md-1:nth-child(6) {
        flex: 0 0 auto;
        padding: 0;
    }
    
    .product-image {
        width: 60px;
    }
    
    .product-image img {
        height: 60px;
        width: 60px;
    }
    
    .product-info {
        text-align: center;
    }
    
    .product-name {
        font-size: 0.7rem;
        margin-bottom: 0.1rem;
        line-height: 1.1;
    }
    
    .product-sku {
        font-size: 0.55rem;
        margin-bottom: 0.05rem;
    }
    
    .variant-info, .supplier-info {
        font-size: 0.55rem;
        margin-bottom: 0;
        justify-content: center;
    }
    
    .price-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.1rem;
    }
    
    .current-price {
        font-size: 0.65rem;
        white-space: nowrap;
    }
    
    .quantity-controls {
        gap: 0.15rem;
    }
    
    .quantity-btn {
        width: 20px;
        height: 20px;
        font-size: 0.5rem;
    }
    
    .quantity-input {
        width: 26px;
        padding: 0.1rem;
        font-size: 0.55rem;
    }
    
    .total-price {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .total-amount {
        font-size: 0.65rem;
        white-space: nowrap;
    }
    
    .total-amount + small {
        font-size: 0.5rem;
    }
    
    .item-actions .btn {
        width: 20px;
        height: 20px;
        font-size: 0.5rem;
    }
    
    .cart-summary-section {
        padding: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .final-summary {
        padding: 0.5rem;
    }
    
    .summary-row {
        font-size: 0.65rem;
        margin-bottom: 0.3rem;
    }
    
    .summary-row.total {
        font-size: 0.75rem;
        padding-top: 0.3rem;
    }
    
    .cart-actions {
        gap: 0.3rem;
    }
    
    .cart-actions .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .empty-cart {
        padding: 1.25rem 0.6rem;
    }
    
    .empty-cart-icon {
        font-size: 2.25rem;
        margin-bottom: 0.6rem;
    }
    
    .empty-cart h4 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    
    .empty-cart p {
        font-size: 0.7rem;
        margin-bottom: 0.75rem;
    }
    
    .empty-cart .btn {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
    }
    
    /* تنظیمات دکمه ثابت برای موبایل کوچک */
    .cart-summary-section {
        padding: 0.6rem 0.75rem;
    }
    
    .final-summary {
        padding: 0.4rem;
    }
    
    .final-summary .summary-row {
        font-size: 0.65rem;
    }
    
    .final-summary .summary-row.total {
        font-size: 0.8rem;
    }
    
    .final-summary .btn-primary {
        font-size: 0.8rem;
        padding: 0.6rem 0.85rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.slide-out {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* Button Hover Effects */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

/* Custom Scrollbar */
.cart-items::-webkit-scrollbar {
    width: 8px;
}

.cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}