/* Стили для селектора подарков */

/* Обертка селектора подарков */
.wc-gift-selector-wrapper {
    padding: 10px;
    background: #fff9c4;
    border-radius: 16px;
    margin: 20px 0;
    position: relative;
    display: block;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    z-index: 0;
}

/* Стили для страницы корзины - более специфичные селекторы */
.woocommerce-cart .wc-gift-selector-wrapper,
body.woocommerce-cart .wc-gift-selector-wrapper,
.woocommerce .wc-gift-selector-wrapper {
    display: block !important;
    padding: 10px !important;
    background: #fff9c4 !important;
    border-radius: 16px !important;
    margin: 20px 0 !important;
    position: relative !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12) !important;
    overflow: hidden !important;
    z-index: 0 !important;
}

/* Внутренний контент поверх SVG-рамки */
.wc-gift-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center; /* Выравнивание по центру вертикально */
    justify-content: flex-start;
    gap: 15px;
    flex-direction: row; /* ПК: в один ряд */
    flex-wrap: nowrap; /* Не переносим на новую строку */
}

/* Стили для страницы корзины - более специфичные селекторы */
.woocommerce-cart .wc-gift-inner,
body.woocommerce-cart .wc-gift-inner,
.woocommerce .wc-gift-inner {
    position: relative !important;
    z-index: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 15px !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

.woocommerce-cart .wc-gift-inner > h3,
body.woocommerce-cart .wc-gift-inner > h3,
.woocommerce .wc-gift-inner > h3 {
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    margin-right: 15px !important;
    flex-shrink: 0 !important;
}

.woocommerce-cart .wc-gift-boxes,
body.woocommerce-cart .wc-gift-boxes,
.woocommerce .wc-gift-boxes {
    display: flex !important;
    justify-content: space-evenly !important;
    align-items: center !important;
    gap: 12px !important;
    margin: 0 !important;
    flex-wrap: nowrap !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.woocommerce-cart .wc-gift-box img,
body.woocommerce-cart .wc-gift-box img,
.woocommerce .wc-gift-box img {
    max-width: 60px !important;
    height: auto !important;
}

/* Состояние после выбора подарка — стилизуем как wc-selected-gift-display */
.wc-gift-selector-wrapper.wc-gift-selected {
    display: flex;
    align-items: center;
    background: #fff9c4;
    border-radius: 15px;
    padding: 10px;
    position: relative;
}

.wc-gift-selector-wrapper.wc-gift-selected .wc-gift-border-svg {
    display: none; /* убираем бегущую рамку после выбора */
}

/* SVG-бордер (анимированная линия, как в примере) */
.wc-gift-border-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.wc-gift-border-line {
    stroke-dasharray: 260;
    filter: blur(3px);
    stroke-width: 4px;
    fill: transparent;
    stroke: rgba(255, 158, 13, 0.6);
    animation: wc-gift-svg-border 5s linear infinite;
}

@keyframes wc-gift-svg-border {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: 1000;
    }
}

/* Контейнер для заголовка и подарков в одной строке - PC версия */
.wc-gift-selector-wrapper > h3,
.wc-gift-inner > h3 {
    margin: 0;
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap; /* Чтобы текст заголовка не переносился на новую строку */
    margin-right: 15px;
    flex-shrink: 0; /* Заголовок не сжимается */
}

/* Контейнер коробок подарков - PC версия (объединено с корзиной выше) */

/* Отдельная коробка подарка - PC версия */
.wc-gift-box {
    cursor: pointer;
    transition: transform 0.3s;
}

.wc-gift-box img {
    max-width: 60px !important;
    height: auto !important;
}

/* Мобильная версия - коробки в один ряд */
@media (max-width: 768px) {
    .wc-gift-selector-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .wc-gift-inner {
        position: relative;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-direction: column;
        gap: 0; /* мобильная версия: убираем gap, чтобы не тянулся с ПК */
    }
    
    /* Переопределяем стили корзины для мобильных устройств */
    .woocommerce-cart .wc-gift-inner,
    body.woocommerce-cart .wc-gift-inner,
    .woocommerce .wc-gift-inner {
        flex-direction: column !important;
        gap: 0 !important;
    }
    
    .wc-gift-selector-wrapper > h3 {
        margin: 0;
        font-size: 14px;
    }
    
    .wc-gift-boxes {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 3px;
        gap: 8px;
        width: 100%;
        justify-content: space-around;
    }
    
    .wc-gift-boxes::-webkit-scrollbar {
        height: 4px;
    }
    
    .wc-gift-boxes::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.1);
        border-radius: 2px;
    }
    
    .wc-gift-boxes::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.3);
        border-radius: 2px;
    }
    
    .wc-gift-box img {
        max-width: 40px;
    }
}

/* Анимация пульсации */
.wc-gift-pulse {
    animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.wc-gift-box:hover {
    transform: scale(1.1) !important;
}

/* Результат выбора подарка */
.wc-gift-result {
    display: none;
    position: relative;
    margin-top: 20px;
}

.wc-gift-result > div {
    display: flex;
    align-items: center;
    background: #fff9c4;
    border-radius: 15px;
    padding: 20px;
    position: relative;
}

.wc-gift-result > div > div:first-child {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-right: 100px;
}

/* Изображение товара в подарке */
.wc-gift-product-image {
    background: white;
    border-radius: 10px;
    padding: 15px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-gift-product-image img,
.wc-gift-image img,
.wc-gift-image a img,
.wc-individual-gift-display .wc-gift-product-image img,
.wc-selected-gift-display .wc-gift-product-image img,
.wc-individual-gift-display a img,
.wc-selected-gift-display a img,
.wc-individual-gift-display img:not([src*="gift"]),
.wc-selected-gift-display img:not([src*="gift"]) {
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    object-fit: contain !important;
    display: block;
}

/* Информация о подарке */
.wc-gift-result > div > div:first-child > div:last-child {
    flex: 1;
}

.wc-gift-result > div > div:first-child > div:last-child > div:first-child {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.wc-gift-name {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.wc-gift-price {
    font-size: 18px;
    font-weight: bold;
    color: #ff5314;
}

/* Изображение коробки подарка */
.wc-gift-box-image {
    position: absolute;
    right: -30px;
    z-index: 10;
}

.wc-gift-box-image img {
    max-width: 120px;
    height: auto;
}

/* Индивидуальный подарок */
.wc-individual-gift-display {
    position: relative;
    margin: 20px 0;
}

.wc-individual-gift-display > div {
    display: flex;
    align-items: center;
    background: #fff9c4;
    border-radius: 15px;
    padding: 20px;
    position: relative;
}

.wc-individual-gift-display > div > div:first-child {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-right: 100px;
}

.wc-individual-gift-display > div > div:first-child > div:first-child {
    background: white;
    border-radius: 10px;
    padding: 15px;
    flex-shrink: 0;
}

.wc-individual-gift-display > div > div:first-child > div:last-child {
    flex: 1;
}

.wc-individual-gift-display > div > div:first-child > div:last-child > div:first-child {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.wc-individual-gift-display > div > div:first-child > div:last-child h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: inherit;
}

.wc-individual-gift-display > div > div:first-child > div:last-child > div:last-child {
    font-size: 11px;
    font-weight: bold;
    color: #ffffff;
}

.wc-individual-gift-display > div > div:last-child {
    position: absolute;
    right: -30px;
    z-index: 10;
}

.wc-individual-gift-display > div > div:last-child img {
    max-width: 120px;
    height: auto;
}

/* Выбранный подарок */
.wc-selected-gift-display {
    position: relative;
    margin: 20px 0;
}

.wc-selected-gift-display > div {
    display: flex;
    align-items: center;
    background: #fff9c4;
    border-radius: 15px;
    padding: 10px;
    position: relative;
}

.wc-selected-gift-display > div > div:first-child {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-right: 100px;
}

.wc-selected-gift-display > div > div:first-child > div:first-child {
    background: white;
    border-radius: 10px;
    padding: 15px;
    flex-shrink: 0;
}

.wc-selected-gift-display > div > div:first-child > div:last-child {
    flex: 1;
}

.wc-selected-gift-display > div > div:first-child > div:last-child > div:first-child {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.wc-selected-gift-display > div > div:first-child > div:last-child h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: inherit;
}

.wc-selected-gift-display > div > div:first-child > div:last-child > div:last-child {
    font-size: 14px;
    font-weight: bold;
    color: #ff5314;
}

.wc-selected-gift-display > div > div:last-child {
    position: absolute;
    right: -30px;
    z-index: 10;
}

.wc-selected-gift-display > div > div:last-child img {
    max-width: 120px;
    height: auto;
}

/* Убираем ссылки */
.wc-individual-gift-display a,
.wc-selected-gift-display a {
    text-decoration: none;
    pointer-events: none;
    cursor: default;
}

/* Бейдж с датой окончания акции для индивидуальных подарков */
.wc-gift-expiry-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 999px;
    font-size: 12px;
    color: #8a6d3b;
}

.wc-gift-expiry-label {
    font-weight: 500;
}

.wc-gift-expiry-date {
    font-weight: 600;
}

/* Товары-подарки в корзине: фон и иконка */
tr.wc-cart-gift-item,
.wc-cart-gift-item td,
.wc-cart-gift-item {
    background-color: #fff5d6 !important;
}

.wc-cart-gift-item .wc-cart-gift-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 14px;
}

/* Мобильная адаптация для отображения подарков */
@media (max-width: 768px) {
    .wc-individual-gift-display > div,
    .wc-selected-gift-display > div,
    .wc-gift-result > div {
        flex-direction: column;
        padding: 15px;
    }
    
    .wc-individual-gift-display > div > div:first-child,
    .wc-selected-gift-display > div > div:first-child,
    .wc-gift-result > div > div:first-child {
        margin-right: 0;
        margin-bottom: 15px;
        width: 100%;
    }
    
    .wc-individual-gift-display > div > div:last-child,
    .wc-selected-gift-display > div > div:last-child,
    .wc-gift-box-image {
        position: static;
        margin-top: 10px;
        text-align: center;
    }
    
    .wc-individual-gift-display > div > div:last-child img,
    .wc-selected-gift-display > div > div:last-child img,
    .wc-gift-box-image img {
        max-width: 100px;
    }

    /* Мобайл: в блоках выбранного и индивидуального подарка большая коробка сверху, контент под ней */
    .wc-selected-gift-display > div,
    .wc-individual-gift-display > div {
        align-items: center;
    }

    .wc-selected-gift-display > div > div:last-child,
    .wc-individual-gift-display > div > div:last-child {
        order: -1;            /* поднять коробку наверх */
        margin-top: -62px;    /* немного вывести над карточкой */
        margin-bottom: 0px;  /* отступ между коробкой и текстом */
    }

    .wc-selected-gift-display > div > div:last-child img,
    .wc-individual-gift-display > div > div:last-child img {
        max-width: 100px;      /* чуть меньше, чем десктоп */
    }
}

