/* File Type Icons */
.file-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
}

.pdf-icon {
    background-image: url('/static/photos/pdf.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.xlsx-icon {
    background-image: url('/static/photos/excel.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Enhanced Product Cards - Adapted for Persian Accounting App */
.product-card {
    --card-bg: #ffffff;
    --card-accent: #22c55e;
    --card-text: #1e293b;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);

    width: 200px;
    height: 280px;
    background: var(--card-bg);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: 'FAFont', sans-serif;
    direction: rtl;
    text-align: right;
}

.product-card__shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        120deg,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 60%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card__glow {
    position: absolute;
    inset: -10px;
    background: radial-gradient(
        circle at 50% 0%,
        rgba(34, 197, 94, 0.3) 0%,
        rgba(34, 197, 94, 0) 70%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
}

.product-card__content {
    padding: 1.25em;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75em;
    position: relative;
    z-index: 2;
}

.product-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #10b981;
    color: white;
    padding: 0.25em 0.5em;
    border-radius: 999px;
    font-size: 0.7em;
    font-weight: 600;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.4s ease 0.1s;
    z-index: 10;
}

.product-card__image {
    width: 100%;
    height: 80px;
    background: linear-gradient(45deg, #22c55e, #16a34a);
    border-radius: 12px;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
}

.product-card__image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 30%
    ),
    repeating-linear-gradient(
        45deg,
        rgba(34, 197, 94, 0.1) 0px,
        rgba(34, 197, 94, 0.1) 2px,
        transparent 2px,
        transparent 4px
    );
    opacity: 0.5;
}

.product-card__text {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    flex-grow: 1;
}

.product-card__title {
    color: #1a1a1a;
    font-size: 1.2em;
    margin: 0;
    font-weight: 800;
    transition: all 0.3s ease;
    text-align: center;
}

.product-card__description {
    color: #2d2d2d;
    font-size: 1em;
    margin: 0;
    opacity: 0.9;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 700;
}

.product-card__inventory {
    color: #4a4a4a;
    font-size: 0.85em;
    margin: 0;
    opacity: 0.8;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 600;
}

.product-card__footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: auto;
    padding: 0 0.5rem;
}

.product-card__price {
    color: var(--card-text);
    font-weight: 700;
    font-size: 1em;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
}

.product-card__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    flex-wrap: nowrap;
}

.product-card__quantity {
    width: 60px;
    text-align: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    padding: 0.5rem 0.25rem;
    font-weight: 600;
    color: #1a1a1a;
    background: #ffffff;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-card__quantity:focus {
    outline: none;
    border-color: var(--card-accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    transform: scale(1.05);
}

.product-card__button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.95);
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
}

.product-card__button::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.6s;
}

.product-card__button:hover::before {
    left: 100%;
}

.product-card__button--remove {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.product-card__button--remove:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.3), 0 3px 6px rgba(239, 68, 68, 0.2);
}

.product-card__button--reset {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.product-card__button--reset:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.3), 0 3px 6px rgba(245, 158, 11, 0.2);
}

/* Hover Effects */
.product-card:hover {
    transform: translateY(-10px);
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: rgba(34, 197, 94, 0.2);
}

.product-card:hover .product-card__shine {
    opacity: 1;
    animation: shine 3s infinite;
}

.product-card:hover .product-card__glow {
    opacity: 1;
}

.product-card:hover .product-card__badge {
    transform: scale(1);
    opacity: 1;
    z-index: 15;
}

.product-card:hover .product-card__image {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.product-card:hover .product-card__title {
    color: var(--card-accent);
    transform: translateX(-2px);
}

.product-card:hover .product-card__description {
    opacity: 1;
    transform: translateX(-2px);
}

.product-card:hover .product-card__inventory {
    opacity: 0.8;
    transform: translateX(-2px);
}

.product-card:hover .product-card__price {
    color: var(--card-accent);
    transform: translateX(-2px);
}

.product-card:hover .product-card__button {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.3), 0 3px 6px rgba(34, 197, 94, 0.2);
}

.product-card:hover .product-card__button svg {
    animation: pulse 1.5s infinite;
}

/* Active State */
.product-card:active {
    transform: translateY(-5px) scale(0.98);
}

/* Special variants for different product types */
.product-card--weight {
    --card-accent: #0ea5e9;
}

.product-card--weight .product-card__image {
    background: linear-gradient(45deg, #0ea5e9, #0284c7);
}

.product-card--weight:hover {
    border-color: rgba(14, 165, 233, 0.2);
}

.product-card--weight:hover .product-card__glow {
    background: radial-gradient(
        circle at 50% 0%,
        rgba(14, 165, 233, 0.3) 0%,
        rgba(14, 165, 233, 0) 70%
    );
}

.product-card--low-stock {
    --card-accent: #f59e0b;
}

.product-card--low-stock .product-card__badge {
    background: #f59e0b;
    opacity: 1;
    transform: scale(1);
}

.product-card--out-of-stock {
    --card-accent: #ef4444;
    opacity: 0.7;
}

.product-card--out-of-stock .product-card__badge {
    background: #ef4444;
    opacity: 1;
    transform: scale(1);
}

.product-card--out-of-stock .product-card__image {
    background: linear-gradient(45deg, #ef4444, #dc2626);
}

/* === EDITED SECTION === */
/* This is the new style for the selected card. */
/* It only adds a blue border and a subtle glow, without changing the background. */
.product-card--selected {
    border: 2px solid #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}
/* The ::before pseudo-element that caused the background change has been removed. */


.product-card--selected .product-card__badge {
    background: #1d4ed8;
    box-shadow: 0 4px 8px rgba(29, 78, 216, 0.3);
}

.product-card--out-of-stock .product-card__controls {
    opacity: 0.6;
}

.product-card--out-of-stock .product-card__quantity:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #d1d5db;
}

.product-card--out-of-stock .product-card__button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(0.95);
}

.product-card--out-of-stock .product-card__button:disabled:hover {
    transform: scale(0.95);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Animations */
@keyframes shine {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes selectedGlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.export-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.export-btn--pdf {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.export-btn--pdf:hover {
    background-color: #dc2626;
    color: white;
}

.export-btn--excel {
    background-color: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.export-btn--excel:hover {
    background-color: #16a34a;
    color: white;
}

.file-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.pdf-icon {
    background-image: url('/static/photos/pdf.svg');
}

.xlsx-icon {
    background-image: url('/static/photos/excel.svg');
}

@media (max-width: 767px) {
    .product-card {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 196px;
        border-radius: 12px;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
        overflow: hidden;
    }

    .product-card__content {
        padding: 0.62rem;
        gap: 0.42rem;
    }

    .product-card__image {
        width: 44px;
        height: 44px;
        margin-inline: auto;
        border-radius: 12px;
        font-size: 1.25rem;
        flex: 0 0 auto;
    }

    .product-card__shine,
    .product-card__glow,
    .product-card__image::after {
        display: none;
    }

    .product-card__badge {
        top: 7px;
        left: 7px;
        font-size: 0.62rem;
        padding: 0.15rem 0.4rem;
        opacity: 1;
        transform: none;
    }

    .product-card__title {
        font-size: 0.82rem;
        line-height: 1.5;
        min-height: 2.45rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
    }

    .product-card__description {
        font-size: 0.74rem;
        line-height: 1.45;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .product-card__inventory {
        font-size: 0.68rem;
        line-height: 1.45;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .product-card__footer {
        padding: 0;
        margin-top: auto;
    }

    .product-card__controls {
        gap: 0.3rem;
        justify-content: space-between;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .product-card__quantity {
        width: min(3rem, 100%);
        min-width: 0;
        min-height: 34px;
        padding: 0.28rem 0.12rem;
        font-size: 0.82rem;
        border-radius: 9px;
        border-width: 1px;
        box-shadow: none;
    }

    .sales-weight-input.product-card__quantity {
        width: 100%;
        flex: 1 1 auto;
        font-size: 0.7rem;
    }

    .product-card__button {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        max-width: 34px;
        max-height: 34px;
        transform: none;
        box-shadow: none;
        padding: 0 !important;
        flex: 0 0 34px;
        display: inline-flex;
        border-radius: 999px;
        aspect-ratio: 1 / 1;
    }

    .product-card__button svg {
        width: 16px;
        height: 16px;
    }

    .product-card:hover,
    .product-card:active,
    .product-card:hover .product-card__image,
    .product-card:hover .product-card__title,
    .product-card:hover .product-card__description,
    .product-card:hover .product-card__inventory,
    .product-card:hover .product-card__price {
        transform: none;
    }

    .product-card:hover .product-card__button {
        transform: none;
    }

    .product-card--selected {
        border: 2px solid #2563eb;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    }

    .product-card--out-of-stock {
        opacity: 0.78;
    }

    .product-card__vendor {
        font-size: 0.66rem !important;
        line-height: 1.35;
        margin-bottom: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .trash-product-card {
        padding: 0.75rem !important;
        border-radius: 12px !important;
        min-height: 150px;
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
    }

    .trash-product-card h3,
    .trash-product-card .font-bold {
        font-size: 0.85rem;
        line-height: 1.45;
    }

    .trash-product-card p,
    .trash-product-card span {
        font-size: 0.72rem;
        line-height: 1.45;
    }

    .trash-product-card button {
        width: auto !important;
        min-width: 0 !important;
        min-height: 34px !important;
        font-size: 0.72rem !important;
        padding: 0.35rem 0.45rem !important;
        flex: 1 1 auto;
    }
}
