/* 1. Основной контейнер виджета */
#side-widget-main.side-widget-container {
    position: fixed;
    right: 0;
    top: 50%;
    padding: 12px 10px 8px 10px;
    transform: translate(0, -50%);
    background: #fff;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
    border-radius: 8px 0 0 8px;
    z-index: 100;
    text-align: center;
    display: none;
    flex-direction: column;
    animation: slideInRight 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, bottom 0.5s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease !important;
}

.widget-block {
    position: relative;
    justify-content: center;
    flex-direction: column;
}

.widget-block:hover .compare-dynamic-img {
    transform: scale(1.1);
}

/* 2. Секция сравнения (иконка и счетчик) */
.icon-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 5px;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    padding: 6px;
    width: 36px;
    height: 36px;
}

.icon-wrapper img {
    width: 100%;
    height: 100%;
    transition: transform 0.2s;
}

.badge-count {
    position: absolute;
    top: -7px;
    right: -11px;
    background: #2E9CFF;
    color: #fff;
    /*font-weight: 500;*/
    border-radius: 7px;
    width: 20px;
    height: 14px;
    line-height: 14px;
    font-size: 11px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.widget-main-link {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.widget-title {
    display: block;
    font-size: 13px;
    text-decoration: none;
    color: #2E9CFF;
    /*font-weight: 500;*/
    margin-top: 8px;
}

/* 3. Просмотренные товары в сайдбаре */
.viewed-items-mini {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.viewed-item-small {
    display: block;
    width: 36px;
    height: 36px;
    overflow: hidden;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    background: #fff;
    padding: 6px;
}

.viewed-item-small img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
}

.viewed-item-small:hover img { transform: scale(1.1); }

/* 4. Разделитель и кнопка закрытия */
.widget-divider {
    border: 0;
    border-top: 1px solid #f0f0f0;
    margin: 10px 0;
}

.close-widget {
    position: absolute;
    top: -5px;
    right: 0;
    background: none; border: none;
    font-size: 18px; cursor: pointer; color: #999;
}

/* 5. Модальное окно (Попап) */
.v-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.v-modal-overlay.active { display: flex; }

.v-modal-window {
    background: #fff;
    width: 90%;
    max-width: 800px;
    border-radius: 12px;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.v-modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.v-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
}

.v-modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* 6. Сетка товаров в попапе */
.v-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.v-product-card {
    border: 1px solid #E2E5E9;
    border-radius: 8px;
    padding: 12px;
}

.v-product-card a {
    text-decoration: none;
    color: #333;
}

.v-img-wrap {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.v-img-wrap img {
    max-height: 80%;
    max-width: 80%;
    object-fit: contain;
}

.v-product-name {
    font-size: 12px;
    color: #333;
    line-height: 1.2;
    margin-top: 5px;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.4em;
}

.v-product-price {
    display: block;
    font-size: 15px;
    font-weight: bold;
    color: #333;
    margin-top: 8px;
    white-space: nowrap;
}



/* Кнопка закрытия */
.side-widget-close-btn {
    position: absolute;
    top: -10px;
    left: -14px;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 50%;
    font-size: 16px;
    line-height: 18px;
    color: #999;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    opacity: 1;
    visibility: visible;
}

/*.side-widget-close-btn:hover {*/
/*    color: #2E9CFF;*/
/*}*/

.widget-chevron {
    display: block;
    font-size: 10px;
    /*color: #2E9CFF;*/
    /*width: 8px;*/
    /*height: 8px;*/
    /*border-right: 2px solid #2E9CFF;*/
    /*border-bottom: 2px solid #2E9CFF;*/
    transform: rotateY(0deg);
    transition: transform 0.4s ease;
    margin-top: 2px;
}

.side-widget-container.is-collapsed {
    transform: translate(calc(100% - 10px), -50%) !important;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.side-widget-container.is-collapsed:hover {
    background: #fdfdfd;
}

.side-widget-container.is-collapsed .side-widget-close-btn {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    left: -14px;
}

.side-widget-container.is-collapsed .widget-chevron {
    transform: rotateY(180deg);
    /*margin-left: 2px;*/
}

/*.side-widget-container.is-collapsed .widget-block,*/
/*.side-widget-container.is-collapsed .widget-divider {*/
/*    opacity: 0;*/
/*    pointer-events: none;*/
/*}*/

@media all and (max-width: 600px) {
    #side-widget-main.side-widget-container {
        top: unset;
        left: 0;
        bottom: 61px;
        transform: translate(0, 0);
        border-radius: 0;
        border-bottom: 1px solid #f0f0f0;
        padding: 12px 30px 12px 12px;
        box-shadow: 0 -20px 20px 0 rgba(0, 0, 0, 0.08);
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
        flex-direction: row;
        animation: slideInRightMobile 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    }

    .side-widget-container.is-collapsed {
        transform: translate(calc(100% - 20px), 0) !important;
        padding: 12px 12px 12px 20px;
    }

    .side-widget-close-btn {
        left: unset;
        top: 50%;
        right: 2px;
        transform: translate(0, -50%);
        box-shadow: none;
        border-left: 1px solid #f0f0f0;
        border-right: none;
        border-bottom: none;
        border-top: none;
        border-radius: unset;
        height: 100%;
    }

    .side-widget-container.is-collapsed .side-widget-close-btn {
        left: 0;
    }

    .widget-block {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: 100%;
    }

    .widget-block.viewed-section {
        justify-content: flex-end;
    }

    .widget-block.compare-section {
        justify-content: flex-start;
    }

    .viewed-items-mini {
        flex-direction: row;
    }

    .widget-title {
        margin-top: 0;
    }

    .viewed-item-small {
        border: none;
        padding: 0;
    }

    .widget-main-link {
        align-items: center;
        gap: 12px;
        flex-direction: row;
    }

    .icon-wrapper {
        border: none;
        padding: 0;
        margin-bottom: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    0% {
        transform: translate(100%, -50%);
        opacity: 0;
    }
    100% {
        transform: translate(0, -50%);
        opacity: 1;
    }
}

@keyframes slideInRightMobile {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}
