/* B2B Account Page - Structure Fix */

/* Armenian Font */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Armenian:wght@400;500;600;700&display=swap');

/* --- MAIN WRAPPER GRID --- */
/* Принудительно задаем сетку для главного контейнера */
.b2b-account-wrapper {
    display: grid !important;
    grid-template-columns: 280px 1fr !important; /* Сайдбар слева, Контент справа */
    gap: 32px !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 20px !important;
    align-items: start !important; /* Важно: выравнивание по верху */
    box-sizing: border-box !important;
    position: relative !important;
}

/* Обрабатываем Woodmart wrapper - делаем его grid контейнером */
.b2b-account-wrapper .wd-my-account-wrapper {
    display: grid !important;
    grid-template-columns: 280px 1fr !important;
    gap: 32px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    grid-column: 1 / -1; /* Занимает обе колонки родителя */
}

/* Скрываем стандартный враппер Woodmart, если он ломает сетку */
.b2b-account-wrapper .wd-my-account-wrapper {
    display: grid !important;
    grid-template-columns: 280px 1fr !important;
    gap: 32px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- SIDEBAR --- */
/* Показываем сайдбар, но скрываем только стандартные элементы Woodmart */
.b2b-account-wrapper .wd-my-account-sidebar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    grid-column: 1 / 2; /* Первая колонка */
    width: 100% !important;
}

/* Скрываем только стандартные элементы Woodmart внутри сайдбара */
.b2b-account-wrapper .wd-my-account-sidebar .woocommerce-MyAccount-navigation:not(.b2b-custom-navigation),
.b2b-account-wrapper .wd-my-account-sidebar .woocommerce-MyAccount-title,
.b2b-account-wrapper .wd-my-account-sidebar .wd-my-account-links {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Навигация должна быть видна в первой колонке */
.b2b-account-wrapper .b2b-custom-navigation,
.b2b-account-wrapper .wd-my-account-sidebar .b2b-custom-navigation {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    position: relative;
    z-index: 10;
    font-family: "Noto Sans Armenian", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.b2b-nav-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f3f4f6;
}

/* --- CONTENT AREA --- */
/* Контент должен быть во второй колонке */
.b2b-account-wrapper .b2b-account-content,
.b2b-account-wrapper .wd-my-account-wrapper > .woocommerce-MyAccount-content {
    width: 100% !important;
    min-width: 0 !important; /* Prevents grid blowout */
    display: block !important;
    grid-column: 2 / 3; /* Вторая колонка */
    position: relative !important;
    z-index: 1 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Убеждаемся, что контент не уходит под хедер при скролле */
/* Контент должен начинаться с нормального отступа */
.b2b-content-area {
    margin-top: 0 !important;
    padding-top: 0 !important;
    position: relative !important;
}

/* Убеждаемся, что дашборд не уходит под хедер */
.b2b-custom-dashboard {
    position: relative !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Предотвращаем перекрытие хедером при скролле */
.wd-content-area .b2b-account-wrapper {
    position: relative !important;
    z-index: 1 !important;
}

/* Убеждаемся, что контент не имеет отрицательных отступов */
.b2b-account-wrapper,
.b2b-account-wrapper * {
    margin-top: 0 !important;
}

.b2b-account-wrapper .b2b-content-area,
#b2b-account-content {
    width: 100% !important;
    min-width: 0 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 400px !important;
    position: relative !important;
    z-index: 10 !important;
    background: transparent !important;
}

/* Убираем класс fade-out, если он есть */
.b2b-content-fade-out {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Убеждаемся, что wrapper контента виден */
.b2b-account-content-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    min-height: 200px !important;
}

/* Если контент внутри wrapper, он тоже должен быть во второй колонке */
.b2b-account-wrapper .wd-my-account-wrapper .b2b-account-content {
    grid-column: 2 / 3;
}

/* Убираем лишние отступы у Woodmart контента */
.woocommerce-MyAccount-content {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* --- NAVIGATION LINKS --- */
.b2b-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.b2b-nav-item {
    margin: 0;
    padding: 0;
}

.b2b-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: #6b7280;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.b2b-nav-link:hover {
    background: rgba(35, 62, 42, 0.05);
    color: #233E2A;
}

.b2b-nav-item.b2b-nav-active .b2b-nav-link {
    background: rgba(35, 62, 42, 0.05);
    color: #233E2A;
    font-weight: 600;
}

.b2b-nav-item.b2b-nav-active .b2b-nav-indicator {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: #233E2A;
    border-radius: 0 4px 4px 0;
}

.b2b-nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.b2b-nav-icon svg {
    width: 100%;
    height: 100%;
}

.b2b-nav-text {
    flex: 1;
}

.b2b-nav-indicator {
    display: none;
}

/* --- HIDE DEFAULT ELEMENTS --- */
/* Прячем лишние ссылки и заголовки Woodmart */
.woocommerce-MyAccount-navigation:not(.b2b-custom-navigation),
.wd-my-account-links,
.woocommerce-MyAccount-content > h3:first-child,
.wd-my-account-sidebar .woocommerce-MyAccount-title { 
    display: none !important; 
}

/* --- LOADER --- */
.b2b-content-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

.b2b-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #233E2A;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- ERROR MESSAGE --- */
.b2b-error-message {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    color: #991b1b;
    font-family: "Noto Sans Armenian", sans-serif;
    font-size: 16px;
    font-weight: 500;
    margin: 20px 0;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    #main-content .b2b-account-wrapper,
    body .site-content .b2b-account-wrapper,
    .b2b-account-wrapper,
    .b2b-account-wrapper .wd-my-account-wrapper {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        position: relative !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .b2b-account-wrapper .wd-my-account-sidebar {
        width: 100% !important;
        position: static !important;
        display: block !important;
        height: auto !important;
        margin-bottom: 20px !important;
        float: none !important;
        transform: none !important;
    }

    .b2b-custom-navigation {
        width: 100% !important;
        position: static !important;
        margin-bottom: 0 !important;
        display: block !important;
    }

    .b2b-nav-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* Сетка меню на мобильном */
        gap: 10px !important;
    }

    .b2b-account-wrapper .b2b-account-content,
    .b2b-account-wrapper .wd-my-account-wrapper > .b2b-account-content,
    .b2b-account-wrapper .wd-my-account-wrapper > .woocommerce-MyAccount-content,
    .b2b-account-wrapper .woocommerce-MyAccount-content {
        width: 100% !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: static !important;
        z-index: 10 !important;
        height: auto !important;
        min-height: 200px !important;
        background: transparent !important;
        overflow: visible !important;
        margin-top: 20px !important;
        padding-bottom: 40px !important;
        float: none !important;
        transform: none !important;
        left: 0 !important;
        right: auto !important;
    }
}

@media (max-width: 600px) {
    .b2b-nav-list {
        grid-template-columns: 1fr; /* Вертикальное меню на телефонах */
    }
    
    .b2b-account-wrapper,
    .b2b-account-wrapper .wd-my-account-wrapper {
        padding: 10px !important;
    }
    
    .b2b-custom-navigation {
        padding: 16px !important;
    }
}
