/* استایل دکمه انتخابگر لامپ */
.knd-lamp-selector-widget {
    margin-top: 25px;
    text-align: center;
    padding: 0 10px;
}

.knd-lamp-selector-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    background: #2c3e50;
    color: white;
    border: 1px solid #2c3e50;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 200px;
}

.knd-lamp-selector-btn:hover {
    background: #34495e;
    border-color: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.4);
}

.knd-lamp-selector-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(44, 62, 80, 0.3);
}

.knd-lamp-selector-btn svg,
.knd-lamp-selector-btn i {
    transition: transform 0.2s ease;
    color: white;
    fill: white;
}

.knd-lamp-selector-btn:hover svg,
.knd-lamp-selector-btn:hover i {
    transform: scale(1.05);
}

/* پاپآپ لامپ */
.knd-lamp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.knd-lamp-popup-overlay.active {
    opacity: 1;
}

.knd-lamp-popup {
    background: #ffffff;
    border-radius: 4px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border: 1px solid #e0e0e0;
}

.knd-lamp-popup-overlay.active .knd-lamp-popup {
    transform: scale(1);
}

.knd-lamp-popup-close {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(44, 62, 80, 0.1);
    border: 1px solid rgba(44, 62, 80, 0.2);
    color: #2c3e50;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    font-weight: 600;
    padding: 0;
    line-height: 1;
    z-index: 10;
}

.knd-lamp-popup-close:hover {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

.knd-lamp-popup-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    background: #ffffff;
    position: relative;
}

/* Grid محصولات - دو ستون در دسکتاپ، یک ستون در موبایل */
.knd-lamp-products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* کارت محصول - افقی مثل CPC موبایل */
.knd-lamp-product-item {
    background: transparent;
    margin: 0;
    padding: 16px;
    box-sizing: border-box;
    position: relative;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transition: box-shadow 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: auto;
    gap: 16px;
    overflow: hidden;
    border-bottom: 1px solid #e0e0e0;
    width: 100%;
    min-height: 140px;
}

.knd-lamp-product-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* تصویر محصول - سمت راست */
.knd-lamp-product-image {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
    margin: 0;
    border-radius: 4px;
    overflow: hidden;
    display: block;
    position: relative;
}

.knd-lamp-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.knd-lamp-product-item:hover .knd-lamp-product-image img {
    transform: scale(1.02);
}

/* محتوای محصول - سمت چپ */
.knd-lamp-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    gap: 8px;
    padding: 0;
}

/* عنوان محصول */
.knd-lamp-product-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #1a1a1a;
    margin: 0 0 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 36px;
}

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

.knd-lamp-product-name a:hover {
    color: #2c3e50;
}

/* قیمت محصول - آیکون سمت چپ، قیمت سمت راست */
.knd-lamp-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 8px 0;
    direction: ltr;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.knd-lamp-product-price .woocommerce-Price-amount.amount {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    white-space: nowrap;
    direction: ltr;
}

/* آیکون تومان - سمت چپ قیمت */
.knd-lamp-product-price .cpc-currency-img {
    width: 0.9em;
    height: 0.9em;
    vertical-align: -0.12em;
    object-fit: contain;
    order: -1;
}

.knd-lamp-product-price .cpc-price-currency {
    order: -1;
}

/* بج تخفیف CPC */
.knd-lamp-product-price .cpc-discount-badge {
    background: #e74c3c;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    min-width: 30px;
    line-height: 1.3;
    display: inline-block;
    margin-bottom: 4px;
}

/* قیمت تخفیف - خاکستری و خط خورده */
.knd-lamp-product-price del {
    font-size: 13px;
    color: #6c757d !important;
    margin-bottom: 4px;
    text-decoration: line-through !important;
    text-decoration-color: #6c757d !important;
    text-decoration-thickness: 1px !important;
    font-weight: 400;
    display: block;
}

.knd-lamp-product-price del .woocommerce-Price-amount.amount {
    color: #6c757d !important;
    font-weight: 400;
    font-size: 13px;
    text-decoration: line-through !important;
    text-decoration-color: #6c757d !important;
}

.knd-lamp-product-price ins {
    text-decoration: none;
    color: #2c3e50;
    font-weight: 700;
    display: block;
}

.knd-lamp-product-price ins .woocommerce-Price-amount.amount {
    color: #2c3e50;
    font-weight: 700;
}

/* مخفی کردن آیکون در قیمت قدیمی */
.knd-lamp-product-price del .cpc-currency-img,
.knd-lamp-product-price del .cpc-price-currency {
    display: none !important;
}

/* ردیف پایین - فقط تعداد */
.knd-lamp-bottom-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: auto;
}

/* انتخابگر تعداد با دکمه + و - */
.knd-lamp-quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.knd-lamp-quantity-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

.knd-lamp-quantity-controls {
    display: flex;
    align-items: center;
    gap: 0;
    border: 2px solid #e8e8e8;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.knd-lamp-quantity-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: #f8f9fa;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
}

.knd-lamp-quantity-btn:hover {
    background: #e9ecef;
    color: #1a1a1a;
}

.knd-lamp-quantity-btn:active {
    background: #dee2e6;
    transform: scale(0.95);
}

.knd-lamp-quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f9fa;
}

.knd-lamp-quantity-input {
    width: 40px;
    height: 24px;
    padding: 0;
    border: none;
    border-left: 1px solid #e8e8e8;
    border-right: 1px solid #e8e8e8;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    background: #ffffff;
    color: #2c3e50;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.knd-lamp-quantity-input::-webkit-outer-spin-button,
.knd-lamp-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.knd-lamp-quantity-input:focus {
    outline: none;
    background: #ffffff;
}


/* دکمه افزودن کلی پایین مودال */
.knd-lamp-global-actions {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    margin-top: 20px;
    text-align: center;
}

.knd-lamp-global-add-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    border: 2px solid #2c3e50;
    background: #2c3e50;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    min-width: 200px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.knd-lamp-global-add-btn:hover:not(:disabled) {
    background: #34495e;
    border-color: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3);
}

.knd-lamp-global-add-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.knd-lamp-global-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #bdc3c7;
    border-color: #bdc3c7;
    transform: none;
    box-shadow: none;
}

/* حالت بارگذاری */
.knd-lamp-global-add-btn.loading {
    position: relative;
    color: transparent;
}

.knd-lamp-global-add-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: knd-spin 1s linear infinite;
}

@keyframes knd-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.knd-lamp-popup-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.knd-lamp-popup-empty {
    text-align: center;
    padding: 40px;
    color: #999;
}

.knd-lamp-popup-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Responsive - موبایل */
@media (max-width: 768px) {
    .knd-lamp-popup {
        max-width: calc(100% - 20px);
        max-height: 90vh;
        border-radius: 8px;
        margin: 10px;
    }

    .knd-lamp-popup-overlay {
        align-items: center;
        padding: 10px;
    }

    .knd-lamp-popup-content {
        padding: 16px;
        padding-bottom: 80px;
    }

    /* دکمه ثابت پایین در موبایل */
    .knd-lamp-global-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px;
        background: #ffffff;
        border-top: 2px solid #e0e0e0;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
        z-index: 10;
        margin-top: 0;
    }

    /* موبایل - یک ستون */
    .knd-lamp-products-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .knd-lamp-product-item {
        padding: 13px;
        gap: 17px;
        min-height: 120px;
    }

    .knd-lamp-product-image {
        flex: 0 0 120px;
        width: 120px;
        height: 120px;
    }

    .knd-lamp-product-info {
        min-height: 120px;
    }

    .knd-lamp-bottom-row {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        justify-content: flex-start;
    }

    .knd-lamp-quantity-wrapper {
        justify-content: flex-start;
    }

    .knd-lamp-global-actions {
        padding: 16px;
    }

    .knd-lamp-global-add-btn {
        width: 100%;
        min-width: auto;
    }

    .knd-lamp-selector-btn {
        padding: 14px 28px;
        font-size: 14px;
        min-width: 180px;
        gap: 10px;
    }
    
    .knd-lamp-selector-btn svg,
    .knd-lamp-selector-btn i {
        font-size: 18px;
    }
}