/* ============================================
   Modern Product Cards - 2024 Design System
   ============================================ */

/* Base Product Card */
.product-card {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(10px);
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #dc2626, #ef4444, #f97316);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.product-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    border-color: rgba(220, 38, 38, 0.4);
}

.product-card:hover::before {
    opacity: 1;
}

.product-card.hidden {
    display: none;
}

/* Card Top Section */
.product-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1rem 0;
    position: relative;
    z-index: 2;
}

.product-select {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.product-select:hover {
    background: rgba(220, 38, 38, 0.05);
}

.product-select .product-checkbox {
    margin: 0;
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: #dc2626;
}

.product-select .form-check-label {
    font-size: 0.75rem;
    color: #64748b;
    user-select: none;
    font-weight: 500;
}

.product-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.product-badges .badge {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: slideInRight 0.3s ease;
}

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

.product-badges .badge.bg-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.product-badges .badge.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Product Image */
.product-thumb {
    display: block;
    margin: 1rem 1rem 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.product-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0) 0%, rgba(220, 38, 38, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover .product-thumb {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.product-card:hover .product-thumb::after {
    opacity: 1;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 1rem;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-thumb img {
    transform: scale(1.1);
}

/* Product Body */
.product-body {
    padding: 1rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex: 1;
}

.product-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-code {
    font-size: 0.7rem;
    color: #64748b;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 0.25rem 0.7rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    width: fit-content;
    font-weight: 600;
    font-family: 'Courier New', 'Monaco', monospace;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.product-name {
    font-size: 1rem;
    margin: 0;
    color: #111827;
    font-weight: 700;
    line-height: 1.5;
    min-height: 3em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.product-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.product-name a:hover {
    color: #dc2626;
    text-decoration: none;
}

.product-desc {
    margin: 0;
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price Box */
.product-price-box {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.product-price-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #dc2626, transparent);
    opacity: 0.3;
}

.price-selection-container {
    margin-bottom: 0.6rem;
}

.product-price-box .btn-group {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.product-price-box .btn-group .btn {
    flex: 0 0 auto;
    width: 100%;
    border-radius: 12px !important;
    font-size: 0.75rem;
    padding: 0.6rem 0.7rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-width: 2px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

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

.product-price-box .btn-group .btn:hover::before {
    left: 100%;
}

.product-price-box .btn-group .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.product-price-box .btn-group .btn .d-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    z-index: 1;
}

.product-price-box .btn-group .btn .d-block span {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.9;
}

.product-price-box .btn-group .btn .d-block small {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
    color: inherit;
}

.price-savings {
    font-size: 0.7rem;
    text-align: center;
    margin-top: 0.6rem;
    padding: 0.4rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    border-radius: 10px;
    color: #059669;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.2);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
    }
}

.isaco-pricing-section {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 2px dashed rgba(226, 232, 240, 0.8);
}

.isaco-pricing-section small {
    font-size: 0.7rem;
    color: #3b82f6;
    font-weight: 700;
    display: block;
    margin-bottom: 0.5rem;
}

/* Product Footer */
.product-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.product-settlement {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1.5px dashed rgba(148, 163, 184, 0.6);
    border-radius: 10px;
    padding: 0.4rem 0.85rem;
    font-size: 0.7rem;
    color: #475569;
    width: fit-content;
    font-weight: 600;
    transition: all 0.2s ease;
}

.product-settlement:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: rgba(220, 38, 38, 0.05);
}

.product-settlement i {
    color: #64748b;
    transition: color 0.2s ease;
}

.product-settlement:hover i {
    color: #dc2626;
}

.quantity-input-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    background: #f8fafc;
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.quantity-btn {
    min-width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-width: 2px;
    font-weight: 700;
    font-size: 1rem;
}

.quantity-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.product-quantity {
    flex: 1;
    text-align: center;
    font-weight: 700;
    border-radius: 10px;
    border-width: 2px;
    font-size: 1rem;
    background: white;
}

.add-to-cart {
    width: 100%;
    padding: 0.75rem;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    border-width: 0;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    position: relative;
    overflow: hidden;
}

.add-to-cart::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 ease;
}

.add-to-cart:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.add-to-cart:hover:not(:disabled)::before {
    left: 100%;
}

.add-to-cart:active:not(:disabled) {
    transform: translateY(-1px);
}

.add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #9ca3af;
    box-shadow: none;
}

.product-points-display {
    text-align: center;
    padding-top: 0.6rem;
    border-top: 1.5px solid rgba(226, 232, 240, 0.6);
}

.product-points-display small {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
}

.product-points-display i {
    color: #f59e0b;
    animation: rotate 3s linear infinite;
}

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

/* Responsive - Tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .product-card-top {
        padding: 0.85rem 0.85rem 0;
    }

    .product-thumb {
        margin: 0.85rem 0.85rem 0;
    }

    .product-body {
        padding: 0.85rem 0.85rem 1rem;
    }

    .product-name {
        font-size: 0.95rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .product-card {
        border-radius: 16px;
    }

    .product-card-top {
        padding: 0.75rem 0.75rem 0;
    }

    .product-select .form-check-label {
        display: none;
    }

    .product-badges {
        flex-direction: row;
        gap: 0.3rem;
    }

    .product-badges .badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .product-thumb {
        margin: 0.75rem 0.75rem 0;
        border-radius: 12px;
    }

    .product-body {
        padding: 0.75rem 0.75rem 1rem;
        gap: 0.7rem;
    }

    .product-code {
        font-size: 0.65rem;
        padding: 0.2rem 0.6rem;
    }

    .product-name {
        font-size: 0.9rem;
        min-height: 2.7em;
    }

    .product-desc {
        font-size: 0.8rem;
    }

    .product-price-box {
        padding: 0.85rem;
        border-radius: 12px;
    }

    .product-price-box .btn-group .btn {
        font-size: 0.7rem;
        padding: 0.5rem 0.6rem;
    }

    .add-to-cart {
        padding: 0.65rem;
        font-size: 0.85rem;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 576px) {
    .product-card-top {
        padding: 0.6rem 0.6rem 0;
    }

    .product-badges .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }

    .product-thumb {
        margin: 0.6rem 0.6rem 0;
        aspect-ratio: 3 / 2;
    }

    .product-body {
        padding: 0.6rem 0.6rem 0.85rem;
        gap: 0.5rem;
    }

    .product-code {
        display: none;
    }

    .product-name {
        font-size: 0.85rem;
        min-height: 2.55em;
    }

    .product-desc {
        display: none;
    }

    /* Compact price box - reduced height */
    .product-price-box {
        padding: 0.4rem 0.5rem;
        border-radius: 10px;
    }

    .price-selection-container {
        margin-bottom: 0.25rem;
    }

    .product-price-box .btn-group {
        flex-direction: row;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }

    .product-price-box .btn-group .btn {
        flex: 1 1 auto;
        width: auto;
        font-size: 0.6rem;
        padding: 0.3rem 0.35rem;
        min-height: 36px;
    }

    .product-price-box .btn-group .btn .d-block span {
        display: none;
    }

    .product-price-box .btn-group .btn .d-block small {
        font-size: 0.65rem;
        font-weight: 700;
        line-height: 1.2;
    }

    .product-settlement {
        display: none;
    }

    /* Quantity selector - visible and compact */
    .quantity-input-group {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0.5rem;
        padding: 0.3rem;
        background: #f1f5f9;
        border-radius: 8px;
        border: 1px solid rgba(220, 38, 38, 0.3);
        min-height: 38px;
    }

    .quantity-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.9rem;
        padding: 0;
        flex-shrink: 0;
    }

    .product-quantity {
        font-size: 0.85rem;
        font-weight: 700;
        min-width: 32px;
        flex: 1;
    }

    .add-to-cart {
        padding: 0.55rem;
        font-size: 0.8rem;
    }
}

/* Very Small Mobile */
@media (max-width: 360px) {
    .product-name {
        font-size: 0.8rem;
    }

    .product-price-box .btn-group .btn .d-block small {
        font-size: 0.58rem;
    }

    .product-price-box .btn-group .btn {
        font-size: 0.55rem;
        padding: 0.25rem 0.3rem;
    }

    .quantity-btn {
        min-width: 28px;
        height: 28px;
    }

    .product-quantity {
        font-size: 0.8rem;
    }

    .add-to-cart {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
}

/* Loading State */
.product-card.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.product-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 20px;
}

.product-card.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f4f6;
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 101;
}

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

/* Selected State */
.product-card.selected {
    border-color: #dc2626;
    border-width: 2.5px;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15), 0 20px 40px rgba(0, 0, 0, 0.12);
    transform: scale(1.02);
}

.product-card.selected::before {
    opacity: 1;
}

/* Out of Stock State */
.product-card.out-of-stock {
    opacity: 0.75;
    position: relative;
}

.product-card.out-of-stock::after {
    content: 'ناموجود';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.product-card.out-of-stock .product-thumb {
    filter: grayscale(0.6);
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .product-card:hover {
        transform: none;
    }

    .product-card:active {
        transform: scale(0.98);
    }

    .quantity-btn:active,
    .add-to-cart:active {
        transform: scale(0.95);
    }
}

/* Print Styles */
@media print {
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .product-select,
    .quantity-input-group,
    .add-to-cart {
        display: none;
    }
}
