/* ========================================================= */
/* 1. БАЗОВІ СТИЛІ (МОБІЛЬНИЙ ВИГЛЯД: min-width: 0) */
/* ========================================================= */

/* 1.1. КОНТЕЙНЕРИ І ЗАГАЛЬНИЙ МАКЕТ СПИСКУ ВАРІАЦІЙ (.rvt-rows) */
#rvt-container {
    padding: 0 0 20px;
}
.rvt-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rvt-row {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column; /* Мобільний: вертикальний макет */
    gap: 6px;
}
.rvt-row-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.rvt-field-image img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
}
.rvt-image-preview {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100vw;
    max-height: 100vh;
    z-index: 9999;
    display: none;
    pointer-events: none;
    background: #fff;
    padding: 6px;
    border-radius: 6px;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.35);
}

.rvt-row-info {
    flex: 1 1 auto;
    font-size: 18px;
}
.rvt-field-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
}
.rvt-field-sku {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 4px;
}
.rvt-field-description {
    margin-bottom: 4px;
}

.rvt-field-attr .rvt-attr-label {
    font-weight: 600;
    margin-right: 3px;
}

/* 1.2. ДІЇ ТА КНОПКИ ============================================================== */
.rvt-row-actions {
    position: relative;
    display: flex;
    justify-content: flex-end; /* Вирівнювання праворуч */
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
}
.rvt-action-price {
    font-weight: 700;
    font-size: 16px;
}
.rvt-col-qty .rvt-qty-wrapper,
.rvt-action-qty .rvt-qty-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.rvt-qty-btn[type="button"] {
    padding: 0;
    width: 24px;
    height: 24px;
    background: none;
    cursor: pointer;
}
.rvt-qty-btn[type="button"]:is(:hover, :active) {
    background: none;
}
.rvt-qty-btn[type="button"] svg {
    stroke-width: 3;
    stroke: #3e3e3e;
    transition:
        transform 0.2s ease,
        filter 0.2s ease,
        stroke 0.2s ease;
    transform: scale(1);
    pointer-events: none;
}
.rvt-qty-btn:hover svg {
    transform: scale(1.3);
    stroke: #333;
    filter: drop-shadow(0 0 5px #3e3e3ecc);
}
.rvt-qty-btn:active svg {
    transform: scale(1);
    filter: drop-shadow(0 0 3px #3e3e3eaa);
}
.rvt-qty-input::-webkit-outer-spin-button,
.rvt-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.rvt-qty-input[type="number"] {
    -moz-appearance: textfield;
    width: 50px;
    font-size: 18px;
}
.rvt-action-button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-height: 48px;
}
.rvt-buy-button.button {
    padding: 6px 16px;
    font-size: 14px;
    height: 40px;
    width: 120px;
    background: var(--wd-primary-color);
    color: #fff;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}
@media (hover: hover) {
    .rvt-buy-button.button:is(:hover, :focus-visible) {
        background-color: color-mix(
            in srgb,
            var(--wd-primary-color) 85%,
            #000 15%
        );
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    }
}
.rvt-buy-button.button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transition-duration: 0.05s;
}
.rvt-buy-button.rvt-loading {
    opacity: 0.6;
    pointer-events: none;
}
.rvt-buy-button.rvt-added {
    animation: rvt-pulse 0.4s ease-out;
}
@keyframes rvt-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
    100% {
        transform: scale(1);
    }
}
.rvt-buy-button:disabled {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.6;
}
.rvt-cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.6;
    background: #13c719;
    color: #fff;
}
a.added_to_cart.wc-forward {
    position: absolute;
    top: -14px;
    font-size: 12px;
    line-height: 1.2;
    align-self: flex-start;
}
/*============================================================*/
/* 1.3. ВЕРХНЯ ПАНЕЛЬ=============================== */
.rvt-topbar {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
}

#rvt-page-size {
    height: 32px;
    padding: 4px 30px 4px 4px;
    width: fit-content;
}

.rvt-page-size-wrapper {
    position: relative;
}
.rvt-page-size-wrapper label {
    position: absolute;
    top: -14px;
    font-size: 12px;
    line-height: 1.2;
    margin: 0;
}
.rvt-search-box {
    width: 100%;
    max-width: 360px;
    flex: 1 1 auto;
}
#rvt-search-input {
    height: 38px;
    padding: 4px 8px;
    font-size: 15px;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}
#rvt-search-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px rgba(34, 113, 177, 0.2);
}

/*=========================================================*/
.rvt-header-filters {
    display: none;
}

.rvt-attr-filters {
    display: flex;
    flex-direction: column; /* Фільтри вертикально */
    align-items: stretch;
    gap: 8px;
}
.rvt-filter-in-cart {
    display: flex;
    align-items: center;
    justify-content: end;
    gap: 10px;
}
#rvt-in-cart-filter {
    width: 16px;
    height: 16px;
}
.rvt-filter-in-cart label {
    margin: 0;
    color: var(--wd-text-color);
    font-size: 16px;
}

/*==========================================================*/
/*==============================================================*/

/* 1.4. ПАГІНАЦІЯ */
.rvt-pagination {
    margin-top: 15px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.rvt-pagination .rvt-page-btn {
    min-width: 32px;
    padding: 4px 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    background: #f7f7f7;
    cursor: pointer;
    border-radius: 3px;
}
.rvt-pagination .rvt-page-btn:hover:not([disabled]) {
    background: #eee;
}

.rvt-pagination .rvt-page-active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}
.rvt-pagination .rvt-page-ellipsis {
    padding: 4px 6px;
    font-size: 13px;
    line-height: 1.4;
    user-select: none;
}
.rvt-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    stroke: currentColor; /* Щоб іконка була видимою */
}

/* 1.5. АНІМАЦІЯ =====================================================*/
@keyframes rvt-blink {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        opacity: 1;
    }
}
.rvt-blinking {
    animation: rvt-blink 1.5s infinite;
    text-align: center;
    padding: 20px 0;
    font-weight: 600;
    color: #999;
}

/* ========================================================= */
/* 2. ДЕСКТОПНИЙ МАКЕТ (min-width: 768px) */
/* ========================================================= */

@media (min-width: 768px) {
    /* 2.1. ОСНОВНИЙ МАКЕТ РЯДКА */
    .rvt-desktop-hidden {
        display: none !important;
    }
    .rvt-row {
        flex-direction: row; /* Десктоп: горизонтальний макет */
        align-items: center;
        justify-content: space-between;
        gap: 20px;
    }

    /* 2.2. ІНФОРМАЦІЯ ТА ДІЇ */
    .rvt-row-main {
        align-items: center; /* Вирівнювання по центру */
        gap: 15px;
        flex: 1 1 auto;
    }
    .rvt-row-actions {
        flex: 0 0 auto;
        margin-top: 0;
    }

    /* 2.3. ВЕРХНЯ ПАНЕЛЬ (ГОРИЗОНТАЛЬНИЙ МАКЕТ) */
    .rvt-topbar .rvt-attr-filters {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px 16px;
    }
    #rvt-in-cart-filter {
        width: 24px;
        height: 24px;
    }
    .rvt-attr-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .rvt-attr-filter-item {
        min-width: calc(50% - 10px);
        max-width: 100%;
    }
}
@media (min-width: 1024px) {
    #rvt-wrap-container {
        padding: 0 30px 20px;
    }
}

@media (min-width: 1280px) {
    #rvt-wrap-container {
        padding: 0 0 20px;
    }
}
@media (max-width: 380px) {
    .rvt-action-price {
        position: absolute;
        top: -24px;
        left: 0;
    }
    .rvt-qty-input {
        width: 40px; /* Вужчий інпут */
        padding: 2px;
    }
    .rvt-qty-btn {
        width: 30px;
        height: 30px;
    }
    .rvt-buy-button {
        padding: 8px 12px;
        font-size: 14px;
    }
    .rvt-pagination .rvt-page-btn {
        width: 28px;
        min-width: unset;
        padding: 2px 6px;
    }
}
