/* New header styles */

#new_header {
    width: fit-content;
    max-width: 80%;
    margin: 10px auto 20px;
    /* центрирование */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, max-content));
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

/* Новый контейнер для всех действий (контакты + User Actions) */
#new_header #header_all_actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
    order: 2;
}

/* Контейнер для группировки иконок User Actions */
#new_header #header_user_actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

#new_header>div {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

#new_header a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

#new_header a:hover {
    opacity: 0.85;
}

/* Modern inline SVG icons */
#new_header .icon {
    width: 30px;
    height: 30px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

#new_header .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 1px, 1px);
    white-space: nowrap;
    border: 0;
}

#new_header #header_search .searchform {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
}

#new_header #header_search .inp {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    min-width: 50ch;
}

#new_header #header_search .inp:focus {
    border-color: #c9c9c9;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

#new_header #header_search .submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    box-sizing: border-box;
    border-radius: 8px;
    cursor: pointer;
}

#new_header #header_search {
    display: inline-flex;
    flex: 0 0 auto;
    white-space: nowrap;
}

#new_header #header_search .submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    box-sizing: border-box;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    border: 1px solid #28a745;
    transition: all 0.2s ease;
}

#new_header #header_search .submit:hover {
    background: linear-gradient(135deg, #1e7e34 0%, #1a9f7a 100%);
    border-color: #1e7e34;
    transform: scale(1.01);
}

/* Fixed plates and search sizing + wrap rules */
#new_header #header_contacts {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    /* never shrink, always fixed size */
}

/* Иконки внутри контейнера header_user_actions */
#new_header #header_user_actions #header_profile,
#new_header #header_user_actions #header_favorites,
#new_header #header_user_actions #header_mini_cart {
    flex: 0 0 auto;
    /* never shrink, always fixed size */
}

#new_header #header_search .searchform-inp {
    flex: 0 1 auto;
    width: 250px;
}

#new_header #header_search .inp {
    height: 40px;
    width: 100%;
    min-width: 0;
}

#new_header #header_search .submit {
    height: 40px;
    width: 120px;
    flex: 0 0 120px;
}

/* Plates: WhatsApp and Phone */
#new_header #header_contacts>div>a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 170px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

#new_header #header_contacts>div>a:hover {
    background: #eaf6ff;
    border-color: #cfe9ff;
}

/* Plates: Profile, Favorites, Cart */
#new_header #header_profile a,
#new_header #header_favorites a,
#new_header #header_mini_cart #mini_cart_toggle,
#new_header #header_user_actions #header_profile a,
#new_header #header_user_actions #header_favorites a,
#new_header #header_user_actions #header_mini_cart #mini_cart_toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 90px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#new_header #header_profile a:hover,
#new_header #header_favorites a:hover,
#new_header #header_mini_cart #mini_cart_toggle:hover,
#new_header #header_user_actions #header_profile a:hover,
#new_header #header_user_actions #header_favorites a:hover,
#new_header #header_user_actions #header_mini_cart #mini_cart_toggle:hover {
    background: #eaf6ff;
    border-color: #cfe9ff;
}


/* Keep all elements fixed size - no shrinking allowed */
#new_header #header_search,
#new_header #header_search .searchform,
#new_header #header_search .searchform * {
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    /* prevent text wrapping */
}

/* Search always goes to second line when wrapping happens */
#new_header #header_search {
    order: 1;
    /* always below plates when wrapping */
    flex: 0 0 auto;
    /* fixed size, no shrinking */
    width: auto;
}

@media (max-width: 1395px) {

    #header_all_actions {
        order: 1 !important;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    /* Контакты остаются в ряд */
    #new_header #header_contacts {
        flex-direction: row;
        gap: 6px;
    }

    #new_header #header_search {
        order: 2 !important;
        width: 60vw !important;
    }

    #new_header #header_search,
    #new_header #header_search .searchform-inp,
    #new_header #header_search .searchform {
        width: 60vw !important;
    }
}

#new_header {
    row-gap: 10px;
    /* gap between rows when wrapping */
}

/* Contacts */
#new_header #header_contacts {
    flex: 0 0 auto;
}

#new_header #header_contacts .tel_lp_item a {
    font-weight: 600;
    white-space: nowrap;
}

#new_header #header_favorites a span,
#new_header #header_user_actions #header_favorites a span {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    margin-left: 6px;
    font-size: 12px;
    line-height: 1.6;
    border-radius: 10px;
    background: #f1f3f5;
}

/* Медиа-запросы для адаптивности */
@media (max-width: 1395px) {
    #new_header {
        width: 100%;
        max-width: 95%;
        grid-template-columns: 1fr;
        justify-items: center;
    }
}

/* Скрываем текст с номерами телефонов, оставляем только иконки */
@media (max-width: 1200px) {

    /* Сжимаем кнопки контактов до размера User Actions */
    #new_header #header_contacts>div>a {
        width: 90px !important;
    }

    /* Скрываем текст после иконок, но оставляем sr-only */
    #new_header #header_contacts a span:not(.sr-only) {
        display: none;
    }

    /* Скрываем только текст номера телефона */
    #new_header #header_contacts a {
        color: transparent;
        font-size: 0;
    }

    /* Но иконки должны быть видимыми */
    #new_header #header_contacts a svg,
    #new_header #header_contacts a .icon {
        color: #374151 !important;
        display: block;
    }
}

/* Сжимаем иконки при нехватке места */
@media (max-width: 1000px) {

    /* Сжимаем кнопки контактов */
    #new_header #header_contacts>div>a {
        width: 70px !important;
        padding: 0 8px !important;
    }

    /* Уменьшаем размер SVG иконок в контактах */
    #new_header #header_contacts a svg {
        width: 24px;
        height: 24px;
    }

    /* Обеспечиваем видимость иконки телефона */
    #new_header #header_contacts a .icon {
        color: #374151 !important;
        stroke: #374151 !important;
    }

    /* Уменьшаем ширину кнопок иконок */
    #new_header #header_profile a,
    #new_header #header_favorites a,
    #new_header #header_mini_cart #mini_cart_toggle,
    #new_header #header_user_actions #header_profile a,
    #new_header #header_user_actions #header_favorites a,
    #new_header #header_user_actions #header_mini_cart #mini_cart_toggle {
        width: 70px;
        padding: 0 8px;
    }

    /* Уменьшаем размер иконок */
    #new_header .icon {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 768px) {
    #new_header {
        max-width: 98%;
        padding: 8px 12px;
        gap: 12px;
    }

    /* Увеличиваем поиск для мобильных устройств */
    #new_header #header_search,
    #new_header #header_search .searchform-inp,
    #new_header #header_search .searchform {
        width: 95vw !important;
    }

    /* Увеличиваем высоту поля поиска для тач-интерфейса */
    #new_header #header_search .inp {
        height: 50px;
        font-size: 16px;
    }

    #new_header #header_search .submit {
        height: 50px;
        font-size: 16px;
    }

    /* Увеличиваем кнопки контактов для тач-интерфейса на мобильных */
    #new_header #header_contacts>div>a {
        width: 90px !important;
        height: 60px !important;
        padding: 0 8px !important;
    }

    /* Увеличиваем размер SVG иконок в контактах для тач-интерфейса */
    #new_header #header_contacts a svg {
        width: 30px;
        height: 30px;
    }

    /* Обеспечиваем видимость иконки телефона */
    #new_header #header_contacts a .icon {
        color: #374151 !important;
        stroke: #374151 !important;
    }

    /* Увеличиваем кнопки для тач-интерфейса на мобильных */
    #new_header #header_profile a,
    #new_header #header_favorites a,
    #new_header #header_mini_cart #mini_cart_toggle,
    #new_header #header_user_actions #header_profile a,
    #new_header #header_user_actions #header_favorites a,
    #new_header #header_user_actions #header_mini_cart #mini_cart_toggle {
        width: 90px;
        height: 60px;
        padding: 0 8px;
    }

    /* Увеличиваем размер иконок для тач-интерфейса */
    #new_header .icon {
        width: 30px;
        height: 30px;
    }

    /* Уменьшаем промежуток между иконками */
    #new_header #header_user_actions {
        gap: 6px;
    }

    /* Уменьшаем промежуток в общем контейнере */
    #new_header #header_all_actions {
        flex-direction: row;
        gap: 6px;
    }

    /* Контакты остаются в ряд */
    #new_header #header_contacts {
        flex-direction: row;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    #new_header {
        max-width: 100%;
        padding: 6px 8px;
        gap: 8px;
        margin: 5px auto 15px;
    }

    /* Увеличиваем поиск для очень маленьких экранов */
    #new_header #header_search,
    #new_header #header_search .searchform-inp,
    #new_header #header_search .searchform {
        width: 95vw !important;
    }

    /* Увеличиваем высоту поля поиска для тач-интерфейса */
    #new_header #header_search .inp {
        height: 50px;
        font-size: 16px;
    }

    #new_header #header_search .submit {
        height: 50px;
        font-size: 16px;
    }

    /* Увеличиваем кнопки контактов для тач-интерфейса на очень маленьких экранах */
    #new_header #header_contacts>div>a {
        width: 75px !important;
        height: 52px !important;
        padding: 0 6px !important;
    }

    /* Увеличиваем размер SVG иконок в контактах для тач-интерфейса */
    #new_header #header_contacts a svg {
        width: 27px;
        height: 27px;
    }

    /* Обеспечиваем видимость иконки телефона */
    #new_header #header_contacts a .icon {
        color: #374151 !important;
        stroke: #374151 !important;
    }

    /* Увеличиваем кнопки для тач-интерфейса на очень маленьких экранах */
    #new_header #header_profile a,
    #new_header #header_favorites a,
    #new_header #header_mini_cart #mini_cart_toggle,
    #new_header #header_user_actions #header_profile a,
    #new_header #header_user_actions #header_favorites a,
    #new_header #header_user_actions #header_mini_cart #mini_cart_toggle {
        width: 75px;
        height: 52px;
        padding: 0 6px;
    }

    /* Увеличиваем размер иконок для тач-интерфейса */
    #new_header .icon {
        width: 27px;
        height: 27px;
    }

    /* Минимальный промежуток между иконками */
    #new_header #header_user_actions {
        gap: 4px;
    }

    /* Минимальный промежуток в общем контейнере */
    #new_header #header_all_actions {
        flex-direction: row;
        gap: 4px;
    }

    /* Контакты остаются в ряд */
    #new_header #header_contacts {
        flex-direction: row;
        gap: 2px;
    }
}