/* ===== FLORA TWO-ROW HEADER v2.0.2 ===== */
/* Дата: 09.07.2025 */
/* Исправленная версия с усиленными фиксами вертикального текста */

/* === КРИТИЧНЫЕ ФИКСЫ для вертикального текста === */
/* Применяем ко всем элементам сразу с максимальным приоритетом */
.flora-header-two-row,
.flora-header-two-row *,
.site-header,
.site-header * {
    writing-mode: horizontal-tb !important;
    writing-mode: initial !important;
    text-orientation: mixed !important;
    text-orientation: initial !important;
    -webkit-writing-mode: horizontal-tb !important;
    -ms-writing-mode: lr-tb !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    text-align: left !important;
    direction: ltr !important;
}

/* Специальный фикс для заголовков и ссылок */
.site-title,
.site-title a,
.site-description,
h1, h2, h3, h4, h5, h6,
a, span, p, div {
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    display: inline-block;
    vertical-align: baseline;
}

/* === Сброс конфликтующих стилей Storefront === */
.site-header .col-full,
.storefront-primary-navigation,
.secondary-navigation,
.storefront-header-cart,
#masthead .col-full {
    display: none !important;
}

/* Убираем все стили Storefront для header */
.site-header.storefront-header,
#masthead {
    all: unset;
    display: block;
}

/* === Базовая структура === */
.flora-header-two-row {
    background: #ffffff;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    position: relative;
    z-index: 1000;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: block;
    contain: layout style;
}

.flora-header-two-row * {
    box-sizing: border-box;
}

.header-container {
    width: 100%;
    display: block;
}

/* === Строки header === */
.header-row {
    width: 100%;
    display: block;
    border-bottom: 1px solid #e8e8e8;
    position: relative;
}

.header-row-top {
    background: #ffffff;
    padding: 12px 0;
}

.header-row-bottom {
    background: #fafafa;
    padding: 8px 0;
    border-bottom: 2px solid #8BC34A;
}

/* === Контейнер колонок === */
.header-col-full {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

/* === Левая и правая части === */
.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* === ПЕРВЫЙ РЯД === */

/* Брендинг (логотип + название) */
.site-branding {
    display: flex !important;
    align-items: center !important;
    gap: 15px;
    flex-direction: row !important;
    writing-mode: horizontal-tb !important;
}

.site-logo-anchor,
.custom-logo-link {
    display: inline-block;
    line-height: 1;
    transition: transform 0.3s ease;
}

.site-logo-anchor:hover,
.custom-logo-link:hover {
    transform: scale(1.05);
}

.custom-logo {
    height: 50px !important;
    width: auto !important;
    object-fit: contain;
    display: block;
}

.site-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px;
    padding-left: 15px;
    border-left: 2px solid #e0e0e0;
    writing-mode: horizontal-tb !important;
}

.site-title {
    margin: 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    color: #2e7d32 !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    display: block !important;
}

.site-title a {
    color: inherit !important;
    text-decoration: none !important;
    display: inline-block !important;
    writing-mode: horizontal-tb !important;
}

.site-description {
    margin: 0 !important;
    font-size: 12px !important;
    color: #666 !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
    max-width: 250px;
    writing-mode: horizontal-tb !important;
    display: block !important;
}

/* Быстрые ссылки */
.header-quick-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-quick-links a {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    writing-mode: horizontal-tb !important;
}

.header-quick-links a:first-child {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

.header-quick-links a:first-child:hover {
    background: #8BC34A;
    color: white;
    border-color: #8BC34A;
}

.header-quick-links a.promo-link {
    background: #ffebee;
    color: #f44336;
    border: 1px solid #ffcdd2;
}

.header-quick-links a.promo-link:hover {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.link-icon {
    font-size: 16px;
    line-height: 1;
}

/* Поиск */
.site-search {
    position: relative;
}

.site-search form {
    display: flex;
    align-items: center;
    position: relative;
}

.site-search input[type="search"] {
    width: 0;
    padding: 0;
    border: none;
    background: transparent;
    transition: all 0.3s ease;
    font-size: 14px;
}

.site-search.expanded input[type="search"] {
    width: 200px;
    padding: 8px 15px;
    padding-right: 40px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    margin-right: -35px;
}

.search-submit {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-size: 20px;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.search-submit:hover {
    color: #8BC34A;
    transform: scale(1.1);
}

/* === ВТОРОЙ РЯД === */

/* Навигация */
.main-navigation {
    flex: 1;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

.main-navigation li {
    position: relative;
}

.main-navigation a {
    display: inline-block !important;
    padding: 10px 18px;
    color: #333;
    text-decoration: none !important;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 25px;
    white-space: nowrap;
    writing-mode: horizontal-tb !important;
}

.main-navigation a:hover {
    background: #f0f7e9;
    color: #2e7d32;
}

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
    background: #8BC34A;
    color: white;
}

/* Подменю */
.main-navigation ul ul {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 200px;
    padding: 10px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.main-navigation li:hover > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.main-navigation ul ul li {
    display: block;
}

.main-navigation ul ul a {
    display: block;
    padding: 8px 20px;
    font-size: 14px;
    border-radius: 0;
}

.main-navigation ul ul a:hover {
    background: #f5f5f5;
}

/* Корзина */
.site-header-cart {
    margin-left: 20px;
}

.site-header-cart a {
    display: inline-flex !important;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #8BC34A;
    color: white;
    border-radius: 25px;
    text-decoration: none !important;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(139, 195, 74, 0.3);
    white-space: nowrap;
    writing-mode: horizontal-tb !important;
}

.site-header-cart a:hover {
    background: #7cb342;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 195, 74, 0.4);
}

.cart-icon {
    font-size: 18px;
    line-height: 1;
    display: inline-block;
}

.cart-text {
    display: inline-block;
    font-size: 14px;
    writing-mode: horizontal-tb !important;
}

.cart-amount {
    font-size: 16px;
    font-weight: 700;
    writing-mode: horizontal-tb !important;
}

.cart-count {
    background: white;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
    display: inline-block;
}

/* === Кнопка мобильного меню === */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: #f5f5f5;
    border-color: #8BC34A;
}

.menu-icon {
    font-size: 18px;
    margin-right: 5px;
    display: inline-block;
    line-height: 1;
}

.menu-text {
    display: inline-block;
}

/* === Липкий header === */
.flora-header-two-row.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Компенсация для липкого header */
body.has-sticky-header {
    padding-top: 120px; /* Высота двухрядного header */
}

/* === Анимации === */
.site-branding,
.header-quick-links,
.site-search,
.main-navigation,
.site-header-cart {
    animation: fadeIn 0.5s ease backwards;
}

.site-branding { animation-delay: 0.1s; }
.header-quick-links { animation-delay: 0.2s; }
.site-search { animation-delay: 0.3s; }
.main-navigation { animation-delay: 0.4s; }
.site-header-cart { animation-delay: 0.5s; }

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Мобильная адаптация === */
@media (max-width: 768px) {
    .header-row-top {
        padding: 10px 0;
    }
    
    .header-row-bottom {
        padding: 5px 0;
    }
    
    .header-col-full {
        flex-wrap: wrap;
        padding: 0 15px;
    }
    
    /* Первый ряд на мобильных */
    .header-row-top .header-left {
        flex: 1 1 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .header-row-top .header-right {
        flex: 1 1 100%;
        justify-content: center;
        gap: 10px;
    }
    
    .custom-logo {
        height: 40px !important;
    }
    
    .site-info {
        display: none;
    }
    
    .header-quick-links {
        order: 2;
    }
    
    .site-search {
        order: 1;
    }
    
    .header-quick-links a {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .header-quick-links .link-text {
        display: none;
    }
    
    .header-quick-links .link-icon {
        font-size: 20px;
    }
    
    /* Второй ряд на мобильных */
    .menu-toggle {
        display: flex;
        align-items: center;
    }
    
    .main-navigation ul {
        display: none;
    }
    
    .main-navigation.toggled ul {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        padding: 10px;
        margin-top: 10px;
        z-index: 1000;
    }
    
    .main-navigation.toggled li {
        display: block;
        margin-bottom: 5px;
    }
    
    .main-navigation.toggled a {
        display: block;
        padding: 10px;
    }
    
    .site-header-cart a {
        padding: 8px 15px;
        font-size: 14px;
    }
    
    .cart-text {
        display: none;
    }
    
    body.has-sticky-header {
        padding-top: 100px;
    }
}

/* === Специальные эффекты === */
/* Пульсация корзины при добавлении товара */
.cart-count.pulse {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Индикатор загрузки для поиска */
.site-search.loading .search-submit::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #8BC34A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* === ДОПОЛНИТЕЛЬНЫЕ УСИЛЕННЫЕ ФИКСЫ === */

/* Принудительное горизонтальное отображение всего текста */
header *,
.flora-header-two-row *,
.site-header * {
    transform: none !important;
    -webkit-transform: none !important;
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    -webkit-text-orientation: mixed !important;
}

/* Убираем любые трансформации текста */
.site-title,
.site-title a,
.site-description {
    transform: rotate(0deg) !important;
    -webkit-transform: rotate(0deg) !important;
    writing-mode: lr-tb !important;
    -webkit-writing-mode: lr-tb !important;
    -ms-writing-mode: lr-tb !important;
}

/* Очистка флоатов */
.header-row::after {
    content: "";
    display: table;
    clear: both;
}

/* Z-index иерархия */
.flora-header-two-row {
    z-index: 1000;
}

.main-navigation ul ul {
    z-index: 1001;
}

.site-search.expanded {
    z-index: 1002;
}

/* Финальная полировка */
.flora-header-two-row img {
    max-width: 100%;
    height: auto;
}

/* Убираем подчеркивания */
.flora-header-two-row a {
    text-decoration: none !important;
}

/* Курсор для кликабельных элементов */
.flora-header-two-row button,
.flora-header-two-row a {
    cursor: pointer;
}

/* Отключаем выделение текста в навигации */
.main-navigation,
.header-quick-links {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* === ФИНАЛЬНЫЙ СБРОС STOREFRONT === */
/* Убедимся что стили Storefront не влияют на наш header */
.storefront-site-header,
.storefront-primary-navigation-wrapper,
.site-header .storefront-container,
#masthead.site-header {
    all: initial;
    display: none !important;
}